Questions tagged [callbacks]
The callbacks tag has no usage guidance.
113
questions
1
vote
1
answer
38
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
0
answers
19
views
Does adding a callback like this to wp_head allows you to add additional content?
$this->add($this->actions, 'wp_head', $frontend, 'wp_head');
Does adding a callback like this to wp_head allows you to add additional content? I already have a wp_head function and adding a ...
0
votes
1
answer
29
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
0
answers
39
views
How to customize 'children comments' in Wordpress?
Hey i am using a callback for wp_list_comments. I took the Code from here -
5balloons.info/custom-html-for-comments-section-in-wordpress-theme/
Now children comments are out of main comment (means ...
0
votes
0
answers
20
views
Warning: call_user_func_array() expects parameter 1 to be a valid callback - whenever i navigate to wp-admin [duplicate]
whenever i navigate to URL/wp-admin/
i face this error:
Warning: call_user_func_array() expects parameter 1 to be a valid callback, first array member is not a valid class name or object in /...
0
votes
0
answers
16
views
I would like to add a review count of a particular website in to my blog and that it should update automatically every time it changes
Hey i would like to be able to add a review count from google reviews or trustpilot of someone else website that i am writing about them in my blog. i would like it to be accurate and therefore update ...
0
votes
1
answer
27
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
126
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
607
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
435
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
30
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
142
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
1
answer
403
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
79
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
732
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
136
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
2k
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
41
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
3k
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
989
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
78
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
460
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
134
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
131
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/...
0
votes
2
answers
12k
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
48
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
991
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
83
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
317
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
639
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
265
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
300
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
832
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
330
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
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
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
289
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
123
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
97
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
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
1
answer
332
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
34
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
<...