WordPress.org

Ready to get started?Download WordPress

Forums

Duplicate Post
[resolved] array_diff() problem (6 posts)

  1. itsmeka
    Member
    Posted 2 years ago #

    I am using WordPress Version 3.3.1 and duplicate post version 2.2. When i click to clone or new draft of main post, it duplicate the post successfully but showing following message:

    Warning: array_diff() [function.array-diff]: Argument #1 is not an array wp-content\plugins\duplicate-post\duplicate-post-admin.php on line 227
    Warning: Invalid argument supplied for foreach() in wp-content\plugins\duplicate-post\duplicate-post-admin.php on line 229
    Warning: Cannot modify header information - headers already sent by (output started at wp-content\plugins\duplicate-post\duplicate-post-admin.php:227) in wp-includes\pluggable.php on line 866

    http://wordpress.org/extend/plugins/duplicate-post/

  2. itsmeka
    Member
    Posted 2 years ago #

    Problem is solved. :)
    i have changed following code in duplicate-post-admin.php at line 278:

    if ($post->post_type == 'page' || (function_exists('is_post_type_hierarchical') && is_post_type_hierarchical( $post->post_type )))
    	do_action( 'dp_duplicate_page', $new_post_id, $post );
    	else
    	do_action( 'dp_duplicate_post', $new_post_id, $post );

    to

    if ($post->post_type == 'page' || (function_exists('is_post_type_hierarchical') && is_post_type_hierarchical( $post->post_type )))
    	do_action( 'dp_duplicate_page', $new_id, $post );
    else
    	do_action( 'dp_duplicate_post', $new_id, $post );
  3. lopo
    Member
    Plugin Author

    Posted 2 years ago #

    Hi,
    thank you for reporting the issue.

    Your workaround isn't exactly right, there is no $new_id in that function, so probably it simply prevents actions to be called.

    This means that custom fields will never be copied.

    You should try to change lines 224-225 from

    $post_meta_keys = get_post_custom_keys($post->ID);
    $meta_blacklist = explode(",",get_option('duplicate_post_blacklist'));

    to

    $post_meta_keys = get_post_custom_keys($post->ID);
    if (empty($post_meta_keys)) return;
    $meta_blacklist = explode(",",get_option('duplicate_post_blacklist'));

    I hope this works.

    I'll make sure to fix the issue in the next version.
    Thank you!

  4. itsmeka
    Member
    Posted 2 years ago #

    I did as you said. Now it is working fine but it does not copy categories, tag and custom fields. After cloning the post, it takes the default categories(Uncategorized), tags(No Tags). Please advice.

    Thank you in advance.

  5. itsmeka
    Member
    Posted 2 years ago #

    Hi logo,
    Sorry, i made some stupid wrong when i edited. Your plugins is great and working great. Thanks for your great work and reply.

  6. lopo
    Member
    Plugin Author

    Posted 2 years ago #

    Hi,
    version 2.3 (out now) includes the fix for this bug.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic