Plugin: AJAX query external API to sync to tables

Sketch/Concept To make requests to remote/external APIs, use the WP HTTP API. More in depth examples/details can be found in some of my answers here. Then simply add an admin page with add_submenu_page() or add_menu_page() or the related functions. Finally add a script via wp_register/enqueue_script() on the admin_enqueue_scripts-hook. There you fire an ajax (search archives) … Read more

Ajax simple experiment

$post isn’t set in your AJAX handler, it doesn’t exist. An AJAX request is a separate request from the one that rendered the page you’re making the request from, php data doesn’t persist across these two requests. You’re passing post_id in your AJAX request, so I assume you want something like: function retrieve_id(){ echo $_POST[‘post_id’]; … Read more

Edit a different page in WP Customizer

The Customizer will apply its changes into the frame over the entire site. Try it yourself with Twenty Thirteen and see. Make some changes, and without saving, navigate to a single post or single page and see how the changes persist even without saving. So likely you’re doing something else that breaks that functionality in … Read more

Including the necessary functions for a custom ajax registration form

Here is a basic setup that I use for AJAX with WordPress. instead of loading wp-load.php on a separate php file; just use WordPress default method for AJAX calls. This allows you to also filter function calls from Javascript through a switch. I also added a quick example for wp_localize_script. <?php add_action(‘wp_enqueue_scripts’, ‘YOUR_NAME_scripts’); //back end … Read more

Theme Customizer – Conditional Controls

I can suggest you another direction : why bother generating a new Control in javascript when you can create controls A and B at the first page load and hide/show them dynamically using javascript ? If I understand well, this was what you described in option 3. Here is a sample code to get you … Read more

Ajax – Call to undefined function get_option()

You’re firing a request to a PHP file that won’t have the WordPress library loaded – hence the undefined function error. You could manually load in WordPress with something like require ‘../../../wp-load.php’. Or, better yet, use the awesome AJAX API. Just fire your request to wp-admin/admin-ajax.php and then register a callback in your plugin or … Read more