N
N
Ninja Mate2016-02-12 19:11:01
WordPress
Ninja Mate, 2016-02-12 19:11:01

How not to request pluggable.php in a plugin?

I don't understand why in my case I have to request require_once(ABSPATH .'wp-includes/pluggable.php'); In all similar examples that I found, it was said that this function is connected automatically.
Maybe I'm somehow not using wp_localize_script correctly?

require_once(ABSPATH .'wp-includes/pluggable.php');

wp_enqueue_script( 'bundle', plugins_url( '/bundle.js', __FILE__ ), array('jquery'), '1.0', true );

add_action( 'wp_ajax_send_message', 'do_send_message' );
add_action( 'wp_ajax_nopriv_send_message', 'do_send_message' );

wp_localize_script( 'bundle', 'MyAjax', array(
  'ajaxurl' => admin_url('admin-ajax.php'),
  'nonce' => wp_create_nonce('myajax-nonce')
  ) );

function do_send_message() {
        exit;
    }
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question