ID && $current_user->has_cap('manage_options') || ($current_user->ID && $current_user->has_cap('wppm_admin')))) { exit; } if ( check_ajax_referer( 'wppm_search_wp_pages', '_ajax_nonce', false ) != 1 ) { wp_send_json_error( 'Unauthorised request!', 401 ); } $term = isset( $_GET['q'] ) ? sanitize_text_field( wp_unslash( $_GET['q'] ) ) : ''; $args = array( 'post_type' => 'page', 'post_status' => 'publish', 'orderby' => array( 'title' => 'ASC' ), 'search_wpsc_title' => $term, ); $query = new WP_Query( $args ); $response = array(); foreach ( $query->posts as $page ) { $response[] = array( 'id' => $page->ID, 'title' => $page->post_title, ); } wp_send_json( $response );