27 lines
869 B
PHP
27 lines
869 B
PHP
<?php
|
|
/**
|
|
* Temporary CLI test for the FE_Settings AJAX endpoint. Run as its own process
|
|
* because wp_send_json_* calls wp_die. NOT part of the plugin. Delete after running.
|
|
*/
|
|
|
|
error_reporting( E_ALL );
|
|
ini_set( 'display_errors', '0' ); // Keep output pure JSON.
|
|
|
|
define( 'WP_USE_THEMES', false );
|
|
define( 'DOING_AJAX', true );
|
|
require dirname( __DIR__, 3 ) . '/wp-load.php';
|
|
|
|
$admin_id = 1;
|
|
if ( ! get_userdata( $admin_id ) ) {
|
|
$admin_id = (int) get_users( array( 'role' => 'administrator', 'number' => 1, 'fields' => 'ID' ) )[0];
|
|
}
|
|
wp_set_current_user( $admin_id );
|
|
|
|
$_POST['s'] = 'hello';
|
|
$_POST['nonce'] = wp_create_nonce( 'fe_admin_nonce' );
|
|
$_REQUEST['nonce'] = $_POST['nonce'];
|
|
$_REQUEST['s'] = $_POST['s'];
|
|
$_REQUEST['action'] = 'fe_search_posts';
|
|
|
|
FE_Settings::ajax_search_posts(); // Echoes JSON and dies.
|