MarkArts
Forum Replies Created
-
Forum: Plugins
In reply to: [Advanced Search by My Solr Server] Trash Items Still In Solr IndexI had the same problem and after some digging I found out why this was happening.
First of the plugin doesn’t have a hook for “transition_post_status”.
And secondly the hook on “save_post” doesn’t contain a check for the trashed, private or protected status (only for draft and auto-draft) causing trashed, private and protected items to be put (back) in the index when saved.
To solve this problem you can either overwrite the hooks in your own functions.php or change the following lines in the advanced-search-by-my-solr-server.php file from the plugin
Line 598
if ($post_info->post_status=='auto-draft' || $post_info->post_status=='draft') return;
To
if ($post_info->post_status=='auto-draft' || $post_info->post_status=='draft' || $post_info->post_status=='private' || $post_info->post_status=='protected' || $post_info->post_status=='trash' ) return;
Line 638
if ( ($_POST['prev_status'] == 'publish' || $_POST['original_post_status'] == 'publish') && ($post_info->post_status == 'draft' || $post_info->post_status == 'private') ) {
To
if ( ($_POST['prev_status'] == 'publish' || $_POST['original_post_status'] == 'publish') && ($post_info->post_status=='draft' || $post_info->post_status=='private' || $post_info->post_status=='protected' || $post_info->post_status=='trash' ) ) {
And add this line to the bottom of the file
add_action( 'transition_post_status', 'mss_handle_status_change');
If you don’t want to change the plugin files you can also ‘overwrite’ the hooks for “transition_post_status” and “save_post” by copying the original functions
You will need to addrequire_once(ABSPATH."wp-content/plugins/advanced-search-by-my-solr-server/advanced-search-by-my-solr-server.php");
in your function to make sure you can use the plugin functions.