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
- Difference Between Filter and Action Hooks?
- ajaxurl not defined on front end
- How many times will this code run? (or, how rich is grandma?)
- Which hook should be used to add an action containing a redirect?
- add_action hook for completely new post?
- Why does WordPress add 0 (zero) to an Ajax response?
- Add a new tab to WordPress Plugin install Listing
- Saving data-URI to media library
- Nonces can be reused multiple times? Bug / Security issue?
- How can I run AJAX on a button click event?
- Changing Plugin Load Order
- Admin settings update updating every time home page is hit?
- WordPress Hook for user register
- How-to implement admin Ajax inside an admin WP_List_Table?
- Global Objects and Public Methods
- Using filters and actions for plugin API?
- How should you hook a session_start() when authoring a plugin?
- Init action hook running late after PayPal’s return url?
- Is there widely accepted phpDoc syntax for documenting which hook calls a function?
- What is nonce and how to use it with Ajax in WordPress? [duplicate]
- Explanation of the “posts_join” and “posts_fields” filter hooks?
- How do you use the plugin boilerplate loader class to hook actions and filters?
- Empty POST data on server on AJAX request using Angular $http
- Using AJAX in FrontEnd with WordPress Plugin Boilerplate (wppb.io)
- How Do I Load My Action Earlier Enough?
- Does WP fire delete_post when trashed posts are automatically deleted?
- What’s the earliest point I can get the queried object ID?
- How do I Make a Theme “plugin-ready”?
- Why does do_action pass a blank string as the first parameter if no $arg is set?
- Build path for a custom portfolio plugin
- WordPress scheduled task is called but not executed
- Using AJAX in a plugin to submit form – REALLY confused
- wp_localize_script $handle
- How to add a link to WordPress Plugin install Listing
- How to modify post content before writing to database?
- I can’t find where a hook is being defined in a plugin – Easy Digital Downloads
- Call activation hook multiple times
- How do I handle multiple Submit buttons in plugin’s option page?
- How to enable users to down-vote in this simple voting counter (that uses the post meta)?
- What’s the difference between hooks, filters and actions? [duplicate]
- How to use filter hook ‘post_updated_messages’ in coherence with action hook ‘save_post’
- Two-step login process – Is it possible?
- How to check if certain plugin exists and in expected version
- Adding callback function for wp_ajax_ has no effect
- Plugin development, hooks, generate content
- Is it possible to create an action hook using do_action() within add_action()?
- get all products of one category
- How can I hook into existing WordPress Bulk actions?
- Hook for post permalink update
- Dynamically Override Fancy Title
- 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
- Built in admin ajax hooks?
- How to post form in ajax mode and handle it in wordpress
- Using Ajax call in jQuery doesn’t work in widget
- Earliest WP Hook to Safely and Reliably Redirect
- WP_LOCALIZE_SCRIPT doesn’t work
- Timeout on Admin-Ajax?
- Admin-ajax.php appending a status code to ajax response
- Define a function outside a class and call the function using action or filter hook
- Is it possible to modify the media library admin screen?
- What function to hook for changes made in status and visibility of a post
- Create a plugin to change the action to which a function is hooked
- Can I differentiate between “Delete Post Permanently” and “Empty Trash” and do something for each accordingly?
- Synchronize Custom post type tags to WordPress default posts tags
- Adding Automatically To In WordPress Using Filter Referencing?
- Order of Operation for these three hooks
- Comment `Reply` link doesn’t work if comments are loaded from ajax
- comment_email hook doesn’t seem to work for comment editor field
- Best Practices for Creating and Handling Forms with Plugins?
- Is there a better way to implement responsive images than what WordPress uses by default?
- Modifying values with add_action to be sent to db
- Woocommerce – Hide a Column in Cart Table
- unable to stop loop when using wp_insert_post with publish_post hook
- save_post hook not triggered in WP v3.6.1
- Ajax in WordPress – path issue
- Cannot search post by taxonomy
- Hook into theme-switching later than `setup_theme`
- Add tab to profile.php wordpress plugin development
- Is it possible to delay execution of shortcode output callback?
- How to set a custom path, for ajax image upload folder in admin?
- Hook to get image filename when it is uploaded
- WP AJAX is not working, always returns 0
- How to display a message about updates in the plugin list
- Ensure function has completed before allowing another Ajax call
- Why my database table not created on activation?
- How do I change the initial quantity of a product in woocommerce?
- How to delete an user including data from custom database tables
- Act on user meta updated, but only once
- Where and how does WordPress store and use its plugin and hook information?
- Is there any way to allow a plugin to write over a previous version?
- Frontend Ajax call not working using wp_ajax, wp_enqueue_script and wp_localize_script
- Which are the hooks run before/after when a category’s deletion?