searchwp\integration\wp-all-import
Da: 4.1.16
Indice
Per impostazione predefinita, SearchWP si adatterà automaticamente ai processi eseguiti da WP All Import secondo il metodo discusso qui: Come integrare con importazioni/migrazioni di contenuti
Puoi usare questo hook per impedire a SearchWP di integrarsi automaticamente con i processi di WP All Import se preferisci implementare qualcosa da solo.
Parametri
| Tipo | Parametro | Predefinito | Da |
|---|---|---|---|
| Booleano | $enabled |
Se WP All Import è attivo | 4.1.16 |
Esempi
All hooks should be added to your custom SearchWP Customizations Plugin.
Disabilita l'integrazione automatica di SearchWP con WP All Import e aggiungi la tua
Questo snippet delinea le basi per disabilitare l'integrazione automatica di SearchWP con i processi di WP All Import e mostra le basi su come implementare la tua.
| <?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 ); |

