Insert wp_editor on front-end with AJAX?

So, after doing some more digging, I answered my own question by “connecting the dots”, so to speak. There’s a lot of bits and pieces of info on this topic on StackOverflow and StackExchange, but none of them really answered my question. So here is the full working code to loading a wp_editor instance with … Read more

Ajax stops working when logged in?

A few things that I see: There’s a space in your first add_action declaration. Should be add_action(‘wp_ajax_wppl_function’, ‘wppl_function’); Have you declared wppl_function to run it? Have you localized your scripts when logged in? Please review the codex entry on wp_ajax_nopriv (action)

wp_localize_script escaping my url – fix or alternative

wp_localize_script() now uses json_encode() which means a multidimensional array will now work for the passed data. And, HTML entity decoding only applies to the first level of the array. Better is an way to use json and default js possibilities from WP. At first, i add the options from the database via script and json_encode … Read more

add_action and Ajax

I skimmed through the plugin’s code and you could try to use the define_public_hooks() method of the Plugin_Name class to register your ajax action callbacks of the Plugin_Name_Public class: /** * Register all of the hooks related to the public-facing functionality * of the plugin. * * @since 1.0.0 * @access private */ private function … Read more

Async Loading of Custom Posts

Testing is the only way to be sure, but my guess would be that it is not the query itself that is slowing the page load. After you have fetched those 2000 records, you are looping through them. Every time you call get_template_part. This function in turn calls locate_template, which leads to load_template, where you … Read more

Allow AJAX call to other roles than admin

All the WordPress AJAX calls should be handled by the admin-ajax.php, wether they happen on the frontend or in the backend. To grant the access you have to register the callbackfuntion for the AJAX call add those lines to your file: add_action( ‘wp_ajax_prefix_update_post’, ‘prefix_update_post’ ); add_action( ‘wp_ajax_nopriv_prefix_update_post’, ‘prefix_update_post’ ); Be sure to add some validation … Read more

Why would admin-ajax.php redirect to the home page for logged out users?

It only redirects when accessed directly, as do all files located in wp-admin/. AJAX requests should work fine regardless of authentication status. Edit: wp-admin/admin-ajax.php should not redirect in any situation. Perhaps a plugin is redirecting all unauthenticated users to the homepage? By default, accessing files inside wp-admin/ when not logged in should redirect to the … Read more