Category: Free Plugins

Multisite Post Duplicator – Actions and Filters


For the latest version of my WordPress plugin (version 0.6) I have added various actions and filters to allow anyone to create addons or to extend the plugins functionality without having to edit the core.


‘mpd_before_core’ inc/core.php Perform actions just before duplication begins
‘mpd_during_core_in_source’ inc/core.php Just after data has been collected form source post but before we being to process the new post
‘mpd_end_of_core’ inc/core.php Immediately after all duplication actions have been performed
‘mpd_before_metabox_content’ inc/postform_ui.php Before the metabox markup is displayed
‘mpd_after_metabox_content’ inc/postform_ui.php After the metabox markup is displayed
‘mdp_start_plugin_setting_page’ in/settings-ui.php After settings page has been registered but before and settings fields have been generated
‘mdp_end_plugin_setting_page’ in/settings-ui.php After all core setting fields have been registered


‘mpd_activation_options’ mpd.php add/edit/delete the option fields added on activation of plugin
‘mdp_default_options’ mpd.php add/edit/delete the default values of each setting in mpd
‘mpd_is_active’ various locations change logic determining if plugin tools are available or not
‘mpd_setup_destination_data’ inc/core.php Hook into the post values for the destination post
‘mpd_returned_information’ inc/core.php add/edit/delete the information on the created post returned by the core function
‘mpd_ignore_post_types’ inc/mpd-functions.php Hook into the array which stores the post types that the mpd metabox will not display on.
‘mpd_featured_image’ inc/mpd-functions.php Filter details on the copied featured image
‘mpd_featured_image_filename’ inc/mpd-functions.php Do stuff with the copied featured image’s filename only
‘mpd_alt_tag_array_from_post_content’ inc/mpd-functions.php Do stuff with the alt tags for the images within the new post content
‘mpd_admin_notice_text’ inc/mpd-functions.php Hook into the ‘success’ admin notice.
‘mpd_global_filter_sites’ inc/mpd-functions.php Control the sites on your network that appear in the MPD functionality
‘mpd_show_settings_page’ inc/settings-ui.php Control the logic that determines when to show the Settings page
‘mpd_source_data’ inc/core.php Control the source data being added to the core duplication process
‘mpd_available_post_statuses’ inc/mpd-functions.php Control what post statuses are available to the user

Please note that this is a very brief summary of the filters and actions, for greater detail into parameters and data that you can gain access to with these hooks please check the source code.


Multisite Post Duplicator

Last post I mentioned a wee function I has written to help me with copying posts and pages from one multisite to another. Well I have packaged it into a plugin and submitted it to WordPress. After a few days I got notice that they approved it!


Check it out on GitHub also:

FireShot Capture - magicstickuk_multisi_ - https___github.com_magicstickuk_multisite-post-duplicator

It doesn’t finish here though. I have several ideas for future features. Stay tuned!


Correct Capitalisation of WordPress

So yesterday, when I wrote my first blog post on this site, I found myself having to go back to my post two or three times because I had noticed that I had used the incorrect capitalisation on the word ‘WordPress’. Should be a capital W and P.

So in my warped mind, tonight I decided to write a wee plugin that will auto fix this issue whenever I publish or update a post. It’s probably the most straightforward plugin you could hope to write but I like the exercise as you never know what you might learn on the way.

What I Did

In WordPress there is a Filter called wp_insert_post_data this filter basically allows you to intercept the POST data from when the user presses ‘Publish’ or ‘Update’ on the CMS and edit the data in any way you want BEFORE the data is added to the database.

The syntax for running this filter looks like this:

function filter_handler( $data , $postarr ) {
  // do something with the post data
  return $data;

add_filter( 'wp_insert_post_data', 'filter_handler', '99', 2 );

So in my function I have basically done a find and replace and returned the new data for WordPress to add to the database.

function correct_capitalisation_WordPress( $data , $postarr ) {
  $correct_capitalisation = array();

  $incorrect_capitalisations = array(

  	'post_content' 	=> $data['post_content'],
  	'post_title' 	=> $data['post_title'],
  	'post_excerpt' 	=> $data['post_excerpt']


  foreach ($incorrect_capitalisations  as $key => $incorrect_capitalisation) {

    $correct_capitalisation[$key] = str_ireplace("WordPress", "WordPress", $incorrect_capitalisation);

  	$data[$key]  = $correct_capitalisation[$key];

  return $data;
add_filter( 'wp_insert_post_data', 'correct_capitalisation_WordPress', '99', 2 );

The Final Plugin:


Download Now