Identical wp_rest nonce returned from rest_api

Despite you already figured it out or found a solution, since this is a follow-up to the other question, I thought it’d be benefecial to post this answer, so hopefully it helps you. =) WordPress uses the native setcookie() function in PHP for setting the authentication cookies, and $_COOKIE for reading the cookies values. But … Read more

how to send Ajax request in wordpress backend

When you enqueue or localize a script you’re doing it specifically for the front end or the admin. If you want to enqueue or localize a script in both, you have to specifically do it for both. This is used to enqueue/localize for the front end add_action( ‘wp_enqueue_scripts’, ‘your_function_front’ ); your_function_front() { wp_localize_script(‘scripts’, ‘myAjax’, array( … Read more

WordPress ajax problem need wordpress expert?

The answer is quite simple – you are not giving admin-ajax what it is expecting. Please refer to the source code http://core.trac.wordpress.org/browser/tags/3.2.1/wp-admin/admin-ajax.php#L17 if ( ! isset( $_REQUEST[‘action’] ) ) die(‘-1’); So make sure you are giving it an action (which you are not). Then, a little lower there is: if ( ! $id ) die(‘-1’); … Read more

Convert this relative path to absolute

As long as your wp-admin directory is still at the root of your site, you can just add a forward slash (/) to the URI. Alterntaively, you can use wp_localize_script() to pass in your site’s URL or, if you are using WordPress’s AJAX functions, the ajaxurl JS variable. var ajaxPath=”/wp-admin/admin-ajax.php”; Or <?php wp_enqueue_script( ‘some_handle’ ); … Read more