Hi,
excellent request! I added a filter named “msls_admin_icon_get_edit_new” which has one argument (string $path) so you can add you vars to the generated URL too. I recommend to use add_query_arg for this (but I’m sure you know this).
I pushed the modifications to the GitHub repository:
https://github.com/lloc/Multisite-Language-Switcher/
Please let me know if it works for you so I can commit it to the WordPress Plugin Directory.
Cheers,
Dennis.
Thread Starter
patnz
(@patnz)
Brilliant, thanks for adding that in! All working well for me. Here’s the function I’m using. I actually completely override the default path in this but I tested simply appending parameters to the default path and all works well!
function add_clone_parameters($path){
// I'm only looking to clone posts not taxonomies etc so we'll
// only modify on post edit or post listing pages.
global $pagenow;
if( $pagenow != 'edit.php' && $pagenow != 'post.php' ){
return $path;
}
global $post;
global $current_blog;
// I'm going to use a custom admin action to fire my create clone function
// so since I don't want to link to add post directly I'll unset $path in this case.
$path = '';
// If on a post edit page - i.e. the links on the MSLS meta box
// global $post doesn't return the value we want so use $_GET post var
if( !$srcpost = $_GET['post'] ){
$srcpost = $post->ID;
}
// Get src blog from global $current_blog
$srcblog = $current_blog->blog_id;
// Get destblog from get_current_blog_id().
// This may seem odd but in MSLS we are switched to the local blog at present
$destblog = get_current_blog_id();
//add variables to path
$path = add_query_arg( 'action', 'clone_product', $path );
$path = add_query_arg( 'srcblog', $srcblog, $path );
$path = add_query_arg( 'destblog', $destblog, $path );
$path = add_query_arg( 'srcpost', $srcpost, $path );
return $path;
}
add_filter('msls_admin_icon_get_edit_new', 'add_clone_parameters');
My actual clone function is a bit environment specific but I’ll tidy it up and post back here when I get a chance in case anyone is looking for it.
Cheers for the heads up on add_query_arg too!
Thanks again,
Pat
OK, excellent. Thanks for sharing your idea!