This will never work:
add_action( 'admin_init', 'my_ajax_checker', 10, 2);
function my_ajax_checker() {
if( wp_doing_ajax() ) {
add_action('plugins_loaded', 'atv_convert_multilingual');
}
}
This is because by the time admin_init
runs, plugins_loaded
has already happened! Making this code would would require the code to travel backwards in time.
Instead it would be much simpler to do this:
add_action('plugins_loaded', 'atv_convert_multilingual');
Or this:
if( wp_doing_ajax() ) {
add_action('plugins_loaded', 'atv_convert_multilingual');
}
Take a look at https://www.rarst.net/wordpress/wordpress-core-load/ for more information on the order that hooks fire in WordPress
Related Posts:
- Get returned variable from a function to add_shortcode function
- WordPress Ajax callback function from plugin – OOP
- .mo translation strings not loading in PHP scripts that handle AJAX calls
- template_redirect or admin-ajax.php?
- Ajax +wordpress onClick link redirect to new page and create html content
- Trigger a JavaScript function based on the data fetched from Woo commerce hook
- ajaxurl not defined on front end
- Which hook should be used to add an action containing a redirect?
- Why does WordPress add 0 (zero) to an Ajax response?
- Saving data-URI to media library
- Nonces can be reused multiple times? Bug / Security issue?
- Is there widely accepted phpDoc syntax for documenting which hook calls a function?
- Empty POST data on server on AJAX request using Angular $http
- What’s the earliest point I can get the queried object ID?
- How do I Make a Theme “plugin-ready”?
- WordPress scheduled task is called but not executed
- How to modify post content before writing to database?
- How to enable users to down-vote in this simple voting counter (that uses the post meta)?
- How to use filter hook ‘post_updated_messages’ in coherence with action hook ‘save_post’
- Plugin development, hooks, generate content
- Is it possible to create an action hook using do_action() within add_action()?
- Plugin Settings not Saving on Ajax re-ordered table
- Hook event for upload image in the menu
- Help with callback using do_action_ref_array
- Using Ajax call in jQuery doesn’t work in widget
- Timeout on Admin-Ajax?
- Comment `Reply` link doesn’t work if comments are loaded from ajax
- Best Practices for Creating and Handling Forms with Plugins?
- Is there a better way to implement responsive images than what WordPress uses by default?
- Woocommerce – Hide a Column in Cart Table
- Ensure function has completed before allowing another Ajax call
- Should action callbacks start with a verb?
- Why is my javascript not invoked in my hooks except wp_head?
- Namespaced action and filter tags
- What filter should I use to insert a button inside on Media>Add New
- include wp-blog-header not working on MAMP
- How can I pass get_the_author_meta(‘user_email’) through the REST API?
- How to use a hook to override an update_post_meta call in a plugin?
- External Authentication, session_tokens not destroyed on logout
- Trying to understand order and frequency of action hooks firing
- get post attachment using ajax
- Dashboard – get status and position of metaboxes and pass them to ajax method
- how to search users by ajax live search
- Fatal error: Uncaught Error: Call to undefined function get_option()
- WordPress custom taxonomy check box to dropdown
- how to get context information inside my funcion
- AJAX form post returns 0
- Bug: Post needs to be updated twice when adding action for save_post hook
- Remove entire [$key] from array stored in custom field using Ajax – unset($array[$key]); not working
- Remove an action by extending class and replacing it
- Trying to get class to instantiate ONCE (or, “why do I keep punching myself in the head?”)
- insert query on a custom table using ajax with jQuery plugin Jeditable
- Plugin AJAX Save to Custom Table
- Why enqueue styles on hook?
- WooCommerce change Tax Class programmatically when Recalculating an existing Order [closed]
- Setting a JSON web token from a secondary api as a secure cookie on WordPress
- Hide one specific woocoomerce product
- Best practice for plugin: always detect admin-ajax call?
- Plugin Form Submitting to admin-ajax.php instead of admin-post.php
- Redirect returning users to a certain page?
- Restrict certain actions to plugin-specific admin menu pages only
- AJAX request not routing through proxy
- Set the payment processor callbacks to a plugin
- Ajax on the Administration Side of plugin – returns 0
- How to enhance a self developed plugin by its own plugin architecture
- GET request return value as error instead of success
- How to update global variables in plugin activation callback?
- How to control ajax calls without effecting memory of server?
- Add two button to page and post admin to redirect to : add new & list of (posts – pages) just after saving post or page
- Forbidden Error in ajax call with wordpress
- `registration_errors` filter doesn’t seem to be called
- ajax stopped working when not logged in wordpress
- ajax call return 406 not acceptable for non logged users only
- Why does do_action pass a blank string as the first parameter if no $arg is set?
- Add a custom submenu under submenu in a Custom WordPress Plugin
- ajax response strips multidimensional array and unable to decode
- WordPress Ajax not returning Response
- Hook for validating and rejecting frontend image upload
- Using AJAX to submit and return data inside the WordPress Plugin Boiler Plate framework
- Inserted data from database does not showing on front-page without referesh page?
- wp_ajax function return the html page
- $_SESSION inside php function executed by AJAX
- Two same AJAX calls – one is working, other doesn’t
- How to get values from Tinymce visual editor popup?
- remove different admin menu for specific users
- How To do Ajax In WordPress Custom Plugin?
- replacing jquery google cdn with a new version dynamically
- How and when would I implement some code which would take data from one part of the Db and put it in another?
- Ajax call not working with
- plugin modal/popup integration best practice
- WP Ajax on page load not working on bluehost but was working on Godaddy
- Ajax not working to insert, query and result data
- Can’t get query string in ajax call
- An adiitional function fires on my AJAX submit
- Get user logged in status from within a plugin. $current_user not defined
- Fatal error: Call to a member function query() on a non-object in my ajaxpage
- how to insert content into wp_head after loop_end
- Apply function on all action hooks?
- Send Webhook when post-status is publish or trash
- Using “add_image_size” to register custom image sizes inside plugins not working