searchwp\integration\wp-all-import
Since: 4.1.16
Table of Contents
By default, SearchWP will automatically accommodate processes run by WP All Import as per the method discussed here: How to Integrate with Content Imports/Migrations
You can use this hook to prevent SearchWP from automatically integrating with WP All Import processes if you’d prefer to implement something on your own.
Parameters
Type | Parameter | Default | Since |
---|---|---|---|
Boolean | $enabled |
Whether WP All Import is active | 4.1.16 |
Examples
All hooks should be added to your custom SearchWP Customizations Plugin.
Disable SearchWP automatic integration with WP All Import and add your own
This snippet outlines the basics of disabling SearchWP’s automatic integration with WP All Import processes and shows the basics of how to implement your own.
<?php | |
// Disable SearchWP's automatic integration with WP All Import. | |
add_filter( 'searchwp\integration\wp-all-import', '__return_false' ); | |
add_action( 'pmxi_before_xml_import', function( $import_id ) { | |
\SearchWP::$indexer->pause(); | |
}, 10 ); | |
add_action( 'pmxi_saved_post', function( $post_id ) { | |
$source_name = \SearchWP\Utils::get_post_type_source_name( get_post_type( $post_id ) ); | |
$source = \SearchWP::$index->get_source_by_name( $source_name ); | |
// Mark this to be dropped after the import has finished. | |
\SearchWP::$index->drop( $source, $post_id ); | |
}, 10 ); | |
add_action( 'pmxi_after_xml_import', function( $import_id ) { | |
\SearchWP::$indexer->unpause(); | |
// Process all entries marked to be dropped. | |
\SearchWP::$index->unpause(); | |
\SearchWP::$index->trigger(); | |
}, 10 ); |