Plugin Development: WordPress processes twice on post update. How to skip process on the first?

@Steve Functions hook to save_post are always called twice, WordPress call functions hooked to save_post twice because: first time it saves the post revision. second time it saves the actual post. NOTE: If you have disabled post revisions using define(‘WP_POST_REVISIONS’, false); then the save_post hook will be fired only once when the actual post will … Read more

WordPress media upload limit?

Three things you need to check. upload_max_filesize, memory_limit and post_max_size in the php.ini configuration file exactly. All of these three settings limit the maximum size of data that can be submitted and handled by PHP. Typically post_max_size and memory_limit need to be larger than upload_max_filesize. This is the function in WordPress that defines the constant … Read more

Any way to use a custom Parameter for youtube embed without using an iframe?

No need for a plugin, You can simply use the Oembed class’s oembed_result filter hook like this: function Oembed_youtube_no_title($html,$url,$args){ $url_string = parse_url($url, PHP_URL_QUERY); parse_str($url_string, $id); if (isset($id[‘v’])) { return ‘<iframe width=”‘.$args[‘width’].'” height=”‘.$args[‘height’].'” src=”http://www.youtube.com/embed/’.$id[‘v’].’?rel=0&showinfo=0″ frameborder=”0″ allowfullscreen></iframe>’; } return $html; } add_filter(‘oembed_result’,’Oembed_youtube_no_title’,10,3); so just paste this code in your theme’s functions.php file, setup the width and height … Read more

Shortcode display outside the div

Use this instead: Concatenate the html then return it. function check_my_login( $atts) { $html=”<form action=”” name=”” method=”post” enctype=”multipart/form-data”>”; $html .= ‘<div class=”form-group”>’; $html .= ‘<label for=”description”>Project Description</label>’; $html .= ‘<textarea name=”p_description” placeholder=”Project Description” class=”form-control”>’; if(isset($_POST[‘p_description’]) && $_POST[‘p_description’] != ”){ $html .= $_POST[‘p_description’]; } $html .= ‘</textarea>’; $html .= ‘</div>’; $html .= ‘<div class=”form-group”>’; $html .= … Read more

Multiple WP install with same users database

You can do the sharing of users fairly easily. Basically, both sites would use the same database (set up in wp-config.php), but each would get it’s own, unique $table_prefix. From there, you can specify custom user and user meta tables that are the same for each site. <?php // site 1 wp-config.php $table_prefix = ‘site1_’; … Read more

Article source link for posts

Thats what meta_boxes are for. First you need to register the metabox within the page or post with the function add_meta_box. Then you want to get that value with get_post_meta on the page where you want the “Source”. This goes into your functions.php file: /* Define the custom box */ add_action( ‘add_meta_boxes’, ‘wpse_source_link’ ); /* … Read more

A plugin for having rel=”nofollow” in posts?

you can add a filter in your functions.php add // Nofollow in content add_filter(‘the_content’, ‘my_nofollow’); function my_nofollow($content) { //return stripslashes(wp_rel_nofollow($content)); return preg_replace_callback(‘/<a[^>]+/’, ‘my_nofollow_callback’, $content); } function my_nofollow_callback($matches) { $link = $matches[0]; $site_link = get_bloginfo(‘url’); if (strpos($link, ‘rel’) === false) { $link = preg_replace(“%(href=\S(?!$site_link))%i”, ‘rel=”nofollow” $1’, $link); } elseif (preg_match(“%href=\S(?!$site_link)%i”, $link)) { $link = preg_replace(‘/rel=\S(?!nofollow)\S*/i’, ‘rel=”nofollow”‘, … Read more

AJAX Call Via Vanilla JavaScript In WordPress Plugin Development

Thanks Muhammad, Your solution is a fantastic working framework on which to base real world AJAX calls. I just added this code to the plugin main php file for a shortcode so I could use it in the Front End too. //For front end use in production add_shortcode(‘wp_testingPlugin_shortcode’, ‘wp_testingPlugin_shortcode’); function wp_testingPlugin_shortcode() { wp_enqueue_script( ‘ajax-script’, plugin_dir_url( … Read more