Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all 8245 articles
Browse latest View live

golazo on "Error mysql_real_escape_string() in wordpress"

$
0
0

I have next code for create account and insert post in database. Problem is, when i logged an i try to submit new post, apear this error:

Warning: mysql_real_escape_string() expects parameter 1 to be string, object given in....

Why?

/* Create acount */

    if (isset($_POST['task']) && $_POST['task'] == 'register')
    {
    $parola_user = $wpdb->escape(trim($_POST['psw']));
    $email_anunt = $wpdb->escape(trim($_POST['email']));

    if (email_exists($email))
    {
    $err = "Adressa exist";
    }
      else
    {
    $user_id = wp_insert_user(array(
    'user_pass' => apply_filters('pre_user_user_pass', $psw) ,
    'user_login' => apply_filters('pre_user_user_login', $email) ,
    'user_email' => apply_filters('pre_user_user_email', $email) ,
    'role' => 'author'
    ));
    }
    }

....

/* Insert post */

$date = array(
    'post_title' => $title,
    'post_content' => $desc,
    'post_status' => 'publish',
    'post_category' => array(
        $categ
    ) ,
    'post_author' => $user_id,
);

$post_id = wp_insert_post($date);

Luke Janicke on "How to customize "Insert Media" output?"

$
0
0

I want my editors to be able to use the default "Insert Media" feature but I want to customize the output. By default, "Insert Media" produces something like this:

[caption id="attachment_414" align="aligncenter" width="600"]<a href="http://www.theharbiner.com/?attachment_id=414" rel="attachment wp-att-414"><img src="http://www.theharbiner.com/media/2014/06/baskets-of-tea-1-600x397.jpg" alt="Baskets of Tea" width="600" height="397" class="size-medium wp-image-414" /></a> Varieties of tea on display and for purchase.[/caption]

Wow! That’s a lot. And it contains a mix of shortcode, hardcoded HTML and a lot of hard-coded attributes.

What I want the output to be is (for a single image):

[image id="414"]

Simple!

This would be easier for my editors (who don’t know HTML) and it’s future proof – I can regenerate images at different sizes and change HTML and attributes any time as I develop the theme. It also looks good alongside the Markdown that I’m making all my editors use.

I have already written the shortcode functions to output the desired HTML in my theme. What I need to do is filter the returned output of the actual "Insert Media" function in the post editor.

Is this possible? What is the filter to use?

Note: The answer is not img_caption_shortcode. That filter is for modifying the HTML output by the theme.

Isidoros Rigas on "How to disable images? (0.domain.com)"

$
0
0

Hello world,

I have a techblog and I want to create an image-free version, something like 0.domain.com like 0.facebook.com, because I usually use large images. My friend complained that his data (30MB) "dried up" quickly while he browsed Fb and my blog. So, how can I do it if I keep the same theme? Do you think it worths trying?

Thanks in advance.

aliput on "Adding extended_valid_elements to Tinymce?"

$
0
0

I need to add extended_valid_elements : "span[!class]" to the tinymce configuration file, but I don't know where to find this or how to implement the syntax. Can someone shed some light for me please?

Thank you

davidmaxwaterman on "hacking tags cloud to only show terms assigned to this project."

$
0
0

Hi,

Disclaimer: I'm no expert on 'driving' wordpress via the UI, but I've been tasked to make changes to the UI and a few other bits and pieces, and I've done that mostly by hacking away at the code, and that seems to work ok.

My latest task is to change something on the project pages. Currently, the 'all' page allows the user to select 'projects', and when one is selected, it takes me to a URL like this :

http://domain/?project=project-space

and this page shows the stuff that's been loaded for that project with a side bar that shows a 'tag cloud' widget, but it doesn't show tags actually - instead it shows the customer taxonomies I've hacked in with all the terms associated with each.

The change they want me to make is to either *only* show the terms that have been 'assigned' to the current page's project, *or* somehow highlight the ones that are 'assigned'.

I see on the 'projects' page on the admin pages that this is done in a table format, so it must be possible somehow, so I wonder if there's a nice simple function like 'get_terms' that I can use ... I see 'get_objects_in_term'? Can that do it?

Apologies if I'm not using the correct 'lingo' - I'm really not familiar with wordpress.

Any pointers appreciated..

Thanks!

Max.

aaronpatty on "shortcode_atts returning indexed arrays instead of associative"

$
0
0

Thanks in advance for your help!

Given the following shortcode function definition:

add_shortcode( 'bros_data', 'bros_data_shortcode' );
function bros_data_shortcode( $atts, $content = null ){
	echo var_dump( $atts ) . "<br>";

	echo var_dump(shortcode_atts( array(
		'stuff' => 'bad stuff id',
		'data' => 'bad data id',
		'max' => 'all'
	), $atts, 'bros_data' ) ) . "<br>";

	echo var_dump(shortcode_atts( array(
		'stuff',
		'data',
		'max'
	), $atts ) ) . "<br>";

	extract( shortcode_atts( array(
		'stuff',
		'data',
		'max'
	), $atts, 'bros_data' ) );

	echo var_dump( array('foo' => 'bar') ) . "<br>";

	echo serialize($stuff) . "<br>";
	echo serialize($data) . "<br>";
	echo serialize($max) . "<br>";
}

I execute this with the following shortcode:
[bros_data stuff='id_for_some_stuff' max="10"]

I get the following output:

array(2) { [0]=> string(25) "stuff='id_for_some_stuff'" [1]=> string(8) "max="10"" }
array(3) { ["stuff"]=> string(12) "bad stuff id" ["data"]=> string(11) "bad data id" ["max"]=> string(3) "all" }
array(3) { [0]=> string(25) "stuff='id_for_some_stuff'" [1]=> string(8) "max="10"" [2]=> string(3) "max" }
array(1) { ["foo"]=> string(3) "bar" }
N;
N;
N;

Notice that:

  1. I am getting indexed arrays returned from shortcode_atts() rather than associative arrays. Why?
  2. This means that the extract function doesn't work, so I don't get the variables created that I expect

How do I fix this?

Thanks!

flogen on "Make post title sit on top of featured image?"

$
0
0

Hey.

I just installed the Editor responsive theme, which I'm happy with overall.

The one issue I have is that the featured images sit on top of a post, followed by the date and author, followed by the post title.

The effect is to make all the elements look separate to each other, rather than part of the one post. (You can see what I mean here).

I'm wondering is there an easy way for me to change this - ideally to put the post title on top of the relevant featured image?

Thanks in advance.

s3korea48 on "plugin that removes from menu, and another plugin that puts it back to menu"

$
0
0

there's a plugin that adds the item to the menu. I wrote a plugin that removes this from the menu, but it appears that my plugin might have been called earlier that's why it was superceded with the plugin that puts it back to menu

is there any way to set priority of plugin?


johansenkristian on "custom fields with do_shortcode error if empty"

$
0
0

Hi

I'm using a the plugin Collapse-O-Matic for my custom fields.. Everything works perfect when there is content in the custom fields. But some of my posts don't have any custom fields. Then I'm deleting the custom field in the backend i get these errors:

Warning: Missing argument 1 for do_shortcode(), called in /Users/kristianjohansen/Sites/name/wp-content/themes/eddiemachado-bones-47a7b6d/index.php on line 29 and defined in /Users/kristianjohansen/Sites/name/wp-includes/shortcodes.php on line 190

Notice: Undefined variable: content in /Users/kristianjohansen/Sites/name/wp-includes/shortcodes.php on line 193

Notice: Undefined variable: content in /Users/kristianjohansen/Sites/name/wp-includes/shortcodes.php on line 194

My query looks like this:

<?php $my_query = query_posts('category_name=posts&showposts=-1');?>
  <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
 				<div class="box <?php foreach( get_the_category() as $cat ) { echo $cat->slug . '  '; } ?>">
 					<div class="border">
				<?php the_content(); ?>
				<?php
				$title = get_post_meta($post ->ID, 'title', true);
				$description = get_post_meta($post ->ID, 'description', true);
				$madeby = get_post_meta($post ->ID, 'madeby', true);
					if ( !empty($title))
				{
					echo '<div id="custom-fields">';
					echo '<ul>';
					echo '<li>';
					echo $title;
					echo '&nbsp;';
					echo '&nbsp;';
					echo '&nbsp;';
					echo do_shortcode('[expand]'.$description. '</br>'. $madeby.'[/expand]');
					echo '</li>';
				}
				?>
						</div>
					</div>
				</div>

				<?php endwhile; endif; ?>
				<?php wp_reset_query();?>

The lines where i get the errors in shortcode.php looks like this:

function do_shortcode($content) {
	global $shortcode_tags;

	if ( false === strpos( $content, '[' ) ) {
		return $content;
	}

	if (empty($shortcode_tags) || !is_array($shortcode_tags))
		return $content;

	$pattern = get_shortcode_regex();
	return preg_replace_callback( "/$pattern/s", 'do_shortcode_tag', $content );
}

Do i have to make a else statement that determining the do_shortcode to leave it empty if there isn't content, or is something in the shortcode.php I'm missing..

I hope someone in hear can help me..

Thanks!

SFGolfer on "Access database outside of WordPress 3.9"

$
0
0

I have been using the code below in a custom .php file outside of WordPress. The code worked without any issues until upgrading to 3.9 or 3.9.1.

define( 'SHORTINIT', true );

require_once( $_SERVER['DOCUMENT_ROOT'] . '/blog/wp-load.php' );

global $wpdb;
$tourney = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM database WHERE player_name='".$player."' And season='".$season."' And status='' ORDER BY date DESC", $null ), ARRAY_N );

Now this error appears:

Call to undefined function __() in /home1/public_html/blog/wp-includes/wp-db.php

What would be the proper method of querying a database outside of WordPress?

kennydowuk on "customizing messages by product category in woocomerce"

$
0
0

im trying to detect a product category when the user adds an item to the cart in woocommerce. So that they get a different 'added to cart' message depending on the product they add

the idea is that if they add a picture from the gallery it points them towards mounting services, but if they add a mounting service it gives the standard message

this is the code i have so far it just skips the category filter and runs the standard message.

function wc_add_to_cart_message( $product_id ) {

if ( is_array( $product_id ) ) {

$titles = array();

foreach ( $product_id as $id ) {
    $titles[] = get_the_title( $id );
}

$added_text = sprintf( __( 'Added &quot;%s&quot; to your cart.', 'woocommerce' ), join( __( '&quot; and &quot;', 'woocommerce' ), array_filter( array_merge( array( join( '&quot;, &quot;', array_slice( $titles, 0, -1 ) ) ), array_slice( $titles, -1 ) ) ) ) );

} elseif ( is_product_category( 'gallery') ) {
$added_text = sprintf( 'add a mount.' );
}else {
$added_text = sprintf( __( '"%s" was successfully added to your cart.', 'woocommerce' ), get_the_title( $product_id ) );
}

Never really dug this deep into the code before so im at a bit of a loss right now
posted this into the plugin forum to but not had a response yet

any thoughts?

Best Credit Cards Canada on "Insert Ad or Image At Top/Bottom of RSS Feed"

$
0
0

Hi!

I just started my website http://www.bestcreditcardscanada.com and was thinking that in the future it would be nice to include an ad at either the top or the bottom of all articles that are read via the RSS feed. I don't want this ad/banner to show up in the regular post however.

Is there a simple way to add an image/banner ad to either the top or bottom of your RSS feed? (I'd rather not use a plug-in, just add the code where it needs to go).

I have a child theme set up.

Thanks!
BCCC

SkyNetworks on "Adding Thumbnail Images to Pages Widget"

$
0
0

Hi Everybody,

Not sure if this is the right section to put this in, but I've managed to tweak my functions.php file to add thumbnails to the 'Recent Posts' widget that displays recent Blog Posts in my sidebar but am really struggling to do the same for my Pages.

Can anyone suggest anything please? I've searched online for several weeks now, but seem to be going around in circles ...

Thanks,
SN.

danishsameer on "Need Fwd Text Button"

$
0
0

Hello Everyone

i need little help..i want to insert a button in every post automitcally when any user click that button the text of that post automatcally go to the text area of form which i m using in my site u can see button in sms4smile site

in the last of everypost there is a button named send/forward this sms to anyone in pakistan when you clcick that button the text automtically go to textbox please check n if anyone knows about that please tell me

thanks,

Regards,
Danish

sipy23 on "Resizing Related products/ more than 4 col"


nicgios on "New plugin configuration policy"

$
0
0

Hi all,

I wrote a set of functions and I want to package them as a plugin, but I have a problem.

Many functions calls a configuration function which stores some general variables (I avoided global variables) defined by user. Is a good way to create a configuration page for the user in order to define such variables? In this case, should the variables be stored in the database directly?

I'd like the user not to touch a function: better to configure a plugin with a proper page, isn't it?

Thanks for your help

taylorshain12 on "Editing Child Theme..."

$
0
0

So I created a Child Theme from the 'Landline Theme' - using the 'One-click child theme plugin' - and I can't seem to create any css changes to my site -

I copied the style code from the 'developer tools' ---but nothing seems to make any changes - Here is the code that I was using: This is just to change the background to black... any one have any ideas? taylorshainfilms.com

<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>/style.css" type="text/css" media="screen" title="no title" charset="utf-8">

/*
Theme Name: Child_of_Landline
Description: Similar to Landline with different fonts, colors and location of the header.
Author: taylorshain12
Template: landline
*/

/*
@import url("../landline/style.css");
*/

<div class="wrapper">

{
.wrapper
{
background: ##000;
width: 720px;
margin: 75px 0 0;
padding: 50px;
box-shadow: 0 0 10px #777;
}
}

revxx14 on "Great, free idea for a mega menu plugin. Someone please make it happen."

$
0
0

After hours and hours of fighting with nav walkers, I thought there needed to be a better way for web developers to create mega menus. After thinking about it a bit, I've come up with this:

  • Wrap second level <ul>s in <section>
  • Add class mega menu and mega-menu-columns-# to parent <li>s that contain mega menus
  • Add "Menu Structure" options to Menu editor
    • New Column: Can only be placed within the second level <ul>. Adds </ul><ul> where a menu item would normally appear. If placed at the beginning or end of a <ul>, it does nothing.
    • Widget: Allows the user to pick a widget to display. Also acts as a column break, as it's a <section> wrapped in </ul><ul>. If placed at the beginning of a <ul>, does not include leading </ul>. If placed at the end of a <ul>, does not include trailing <ul>. Can only be placed within the second level <ul>.
  • Menu structure appears as below:
<ul>
	<li id="menu-item-1" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-1 mega-menu mega-menu-columns-2">
		<a href="http://www.example.com/about/">
			About Us
		</a>
		<section>
			<ul class="sub-menu">
				<li id="menu-item-2" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-2">
					<a href="http://www.example.com/about/company-profile/">
						Company Profile
					</a>
				</li>
				<li id="menu-item-3" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-3">
					<a href="http://www.example.com/about/leadership-team/">
						Leadership Team
					</a>
				</li>
				<li id="menu-item-4" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-4">
					<a href="http://www.example.com/about/professional-affiliations/">
						Professional Affiliations
					</a>
				</li>
			</ul>
			<ul>
				<li id="menu-item-5" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-5">
					<a href="http://www.example.com/about/clients/">
						Clients
					</a>
				</li>
				<li id="menu-item-6" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-6">
					<a href="http://www.example.com/about/partnerships/">
						Partnerships
					</a>
				</li>
			</ul>
		</section>
	</li>
	<li id="menu-item-7" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-7 mega-menu mega-menu-columns-3">
		<a href="http://www.example.com/services/">
			Services
		</a>
		<section>
			<ul class="sub-menu">
				<li id="menu-item-8" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-8">
					<a href="http://www.example.com/services/civil-engineering/">
						Civil Engineering
					</a>
				</li>
				<li id="menu-item-9" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-9">
					<a href="http://www.example.com/services/land-planning/">
						Land Planning
					</a>
				</li>
				<li id="menu-item-10" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-10">
					<a href="http://www.example.com/services/surveying/">
						Surveying
					</a>
				</li>
			</ul>
			<ul class="sub-menu">
				<li id="menu-item-11" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-11">
					<a href="http://www.example.com/services/information-technology/">
						Information Technology
					</a>
				</li>
				<li id="menu-item-12" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-12">
					<a href="http://www.example.com/services/subsurface-utility-engineering/">
						Subsurface Utility Engineering
					</a>
				</li>
			</ul>
			<aside>
				<h6>Widget Title</h6>
				<p>Maecenas quis semper arcu. Quisque consequat risus nisi. Sed venenatis urna porta eros malesuada euismod. Nulla sollicitudin fringilla posuere. Nulla et tellus eu nisi sodales convallis non vel tellus.</p>
			</aside>
		</section>
	</li>
	<li id="menu-item-13" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-13">
		<a href="http://www.example.com/projects/">
			Projects
		</a>
	</li>
	<li id="menu-item-14" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-14">
		<a href="http://www.example.com/news/">
			News
		</a>
		</li>
	<li id="menu-item-15" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-15">
		<a href="http://www.example.com/contact/">
			Contact Us
		</a>
	</li>
</ul>

s3korea48 on "How can i add a button in post area for shortcode"

$
0
0

It is very tedious to write shortcodes esp when using mobile. Is there a way for me to create button in post area (post and pages) that when clicked, will insert the shortcode automatically?

bterich on "Strip characers from tag names"

$
0
0

Hi,

I'm looking for a way to strip the frst two characters from all tags being displayed.

I have added $tag_name = substr($tag_name,2); to category-template.php, which has worked for the side bar widgets, but I'm lost on how to do the same for the rest of the content - i.e. main blog and tag archive pages?

Any suggestions would be very much appreciated.

Thanks!

Viewing all 8245 articles
Browse latest View live




Latest Images