Best place to load wp_ajax_the_ajax_hook action in plugin
I don’t know if it is the ‘best’ place, but get_header is early enough to still enqueue scripts: function at_set_header () { global $post, $has_the shortcode; if ( is_object( $post ) && has_shortcode( $post->post_content, ‘shortcode_name’) ) { $has_the_shortcode = true; wp_enqueue_script( ‘my-ajax-handle’, FAU_PLUGIN_URL . ‘js/ajax.js’, array( ‘jquery’ ) ); wp_localize_script( ‘my-ajax-handle’, ‘the_ajax_script’, array( ‘ajaxurl’ => … Read more