Support » Plugin: Search Exclude » Does not work with “Search Exclude”

  • Resolved eamax

    (@eamax)


    It would be possivelable to add support to the “Duplicate Post” plugin, when the post is cloned the “Search Exclude” option also be cloned.

    The Duplicate Post Developer said: (Lopo)

    You could ask the developers of Search Exclude to enforce compatibility with my plugin: they could use the information I’ve detailed here under “Action Hooks”, probably it would need just a few lines of code.

    • This topic was modified 2 years, 11 months ago by eamax.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author pronskiy

    (@pronskiy)

    Hello,

    I will take a look at this and get back to you soon.

    Cheers!
    Roman

    Thank you

    Plugin Author pronskiy

    (@pronskiy)

    Here is the solution. You need to copy this code to your theme’s function.php:

    
    function search_exclude_clone_value($new_post_id, $old_post_object) {
        global $pluginSearchExclude;
        $method = new ReflectionMethod('SearchExclude', 'getExcluded');
        $method->setAccessible(true);
        $excluded = $method->invoke($pluginSearchExclude);
        $exclude = false !== array_search($old_post_object->ID, $excluded);
        do_action('searchexclude_hide_from_search', array($new_post_id), $exclude);
    }
    
    add_action( "dp_duplicate_post", "search_exclude_clone_value", 10, 2);
    add_action( "dp_duplicate_page", "search_exclude_clone_value", 10, 2);
    

    Next update of SearchExclude will support a more elegant solution. But anyway, please try the one above and let me know how it works for you.

    • This reply was modified 2 years, 11 months ago by pronskiy.

    Worked perfectly. Thank you.
    When update happens I can remove the code?

    • This reply was modified 2 years, 11 months ago by eamax.
    Plugin Author pronskiy

    (@pronskiy)

    eamax,

    Great, you’re welcome!
    Most likely not. The plan was to make code shorter. But I will consider the idea of removing code at all.
    Anyway, the updated version will be backward compatible and the solution above will stay working.

    Cheers!
    Roman

    • This reply was modified 2 years, 11 months ago by pronskiy.
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Does not work with “Search Exclude”’ is closed to new replies.