SearchWP e REST API di WordPress
SearchWP si integrerà con la REST API di WordPress durante l'esecuzione delle ricerche.
Nota: Quando viene eseguita una ricerca tramite REST API, SearchWP utilizzerà il suo Motore Predefinito, come fa per le richieste di ricerca native di WordPress.
La REST API è utilizzata dal core di WordPress in alcuni punti, inclusa la ricerca nella finestra di dialogo 'Aggiungi link'. Se hai impostato uno dei tuoi Motori SearchWP per essere utilizzato durante le ricerche nell'area di amministrazione, quel Motore verrà utilizzato in questo caso. Ciò potrebbe comportare un comportamento indesiderato a seconda della configurazione del tuo Motore.
Disabilita l'integrazione di SearchWP con la REST API
Puoi usare questo hook per impedire a SearchWP di integrarsi con la REST API:
All hooks should be added to your custom SearchWP Customizations Plugin.
| <?php | |
| // @link https://searchwp.com/documentation/rest-api/ | |
| // Disable default SearchWP REST API Integration. | |
| add_filter( 'searchwp\rest', '__return_false' ); |
Personalizza il Motore utilizzato per le richieste REST
Per personalizzare il Motore SearchWP utilizzato per le richieste REST applicabili:
All hooks should be added to your custom SearchWP Customizations Plugin.
| <?php | |
| // @link https://searchwp.com/documentation/rest-api/ | |
| // Customize the SearchWP Engine used for applicable REST requests. | |
| add_filter( 'searchwp\rest\engine', function( $engine, $args ) { | |
| return 'my_rest_engine_name'; | |
| }, 10, 2 ); |
Personalizza gli argomenti della Query di SearchWP utilizzati per le richieste REST
Per personalizzare gli argomenti della Query di SearchWP utilizzati per le richieste REST applicabili:
All hooks should be added to your custom SearchWP Customizations Plugin.
| <?php | |
| // @link https://searchwp.com/documentation/rest-api/ | |
| // Customize the SearchWP Query arguments used for REST requests. | |
| add_filter( 'searchwp\rest\args', function( $args, $params ) { | |
| // $args are sent to \SWP_Query after this. | |
| // @link https://searchwp.com/documentation/classes/swp_query/ | |
| return $args; | |
| }, 10, 2 ); |

