Questions tagged [callbacks]

The tag has no usage guidance.

0
votes
1answer
25 views

Extend Woocommerce rest api routes fails

While I'm trying to extend Woocommerce Rest-API routes with a custom one I face the following problem. I have the following class which tries to hook inside Woocommerce API class API_LOADER { ...
0
votes
1answer
25 views

Warning and fatal error

I am getting this error when running my website : Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'sanitize_comment_cookies' not found or invalid function name in ...
0
votes
0answers
40 views

Not able to get my callback URL to work with my wordpress plugins

I have installed a Wordpress Plugin (Revive old Post). This plugins on my wordpress website to send old post to my twitter account.. I have setup my developer account with twitter.. for this plugin ...
0
votes
0answers
7 views

Is there a way to execute a function whenever Gutenberg Blocks are rearranged?

i'm having the following problem: I have created a grid component which uses a binary packing script (packery by metafizzy) to fit its child blocks depending on their size. To improve the editing ...
2
votes
1answer
85 views

WP showing “warning: call_user_func_array()”, What to do?

I am currently working on designing my blog and am almost done but when I updated to 5.1 WordPress version in XAMPP, it started showing up this error message: Warning: call_user_func_array() expects ...
0
votes
0answers
89 views

Callback to custom field is not working in Wordpress REST API

I'm pretty new to the REST API so please excuse any stupid questions. I'm currently trying to develop a plugin and therefore I need to register a custom post type including a custom field. This is all ...
3
votes
0answers
48 views

Hooking a callback into the code within a Gutenberg block

I want to run some JavaScript when a user uploads an image or images using the core/image block or core/gallery block. Ideally I would run my own code when the onSelectImage function is called (and ...
0
votes
1answer
25 views

How to create callback function which returns all posts with specific data?

I need to create a new route all which returns only the specified fields for all posts. add_action( 'rest_api_init', function () { register_rest_route( 'custom', 'all' ,array( 'methods'...
4
votes
1answer
250 views

gutenberg dynamic block is returning 404

I am trying to create a dynamic block and I followed the steps described in the documentation, but for some reason the content that is being returned from /wp-json/wp/v2/block-renderer/plugin-blocks/...
0
votes
2answers
2k views

call_user_func_array expects parameter 1 to be a valid callback

Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'wp_my_admin_enqueue_scripts' not found or invalid function name in /mnt/data/vhosts/casite-961871.cloudaccess.net/...
0
votes
1answer
33 views

Debug in WP backend

The problem - I get these warnings each time I login to /admin page in WP. Depending on which browser I use, there are problems with these: Warning: call_user_func_array() expects parameter 1 to ...
0
votes
1answer
292 views

Creating a Callback URL for Wordpress Woocommerce to update Order Status

I want to create a Callback URL to update the order status when data in JSON format is POST to it. Post Format Example: "hash": "43745580XXXXXXXXXXXXXXXXXXXXXX", "status_feed": [{ "order_id":...
1
vote
0answers
119 views

Shortcode function executed twice?

I use a shortcode function to do some processing as a callback from external service. I created a page, the only content of which is the shortcode. User is redirected to this page from external ...
1
vote
1answer
39 views

Best practice for query_posts in responsive design?

I'm working on a responsive design desktop/mobile but I have a doubt regarding PHP calls, as the hosting provider didn't like high cpu usage. In the loop query I have something like this: <?php ...
1
vote
1answer
143 views

Problems with comments callback (Argument #1 is not an array?)

I built my callback function using class-walker-comment.php as a reference and am at a loss as to why it's not working. Any help is greatly appreciated. The issues I'm encountering are: 1) Avatars ...
0
votes
0answers
336 views

iFrame onLoad in custom Gutenberg block

I have this code that I am trying to rewrite for Gutenberg block: <script type="text/javascript"> <iframe onload="javascript:resizeIframe(this);" src="/...
0
votes
1answer
892 views

Website Warning: call_user_func_array() expects parameter 1 to be a valid callback, class 'Wppr_Public' does not have a method 'amp_support'

Warning: call_user_func_array() expects parameter 1 to be a valid callback, class 'Wppr_Public' does not have a method 'amp_support' in /home1/thrfolde/public_html/3foldtraining/wp-includes/class-...
1
vote
1answer
53 views

Get returned variable from a function to add_shortcode function

I'm passing successfully an ajax object to the backend following this (the script in the JS really it does not matters because I'm getting it well): add_action( 'wp_ajax_my_action', '...
0
votes
0answers
122 views

What is the proper way to call a function (from functions.php) on a link click?

When using frameworks, we have routes where we can configure a callback functions for links, in drupal too there are menus that can be used to do the same. So i would like to know if there is a proper ...
0
votes
1answer
264 views

Add_action not calling callback function

I am currently trying to build a plugin for wordpress to build a settings page. But for some reason when I use add_action("admin_init", array(class_object, 'function_name')) it will run the add_action ...
0
votes
1answer
640 views

How To Override A WooCommerce AJAX Function

I would like to override a WP (WooCommerce AJAX function) using add_filter. The original code is set in a WC OOP class via something like: add_action( 'wp_ajax_wc_function', array( $this, '...
0
votes
1answer
589 views

WooCommerce - callback after order successfully placed

I am using woocommerce with some custom code to add more details on the cart object when it's submitted to the db. This works fine, now I am afater a way to clear the localstorage after the order has ...
0
votes
1answer
392 views

Detect device change (desktop, tablet or mobile) in Customizer

In the Theme Customizer preview I am using Modernizr to include certain classes that change the page styles. If I understand it correctly, changing the device type to tablet or mobile only changes the ...
0
votes
1answer
91 views

How to access $post from a callback function

I am wondering whether using global $post is a 'best practice' when it is necessary to get the $post within a callback function triggered by an action hook. The code would be: class myPlugin { ...
1
vote
1answer
2k views

How to Dynamically Load Content Into Body of Bootstrap Modal Window?

I found this answer on Stack Overflow, answer this exact question. I've modified it slightly, because I'm using a button and not an anchor: jQuery( ".modal" ).on( "show.bs.modal", function ( e ) { ...
0
votes
2answers
769 views

Using Javascript Callback from plugin in a theme

I'm definitely missing some basics here. I'm using this plugin wich performs ajax actions, and then fires a js function as callback. I would like to use the callback in a custom js script of my theme....
1
vote
2answers
498 views

How do I check if AJAX nonces are implemented correctly?

I have a simple "favorite post" button that works with AJAX. I understand that using a WordPress nonce improves security, but am not quite sure why or how it does this. This also makes me unable to ...
1
vote
0answers
189 views

Customizer: Category Select Sanitize

as a noob I managed out to create a custom selectbox control for categories in customizer. But now I am trying to find a clever 'sanitize_callback' function in order to ensure security. Here is my ...
0
votes
1answer
88 views

Callback After WordPress Customizer Complete Loading

I'm facing a problem and it is that I'm trying to select textarea inside text widget, but problem is customizer appends dynamically content inside it so I'm unable to select it. I have successfully ...
1
vote
1answer
60 views

Stop post being published

i am attempting to stop a page from being published if certain criteria are not met using the transition_post_status hook. However the WP_DIE does not stop the post from being published. function ...
0
votes
1answer
1k views

Filter Hook callback error, is it due to using $this inside a filter or something else?

I'm trying to apply a filter, but I get a callback error and I'm not sure why. I think it might have to do with the fact that the filter I'm using includes a $this because I extracted the function ...
0
votes
1answer
224 views

standard callback function for wp_list_comments

I know that the code for the comment is generated in Walker_Comment::comment() and for html5 themes in the method Walker_Comment::html5_comment. But if I try to copy the code from that last method ...
1
vote
1answer
24 views

Settings API callback function inserts html quotes from nowhere

currently I try to write a callback for a Wordpress option of my theme with the settings API. This is my function: function background_callback($args){ printf( 'Picture <...
0
votes
1answer
3k views

How to use wp_send_json_error?

I'm having trouble understanding how wp_send_json_error works to return error messages. It works fine as long as none of the error conditions are met. But if there is an error, then nothing gets ...
6
votes
1answer
3k views

Wordpress REST API - Permission Callbacks

I'm currently building a small REST API with the WP-REST v2 plugin. Everything is working perfectly fine, however, in the documentation there are permission callbacks, which restrict access to certain ...
3
votes
1answer
254 views

Callback for wp.autosave.server.triggerSave();

I'm using following code to force WordPress page to save post as draft, is there any callback function for it, I want to alert a text after it complete saving post as draft. if ( wp.autosave.server ) ...
0
votes
0answers
49 views

Ajax callback and shortcode functionality

I see that some people are having troubles using shortcodes in Ajax callbacks as apparently the Ajax instance is run in a different environment than usual. Advices are more than one, many of them ...
1
vote
2answers
403 views

call_user_func_array() errors after migrating site with InstantWP

I am setting up a WordPress site locally from a site online. I downloaded the files and database. I used InstantWP to set up the site. I imported the database and moved over the proper files for the ...
0
votes
2answers
755 views

Calling PHP function doesn't work in index.php

I have a function I wrote in my functions.php page for a gallery to display on certain pages. It displays on custom templates, but now I need it to display on index.php Here is the code from my ...
0
votes
1answer
142 views

register_settings callback function erases data

I have registered a setting with a callback function: register_setting( 'my-plugin-settings-group', 'notification_email', 'email_validation' ) and callback function looks like: function ...
0
votes
1answer
3k views

Warning: call_user_func() expects parameter 1 to be a valid callback, function

I keep getting this error when. I am trying to insert a dashboard widget and I don't know what's causing the error. Warning: call_user_func() expects parameter 1 to be a valid callback, function '...
0
votes
1answer
30 views

custom-background callback breaks media uploader

I've added theme support for a custom background/color along with a callback and it seems to be breaking my media uploader, as while the uploader box appears, uploads result in an error and image ...
0
votes
1answer
1k views

Retrieve post in AJAX Callback

I have a JS file that triggers a PHP callback file. The PHP file is supposed to work on the Post that is currently opened (wp-admin/post.php). I do not want the JS file to pass the post id though ...
0
votes
2answers
361 views

Customiser sections not being displayed with `active_callback`

I've added several customisation options to my theme, and I'm (trying to) use the active_callback argument with $wp_customiser->add_section(). In the first instance, this appears to be working ...
0
votes
1answer
300 views

Custom Sanitation Function Triggering an Alert in Customizer?

I have an image upload field in theme-customizer : /* Background Image */ $wp_customize->add_setting( 'tcx_background_image', array( 'default' => '', 'transport' ...
0
votes
1answer
3k views

How to return multiple arguments from AJAX callback function

First of all, please don't mark the question as duplicate as I didn't ask how to send arguments with ajax request. I want to receive some extra arguments on ajax success. My callback function will ...
2
votes
1answer
1k views

How to get control choices from $setting object passed to sanitize_callback

Example Code Working with the Customizer API. Setting added (example) like so: $wp_customize->add_setting( 'theme_oenology_options[' . $option_parameter['name'] . ']', array( '...
2
votes
1answer
4k views

Callback URL in WordPress

I want to use this service OnWebChange to monitor when a website changes and change mine accordingly. It would notify me via a URL callback to my website URL with a HTTP POST method. What tools/API/...
0
votes
1answer
235 views

Problem with Class, Filters and Callbacks

according to this Callback example if I'm referencing a method inside a class, I should use add_filter by specifying an array with 2 elements, first the object then the method. Here is my code: ...
0
votes
3answers
5k views

Ajax insert or update data

I've been browsing through similar questions and have yet to get this functionality to work. I'm tracking the progress a user makes an embedded vimeo video and insert data or update data. JS on the ...