Questions tagged [callbacks]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
3
votes
2answers
95 views

How to check if which hook triggered the call to a function?

I have a situation where I have a function hooked to more than one custom hooks. How to check in the callback function which custom hook triggered the call? Or the question in code will be add_action('...
0
votes
0answers
17 views

JavaScript missing from shortcode content

I am trying to add a short javascript as part of registering a WP shortcode. You can see my simplified code below. When I execute this on my website everything loads fine except for the part between ...
0
votes
0answers
74 views

CallBack URL for payment gateway redirecting to homepage instead of executing callback function

I am working on a payment plugin for Woocommerce which requires that I set the URL to redirect after payment. I set this as home_url('/?').'wc-api=WC_Payment_Gateway'. The payment gateway appends ...
0
votes
1answer
27 views

Code works, but warning about call_user_func_array() appears

I'm a newbie to Wordpress. I'm trying to make custom page that displays contact info for all users. I use code snippet provided by THIS POST. <ul> <?php $blogusers = get_users('blog_id=1&...
0
votes
0answers
25 views

“Class Not Found” in HTML Form Target PHP File that contains the class

How do I make the HTML form's action target file 'aware' of classes that WordPress has already loaded? File A -> Creates a WordPress shortcode that inserts a form that has 'File B' as the target. ...
0
votes
1answer
71 views

admin_notices action doesn't trigger within save_post action

After the save_post action runs, I'm attempting to also use the admin_notices action and it doesn't work. What am I doing wrong? If I move the admin_notices action into the constructor, it works fine ...
1
vote
1answer
53 views

Using shortcode content with nested shortcode

This is a shortcode example. [a][b]something[/b][/a] It should be used like this with do_shortcode($content); function a_shortcode($atts = [], $content = null) { do_shortcode($content); ...
0
votes
1answer
296 views

Update block once an API request returns with a value

I've got a block that allows the user to enter a script when in edit mode, then sends this script to a REST endpoint which returns a WP_Post representing a media file which is then displayed to the ...
1
vote
1answer
51 views

settings_fields doesn't appear to be running

I'm creating a settings page for a plugin. It adds: a submenu item registers a setting adds a section adds a field and then renders the page/section/field. It is all pretty straightforward, only "...
1
vote
1answer
1k views

How to insert a record by clicking on the link using AJAX

I am developing a plugin for WordPress. Looking for a solution I want to insert record (it may be any CRUD operation) when the user click on the link order-button I am very much new to Ajax so ...
0
votes
1answer
29 views

Call function with button and return response

I'm trying to do the folllowing. I have a button in my template (in templates folder of my plugin). When they press the button I want to call a function and send and id to the function. In that ...
0
votes
1answer
2k views

Can we access the REST request parameters from within the permission_callback to enforce a 401 by returning false?

From what I have tried and tested so far, the getters and setters do not work inside the function permission_callback. The alternate way would be to throw a custom 401 from the callback itself. Is ...
0
votes
1answer
726 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
60 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 ...
4
votes
1answer
1k 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 ...
1
vote
0answers
360 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
97 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
68 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
1k 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
8k 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
41 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 be a ...
0
votes
1answer
2k 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
698 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
55 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
295 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
498 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
2k 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
171 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
243 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
734 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
1k 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
973 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
705 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 ...
1
vote
1answer
222 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
1k 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
864 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
267 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
107 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
87 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
2k 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
295 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
25 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 <...
1
vote
1answer
6k 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
4k 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
450 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
52 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
579 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
1k 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
239 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 ...