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

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

Load custom formatted comment with AJAX: reply link isn’t rendered?

It appears you can get max_depth from the options via get_option(‘thread_comments_depth’): function prefix_submit_ajax_comment(){ $comment = wp_handle_comment_submission( wp_unslash( $_POST ) ); …handle errors and get $comment_depth… $GLOBALS[‘comment’] = $comment; $GLOBALS[‘comment_depth’] = $comment_depth; $args[‘max_depth’] = get_option( ‘thread_comments_depth’ ); // solution op_format_comment($comment, $args, $comment_depth); }

How to securely add an Ajax button to a WP Admin page?

In this answer I created 2 buttons which are visually disabled and get an invalid nonce before submitting. <?php /* Plugin Name: Ajax Example */ add_action( ‘admin_notices’, ‘my_action_button’ ); define( ‘MY_ACTION_NONCE’, ‘my-action-‘ ); function my_action_button() { $id = 4321; $data = array( ‘data-nonce’ => wp_create_nonce( MY_ACTION_NONCE . $id ), ‘data-id’ => $id, ); echo get_submit_button( … Read more

Error 400 bad request using admin-ajax.php

The hook prefix is wrong — it should be wp_ and not admin_: add_action( ‘admin_ajax_nopriv_pedido_clientes’, ‘enviar_pedido_clientes’ ); add_action( ‘admin_ajax_pedido_clientes’, ‘enviar_pedido_clientes’ ); So the correct code is: add_action( ‘wp_ajax_nopriv_pedido_clientes’, ‘enviar_pedido_clientes’ ); add_action( ‘wp_ajax_pedido_clientes’, ‘enviar_pedido_clientes’ );

Why is admin ajax reloading my page

This is probably the new Heartbeat API. It is running in intervals from 15 to 60 seconds and offers a simple way to communicate with WordPress per AJAX in the background. You can disable it in JavaScript with wp.heartbeat.stop(); and in PHP with remove_action( ‘admin_init’, ‘wp_auth_check_load’ ); (might not be enough on some pages).

jQuery UI Autocomplete showing all results

You get all terms because you’re asking for all terms, in fact, the line $tradeList = get_terms(‘trade’); just get all the terms, ignoring the ‘term’ query string passed to file. If you want to get all the terms “filterd” you have to use the string in the query, something like: include_once( ‘../../../wp-load.php’ ); // adjust … Read more