Ah! Nice one. I’ll do that in a future release. But will also add an option to ‘inherit source post status’ on the settings page too. Thanks for the good idea.
Hi Tiduspt. I was actually having a poke about my code tonight and released I already did a filter you can use for this. It actually holds a lot of information for you to do pretty much anything with.
Tag: “mpd_setup_destination_data”
$arg1 : Is an array which holds the main information for the destination post:
[‘post_title’]
[‘post_status’]
[‘post_type’]
[‘post_author’]
[‘post_content’]
[‘post_excerpt’]
[‘post_content_filtered’]
$arg2: The is the original data which is passed into the core function for from the source post for duplication:
‘source_id’
‘destination_id’
‘post_type’
‘post_author’
‘prefix’
‘requested_post_status’
Usage Example:
add_filter('mpd_setup_destination_data', 'my_hooked_in_function', 10, 2);
function my_hooked_in_function($arg1, $arg2){
$current_status = get_post_status( $arg2['source_id'] );
$arg1['post_status'] = $current_status;
return $arg1;
}
See inc/core.php, function ‘mpd_duplicate_over_multisite’ for all the detail.
That unfortunately wont do what I need, that will filter the data after input. I need to filter data when displaying available status to users.
So instead of having as possible duplicated post status:
– Draft
– Pending
– Private
– Public
I want to have as only options:
– Draft
– Pending
I need something like this on /inc/postform_ui.php
function mpd_publish_top_right(){
$post_statuses = get_post_statuses();
$sites = mpd_wp_get_sites()
$post_statuses = apply_filters( 'mpd_filter_display_poststatuses', $post_statuses );
?>
Please let me know the slug you will use for your filter so that I can implement it right away while having no problems when updating.
Thanks!
Sounds perfectly reasonable to me. I’ll get that added and push a wee update out asap.
Hi Tiduspt. I’ve just pushed out an update v0.7.4 just for you! :-). I now run all get_post_status() functions through the filter ‘mpd_available_post_statuses’. This will give you the access/control you need. Please note that this filter isn’t specific to the post/page metabox as I felt it appropriate to offer the filter wherever other users may require too; so you might want to wrap your hook in some current_screen logic to control where you want the filter to run.
Like so:
add_filter( 'mpd_available_post_statuses', 'filter_the_statuses');
function filter_the_statuses($available_statuses){
$currentScreen = get_current_screen();
if($currentScreen->post_type === 'page'){
unset($available_statuses['publish']);
}
return $available_statuses;
}
Thank you so much for such a good support!
It suits me perfectly!