/** * Display duplicate post link for post. * * @param string $link Optional. Anchor text. * @param string $before Optional. Display before edit link. * @param string $after Optional. Display after edit link. * @param int $id Optional. Post ID. */ function duplicate_post_clone_post_link($link = null, $before = '', $after = '', $id = 0) { if (!($post =& get_post($id))) { return; } if (!($url = duplicate_post_get_clone_post_link($post->ID))) { return; } if (null === $link) { $link = __('Copy to a new draft', DUPLICATE_POST_I18N_DOMAIN); } $post_type_obj = get_post_type_object($post->post_type); $link = '<a class="post-clone-link" href="' . $url . '" title="' . esc_attr(__("Copy to a new draft", DUPLICATE_POST_I18N_DOMAIN)) . '">' . $link . '</a>'; echo $before . apply_filters('duplicate_post_clone_post_link', $link, $post->ID) . $after; }
function duplicate_post_add_duplicate_post_button() { if (isset($_GET['post'])) { $id = $_GET['post']; $post = get_post($id); if (duplicate_post_is_current_user_allowed_to_copy() && duplicate_post_is_post_type_enabled($post->post_type)) { ?> <div id="duplicate-action"> <a class="submitduplicate duplication" href="<?php echo duplicate_post_get_clone_post_link($_GET['post']); ?> "><?php _e('Copy to a new draft', 'duplicate-post'); ?> </a> </div> <?php } } }
function duplicate_post_admin_bar_render() { global $wp_admin_bar; $current_object = get_queried_object(); if (empty($current_object)) { return; } if (!empty($current_object->post_type) && ($post_type_object = get_post_type_object($current_object->post_type)) && duplicate_post_is_current_user_allowed_to_copy() && ($post_type_object->show_ui || 'attachment' == $current_object->post_type)) { $wp_admin_bar->add_menu(array('parent' => 'edit', 'id' => 'new_draft', 'title' => __("Copy to a new draft", DUPLICATE_POST_I18N_DOMAIN), 'href' => duplicate_post_get_clone_post_link($current_object->ID))); } }
function duplicate_post_add_duplicate_post_button() { if (isset($_GET['post']) && duplicate_post_is_current_user_allowed_to_copy()) { ?> <div id="duplicate-action"> <a class="submitduplicate duplication" href="<?php echo duplicate_post_get_clone_post_link($_GET['post']); ?> "><?php _e('Copy to a new draft', DUPLICATE_POST_I18N_DOMAIN); ?> </a> </div> <?php } }