Articles of callbacks

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 check if I’ve implemented the nonce correctly and securely. jQuery Script function favorites_javascript() { $ajax_nonce = wp_create_nonce( “ajax-nonce-favorites” […]

default callback function in wp_list_comments

Which default callback function wp_list_comments use if I don’t set callback parameter? I saw in the code of this function but I can’t understand it.

Update term count using a callback function

With the wp_update_term_count_now, how can I use the update_count_callback to specify my own count. I need to include counts from another database that the current database category is able to display. The current categories may not have any posts in them, but are able to be viewed showing posts from the same category in another […]

How to validate register settings array

I would like to know how to perform a proper validation with the register_setting() callback function. Here is a sample part of my code I want to work with: register_setting( ‘wpPart_options’, ‘wpPart_options’, array( &$this, ‘wpPartValidate_settings’ ) ); $this is an array of objects. And here is the content of my wpPartValidate_settings(); function. public function wpPartValidate_settings( […]

settings API: how to create a multi checkbox with blog categories?

i need to create a callback function with a multi checkbox with all the web/blog categories as multi options. my add_settings_fields are: add_settings_field( ‘select_page’, ‘Select Blog Page’, / ‘journal_combo_select_page_callback’, ‘journal_theme_blog_2_col’, ‘blog_page_blog_2_col_section’ ); add_settings_field( ‘limit_posts’, ‘Limit Posts’, ‘journal_limit_posts_callback’, ‘journal_theme_blog_2_col’, ‘blog_page_blog_2_col_section’ ); add_settings_field( // $id, $title, $callback, $page, $section, $args ‘check_categories’, // $id ‘Choose Categories’, // $title […]

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( ‘default’ => $option_parameter[‘default’], ‘type’ => ‘option’, ‘sanitize_callback’ => ‘oenology_sanitize_’ . $option_parameter[‘sanitize’] ) ); Control added (example) like so: $wp_customize->add_control( ‘oenology_’ . $option_parameter[‘name’], $customizer_control_parameters ); Note: $customizer_control_parameters is an array defined elsewhere. For select-type controls (select, radio, […]

How can one utilize a variable as a callback function name for add_settings_field

I’m trying to cut down on the amount of code that is in my theme options function. I’m adding my settings like so: add_settings_field($k,$v,$callback,$the_options,$the_group,$args); This works for me in every way as long as I write out the name of the function. For example, if $callback = ‘awesome_callback’ – and I create a function called […]

wp_insert_post() Callback?

After I added a post by wp_insert_post(); Any callback after I added ? I need permalink of added post. I have idea only search by title and post-type (I use custom post-type in my case), But any better function ?

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 ) { wp.autosave.server.triggerSave(); }

Using a private method as an action callback from within a class

I have created a class from within which I would like to call a private method (from within the same class) from the __construct method as an action callback. When I would like to use a public method I can access it by: add_action( ‘init’, array( $this, ‘action_callback’ ) ); However, this causes an error […]