Support » Plugin: Yoast Duplicate Post » Disable on certain post types?

  • Resolved asocalguy

    (@asocalguy)


    Is there a way to disable this plugin on certain post types? I looked through the code and didn’t find any filters that would help me accomplish that.

    WooCommerce (for example) has it’s own built in features for duplicating products. Your plugin does not completely/accurately duplicate WooCommerce products when running certain WC plugins. I’d like to exclude products so my users won’t accidentally use your features on their products and end up with incomplete duplicates.

    Thanks!

    https://wordpress.org/plugins/duplicate-post/

Viewing 3 replies - 1 through 3 (of 3 total)
  • in file “duplicate-post-admin.php” find the below function
    add this line to the function duplicate_post_make_duplicate_link_row($actions, $post)

    if( !in_array(get_current_screen()->post_type, array('post', 'page')) ) return $actions;
    this will show the actions links on pages and posts only, you still have to deactivate “Edit Screen” option in plugin settings

    The new function must read

    function duplicate_post_make_duplicate_link_row($actions, $post) {
    	if(  !in_array(get_current_screen()->post_type, array('post', 'page')) ) return $actions;
    
    	if (duplicate_post_is_current_user_allowed_to_copy()) {
    		$actions['clone'] = '<a href="'.duplicate_post_get_clone_post_link( $post->ID , 'display', false).'" title="'
    		. esc_attr(__("Clone this item", DUPLICATE_POST_I18N_DOMAIN))
    		. '">' .  __('Clone', DUPLICATE_POST_I18N_DOMAIN) . '</a>';
    		$actions['edit_as_new_draft'] = '<a href="'. duplicate_post_get_clone_post_link( $post->ID ) .'" title="'
    		. esc_attr(__('Copy to a new draft', DUPLICATE_POST_I18N_DOMAIN))
    		. '">' .  __('New Draft', DUPLICATE_POST_I18N_DOMAIN) . '</a>';
    	}
    	return $actions;
    }

    Thank you Fad Bad, your solution worked for me.

    If anyone wants to turn off duplication for just pages, here is the above code altered a bit:

    if( in_array(get_current_screen()->post_type, array('page')) ) return $actions;

    In the code, I removed the exclamation point (not symbol) from in front of the first array and posts from the second array.

    This means if the current screen IS the page post type, then don’t show the links.

    Hope this helps. 🙂

    Plugin Author Enrico Battocchi

    (@lopo)

    Hi,
    next version (to be released soon, I hope) will feature an option to enable/disable on a post-type basis.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Disable on certain post types?’ is closed to new replies.