Built in admin ajax hooks?

WordPress core is something where you cannot create your own hooks. Hooks in WordPress are created with these apply_filters apply_filters_ref_array apply_filters_deprecated do_action do_action_ref_array do_action_deprecated The only thing you can do is to register your function to certain WordPress core hook. But where are these hooks? You may expect these hooks in a function called activate_plugin. … Read more

ajax jquery update custom field meta value front end

First, you need to output a response in your my_action_callback() function. That response will be available inside your jQuery success callback: function(response){}. At that point it is just a matter of updating the HTML of the page with the new views count. PHP: function my_action_callback() { // … echo $views; exit; } JavaScript: jQuery.post(ajaxurl, data, … Read more

Plupload in metabox – AJAX action not working in Class

Aha, the problem as that I was calling the wp_ajax_plupload_action from within my page conditional check like so: function __construct() { global $pagenow; $pages = array(‘post.php’, ‘post-new.php’); if (in_array($pagenow, $pages)) : add_action(‘add_meta_boxes’, array($this, ‘dhf_video_meta_box’)); add_action(‘admin_print_scripts’, array($this, ‘video_meta_js’)); add_action(‘admin_head’, array($this, ‘plupload_admin_head’)); add_action(‘admin_print_scripts’, array($this, ‘video_meta_css’)); add_action(‘wp_ajax_plupload_action’, array($this, ‘plupload_action’)); endif; } You don’t want to do it like … Read more

Vue.js + AJAX Shortcode

My solution was simpler than I thought…. Since I’m just trying to execute shortcodes in the frontend, I can just localize the script and pass the shortcodes as variables: functions.php wp_localize_script( ‘BUILD-script’, ‘sharedData’, array( ‘ajax_url’ => admin_url( ‘admin-ajax.php’ ), ‘mailchimpForm’ => do_shortcode(‘[mc4wp_form id=”100″]’), ‘contactForm’ => do_shortcode(‘[contact-form-7 id=”98″ title=”Contact form 1″]’) ) ); Basically I’m jus … Read more

I can’t access wordpress functions from an ajax php call

You are making a new request to the server and you appear to be loading a page that is not loading WordPress core functions. I’d need to see your HitCount.php to confirm this but I can’t think of another explanation. Loading WordPRess files piecemeal is tricky and prone to breakage as core code changes. You … Read more

Quick Edit: Selected Custom Taxonomy Not Refreshing After Save

Added this code to updated the selected field by identifying the appropriate value in the taxonomy column: jQuery(document).ready(function($) { // Create a copy of the WP inline edit post function var $wp_inline_edit = inlineEditPost.edit; // Overwrite the function with our own code inlineEditPost.edit = function( id ) { // Call the original WP edit function … Read more

pop-up lighbox with AJAX

To use AJAX in a WordPress website you can the admin-ajax.php file. This file handles your requests and sends it to the correct function. A short step-by-step guide on how to achieve: First you need to localize your javascript file so that it knows the URL of the admin-ajax.php file on your server. add_action( ‘wp_enqueue_scripts’, … Read more