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( … Read more

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 … Read more

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, … Read more

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 … Read more

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 returned. How do I return the error messages set in wp_send_json_error() when there is an error? See my code: function submit_youtube_callback() { … Read more

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 it possible to use the permission_callback, check the parameter, and return false instead of writing a custom response in the … Read more

How do I use the control callback when creating a simple dashboard plugin

On this page: http://codex.wordpress.org/Function_Reference/wp_add_dashboard_widget The function wp_add_dashboard_widget is described. It states: wp_add_dashboard_widget($widget_id, $widget_name, $callback, $control_callback = null) How do you use the $control_callback, properly? I am completeley stuck, as I have defined it but cannot use it. I need to create a form within this widget which is why I am using the control_callback. EDIT: … Read more