\

Constants

MPD_DOMAIN

MPD_DOMAIN

MPD_PLUGIN

MPD_PLUGIN

MPD_SETTING_PAGE

MPD_SETTING_PAGE

MPD_SETTING_SECTION

MPD_SETTING_SECTION

Functions

mdp_add_admin_menu()

mdp_add_admin_menu() : null

Add MDP Settings navigation to WordPress navigation

Returns

null

mdp_copy_content_image_render()

mdp_copy_content_image_render() : null

Create the UI for the Inline Image Copy Selection setting

Returns

null

mdp_default_feat_image_copy_render()

mdp_default_feat_image_copy_render() : null

Create the UI for the Featured Image Copy Selection Setting

Returns

null

mdp_default_prefix_render()

mdp_default_prefix_render() : null

Create the UI for the Prefix Setting

Returns

null

mdp_default_tags_copy_render()

mdp_default_tags_copy_render() : null

Create the UI for the Tag Copy Selection Setting

Returns

null

mdp_get_default_options()

mdp_get_default_options() : array

Static function to allow MDP default options to be referenced globally

Returns

array

mdp_get_posts_for_type()

mdp_get_posts_for_type() 

This is the markup to display once the user has selected Question 2 in the Tools admin

mdp_get_site_on_network()

mdp_get_site_on_network() 

This is the markup to display once the user has selected Question 3 in the Tools admin

mdp_get_users_on_site()

mdp_get_users_on_site() 

This is the markup to display once the user has selected Question 4 in the Tools admin

mdp_load_admin_styles()

mdp_load_admin_styles() 

Enqueue all the required files for this plugin to display/run

mdp_make_admin_notice()

mdp_make_admin_notice(string  $site_name, string  $site_url, array  $destination_blog_details) : string

Generates markup for the 'Success Notice' once the MPD core function has been run.

Once the markup has been generated it is then saved as an option in wp_options database for use when the page loads.

Parameters

string $site_name

The site name of the destination blog

string $site_url

The edit URL link of the destination blog

array $destination_blog_details

An array of information about the detination blog. Passed over so the details can be used in filter

Returns

string —

The markup to be added to the success notice

mdp_plugin_activate()

mdp_plugin_activate() 

Set the default options in WordPress on activation of the plugin

mdp_settings_init()

mdp_settings_init() : null

Register the settings for MPD

Returns

null

mdp_settings_section_callback()

mdp_settings_section_callback() : null

Generate a sub heading for the settings page

Returns

null

meta_box_post_type_selector_render()

meta_box_post_type_selector_render(array  $args) : null

Create the UI for the Post Type chexboxes

Parameters

array $args

The post type checkbox to render. Probably generated in mdp_settings_init()

Returns

null

meta_box_show_radio_render()

meta_box_show_radio_render() : null

Create the UI for the Post Type Selector in Settings

Returns

null

mpd_admin_menu_markup()

mpd_admin_menu_markup() 

This is the markup to display in the Multisite Post Duplicator Tools page

mpd_admin_pages()

mpd_admin_pages() 

Add Multisite Post Duplucator Tool Page to WordPress Navigation

mpd_checked_lookup()

mpd_checked_lookup(array  $options, string  $option_key, string  $option_value,   $type = null) : string

A helper function to help display the default state of a settings page checkbox

Parameters

array $options

The option from the database

string $option_key

The key from the options array you are checking

string $option_value

The value you are checking against

$type

Returns

string —

The markup to be added to the checkbox

mpd_clone_post()

mpd_clone_post(integer  $post_id) : integer

This function sets up the MPD core function and calls it based on values added by the user in the MPD metabox

Parameters

integer $post_id

The post ID of the post currently being viewed.

Returns

integer —

The post ID of the post currently being viewed.

mpd_do_version_log()

mpd_do_version_log() : string

Log current version in WordPress Options. This is to allow logical upgrade scripts depending on current version in future updates

Returns

string —

A string that informs mpd of the type of upgrate that has orrured on activation

Values can be either 'new_install', 'had_before' or 'change_of_version'

mpd_duplicate_over_multisite()

mpd_duplicate_over_multisite(integer  $post_id_to_copy, integer  $new_blog_id, string  $post_type, integer  $post_author, string  $prefix, string  $post_status) : array

This is the main core function on Multisite Post Duplicator that processes the duplication of a post on a network from one site to another

Parameters

integer $post_id_to_copy

The ID of the source post to copy

integer $new_blog_id

The ID of the destination blog to copy to.

string $post_type

The destination post type.

integer $post_author

The ID of the requested post author from the destination site.

string $prefix

Optional prefix to be used on the destination post.

string $post_status

The post status for the destination ID. Has to be one of the values returned from WordPress's get_post_statuses() function

Returns

array —

An array containing information about the newly created post

Example:

     id           => 20,
     edit_url     => 'http://[...]/site1/wp-admin/post.php?post=20&action=edit',
     site_name    => 'Another Site'

mpd_get_featured_image_from_source()

mpd_get_featured_image_from_source(integer  $post_id) : array

Gets information on the featured image attached to a post

This function will get the meta data and other information on the posts featured image; including the url to the full size version of the image.

Parameters

integer $post_id

The ID of the post that the featured image is attached to.

Returns

array —

Example

     id => '23',
     url => 'http://www.example.com/image/image.jpg',
     alt => 'Image Alt Tag',
     description => 'Probably a big string of text here',
     caption => 'A nice caption for the image hopefully'

mpd_get_image_alt_tags()

mpd_get_image_alt_tags(object  $post_media_attachments) : array

This function works with mpd_get_images_from_the_content() and produces alt tags associated with a matching array of image objects

Parameters

object $post_media_attachments

Probably generated from mpd_get_images_from_the_content()

Returns

array —

List of alt tags to be copied in core matching the array order of mpd_get_images_from_the_content()

mpd_get_image_new_url_without_extension()

mpd_get_image_new_url_without_extension(integer  $attach_id, integer  $source_id, integer  $new_blog_id, string  $new_file_url) : string

This function is to generate the image URL from the newly created media libray object for use in the core functions 'find and replace' action

Parameters

integer $attach_id

The ID of the new image

integer $source_id

The ID of the blog the image has come from

integer $new_blog_id

The ID of the blog the image is going to

string $new_file_url

The previously generated URL for the new image

Returns

string

mpd_get_images_from_the_content()

mpd_get_images_from_the_content(integer  $post_id) : array

This function looks at the post_content of a post and attempts to return all the id's of images that are used in the content

When adding an image to your post content in WordPress, WordPress it will give the image a class of wp-image-{image id} This function anticipates this behaviour and searchs the content of any instances of this class structure and grabs the {image id} and collects these id's into an array.

Parameters

integer $post_id

The ID of the post to analise

Returns

array —

Example:

    ['20', '30', '1', '456']

mpd_get_post_types_to_ignore()

mpd_get_post_types_to_ignore() : array

Get the value of the post types that we don't want to use in Multisite Post Duplicator

WordPress has some post types that are not applicable to MPD's behaviour. This is where we have defined these post types for reference throughout MPD

Returns

array —

One dimentional array containing all post types to be ignored.

Example :

['revision', 'nav_menu_item', 'attachment']

mpd_get_postype_decision_from_options()

mpd_get_postype_decision_from_options() : array

This function returns the all post types that the user has selected they want to display the MDP metabox on

Returns

array —

Containing post types that will show a MPD Metabox.

Example :

 ['post', 'page']

mpd_get_prefix()

mpd_get_prefix() : string

This function returns the current default prefix for the duplication.

Returns either the core default value or the value of prefix saved by user in settings

Returns

string

mpd_get_some_postypes_to_show_options()

mpd_get_some_postypes_to_show_options() : array

Get a list of post types the user wants to show the MPD Metabox (if the 'Some Post Types' option was selected in settings)

This function checks the settings for MPD and returns all the option values that are associated with post types

Returns

array —

Containing post types for use with MPD Metabox

mpd_globalise_settings()

mpd_globalise_settings() : null

This function is used to copy the saved settings to all other sites options table, therefore globalising the MPD settings arcroos all sites.

Returns

null

mpd_metaboxes()

mpd_metaboxes() : null

This function initialises the MPD Metabox on the WordPress Post

Before displaying this function will check the plugin settings option to make sure the use wants to display the metabox or not depending on the post type.

Returns

null

mpd_plugin_admin_notices()

mpd_plugin_admin_notices() : \none

Displays the admin notice.

Once the notice has been displayed on the screen it is then delted form the database

Returns

\none

mpd_process_post_media_attachements()

mpd_process_post_media_attachements(integer  $destination_post_id, array  $post_media_attachments, array  $attached_images_alt_tags, integer  $source_id, integer  $new_blog_id) : null

This function performs the action of copying the attached media image(s) to the newly created post in the core function.

Parameters

integer $destination_post_id

The ID of the post we are copying the media to

array $post_media_attachments

An array of media library IDs to copy. Probably generated from mpd_get_images_from_the_content()

array $attached_images_alt_tags

An array of alt tags associated with the images in $post_media_attachments array. Mirrors the array order of this for association. Probably generated from mpd_get_image_alt_tags()

integer $source_id

The ID of the blog these images are being copied from.

integer $new_blog_id

The ID of the blog these images are going to.

Returns

null

mpd_publish_top_right()

mpd_publish_top_right() : null

This function generates the markup for the MPD Metabox

Returns

null

mpd_set_featured_image_to_destination()

mpd_set_featured_image_to_destination(integer  $destination_id, array  $image_details) : null

This function performs the action of copying the featured image to the newly created post in the core function.

Parameters

integer $destination_id

The ID of the newly created post

array $image_details

The details of the featured image to be copied. Linked to: mpd_get_featured_image_from_source() which will generate the correct array structure for use here.

Returns

null

mpd_settings_field()

mpd_settings_field(  $tag,   $settings_title,   $callback_function_to_markup,   $args = null) : \none

Helper function to create setting field in mpd.

Uses 'add settings field'. See https://codex.wordpress.org/Function_Reference/add_settings_field

Parameters

$tag

string Unique name for settings field

$settings_title

string Title for the settings field in on the settings page. (accepts markup)

$callback_function_to_markup

string The name of the function to render setting markup

$args

string Any arguments you want to pass to the function

Returns

\none