Questions tagged [callbacks]
The callbacks tag has no usage guidance.
113
questions
1
vote
1
answer
28
views
Trouble with WordPress Settings API: Form Submits When Fields Called Directly, Fails When Using Callbacks
0
I'm working on a WordPress plugin and facing an issue with the Settings API. I have a settings page with two forms. The first form uses do_settings_sections() to call fields from a public function (...
0
votes
1
answer
19
views
I need help with this error [duplicate]
Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'uthan_preloader' not found or invalid function name in /home/u815400924/domains/jardineschapa.com/public_html/wp-...
1
vote
0
answers
13
views
Create and publish a new post every Monday, listing the post titles and links to the posts published during the previous week
Newbie to Wordpress and PHP!
Every Monday, my task is to create one post (let's call it summary) in a custom post-type called "news".
In summary, the "contents" field will be a ...
0
votes
0
answers
149
views
Callback API for getting response from fygaro payment gateway
I am using fygaro payment gateway.
On successful payment , I am getting json response from fygaro on fygaro's domain itself.
But on successful payment, I want to store some data in database for that ...
1
vote
1
answer
116
views
Gutenberg: How to check if a block is used in a paginated post?
There is the render_callback of the register_block_type function. In this callback, I can use add_filter('render_block', __NAMESPACE__ . '\\filter_block', 10, 2);
filter_block iterates through all ...
0
votes
1
answer
68
views
Add parameters to 3rd party callback function
I have been working on a WordPress plugin and have used the do_shortcode() to implement some functionality within a form...a file upload. The upload processing comes from a 3rd party plugin and It ...
0
votes
1
answer
63
views
How to 'clone' select metabox options with a callback function? [closed]
Here is my metabox
array(
'id' => 'all_btns',
'name' => 'Button Select',
'type' => 'select',
'options' => array(
'button' =&...
0
votes
1
answer
270
views
Run function after a post has finished saving - callback function perhaps?
Upon saving a new post (of a certain post type), a given operation has to run. The problem is that the operation is calling an external (slow) API, which means that the (not logget in) end-user might ...
4
votes
2
answers
2k
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
0
answers
22
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
0
answers
820
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
1
answer
36
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
0
answers
255
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.
...
1
vote
1
answer
955
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
1
answer
212
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
1
answer
1k
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
1
answer
295
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
1
answer
3k
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
1
answer
67
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 ...
2
votes
1
answer
4k
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
1
answer
1k
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
1
answer
112
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
1
answer
2k
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
0
answers
569
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 ...
4
votes
0
answers
185
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
1
answer
376
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
1
answer
2k
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/...
1
vote
2
answers
14k
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
1
answer
55
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 ...
1
vote
0
answers
3k
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
0
answers
1k
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
1
answer
164
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
1
answer
333
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
0
answers
809
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
1
answer
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
1
answer
321
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
0
answers
384
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
1
answer
1k
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
1
answer
2k
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
1
answer
915
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
1
answer
359
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
1
answer
3k
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
2
answers
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
2
answers
1k
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
0
answers
296
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
1
answer
128
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
1
answer
100
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
1
answer
3k
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
1
answer
375
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
1
answer
45
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
<...