WordPress Settings api data not sanitized if i use ajax
WordPress Settings api data not sanitized if i use ajax
WordPress Settings api data not sanitized if i use ajax
You have to escape the quotation marks like this. <input type=”radio” name=”%1$s[%2$s]” onclick= “showChoosenField(\’%3$s\’)” value=”<?php checked(\’%3$s\’, get_option(\’%1$s[%2$s]\’), true); ?>”/>
WordPress custom setting page – add flashing message
You’d do it something like this: function sanitize_number_callback ($input){ if( !preg_match( ‘/…regex for valid here…/’, $input ) ){ add_settings_error( ‘my_option’, esc_attr( ‘my_option’ ), //becomes part of id attribute of error message __( ‘Number must be a positive integer’, ‘wordpress’ ), //default text zone ‘error’ ); $input = get_option( ‘my_option’ ); //keep old value } return … Read more
you are registering two separate settings groups for setting fields & the problem might be here. function set_options() { register_setting( ‘checkbox-1-settings’, ‘my_checkbox_1_name’ ); register_setting( ‘checkbox-2-settings’, ‘my_checkbox_2_name’ ); } so use only one settings group for both fields to see if it works. function set_options() { register_setting( ‘checkbox-settings’, ‘my_checkbox_1_name’ ); register_setting( ‘checkbox-settings’, ‘my_checkbox_2_name’ ); } Update … Read more
Short answer: your name attribute values must use the schema option_name[array_key]. So, when you use … <input name=”option_name[key1]”> <input name=”option_name[key2]”> … you get an array as option value in your validation function: array ( ‘key1’ => ‘some value’, ‘key2’ => ‘some other value’ ) PHP does that for you, this is not a WordPress feature. … Read more
Modifying form code with echo do_settings_sections(‘rma’) ? ‘something’ : ‘nothing’; renders nothing, so do_settings_sections(‘rma’) is empty. With that in mind, I dont see you adding a section in your posted code. If you add a section to your register_rma_settings() function, and than add this section to your add_settings_field(), than the input will show. function register_rma_settings() … Read more
Seeking clarity on data sanitization fields for settings textarea
I finally got this one. I’ll write out the solution for any other inexperienced person, like me, who is trying to handle a checkbox array when using just one options array. First, the two articles I linked two at the top of the question are good for learning the basic about the topic. Solution – … Read more
Well you could do something like this: Create an associative array for settings, then loop through them to create settings and sections for each field. $settings = array( ‘setting_1_id’ => array( ‘title’=>’First Box Settings’, ‘page’=>’first_box_option’, ‘fields’=> array( array( ‘id’=> ‘box_first_title’, ‘title’=>’Title’, ‘callback’=> ‘text_callback’ ), array( ‘id’=> ‘box_first_desc’, ‘title’=>’Description’, ‘callback’=> ‘textarea_callback’ ), array( ‘id’=> ‘box_first_link’, ‘title’=>’Link’, … Read more