Example #1
0
function wvpd_get_clone_post_link($id = 0, $context = 'display', $draft = true)
{
    if (!wvpd_is_current_user_allowed_to_copy()) {
        return;
    }
    if (!($post = get_post($id))) {
        return;
    }
    global $newposttype;
    $newposttype = 'post';
    if ($draft) {
        $action_name = "wvpd_save_as_new_post_draft";
    } else {
        $action_name = "wvpd_save_as_new_post";
    }
    if ('display' == $context) {
        $action = '?action=' . $action_name . '&post=' . $post->ID;
    } else {
        $action = '?action=' . $action_name . '&post=' . $post->ID;
    }
    $post_type_object = get_post_type_object($newposttype);
    if (!$post_type_object) {
        return;
    }
    return apply_filters('wvpd_get_clone_post_link', admin_url("admin.php" . $action), $post->ID, $context);
}
Example #2
0
function wvpd_add_wvpd_button()
{
    if (isset($_GET['post']) && wvpd_is_current_user_allowed_to_copy()) {
        ?>
<div id="duplicate-action">
<?php 
        if (get_option('wvpd_copy2others') == 1) {
            $label = __('Copy to listed post types', 'wvpd');
        } else {
            $label = __('Copy to current post types', 'wvpd');
        }
        ?>
	<a class="submitduplicate duplication"	href="<?php 
        echo wvpd_get_clone_post_link($_GET['post'], 'display', false);
        ?>
">
	<?php 
        echo $label;
        ?>
	</a>
</div>
<?php 
    }
}