| @@ -12,1409 +12,1616 @@ | ||
| 12 | 12 | |
| 13 | 13 | if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 14 | 14 | |
| 15 | 15 | |
| 16 | -abstract class WPBC_Settings_API { | |
| 17 | - | |
| 18 | - /** | |
| 19 | - * ID of specific Settings page | |
| 20 | - * basically its prefix near each generated Input field | |
| 21 | - * | |
| 22 | - * @var String | |
| 23 | - */ | |
| 24 | - public $id; | |
| 25 | - | |
| 26 | - /** | |
| 27 | - * Define different options for CLASS - check more in constructor. | |
| 28 | - * | |
| 29 | - * @var array | |
| 30 | - */ | |
| 31 | - public $options; | |
| 32 | - | |
| 33 | - /** | |
| 34 | - * List of all settings rows | |
| 35 | - * @var array | |
| 36 | - */ | |
| 37 | - public $fields = array(); | |
| 38 | - | |
| 39 | - /** | |
| 40 | - * Values of all settings fields | |
| 41 | - * @var array | |
| 42 | - */ | |
| 43 | - public $fields_values = array(); | |
| 44 | - | |
| 45 | - /** | |
| 46 | - * Validated fields after $_POST request - for example before saving to DB | |
| 47 | - * | |
| 48 | - * @var array | |
| 49 | - */ | |
| 50 | - public $validated_fields = array(); | |
| 51 | - | |
| 52 | - | |
| 53 | - /** | |
| 16 | +abstract class WPBC_Settings_API { | |
| 17 | + | |
| 18 | + /** | |
| 19 | + * ID of specific Settings page | |
| 20 | + * basically its prefix near each generated Input field | |
| 21 | + * | |
| 22 | + * @var String | |
| 23 | + */ | |
| 24 | + public $id; | |
| 25 | + | |
| 26 | + /** | |
| 27 | + * Define different options for CLASS - check more in constructor. | |
| 28 | + * | |
| 29 | + * @var array | |
| 30 | + */ | |
| 31 | + public $options; | |
| 32 | + | |
| 33 | + /** | |
| 34 | + * List of all settings rows | |
| 35 | + * @var array | |
| 36 | + */ | |
| 37 | + public $fields = array(); | |
| 38 | + | |
| 39 | + /** | |
| 40 | + * Values of all settings fields | |
| 41 | + * @var array | |
| 42 | + */ | |
| 43 | + public $fields_values = array(); | |
| 44 | + | |
| 45 | + /** | |
| 46 | + * Validated fields after $_POST request - for example before saving to DB | |
| 47 | + * | |
| 48 | + * @var array | |
| 49 | + */ | |
| 50 | + public $validated_fields = array(); | |
| 51 | + | |
| 52 | + | |
| 53 | + /** | |
| 54 | 54 | * If setted, then we can validate all form fields, BEFORE post. |
| 55 | - * Each form field that we need to validate have to have parameter: "validate_as" which ia array, like array('required') | |
| 56 | - * HTML fields elements will have additional CSS classes, like "validate-required" | |
| 57 | - * If this $validated_form_id empty so then no validation procedure. | |
| 58 | - * | |
| 59 | - * @var string | |
| 60 | - */ | |
| 61 | - public $validated_form_id = ''; | |
| 62 | - /** | |
| 63 | - * Constructor for Settings API | |
| 64 | - * | |
| 65 | - * @param string $id - unique ID of this Settings | |
| 66 | - * @param array $options - Optional. Array of parameters. | |
| 67 | - * array( | |
| 68 | - * 'db_prefix_option' => 'wpbc_' | |
| 69 | - * , 'db_saving_type' => 'togather' ['togather'|'separate'|'separate_prefix'] | |
| 70 | - * ) | |
| 71 | - * @param array $fields_values - optional array of values. If skipped, then case system try to get values from DB. | |
| 72 | - */ | |
| 73 | - public function __construct( $id, $options = array(), $fields_values = array() ) { | |
| 55 | + * Each form field that we need to validate have to have parameter: "validate_as" which ia array, like array('required') | |
| 56 | + * HTML fields elements will have additional CSS classes, like "validate-required" | |
| 57 | + * If this $validated_form_id empty so then no validation procedure. | |
| 58 | + * | |
| 59 | + * @var string | |
| 60 | + */ | |
| 61 | + public $validated_form_id = ''; | |
| 74 | 62 | |
| 75 | - $this->id = $id; // Define name of this settings page | |
| 76 | - | |
| 77 | - $default_options = array( | |
| 78 | - 'db_prefix_option' => 'wpbc_' // Prefix for adding to option name before saving to DB | |
| 79 | - , 'db_saving_type' => 'separate' // Type of DB saving: 'togather' | 'separate' | 'separate_prefix' | |
| 80 | - /* 'togather' - saving all parameters from settings page to one DB option | |
| 81 | - 'separate' - saving each settings parameters as separate DB options | |
| 82 | - 'separate_prefix' - saving each settings parameters as separate DB options | |
| 83 | - with prefix $id */ | |
| 84 | - ); | |
| 85 | - | |
| 86 | - $this->options = wp_parse_args( $options, $default_options ); | |
| 63 | + /** | |
| 64 | + * Constructor for Settings API | |
| 65 | + * | |
| 66 | + * @param string $id - unique ID of this Settings | |
| 67 | + * @param array $options - Optional. Array of parameters. | |
| 68 | + * array( | |
| 69 | + * 'db_prefix_option' => 'wpbc_' | |
| 70 | + * , 'db_saving_type' => 'togather' ['togather'|'separate'|'separate_prefix'] | |
| 71 | + * ) | |
| 72 | + * @param array $fields_values - optional array of values. If skipped, then case system try to get values from DB. | |
| 73 | + */ | |
| 74 | + public function __construct( $id, $options = array(), $fields_values = array() ) { | |
| 87 | 75 | |
| 88 | - // Define what fields we are having | |
| 89 | - $this->init_settings_fields(); // Init all Fields Rows for settings page | |
| 90 | - | |
| 91 | - | |
| 92 | - // Get Values for the fields | |
| 93 | - if ( empty( $fields_values ) ) { | |
| 94 | - $this->define_fields_values_from_db(); // Define Fields Values from DB | |
| 95 | - } else { | |
| 96 | - $this->define_fields_values( $fields_values ); // Define Fields by transmited values | |
| 97 | - } | |
| 98 | - | |
| 99 | - // Set Values for the fields | |
| 100 | - $this->set_values_to_fields(); // Assign $this->fields_values['some_field'] to $this->fields[ 'some_field' ]['value'] | |
| 101 | - | |
| 102 | - add_action( 'wpbc_after_settings_content', array($this, 'enqueue_validate_js'), 10, 3 ); // Add JavaScript if you need | |
| 103 | - } | |
| 104 | - | |
| 105 | - | |
| 106 | - /** | |
| 76 | + $this->id = $id; // Define name of this settings page . | |
| 77 | + | |
| 78 | + $default_options = array( | |
| 79 | + 'db_prefix_option' => 'wpbc_', | |
| 80 | + // Prefix for adding to option name before saving to DB. | |
| 81 | + 'db_saving_type' => 'separate' | |
| 82 | + // Type of DB saving: 'togather' | 'separate' | 'separate_prefix'. | |
| 83 | + /* 'togather' - saving all parameters from settings page to one DB option | |
| 84 | + 'separate' - saving each settings parameters as separate DB options | |
| 85 | + 'separate_prefix' - saving each settings parameters as separate DB options | |
| 86 | + with prefix $id */ | |
| 87 | + ); | |
| 88 | + | |
| 89 | + $this->options = wp_parse_args( $options, $default_options ); | |
| 90 | + | |
| 91 | + // Define what fields we are having. | |
| 92 | + $this->init_settings_fields(); // Init all Fields Rows for settings page. | |
| 93 | + | |
| 94 | + | |
| 95 | + // Get Values for the fields | |
| 96 | + if ( empty( $fields_values ) ) { | |
| 97 | + $this->define_fields_values_from_db(); // Define Fields Values from DB. | |
| 98 | + } else { | |
| 99 | + $this->define_fields_values( $fields_values ); // Define Fields by transmited values. | |
| 100 | + } | |
| 101 | + | |
| 102 | + // Set Values for the fields. | |
| 103 | + $this->set_values_to_fields(); // Assign $this->fields_values['some_field'] to $this->fields[ 'some_field' ]['value']. | |
| 104 | + | |
| 105 | + add_action( 'wpbc_after_settings_content', array( | |
| 106 | + $this, | |
| 107 | + 'enqueue_validate_js' | |
| 108 | + ), 10, 3 ); // Add JavaScript if you need. | |
| 109 | + } | |
| 110 | + | |
| 111 | + | |
| 112 | + /** | |
| 107 | 113 | * Validate Form Fields before $_POST request |
| 108 | - * | |
| 109 | - * @param string $page_tag | |
| 110 | - */ | |
| 111 | - public function enqueue_validate_js( $page_tag, $active_page_tab, $active_page_subtab ) { | |
| 114 | + * | |
| 115 | + * @param string $page_tag | |
| 116 | + */ | |
| 117 | + public function enqueue_validate_js( $page_tag, $active_page_tab, $active_page_subtab ) { | |
| 112 | 118 | |
| 113 | - if ( empty( $this->validated_form_id ) ) | |
| 114 | - return; | |
| 115 | - | |
| 116 | - // Get Fields to validate | |
| 117 | - $fields_to_validate = array(); | |
| 118 | - foreach ( $this->fields as $field_name => $field_values ) { | |
| 119 | + if ( empty( $this->validated_form_id ) ) { | |
| 120 | + return; | |
| 121 | + } | |
| 119 | 122 | |
| 120 | - if ( ( isset( $field_values['validate_as'] ) ) && ( ! empty( $field_values['validate_as'] ) ) ) { | |
| 121 | - $field_html_id = $this->id . '_' . $field_name; | |
| 122 | - $fields_to_validate[ $field_html_id ] = $field_values['validate_as']; | |
| 123 | - } | |
| 124 | - } | |
| 125 | - // JavaScript ////////////////////////////////////////////////////////////// | |
| 126 | - | |
| 127 | - $js_script = ''; | |
| 123 | + // Get Fields to validate | |
| 124 | + $fields_to_validate = array(); | |
| 125 | + foreach ( $this->fields as $field_name => $field_values ) { | |
| 128 | 126 | |
| 129 | - $js_script .= " jQuery('#". $this->validated_form_id ."').on( 'submit', function(){ "; // Catch Submit event | |
| 130 | - | |
| 131 | - foreach ( $fields_to_validate as $field_html_id => $field_validate_array ) { | |
| 132 | - | |
| 133 | - // Validate Required. | |
| 134 | - $js_script .= " if ( jQuery('#". $field_html_id ."').val() == '' ) { " . "\n" ; | |
| 135 | - | |
| 136 | - $js_script .= " wpbc_field_highlight( '#". $field_html_id ."' );" . "\n" ; | |
| 137 | - | |
| 138 | - //$js_script .= " wpbc_scroll_to( '#". $field_html_id ."' );" . "\n" ; | |
| 139 | - //$js_script .= " showWarningUnderElement( '#". $field_html_id ."' );" . "\n" ; | |
| 140 | - | |
| 141 | - $js_script .= " return false; " . "\n" ; // - cancel event - Submit | |
| 142 | - | |
| 143 | - $js_script .= " }" . "\n" ; | |
| 144 | - } | |
| 145 | - | |
| 146 | - $js_script .= " } ); " . "\n"; | |
| 147 | - | |
| 148 | - // Eneque JS to the footer of the page | |
| 149 | - wpbc_enqueue_js( $js_script ); | |
| 150 | - } | |
| 151 | - | |
| 152 | - //////////////////////////////////////////////////////////////////////////// | |
| 153 | - // Abstract methods | |
| 154 | - //////////////////////////////////////////////////////////////////////////// | |
| 155 | - | |
| 156 | - /** | |
| 157 | - * Init all fields rows for settings page | |
| 158 | - */ | |
| 159 | - abstract public function init_settings_fields(); | |
| 160 | - | |
| 127 | + if ( ( isset( $field_values['validate_as'] ) ) && ( ! empty( $field_values['validate_as'] ) ) ) { | |
| 128 | + $field_html_id = $this->id . '_' . $field_name; | |
| 129 | + $fields_to_validate[ $field_html_id ] = $field_values['validate_as']; | |
| 130 | + } | |
| 131 | + } | |
| 132 | + // JavaScript . | |
| 161 | 133 | |
| 162 | - | |
| 163 | - | |
| 164 | - //////////////////////////////////////////////////////////////////////////// | |
| 165 | - // Functions | |
| 166 | - //////////////////////////////////////////////////////////////////////////// | |
| 167 | - | |
| 168 | - /** | |
| 134 | + $js_script = ''; | |
| 135 | + | |
| 136 | + $js_script .= " jQuery('#" . $this->validated_form_id . "').on( 'submit', function(){ "; // Catch Submit event. | |
| 137 | + | |
| 138 | + foreach ( $fields_to_validate as $field_html_id => $field_validate_array ) { | |
| 139 | + | |
| 140 | + // Validate Required. | |
| 141 | + $js_script .= " if ( jQuery('#" . $field_html_id . "').val() == '' ) { " . "\n"; | |
| 142 | + | |
| 143 | + $js_script .= " wpbc_field_highlight( '#" . $field_html_id . "' );" . "\n"; | |
| 144 | + | |
| 145 | + //$js_script .= " wpbc_scroll_to( '#". $field_html_id ."' );" . "\n" ; | |
| 146 | + //$js_script .= " showWarningUnderElement( '#". $field_html_id ."' );" . "\n" ; | |
| 147 | + | |
| 148 | + $js_script .= " return false; " . "\n"; // - cancel event - Submit. | |
| 149 | + | |
| 150 | + $js_script .= " }" . "\n"; | |
| 151 | + } | |
| 152 | + | |
| 153 | + $js_script .= " } ); " . "\n"; | |
| 154 | + | |
| 155 | + // Eneque JS to the footer of the page. | |
| 156 | + wpbc_enqueue_js( $js_script ); | |
| 157 | + } | |
| 158 | + | |
| 159 | + // ----------------------------------------------------------------------------------------------------------------- | |
| 160 | + // Abstract methods | |
| 161 | + // ----------------------------------------------------------------------------------------------------------------- | |
| 162 | + /** | |
| 163 | + * Init all fields rows for settings page | |
| 164 | + */ | |
| 165 | + abstract public function init_settings_fields(); | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + // ----------------------------------------------------------------------------------------------------------------- | |
| 171 | + // Functions | |
| 172 | + // ----------------------------------------------------------------------------------------------------------------- | |
| 173 | + /** | |
| 169 | 174 | * Get array of Default fields Names and Values. |
| 170 | - * Example: | |
| 171 | - * $default_values = array( | |
| 172 | - * 'my_date_format' => get_option('date_format') | |
| 173 | - * , 'my_time_format' => get_option('time_format') | |
| 174 | - * ); | |
| 175 | - * | |
| 176 | - * @return array | |
| 177 | - */ | |
| 178 | - public function get_default_values() { | |
| 179 | - | |
| 180 | - $default_values = array(); | |
| 181 | - | |
| 182 | - foreach ( $this->fields as $field_name => $field_data ) { | |
| 183 | - if ( isset( $field_data['default'] ) ) { | |
| 184 | - $default_values[ $field_name ] = $field_data['default']; | |
| 185 | - } else { | |
| 186 | - // Action here if no default value in field. | |
| 187 | - } | |
| 188 | - } | |
| 175 | + * Example: | |
| 176 | + * $default_values = array( | |
| 177 | + * 'my_date_format' => get_option('date_format') | |
| 178 | + * , 'my_time_format' => get_option('time_format') | |
| 179 | + * ); | |
| 180 | + * | |
| 181 | + * @return array | |
| 182 | + */ | |
| 183 | + public function get_default_values() { | |
| 189 | 184 | |
| 190 | - return $default_values; | |
| 191 | - } | |
| 185 | + $default_values = array(); | |
| 192 | 186 | |
| 193 | - | |
| 194 | - /** | |
| 187 | + foreach ( $this->fields as $field_name => $field_data ) { | |
| 188 | + if ( isset( $field_data['default'] ) ) { | |
| 189 | + $default_values[ $field_name ] = $field_data['default']; | |
| 190 | + } else { | |
| 191 | + // Action here if no default value in field. | |
| 192 | + } | |
| 193 | + } | |
| 194 | + | |
| 195 | + return $default_values; | |
| 196 | + } | |
| 197 | + | |
| 198 | + | |
| 199 | + /** | |
| 195 | 200 | * Define "Default Values" for all exist settings Fields. |
| 196 | - * | |
| 197 | - * @param array $fields_values - Optional. Field values | |
| 198 | - */ | |
| 199 | - public function define_fields_values( $fields_values = array(), $is_check_exist_values_from_fields = true ) { | |
| 200 | - | |
| 201 | - // Default | |
| 202 | - if ( $is_check_exist_values_from_fields ) | |
| 203 | - $default_values = $this->get_default_values(); | |
| 204 | - else | |
| 205 | - $default_values = array(); | |
| 206 | - | |
| 207 | - // Parse | |
| 208 | - $this->fields_values = wp_parse_args( $fields_values, $default_values ); | |
| 209 | - | |
| 210 | - if ( $is_check_exist_values_from_fields ) { // We no need to check it after saving to DB | |
| 211 | - $defined_values_in_fields = array(); | |
| 212 | - foreach ( $this->fields as $field_name => $field_data) { | |
| 213 | - if (isset($field_data['value'])) { | |
| 214 | - $defined_values_in_fields[$field_name] = $field_data['value']; | |
| 215 | - } | |
| 216 | - } | |
| 217 | - $this->fields_values = wp_parse_args( $defined_values_in_fields, $this->fields_values ); | |
| 218 | - } | |
| 219 | - } | |
| 220 | - | |
| 201 | + * | |
| 202 | + * @param array $fields_values - Optional. Field values | |
| 203 | + */ | |
| 204 | + public function define_fields_values( $fields_values = array(), $is_check_exist_values_from_fields = true ) { | |
| 221 | 205 | |
| 222 | - | |
| 223 | - /** | |
| 206 | + // Default . | |
| 207 | + if ( $is_check_exist_values_from_fields ) { | |
| 208 | + $default_values = $this->get_default_values(); | |
| 209 | + } else { | |
| 210 | + $default_values = array(); | |
| 211 | + } | |
| 212 | + | |
| 213 | + // Parse. | |
| 214 | + $this->fields_values = wp_parse_args( $fields_values, $default_values ); | |
| 215 | + | |
| 216 | + if ( $is_check_exist_values_from_fields ) { // We no need to check it after saving to DB. | |
| 217 | + $defined_values_in_fields = array(); | |
| 218 | + foreach ( $this->fields as $field_name => $field_data ) { | |
| 219 | + if ( isset( $field_data['value'] ) ) { | |
| 220 | + $defined_values_in_fields[ $field_name ] = $field_data['value']; | |
| 221 | + } | |
| 222 | + } | |
| 223 | + $this->fields_values = wp_parse_args( $defined_values_in_fields, $this->fields_values ); | |
| 224 | + } | |
| 225 | + } | |
| 226 | + | |
| 227 | + | |
| 228 | + /** | |
| 224 | 229 | * Set Values to Fiels |
| 225 | - * Assign $this->fields_values to $fields[ 'some_field' ]['value'] | |
| 226 | - */ | |
| 227 | - public function set_values_to_fields() { | |
| 228 | - | |
| 229 | - foreach ( $this->fields_values as $field_name => $field_value ) { | |
| 230 | - | |
| 231 | - if ( isset( $this->fields[ $field_name ] ) ) { | |
| 232 | - $this->fields[ $field_name ][ 'value' ] = $field_value; | |
| 233 | - } | |
| 234 | - } | |
| 235 | - } | |
| 236 | - | |
| 237 | - | |
| 238 | - /** | |
| 239 | - * Get ID of this settings page | |
| 240 | - * | |
| 241 | - * @return string | |
| 242 | - */ | |
| 243 | - public function get_id() { | |
| 244 | - return $this->id; | |
| 245 | - } | |
| 230 | + * Assign $this->fields_values to $fields[ 'some_field' ]['value'] | |
| 231 | + */ | |
| 232 | + public function set_values_to_fields() { | |
| 246 | 233 | |
| 247 | - | |
| 248 | - /** | |
| 249 | - * Get Value of specfic Field | |
| 250 | - * @param string $field_name | |
| 251 | - * @return mixed or false, if field does not exist | |
| 252 | - * | |
| 253 | - */ | |
| 254 | - public function get_field_value( $field_name ) { | |
| 255 | - | |
| 256 | - if ( empty( $this->fields_values ) ) | |
| 257 | - $this->define_fields_values(); // If empty, then define by Default values | |
| 258 | - | |
| 259 | - return isset( $this->fields_values[ $field_name ] ) ? $this->fields_values[ $field_name ] : false; | |
| 260 | - } | |
| 261 | - | |
| 234 | + foreach ( $this->fields_values as $field_name => $field_value ) { | |
| 262 | 235 | |
| 263 | - | |
| 264 | - /** | |
| 236 | + if ( isset( $this->fields[ $field_name ] ) ) { | |
| 237 | + $this->fields[ $field_name ]['value'] = $field_value; | |
| 238 | + } | |
| 239 | + } | |
| 240 | + } | |
| 241 | + | |
| 242 | + | |
| 243 | + /** | |
| 244 | + * Get ID of this settings page | |
| 245 | + * | |
| 246 | + * @return string | |
| 247 | + */ | |
| 248 | + public function get_id() { | |
| 249 | + return $this->id; | |
| 250 | + } | |
| 251 | + | |
| 252 | + | |
| 253 | + /** | |
| 254 | + * Get Value of specfic Field | |
| 255 | + * | |
| 256 | + * @param string $field_name | |
| 257 | + * | |
| 258 | + * @return mixed or false, if field does not exist | |
| 259 | + * | |
| 260 | + */ | |
| 261 | + public function get_field_value( $field_name ) { | |
| 262 | + | |
| 263 | + if ( empty( $this->fields_values ) ) { | |
| 264 | + $this->define_fields_values(); | |
| 265 | + } // If empty, then define by Default values | |
| 266 | + | |
| 267 | + return isset( $this->fields_values[ $field_name ] ) ? $this->fields_values[ $field_name ] : false; | |
| 268 | + } | |
| 269 | + | |
| 270 | + | |
| 271 | + /** | |
| 265 | 272 | * Set Value to specfic Field |
| 266 | - * @param string $field_name | |
| 267 | - * @return mixed or false, if field does not exist | |
| 268 | - * | |
| 269 | - */ | |
| 270 | - public function set_field_value( $field_name , $field_value ) { | |
| 271 | - | |
| 272 | - if ( empty( $this->fields_values ) ) | |
| 273 | - $this->define_fields_values(); // If empty, then define by Default values | |
| 274 | - | |
| 275 | - $this->fields_values[ $field_name ] = $field_value; | |
| 276 | - } | |
| 277 | - | |
| 278 | - | |
| 279 | - /** | |
| 280 | - * Get all exist form fields | |
| 281 | - * and Init fields, if fields are empty. | |
| 282 | - * | |
| 283 | - * @return array | |
| 284 | - */ | |
| 285 | - public function get_form_fields() { | |
| 286 | - | |
| 287 | - if ( empty( $this->fields ) ) { | |
| 288 | - $this->init_settings_fields(); | |
| 289 | - } | |
| 290 | - | |
| 291 | - return $this->fields; | |
| 292 | - } | |
| 293 | - | |
| 294 | - | |
| 295 | - /** | |
| 296 | - * Generate Settings Table | |
| 297 | - */ | |
| 298 | - public function show( $group = false ) { | |
| 299 | - ?> | |
| 300 | - <table class="form-table"> | |
| 301 | - <?php $this->generate_settings_rows( $group ); ?> | |
| 302 | - </table><?php | |
| 303 | - } | |
| 304 | - | |
| 305 | - | |
| 306 | - /** | |
| 307 | - * Loop through the fields array and show settings. | |
| 308 | - */ | |
| 309 | - public function generate_settings_rows( $group = false, $form_fields = false ) { | |
| 273 | + * | |
| 274 | + * @param string $field_name | |
| 275 | + * | |
| 276 | + * @return mixed or false, if field does not exist | |
| 277 | + * | |
| 278 | + */ | |
| 279 | + public function set_field_value( $field_name, $field_value ) { | |
| 310 | 280 | |
| 311 | - if ( ! $form_fields ) { | |
| 312 | - $form_fields = $this->get_form_fields(); | |
| 313 | - } | |
| 281 | + if ( empty( $this->fields_values ) ) { | |
| 282 | + $this->define_fields_values(); | |
| 283 | + } // If empty, then define by Default values | |
| 314 | 284 | |
| 315 | - $html = ''; | |
| 316 | - foreach ( $form_fields as $k => $v ) { | |
| 317 | - | |
| 318 | - $k = $this->id . '_' . $k; | |
| 319 | - | |
| 320 | - if ( ! isset( $v['type'] ) || ( $v['type'] == '' ) ) { | |
| 321 | - $v['type'] = 'text'; | |
| 322 | - } | |
| 323 | - | |
| 324 | - if ( ( $group === false ) | |
| 325 | - || ( ( ! isset( $v['group'] ) ) && ( $group == 'general' ) ) | |
| 326 | - || ( ( isset( $v['group'] ) ) && ( $group == $v['group'] ) ) | |
| 327 | - ) { | |
| 328 | - if ( method_exists( $this, 'field_' . $v['type'] . '_row' ) ) { | |
| 329 | - $html .= $this->{'field_' . $v['type'] . '_row'}( $k, $v ); | |
| 330 | - } else { | |
| 331 | - $html .= $this->{'field_text_row'}( $k, $v ); | |
| 332 | - } | |
| 333 | - } | |
| 334 | - } | |
| 285 | + $this->fields_values[ $field_name ] = $field_value; | |
| 286 | + } | |
| 335 | 287 | |
| 336 | - echo $html; | |
| 337 | - } | |
| 338 | - | |
| 339 | - | |
| 340 | - // <editor-fold defaultstate="collapsed" desc=" G e n e r a t e F i e l d s " > | |
| 341 | - | |
| 342 | - //////////////////////////////////////////////////////////////////////////// | |
| 343 | - // Input Fields | |
| 344 | - //////////////////////////////////////////////////////////////////////////// | |
| 345 | - | |
| 346 | - /** | |
| 347 | - * Text Input Row | |
| 348 | - * | |
| 349 | - * @param string $field_name - name of field | |
| 350 | - * @param array $field - parameters | |
| 351 | - * @param boolean $echo - show or return reaults {default true} | |
| 352 | - * @return string - html || nothing | |
| 353 | - */ | |
| 354 | - public function field_text_row( $field_name, $field, $echo = true ) { | |
| 355 | - if ( ! $echo ) | |
| 356 | - return self::field_text_row_static( $field_name, $field, $echo ); | |
| 357 | - else | |
| 358 | - self::field_text_row_static( $field_name, $field, $echo ); | |
| 359 | - } | |
| 360 | 288 | |
| 361 | - | |
| 362 | - /** | |
| 363 | - * Text Color Row | |
| 364 | - * | |
| 365 | - * @param string $field_name - name of field | |
| 366 | - * @param array $field - parameters | |
| 367 | - * @param boolean $echo - show or return reaults {default true} | |
| 368 | - * @return string - html || nothing | |
| 369 | - */ | |
| 370 | - public function field_color_row( $field_name, $field, $echo = true ) { | |
| 371 | - if ( ! $echo ) | |
| 372 | - return self::field_color_row_static( $field_name, $field, $echo ); | |
| 373 | - else | |
| 374 | - self::field_color_row_static( $field_name, $field, $echo ); | |
| 375 | - } | |
| 376 | - | |
| 377 | - | |
| 378 | - /** | |
| 379 | - * Textarea Row | |
| 380 | - * | |
| 381 | - * @param string $field_name - name of field | |
| 382 | - * @param array $field - parameters | |
| 383 | - * @param boolean $echo - show or return reaults {default true} | |
| 384 | - * @return string - html || nothing | |
| 385 | - */ | |
| 386 | - public function field_textarea_row( $field_name, $field, $echo = true ) { | |
| 387 | - if ( ! $echo ) | |
| 388 | - return self::field_textarea_row_static( $field_name, $field, $echo ); | |
| 389 | - else | |
| 390 | - self::field_textarea_row_static( $field_name, $field, $echo ); | |
| 391 | - } | |
| 392 | - | |
| 393 | - | |
| 394 | - /** | |
| 395 | - * WP Rich Content Edit Textarea Row | |
| 396 | - * | |
| 397 | - * @param string $field_name - name of field | |
| 398 | - * @param array $field - parameters | |
| 399 | - * @param boolean $echo - show or return reaults {default true} | |
| 400 | - * @return string - html || nothing | |
| 401 | - */ | |
| 402 | - public function field_wp_textarea_row( $field_name, $field, $echo = true ) { | |
| 403 | - if ( ! $echo ) | |
| 404 | - return self::field_wp_textarea_row_static( $field_name, $field, $echo ); | |
| 405 | - else | |
| 406 | - self::field_wp_textarea_row_static( $field_name, $field, $echo ); | |
| 407 | - } | |
| 408 | - | |
| 409 | - | |
| 410 | - /** | |
| 411 | - * Radio buttons field row | |
| 412 | - * | |
| 413 | - * @param string $field_name - name of field | |
| 414 | - * @param array $field - parameters | |
| 415 | - * @param boolean $echo - show or return reaults {default true} | |
| 416 | - * @return string - html || nothing | |
| 417 | - */ | |
| 418 | - public function field_radio_row( $field_name, $field, $echo = true ) { | |
| 419 | - if ( ! $echo ) | |
| 420 | - return self::field_radio_row_static( $field_name, $field, $echo); | |
| 421 | - else | |
| 422 | - self::field_radio_row_static( $field_name, $field, $echo); | |
| 423 | - } | |
| 424 | - | |
| 425 | - | |
| 426 | - /** | |
| 427 | - * Selectbox field row | |
| 428 | - * | |
| 429 | - * @param string $field_name - name of field | |
| 430 | - * @param array $field - parameters | |
| 431 | - * @param boolean $echo - show or return reaults {default true} | |
| 432 | - * @return string - html || nothing | |
| 433 | - */ | |
| 434 | - public function field_select_row( $field_name, $field, $echo = true ) { | |
| 435 | - if ( ! $echo ) | |
| 436 | - return self::field_select_row_static( $field_name, $field, $echo ); | |
| 437 | - else | |
| 438 | - self::field_select_row_static( $field_name, $field, $echo ); | |
| 439 | - } | |
| 440 | - | |
| 441 | - | |
| 442 | - /** | |
| 443 | - * Checkbox field row | |
| 444 | - * | |
| 445 | - * @param string $field_name - name of field | |
| 446 | - * @param array $field - parameters | |
| 447 | - * @param boolean $echo - show or return reaults {default true} | |
| 448 | - * @return string - html || nothing | |
| 449 | - */ | |
| 450 | - public function field_checkbox_row( $field_name, $field, $echo = true ) { | |
| 451 | - if ( ! $echo ) | |
| 452 | - return self::field_checkbox_row_static( $field_name, $field, $echo ); | |
| 453 | - else | |
| 454 | - self::field_checkbox_row_static( $field_name, $field, $echo ); | |
| 455 | - } | |
| 456 | - | |
| 457 | - //////////////////////////////////////////////////////////////////////////// | |
| 458 | - // Static Methods | |
| 459 | - //////////////////////////////////////////////////////////////////////////// | |
| 460 | - | |
| 461 | - /** | |
| 462 | - * Static Text Input Row | |
| 463 | - * | |
| 464 | - * @param string $field_name - name of field | |
| 465 | - * @param array $field - parameters | |
| 466 | - * @param boolean $echo - show or return reaults {default true} | |
| 467 | - * @return string - html || nothing | |
| 468 | - */ | |
| 469 | - public static function field_text_row_static( $field_name, $field, $echo = true ) { | |
| 470 | - | |
| 471 | - $defaults = array( | |
| 472 | - 'title' => '', | |
| 473 | - 'disabled' => false, | |
| 474 | - 'class' => '', | |
| 475 | - 'css' => '', | |
| 476 | - 'placeholder' => '', | |
| 477 | - 'type' => 'text', | |
| 478 | - 'description' => '', | |
| 479 | - 'attr' => array(), | |
| 480 | - 'group' => 'general', | |
| 481 | - 'tr_class' => '', | |
| 482 | - 'only_field' => false, | |
| 483 | - 'description_tag' => 'p' | |
| 484 | - , 'validate_as' => array() | |
| 485 | - ); | |
| 289 | + /** | |
| 290 | + * Get all exist form fields | |
| 291 | + * and Init fields, if fields are empty. | |
| 292 | + * | |
| 293 | + * @return array | |
| 294 | + */ | |
| 295 | + public function get_form_fields() { | |
| 486 | 296 | |
| 487 | - $field = wp_parse_args( $field, $defaults ); | |
| 488 | - | |
| 489 | - if ( ! $echo ) { | |
| 490 | - ob_start(); | |
| 491 | - } | |
| 492 | - | |
| 493 | - if ( ! $field['only_field'] ) { | |
| 494 | - ?> | |
| 495 | - <tr valign="top" class="wpbc_tr_<?php echo esc_attr( $field_name ), ' ', esc_attr( $field['tr_class'] ); ?>"> | |
| 496 | - <th scope="row"> | |
| 497 | - <?php echo self::label_static( $field_name, $field ); ?> | |
| 498 | - </th> | |
| 499 | - <td><fieldset><?php | |
| 500 | - } | |
| 501 | - ?> | |
| 502 | - <legend class="screen-reader-text"><span><?php echo wp_kses_post( $field['title'] ); ?></span></legend> | |
| 503 | - <input type="<?php echo esc_attr( $field['type'] ); ?>" | |
| 504 | - id="<?php echo esc_attr( $field_name ); ?>" | |
| 505 | - name="<?php echo esc_attr( $field_name ); ?>" | |
| 506 | - value="<?php echo esc_attr($field['value']); ?>" | |
| 507 | - class="regular-text <?php echo esc_attr( $field['class'] ); | |
| 508 | - echo ( ! empty($field['validate_as']) ) ? ' validate-' . implode( ' validate-', $field['validate_as'] ) : ''; ?>" | |
| 509 | - style="<?php echo esc_attr( $field['css'] ); ?>" | |
| 510 | - placeholder="<?php echo esc_attr( $field['placeholder'] ); ?>" | |
| 511 | - <?php echo self::get_custom_attr_static( $field ); ?> | |
| 512 | - <?php disabled( $field['disabled'], true ); ?> | |
| 297 | + if ( empty( $this->fields ) ) { | |
| 298 | + $this->init_settings_fields(); | |
| 299 | + } | |
| 300 | + | |
| 301 | + return $this->fields; | |
| 302 | + } | |
| 303 | + | |
| 304 | + | |
| 305 | + /** | |
| 306 | + * Generate Settings Table | |
| 307 | + */ | |
| 308 | + public function show( $group = false ) { | |
| 309 | + ?> | |
| 310 | + <table class="form-table"> | |
| 311 | + <?php | |
| 312 | + $this->generate_settings_rows( $group ); | |
| 313 | + ?> | |
| 314 | + </table> | |
| 315 | + <?php | |
| 316 | + } | |
| 317 | + | |
| 318 | + | |
| 319 | + /** | |
| 320 | + * Loop through the fields array and show settings. | |
| 321 | + */ | |
| 322 | + public function generate_settings_rows( $group = false, $form_fields = false ) { | |
| 323 | + | |
| 324 | + if ( ! $form_fields ) { | |
| 325 | + $form_fields = $this->get_form_fields(); | |
| 326 | + } | |
| 327 | + | |
| 328 | + $html = ''; | |
| 329 | + foreach ( $form_fields as $k => $v ) { | |
| 330 | + | |
| 331 | + $k = $this->id . '_' . $k; | |
| 332 | + | |
| 333 | + if ( ! isset( $v['type'] ) || ( $v['type'] == '' ) ) { | |
| 334 | + $v['type'] = 'text'; | |
| 335 | + } | |
| 336 | + | |
| 337 | + if ( | |
| 338 | + ( $group === false ) || ( ( ! isset( $v['group'] ) ) && ( $group == 'general' ) ) || ( ( isset( $v['group'] ) ) && ( $group == $v['group'] ) ) ) { | |
| 339 | + if ( method_exists( $this, 'field_' . $v['type'] . '_row' ) ) { | |
| 340 | + $html .= $this->{'field_' . $v['type'] . '_row'}( $k, $v ); | |
| 341 | + } else { | |
| 342 | + $html .= $this->{'field_text_row'}( $k, $v ); | |
| 343 | + } | |
| 344 | + } | |
| 345 | + } | |
| 346 | + | |
| 347 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 348 | + echo $html; | |
| 349 | + } | |
| 350 | + | |
| 351 | + | |
| 352 | + // <editor-fold defaultstate="collapsed" desc=" G e n e r a t e F i e l d s " > | |
| 353 | + | |
| 354 | + // ----------------------------------------------------------------------------------------------------------------- | |
| 355 | + // Input Fields | |
| 356 | + // ----------------------------------------------------------------------------------------------------------------- | |
| 357 | + /** | |
| 358 | + * Text Input Row | |
| 359 | + * | |
| 360 | + * @param string $field_name - name of field | |
| 361 | + * @param array $field - parameters | |
| 362 | + * @param boolean $echo - show or return reaults {default true} | |
| 363 | + * | |
| 364 | + * @return string - html || nothing | |
| 365 | + */ | |
| 366 | + public function field_text_row( $field_name, $field, $echo = true ) { | |
| 367 | + if ( ! $echo ) { | |
| 368 | + return self::field_text_row_static( $field_name, $field, $echo ); | |
| 369 | + } else { | |
| 370 | + self::field_text_row_static( $field_name, $field, $echo ); | |
| 371 | + } | |
| 372 | + } | |
| 373 | + | |
| 374 | + | |
| 375 | + /** | |
| 376 | + * Text Color Row | |
| 377 | + * | |
| 378 | + * @param string $field_name - name of field | |
| 379 | + * @param array $field - parameters | |
| 380 | + * @param boolean $echo - show or return reaults {default true} | |
| 381 | + * | |
| 382 | + * @return string - html || nothing | |
| 383 | + */ | |
| 384 | + public function field_color_row( $field_name, $field, $echo = true ) { | |
| 385 | + if ( ! $echo ) { | |
| 386 | + return self::field_color_row_static( $field_name, $field, $echo ); | |
| 387 | + } else { | |
| 388 | + self::field_color_row_static( $field_name, $field, $echo ); | |
| 389 | + } | |
| 390 | + } | |
| 391 | + | |
| 392 | + | |
| 393 | + /** | |
| 394 | + * Textarea Row | |
| 395 | + * | |
| 396 | + * @param string $field_name - name of field | |
| 397 | + * @param array $field - parameters | |
| 398 | + * @param boolean $echo - show or return reaults {default true} | |
| 399 | + * | |
| 400 | + * @return string - html || nothing | |
| 401 | + */ | |
| 402 | + public function field_textarea_row( $field_name, $field, $echo = true ) { | |
| 403 | + if ( ! $echo ) { | |
| 404 | + return self::field_textarea_row_static( $field_name, $field, $echo ); | |
| 405 | + } else { | |
| 406 | + self::field_textarea_row_static( $field_name, $field, $echo ); | |
| 407 | + } | |
| 408 | + } | |
| 409 | + | |
| 410 | + | |
| 411 | + /** | |
| 412 | + * WP Rich Content Edit Textarea Row | |
| 413 | + * | |
| 414 | + * @param string $field_name - name of field | |
| 415 | + * @param array $field - parameters | |
| 416 | + * @param boolean $echo - show or return reaults {default true} | |
| 417 | + * | |
| 418 | + * @return string - html || nothing | |
| 419 | + */ | |
| 420 | + public function field_wp_textarea_row( $field_name, $field, $echo = true ) { | |
| 421 | + if ( ! $echo ) { | |
| 422 | + return self::field_wp_textarea_row_static( $field_name, $field, $echo ); | |
| 423 | + } else { | |
| 424 | + self::field_wp_textarea_row_static( $field_name, $field, $echo ); | |
| 425 | + } | |
| 426 | + } | |
| 427 | + | |
| 428 | + | |
| 429 | + /** | |
| 430 | + * Radio buttons field row | |
| 431 | + * | |
| 432 | + * @param string $field_name - name of field | |
| 433 | + * @param array $field - parameters | |
| 434 | + * @param boolean $echo - show or return reaults {default true} | |
| 435 | + * | |
| 436 | + * @return string - html || nothing | |
| 437 | + */ | |
| 438 | + public function field_radio_row( $field_name, $field, $echo = true ) { | |
| 439 | + if ( ! $echo ) { | |
| 440 | + return self::field_radio_row_static( $field_name, $field, $echo ); | |
| 441 | + } else { | |
| 442 | + self::field_radio_row_static( $field_name, $field, $echo ); | |
| 443 | + } | |
| 444 | + } | |
| 445 | + | |
| 446 | + | |
| 447 | + /** | |
| 448 | + * Selectbox field row | |
| 449 | + * | |
| 450 | + * @param string $field_name - name of field | |
| 451 | + * @param array $field - parameters | |
| 452 | + * @param boolean $echo - show or return reaults {default true} | |
| 453 | + * | |
| 454 | + * @return string - html || nothing | |
| 455 | + */ | |
| 456 | + public function field_select_row( $field_name, $field, $echo = true ) { | |
| 457 | + if ( ! $echo ) { | |
| 458 | + return self::field_select_row_static( $field_name, $field, $echo ); | |
| 459 | + } else { | |
| 460 | + self::field_select_row_static( $field_name, $field, $echo ); | |
| 461 | + } | |
| 462 | + } | |
| 463 | + | |
| 464 | + | |
| 465 | + /** | |
| 466 | + * Checkbox field row | |
| 467 | + * | |
| 468 | + * @param string $field_name - name of field | |
| 469 | + * @param array $field - parameters | |
| 470 | + * @param boolean $echo - show or return reaults {default true} | |
| 471 | + * | |
| 472 | + * @return string - html || nothing | |
| 473 | + */ | |
| 474 | + public function field_checkbox_row( $field_name, $field, $echo = true ) { | |
| 475 | + if ( ! $echo ) { | |
| 476 | + return self::field_checkbox_row_static( $field_name, $field, $echo ); | |
| 477 | + } else { | |
| 478 | + self::field_checkbox_row_static( $field_name, $field, $echo ); | |
| 479 | + } | |
| 480 | + } | |
| 481 | + | |
| 482 | + // ----------------------------------------------------------------------------------------------------------------- | |
| 483 | + // Static Methods | |
| 484 | + // ----------------------------------------------------------------------------------------------------------------- | |
| 485 | + /** | |
| 486 | + * Static Text Input Row | |
| 487 | + * | |
| 488 | + * @param string $field_name - name of field | |
| 489 | + * @param array $field - parameters | |
| 490 | + * @param boolean $echo - show or return reaults {default true} | |
| 491 | + * | |
| 492 | + * @return string - html || nothing | |
| 493 | + */ | |
| 494 | + public static function field_text_row_static( $field_name, $field, $echo = true ) { | |
| 495 | + | |
| 496 | + $defaults = array( | |
| 497 | + 'title' => '', | |
| 498 | + 'disabled' => false, | |
| 499 | + 'class' => '', | |
| 500 | + 'css' => '', | |
| 501 | + 'placeholder' => '', | |
| 502 | + 'type' => 'text', | |
| 503 | + 'description' => '', | |
| 504 | + 'attr' => array(), | |
| 505 | + 'group' => 'general', | |
| 506 | + 'tr_class' => '', | |
| 507 | + 'only_field' => false, | |
| 508 | + 'description_tag' => 'p', | |
| 509 | + 'validate_as' => array() | |
| 510 | + ); | |
| 511 | + | |
| 512 | + $field = wp_parse_args( $field, $defaults ); | |
| 513 | + | |
| 514 | + if ( ! $echo ) { | |
| 515 | + ob_start(); | |
| 516 | + } | |
| 517 | + | |
| 518 | + if ( ! $field['only_field'] ) { | |
| 519 | + ?> | |
| 520 | + <tr valign="top" class="wpbc_tr_<?php | |
| 521 | + echo esc_attr( $field_name ), ' ', esc_attr( $field['tr_class'] ); | |
| 522 | + ?>"> | |
| 523 | + <th scope="row"> | |
| 524 | + <?php | |
| 525 | + echo wp_kses_post( self::label_static( $field_name, $field ) ); ?> | |
| 526 | + </th> | |
| 527 | + <td><fieldset><?php | |
| 528 | + } | |
| 529 | + ?> | |
| 530 | + <legend class="screen-reader-text"><span><?php | |
| 531 | + echo wp_kses_post( $field['title'] ); ?></span></legend> | |
| 532 | + <input type="<?php | |
| 533 | + echo esc_attr( $field['type'] ); ?>" | |
| 534 | + id="<?php | |
| 535 | + echo esc_attr( $field_name ); ?>" | |
| 536 | + name="<?php | |
| 537 | + echo esc_attr( $field_name ); ?>" | |
| 538 | + value="<?php | |
| 539 | + echo esc_attr( $field['value'] ); ?>" | |
| 540 | + class="regular-text <?php | |
| 541 | + echo esc_attr( $field['class'] ); | |
| 542 | + echo esc_attr( ( ! empty( $field['validate_as'] ) ) ? ' validate-' . implode( ' validate-', $field['validate_as'] ) : '' ); ?>" | |
| 543 | + style="<?php | |
| 544 | + echo esc_attr( $field['css'] ); ?>" | |
| 545 | + placeholder="<?php | |
| 546 | + echo esc_attr( $field['placeholder'] ); ?>" | |
| 547 | + <?php | |
| 548 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 549 | + echo self::get_custom_attr_static( $field ); ?> | |
| 550 | + <?php | |
| 551 | + disabled( $field['disabled'], true ); ?> | |
| 552 | + autocomplete="off" | |
| 553 | + /> | |
| 554 | + <?php | |
| 555 | + echo wp_kses_post( self::description_static( $field, $field['description_tag'] ) ); ?> | |
| 556 | + <?php | |
| 557 | + if ( ! $field['only_field'] ) { | |
| 558 | + ?> | |
| 559 | + </fieldset></td> | |
| 560 | + </tr> | |
| 561 | + <?php | |
| 562 | + } | |
| 563 | + | |
| 564 | + if ( ! $echo ) { | |
| 565 | + return ob_get_clean(); | |
| 566 | + } | |
| 567 | + } | |
| 568 | + | |
| 569 | + | |
| 570 | + /** | |
| 571 | + * Static Color Input Row | |
| 572 | + * | |
| 573 | + * @param string $field_name - name of field | |
| 574 | + * @param array $field - parameters | |
| 575 | + * @param boolean $echo - show or return reaults {default true} | |
| 576 | + * | |
| 577 | + * @return string - html || nothing | |
| 578 | + */ | |
| 579 | + public static function field_color_row_static( $field_name, $field, $echo = true ) { | |
| 580 | + | |
| 581 | + $defaults = array( | |
| 582 | + 'title' => '', | |
| 583 | + 'disabled' => false, | |
| 584 | + 'class' => '', | |
| 585 | + 'css' => '', | |
| 586 | + 'placeholder' => '', | |
| 587 | + 'type' => 'text', | |
| 588 | + 'description' => '', | |
| 589 | + 'attr' => array(), | |
| 590 | + 'group' => 'general', | |
| 591 | + 'tr_class' => '', | |
| 592 | + 'only_field' => false, | |
| 593 | + 'description_tag' => 'p' | |
| 594 | + ); | |
| 595 | + | |
| 596 | + $field = wp_parse_args( $field, $defaults ); | |
| 597 | + | |
| 598 | + if ( ! $echo ) { | |
| 599 | + ob_start(); | |
| 600 | + } | |
| 601 | + if ( ! $field['only_field'] ) { | |
| 602 | + ?> | |
| 603 | + <tr valign="top" class="wpbc_tr_<?php | |
| 604 | + echo esc_attr( $field_name ), ' ', esc_attr( $field['tr_class'] ); ?>"> | |
| 605 | + <th scope="row"> | |
| 606 | + <?php | |
| 607 | + echo wp_kses_post( self::label_static( $field_name, $field ) ); ?> | |
| 608 | + </th> | |
| 609 | + <td><fieldset><?php | |
| 610 | + } | |
| 611 | + ?> | |
| 612 | + <legend class="screen-reader-text"><span><?php | |
| 613 | + echo wp_kses_post( $field['title'] ); ?></span></legend> | |
| 614 | + <input type="text" | |
| 615 | + id="<?php | |
| 616 | + echo esc_attr( $field_name ); ?>" | |
| 617 | + name="<?php | |
| 618 | + echo esc_attr( $field_name ); ?>" | |
| 619 | + value="<?php | |
| 620 | + echo esc_attr( $field['value'] ); ?>" | |
| 621 | + class="regular-text wpbc_colorpick <?php | |
| 622 | + echo esc_attr( $field['class'] ); ?>" | |
| 623 | + style="width: 6em; background-color: <?php | |
| 624 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 625 | + echo $field['value']; ?>;<?php | |
| 626 | + echo esc_attr( $field['css'] ); ?>" | |
| 627 | + placeholder="<?php | |
| 628 | + echo esc_attr( $field['placeholder'] ); ?>" | |
| 629 | + <?php | |
| 630 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 631 | + echo self::get_custom_attr_static( $field ); ?> | |
| 632 | + <?php | |
| 633 | + disabled( $field['disabled'], true ); ?> | |
| 634 | + autocomplete="off" | |
| 635 | + /> | |
| 636 | + <?php | |
| 637 | + echo wp_kses_post( self::description_static( $field, $field['description_tag'] ) ); ?> | |
| 638 | + <?php | |
| 639 | + if ( ! $field['only_field'] ) { | |
| 640 | + ?> | |
| 641 | + </fieldset></td> | |
| 642 | + </tr> | |
| 643 | + <?php | |
| 644 | + } | |
| 645 | + | |
| 646 | + if ( ! $echo ) { | |
| 647 | + return ob_get_clean(); | |
| 648 | + } | |
| 649 | + } | |
| 650 | + | |
| 651 | + | |
| 652 | + /** | |
| 653 | + * Static Textarea Row | |
| 654 | + * | |
| 655 | + * @param string $field_name - name of field | |
| 656 | + * @param array $field - parameters | |
| 657 | + * @param boolean $echo - show or return reaults {default true} | |
| 658 | + * | |
| 659 | + * @return string - html || nothing | |
| 660 | + */ | |
| 661 | + public static function field_textarea_row_static( $field_name, $field, $echo = true ) { | |
| 662 | + | |
| 663 | + $defaults = array( | |
| 664 | + 'title' => '', | |
| 665 | + 'disabled' => false, | |
| 666 | + 'class' => '', | |
| 667 | + 'css' => '', | |
| 668 | + 'placeholder' => '', | |
| 669 | + 'type' => 'text', | |
| 670 | + 'description' => '', | |
| 671 | + 'attr' => array(), | |
| 672 | + 'rows' => 3, | |
| 673 | + 'cols' => 20, | |
| 674 | + 'show_in_2_cols' => false, | |
| 675 | + 'group' => 'general', | |
| 676 | + 'tr_class' => '', | |
| 677 | + 'only_field' => false, | |
| 678 | + 'description_tag' => 'p', | |
| 679 | + 'validate_as' => array() | |
| 680 | + ); | |
| 681 | + | |
| 682 | + $field = wp_parse_args( $field, $defaults ); | |
| 683 | + | |
| 684 | + if ( ! $echo ) { | |
| 685 | + ob_start(); | |
| 686 | + } | |
| 687 | + | |
| 688 | + if ( ! $field['only_field'] ) { | |
| 689 | + ?> | |
| 690 | + <tr valign="top" class="wpbc_tr_<?php | |
| 691 | + echo esc_attr( $field_name ), ' ', esc_attr( $field['tr_class'] ); ?>"> | |
| 692 | + <th scope="row"> | |
| 693 | + <?php | |
| 694 | + echo wp_kses_post( self::label_static( $field_name, $field ) ); ?> | |
| 695 | + <?php | |
| 696 | + if ( $field['show_in_2_cols'] ) { ?> | |
| 697 | + </th> | |
| 698 | + <td></td> | |
| 699 | + </tr> | |
| 700 | + <tr valign="top" class="wpbc_tr_<?php | |
| 701 | + echo esc_attr( $field_name ), ' ', esc_attr( $field['tr_class'] ); ?>"> | |
| 702 | + <td colspan="2"><fieldset> | |
| 703 | + <?php | |
| 704 | + } else { | |
| 705 | + echo ' </th>'; // FixIn: 9.6.3.3. | |
| 706 | + echo ' <td><fieldset>'; | |
| 707 | + } ?><?php | |
| 708 | + } | |
| 709 | + ?> | |
| 710 | + <legend class="screen-reader-text"><span><?php | |
| 711 | + echo wp_kses_post( $field['title'] ); ?></span></legend> | |
| 712 | + <textarea | |
| 713 | + rows="<?php | |
| 714 | + echo esc_attr( $field['rows'] ); ?>" | |
| 715 | + cols="<?php | |
| 716 | + echo esc_attr( $field['cols'] ); ?>" | |
| 717 | + <?php | |
| 718 | + /* type="<?php echo esc_attr( $field['type'] ); ?>" */ ?> | |
| 719 | + id="<?php | |
| 720 | + echo esc_attr( $field_name ); ?>" | |
| 721 | + name="<?php | |
| 722 | + echo esc_attr( $field_name ); ?>" | |
| 723 | + class="input-text wide-input <?php | |
| 724 | + echo esc_attr( $field['class'] ); | |
| 725 | + echo esc_attr( ( ! empty( $field['validate_as'] ) ) ? ' validate-' . implode( ' validate-', $field['validate_as'] ) : '' ); ?>" | |
| 726 | + style="<?php | |
| 727 | + echo esc_attr( $field['css'] ); ?>" | |
| 728 | + placeholder="<?php | |
| 729 | + echo esc_attr( $field['placeholder'] ); ?>" | |
| 730 | + <?php | |
| 731 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 732 | + echo self::get_custom_attr_static( $field ); ?> | |
| 733 | + <?php | |
| 734 | + disabled( $field['disabled'], true ); ?> | |
| 513 | 735 | autocomplete="off" |
| 514 | - /> | |
| 515 | - <?php echo self::description_static( $field, $field['description_tag'] ); ?> | |
| 516 | - <?php | |
| 517 | - if ( ! $field['only_field'] ) { | |
| 518 | - ?> | |
| 519 | - </fieldset></td> | |
| 520 | - </tr> | |
| 521 | - <?php | |
| 522 | - } | |
| 523 | - | |
| 524 | - if ( ! $echo ) { | |
| 525 | - return ob_get_clean(); | |
| 526 | - } | |
| 527 | - } | |
| 528 | - | |
| 529 | - | |
| 530 | - /** | |
| 531 | - * Static Color Input Row | |
| 532 | - * | |
| 533 | - * @param string $field_name - name of field | |
| 534 | - * @param array $field - parameters | |
| 535 | - * @param boolean $echo - show or return reaults {default true} | |
| 536 | - * @return string - html || nothing | |
| 537 | - */ | |
| 538 | - public static function field_color_row_static( $field_name, $field, $echo = true ) { | |
| 539 | - | |
| 540 | - $defaults = array( | |
| 541 | - 'title' => '', | |
| 542 | - 'disabled' => false, | |
| 543 | - 'class' => '', | |
| 544 | - 'css' => '', | |
| 545 | - 'placeholder' => '', | |
| 546 | - 'type' => 'text', | |
| 547 | - 'description' => '', | |
| 548 | - 'attr' => array(), | |
| 549 | - 'group' => 'general', | |
| 550 | - 'tr_class' => '', | |
| 551 | - 'only_field' => false, | |
| 552 | - 'description_tag' => 'p' | |
| 553 | - ); | |
| 736 | + ><?php | |
| 737 | + echo esc_textarea( $field['value'] ); ?></textarea> | |
| 738 | + <?php | |
| 739 | + echo wp_kses_post( self::description_static( $field, $field['description_tag'] ) ); ?> | |
| 740 | + <?php | |
| 741 | + if ( ! $field['only_field'] ) { | |
| 742 | + ?> | |
| 743 | + </fieldset></td> | |
| 744 | + </tr> | |
| 745 | + <?php | |
| 746 | + } | |
| 554 | 747 | |
| 555 | - $field = wp_parse_args( $field, $defaults ); | |
| 556 | - | |
| 557 | - if ( ! $echo ) { | |
| 558 | - ob_start(); | |
| 559 | - } | |
| 560 | - if ( ! $field['only_field'] ) { | |
| 561 | - ?> | |
| 562 | - <tr valign="top" class="wpbc_tr_<?php echo esc_attr( $field_name ), ' ', esc_attr( $field['tr_class'] ); ?>"> | |
| 563 | - <th scope="row"> | |
| 564 | - <?php echo self::label_static( $field_name, $field ); ?> | |
| 565 | - </th> | |
| 566 | - <td><fieldset><?php | |
| 567 | - } | |
| 568 | - ?> | |
| 569 | - <legend class="screen-reader-text"><span><?php echo wp_kses_post( $field['title'] ); ?></span></legend> | |
| 570 | - <input type="text" | |
| 571 | - id="<?php echo esc_attr( $field_name ); ?>" | |
| 572 | - name="<?php echo esc_attr( $field_name ); ?>" | |
| 573 | - value="<?php echo esc_attr($field['value']); ?>" | |
| 574 | - class="regular-text wpbc_colorpick <?php echo esc_attr( $field['class'] ); ?>" | |
| 575 | - style="width: 6em; background-color: <?php echo $field['value']; ?>;<?php echo esc_attr( $field['css'] ); ?>" | |
| 576 | - placeholder="<?php echo esc_attr( $field['placeholder'] ); ?>" | |
| 577 | - <?php echo self::get_custom_attr_static( $field ); ?> | |
| 578 | - <?php disabled( $field['disabled'], true ); ?> | |
| 579 | - autocomplete="off" | |
| 580 | - /> | |
| 581 | - <?php echo self::description_static( $field, $field['description_tag'] ); ?> | |
| 582 | - <?php | |
| 583 | - if ( ! $field['only_field'] ) { | |
| 584 | - ?> | |
| 585 | - </fieldset></td> | |
| 586 | - </tr> | |
| 587 | - <?php | |
| 588 | - } | |
| 589 | - | |
| 590 | - if ( ! $echo ) { | |
| 591 | - return ob_get_clean(); | |
| 592 | - } | |
| 593 | - } | |
| 748 | + if ( ! $echo ) { | |
| 749 | + return ob_get_clean(); | |
| 750 | + } | |
| 751 | + } | |
| 594 | 752 | |
| 595 | - | |
| 596 | - /** | |
| 597 | - * Static Textarea Row | |
| 598 | - * | |
| 599 | - * @param string $field_name - name of field | |
| 600 | - * @param array $field - parameters | |
| 601 | - * @param boolean $echo - show or return reaults {default true} | |
| 602 | - * @return string - html || nothing | |
| 603 | - */ | |
| 604 | - public static function field_textarea_row_static( $field_name, $field, $echo = true ) { | |
| 605 | - | |
| 606 | - $defaults = array( | |
| 607 | - 'title' => '', | |
| 608 | - 'disabled' => false, | |
| 609 | - 'class' => '', | |
| 610 | - 'css' => '', | |
| 611 | - 'placeholder' => '', | |
| 612 | - 'type' => 'text', | |
| 613 | - 'description' => '', | |
| 614 | - 'attr' => array(), | |
| 615 | - 'rows' => 3, | |
| 616 | - 'cols' => 20, | |
| 617 | - 'show_in_2_cols' => false, | |
| 618 | - 'group' => 'general', | |
| 619 | - 'tr_class' => '', | |
| 620 | - 'only_field' => false, | |
| 621 | - 'description_tag' => 'p' | |
| 622 | - , 'validate_as' => array() | |
| 623 | - ); | |
| 624 | 753 | |
| 625 | - $field = wp_parse_args( $field, $defaults ); | |
| 626 | - | |
| 627 | - if ( ! $echo ) { | |
| 628 | - ob_start(); | |
| 629 | - } | |
| 630 | - | |
| 631 | - if ( ! $field['only_field'] ) { | |
| 632 | - ?> | |
| 633 | - <tr valign="top" class="wpbc_tr_<?php echo esc_attr( $field_name ), ' ', esc_attr( $field['tr_class'] ); ?>"> | |
| 634 | - <th scope="row"> | |
| 635 | - <?php echo self::label_static( $field_name, $field ); ?> | |
| 636 | - <?php if ( $field['show_in_2_cols'] ) { ?> | |
| 637 | - </th> | |
| 638 | - <td></td> | |
| 639 | - </tr> | |
| 640 | - <tr valign="top" class="wpbc_tr_<?php echo esc_attr( $field_name ), ' ', esc_attr( $field['tr_class'] ); ?>"> | |
| 641 | - <td colspan="2"><fieldset> | |
| 642 | - <?php } else { | |
| 643 | - echo ' </th>'; //FixIn: 9.6.3.3 | |
| 644 | - echo ' <td><fieldset>'; | |
| 645 | - } ?><?php | |
| 646 | - } | |
| 647 | - ?> | |
| 648 | - <legend class="screen-reader-text"><span><?php echo wp_kses_post( $field['title'] ); ?></span></legend> | |
| 649 | - <textarea | |
| 650 | - rows="<?php echo esc_attr( $field['rows'] ); ?>" | |
| 651 | - cols="<?php echo esc_attr( $field['cols'] ); ?>" | |
| 652 | - <?php /* type="<?php echo esc_attr( $field['type'] ); ?>" */ ?> | |
| 653 | - id="<?php echo esc_attr( $field_name ); ?>" | |
| 654 | - name="<?php echo esc_attr( $field_name ); ?>" | |
| 655 | - class="input-text wide-input <?php echo esc_attr( $field['class'] ); | |
| 656 | - echo ( ! empty($field['validate_as']) ) ? ' validate-' . implode( ' validate-', $field['validate_as'] ) : ''; ?>" | |
| 657 | - style="<?php echo esc_attr( $field['css'] ); ?>" | |
| 658 | - placeholder="<?php echo esc_attr( $field['placeholder'] ); ?>" | |
| 659 | - <?php echo self::get_custom_attr_static( $field ); ?> | |
| 660 | - <?php disabled( $field['disabled'], true ); ?> | |
| 661 | - autocomplete="off" | |
| 662 | - ><?php | |
| 663 | - echo esc_textarea( $field['value'] ); ?></textarea> | |
| 664 | - <?php echo self::description_static( $field, $field['description_tag'] ); ?> | |
| 665 | - <?php | |
| 666 | - if ( ! $field['only_field'] ) { | |
| 667 | - ?> | |
| 668 | - </fieldset></td> | |
| 669 | - </tr> | |
| 670 | - <?php | |
| 671 | - } | |
| 672 | - | |
| 673 | - if ( ! $echo ) { | |
| 674 | - return ob_get_clean(); | |
| 675 | - } | |
| 676 | - } | |
| 754 | + /** | |
| 755 | + * Static WP Rich Content Edit Textarea Row | |
| 756 | + * | |
| 757 | + * @param string $field_name - name of field | |
| 758 | + * @param array $field - parameters | |
| 759 | + * @param boolean $echo - show or return reaults {default true} | |
| 760 | + * | |
| 761 | + * @return string - html || nothing | |
| 762 | + */ | |
| 763 | + public static function field_wp_textarea_row_static( $field_name, $field, $echo = true ) { | |
| 677 | 764 | |
| 678 | - | |
| 679 | - /** | |
| 680 | - * Static WP Rich Content Edit Textarea Row | |
| 681 | - * | |
| 682 | - * @param string $field_name - name of field | |
| 683 | - * @param array $field - parameters | |
| 684 | - * @param boolean $echo - show or return reaults {default true} | |
| 685 | - * @return string - html || nothing | |
| 686 | - */ | |
| 687 | - public static function field_wp_textarea_row_static( $field_name, $field, $echo = true ) { | |
| 688 | - | |
| 689 | - $defaults = array( | |
| 690 | - 'title' => '', | |
| 691 | - 'disabled' => false, | |
| 692 | - 'class' => '', | |
| 693 | - 'css' => '', | |
| 694 | - 'placeholder' => '', | |
| 695 | - 'type' => 'text', | |
| 696 | - 'description' => '', | |
| 697 | - 'attr' => array(), | |
| 698 | - 'rows' => 3, | |
| 699 | - 'editor_height' => '', | |
| 700 | - 'cols' => 20, | |
| 701 | - 'teeny' => true, | |
| 702 | - 'show_visual_tabs' => true, | |
| 703 | - 'default_editor' => 'tinymce', // 'tinymce' | 'html' // 'html' is used for the "Text" editor tab. | |
| 704 | - 'drag_drop_upload' => false, | |
| 705 | - 'show_in_2_cols' => false, | |
| 706 | - 'group' => 'general', | |
| 707 | - 'tr_class' => '', | |
| 708 | - 'only_field' => false, | |
| 709 | - 'description_tag' => 'p' | |
| 710 | - ); | |
| 765 | + $defaults = array( | |
| 766 | + 'title' => '', | |
| 767 | + 'disabled' => false, | |
| 768 | + 'class' => '', | |
| 769 | + 'css' => '', | |
| 770 | + 'placeholder' => '', | |
| 771 | + 'type' => 'text', | |
| 772 | + 'description' => '', | |
| 773 | + 'attr' => array(), | |
| 774 | + 'rows' => 3, | |
| 775 | + 'editor_height' => '', | |
| 776 | + 'cols' => 20, | |
| 777 | + 'teeny' => true, | |
| 778 | + 'show_visual_tabs' => true, | |
| 779 | + 'default_editor' => 'tinymce', | |
| 780 | + // 'tinymce' | 'html' // 'html' is used for the "Text" editor tab. | |
| 781 | + 'drag_drop_upload' => false, | |
| 782 | + 'show_in_2_cols' => false, | |
| 783 | + 'group' => 'general', | |
| 784 | + 'tr_class' => '', | |
| 785 | + 'only_field' => false, | |
| 786 | + 'description_tag' => 'p' | |
| 787 | + ); | |
| 711 | 788 | |
| 712 | - $field = wp_parse_args( $field, $defaults ); | |
| 713 | - | |
| 714 | - if ( ! $echo ) { | |
| 715 | - ob_start(); | |
| 716 | - } | |
| 717 | - if ( ! $field['only_field'] ) { | |
| 718 | - ?> | |
| 719 | - <tr valign="top" class="wpbc_tr_<?php echo esc_attr( $field_name ), ' ', esc_attr( $field['tr_class'] ); ?>"> | |
| 720 | - <th scope="row"> | |
| 721 | - <?php echo self::label_static( $field_name, $field ); ?> | |
| 722 | - <?php if ( $field['show_in_2_cols'] ) { ?> | |
| 723 | - </th> | |
| 724 | - <td></td> | |
| 725 | - </tr> | |
| 726 | - <tr valign="top" class="wpbc_tr_<?php echo esc_attr( $field_name ), ' ', esc_attr( $field['tr_class'] ); ?>"> | |
| 727 | - <td colspan="2"><fieldset> | |
| 728 | - <?php } else { | |
| 729 | - echo ' </th>'; //FixIn: 9.6.3.3 | |
| 730 | - echo ' <td><fieldset>'; | |
| 731 | - } ?><?php | |
| 732 | - } | |
| 733 | - ?> | |
| 734 | - <legend class="screen-reader-text"><span><?php echo wp_kses_post( $field['title'] ); ?></span></legend><?php | |
| 735 | - wp_editor( | |
| 736 | - $field['value'], | |
| 737 | - esc_attr( $field_name ), | |
| 738 | - array( | |
| 739 | - 'wpautop' => false | |
| 740 | - , 'media_buttons' => false | |
| 741 | - , 'textarea_name' => esc_attr( $field_name ) | |
| 742 | - , 'textarea_rows' => $field['rows'] | |
| 743 | - , 'editor_class' => 'wpbc-textarea-tinymce ' . esc_attr( $field['class'] ) // Any extra CSS Classes to append to the Editor textarea | |
| 744 | - , 'teeny' => esc_attr( $field['teeny'] ) // Whether to output the minimal editor configuration used in PressThis | |
| 745 | - , 'drag_drop_upload' => esc_attr( $field['drag_drop_upload'] ) // Enable Drag & Drop Upload Support (since WordPress 3.9) | |
| 746 | - , 'tinymce' => $field['show_visual_tabs'] // Remove Visual Mode from the Editor | |
| 747 | - , 'default_editor' => $field['default_editor'] // 'tinymce' | 'html' // 'html' is used for the "Text" editor tab. | |
| 748 | - , 'editor_height' => $field['editor_height'] // '' | '500' | |
| 749 | - ) | |
| 750 | - ); | |
| 751 | - echo self::description_static( $field, $field['description_tag'] ); ?> | |
| 752 | - <?php | |
| 753 | - if ( ! $field['only_field'] ) { | |
| 754 | - ?> | |
| 755 | - </fieldset></td> | |
| 756 | - </tr> | |
| 757 | - <?php | |
| 758 | - } | |
| 759 | - | |
| 760 | - if ( ! $echo ) { | |
| 761 | - return ob_get_clean(); | |
| 762 | - } | |
| 763 | - } | |
| 764 | - | |
| 765 | - | |
| 766 | - /** | |
| 767 | - * Static Radio buttons field row | |
| 768 | - * | |
| 769 | - * @param string $field_name - name of field | |
| 770 | - * @param array $field - parameters | |
| 771 | - * @param boolean $echo - show or return reaults {default true} | |
| 772 | - * @return string - html || nothing | |
| 773 | - */ | |
| 774 | - public static function field_radio_row_static( $field_name, $field, $echo = true ) { | |
| 789 | + $field = wp_parse_args( $field, $defaults ); | |
| 775 | 790 | |
| 776 | - $defaults = array( | |
| 777 | - 'title' => '', | |
| 778 | - 'label' => '', | |
| 779 | - 'disabled' => false, | |
| 780 | - 'disabled_options' => array(), | |
| 781 | - 'class' => '', | |
| 782 | - 'css' => '', | |
| 783 | - 'type' => 'radio', | |
| 784 | - 'description' => '', | |
| 785 | - 'attr' => array(), | |
| 786 | - 'options' => array(), | |
| 787 | - 'group' => 'general', | |
| 788 | - 'tr_class' => '', | |
| 789 | - 'only_field' => false, | |
| 790 | - 'is_new_line' => false, | |
| 791 | - 'description_tag' => 'span' | |
| 792 | - ); | |
| 791 | + if ( ! $echo ) { | |
| 792 | + ob_start(); | |
| 793 | + } | |
| 794 | + if ( ! $field['only_field'] ) { | |
| 795 | + ?> | |
| 796 | + <tr valign="top" class="wpbc_tr_<?php | |
| 797 | + echo esc_attr( $field_name ), ' ', esc_attr( $field['tr_class'] ); ?>"> | |
| 798 | + <th scope="row"> | |
| 799 | + <?php | |
| 800 | + echo wp_kses_post( self::label_static( $field_name, $field ) ); ?> | |
| 801 | + <?php | |
| 802 | + if ( $field['show_in_2_cols'] ) { ?> | |
| 803 | + </th> | |
| 804 | + <td></td> | |
| 805 | + </tr> | |
| 806 | + <tr valign="top" class="wpbc_tr_<?php | |
| 807 | + echo esc_attr( $field_name ), ' ', esc_attr( $field['tr_class'] ); ?>"> | |
| 808 | + <td colspan="2"><fieldset> | |
| 809 | + <?php | |
| 810 | + } else { | |
| 811 | + echo ' </th>'; // FixIn: 9.6.3.3. | |
| 812 | + echo ' <td><fieldset>'; | |
| 813 | + } ?><?php | |
| 814 | + } | |
| 815 | + ?> | |
| 816 | + <legend class="screen-reader-text"><span><?php | |
| 817 | + echo wp_kses_post( $field['title'] ); ?></span></legend><?php | |
| 818 | + wp_editor( $field['value'], esc_attr( $field_name ), array( | |
| 819 | + 'wpautop' => false, | |
| 820 | + 'media_buttons' => false, | |
| 821 | + 'textarea_name' => esc_attr( $field_name ), | |
| 822 | + 'textarea_rows' => $field['rows'], | |
| 823 | + 'editor_class' => 'wpbc-textarea-tinymce ' . esc_attr( $field['class'] ) | |
| 824 | + // Any extra CSS Classes to append to the Editor textarea | |
| 825 | + , | |
| 826 | + 'teeny' => esc_attr( $field['teeny'] ) | |
| 827 | + // Whether to output the minimal editor configuration used in PressThis | |
| 828 | + , | |
| 829 | + 'drag_drop_upload' => esc_attr( $field['drag_drop_upload'] ) | |
| 830 | + // Enable Drag & Drop Upload Support (since WordPress 3.9) | |
| 831 | + , | |
| 832 | + 'tinymce' => $field['show_visual_tabs'] | |
| 833 | + // Remove Visual Mode from the Editor | |
| 834 | + , | |
| 835 | + 'default_editor' => $field['default_editor'] | |
| 836 | + // 'tinymce' | 'html' // 'html' is used for the "Text" editor tab. | |
| 837 | + , | |
| 838 | + 'editor_height' => $field['editor_height'] | |
| 839 | + // '' | '500' | |
| 840 | + ) ); | |
| 841 | + echo wp_kses_post( self::description_static( $field, $field['description_tag'] ) ); ?> | |
| 842 | + <?php | |
| 843 | + if ( ! $field['only_field'] ) { | |
| 844 | + ?> | |
| 845 | + </fieldset></td> | |
| 846 | + </tr> | |
| 847 | + <?php | |
| 848 | + } | |
| 793 | 849 | |
| 794 | - $field = wp_parse_args( $field, $defaults ); | |
| 795 | - | |
| 796 | - if ( ! $echo ) { | |
| 797 | - ob_start(); | |
| 798 | - } | |
| 799 | - if ( ! $field['only_field'] ) { | |
| 800 | - ?> | |
| 801 | - <tr valign="top" class="wpbc_tr_<?php echo esc_attr( $field_name ), ' ', esc_attr( $field['tr_class'] ); ?>"> | |
| 802 | - <th scope="row"> | |
| 803 | - <?php echo self::label_static( $field_name, $field ); ?> | |
| 804 | - </th> | |
| 805 | - <td><fieldset><?php | |
| 806 | - } | |
| 807 | - ?> | |
| 808 | - <legend class="screen-reader-text"><span><?php echo wp_kses_post( $field['title'] ); ?></span></legend> | |
| 809 | - <?php | |
| 810 | - foreach ($field['options'] as $option_value => $option_title ) { | |
| 811 | - | |
| 812 | - $option_parameters = array(); | |
| 813 | - if ( is_array( $option_title ) ) { | |
| 814 | - $option_parameters = $option_title; | |
| 815 | - $option_title = $option_title['title']; | |
| 816 | - } | |
| 817 | - | |
| 818 | - ?><label class="wpbc-form-radio" title="<?php echo esc_attr( $option_title ); ?>"> | |
| 819 | - <input type="radio" | |
| 820 | - name="<?php echo esc_attr( $field_name ); ?>" | |
| 821 | - value="<?php echo esc_attr( $option_value ); ?>" | |
| 822 | - class="<?php echo esc_attr( $field['class'] ); ?>" | |
| 823 | - style="<?php echo esc_attr( $field['css'] ); ?>" | |
| 824 | - <?php echo self::get_custom_attr_static( $field ); ?> | |
| 825 | - <?php echo self::get_custom_attr_static( $option_parameters ); ?> | |
| 826 | - <?php checked( $field['value'], $option_value ); ?> | |
| 827 | - <?php disabled( $field['disabled'], true ); ?> | |
| 828 | - <?php disabled( in_array($option_value, $field['disabled_options'] ), true ); ?> | |
| 829 | - autocomplete="off" | |
| 830 | - /> <?php echo wp_kses_post( $option_title ); ?></label><?php echo ( $field['is_new_line'] ) ? '<br/>' : ' '; | |
| 831 | - | |
| 832 | - if ( isset( $option_parameters['html'] ) ) { | |
| 833 | - echo $option_parameters['html']; | |
| 834 | - } | |
| 835 | - } ?> | |
| 836 | - <?php echo self::description_static( $field, $field['description_tag'] ); ?> | |
| 837 | - <?php | |
| 838 | - if ( ! $field['only_field'] ) { | |
| 839 | - ?> | |
| 840 | - </fieldset></td> | |
| 841 | - </tr> | |
| 842 | - <?php | |
| 843 | - } | |
| 844 | - | |
| 845 | - if ( ! $echo ) { | |
| 846 | - return ob_get_clean(); | |
| 847 | - } | |
| 848 | - } | |
| 850 | + if ( ! $echo ) { | |
| 851 | + return ob_get_clean(); | |
| 852 | + } | |
| 853 | + } | |
| 849 | 854 | |
| 850 | - | |
| 851 | - /** | |
| 852 | - * Static Selectbox field row | |
| 853 | - * | |
| 854 | - * @param string $field_name - name of field | |
| 855 | - * @param array $field - parameters | |
| 856 | - * @param boolean $echo - show or return reaults {default true} | |
| 857 | - * @return string - html || nothing | |
| 858 | - */ | |
| 859 | - public static function field_select_row_static( $field_name, $field, $echo = true ) { | |
| 860 | - | |
| 861 | - $defaults = array( | |
| 862 | - 'title' => '', | |
| 863 | - 'label' => '', | |
| 864 | - 'disabled' => false, | |
| 865 | - 'disabled_options' => array(), | |
| 866 | - 'class' => '', | |
| 867 | - 'css' => '', | |
| 868 | - 'type' => 'select', | |
| 869 | - 'description' => '', | |
| 870 | - 'multiple' => false, | |
| 871 | - 'attr' => array(), | |
| 872 | - 'options' => array(), | |
| 873 | - 'group' => 'general', | |
| 874 | - 'tr_class' => '', | |
| 875 | - 'only_field' => false, | |
| 876 | - 'description_tag' => 'span' | |
| 877 | - ); | |
| 878 | 855 | |
| 879 | - $field = wp_parse_args( $field, $defaults ); | |
| 880 | - | |
| 881 | - if ( ! $echo ) { | |
| 882 | - ob_start(); | |
| 883 | - } | |
| 884 | - | |
| 885 | - if ( ! $field['only_field'] ) { | |
| 886 | - ?> | |
| 887 | - <tr valign="top" class="wpbc_tr_<?php echo esc_attr( $field_name ), ' ', esc_attr( $field['tr_class'] ); ?>"> | |
| 888 | - <th scope="row"> | |
| 889 | - <?php echo self::label_static( $field_name, $field ); ?> | |
| 890 | - </th> | |
| 891 | - <td><fieldset> | |
| 892 | - <?php | |
| 893 | - } | |
| 894 | - ?> | |
| 895 | - <legend class="screen-reader-text"><span><?php echo wp_kses_post( $field['title'] ); ?></span></legend> | |
| 896 | - <select | |
| 897 | - id="<?php echo esc_attr( $field_name ); ?>" | |
| 898 | - name="<?php echo esc_attr( $field_name ); echo ( $field['multiple'] ? '[]' : '' ); ?>" | |
| 899 | - class="<?php echo esc_attr( $field['class'] ); ?>" | |
| 900 | - style="<?php echo esc_attr( $field['css'] ); ?>" | |
| 901 | - <?php disabled( $field['disabled'], true ); ?> | |
| 902 | - <?php echo self::get_custom_attr_static( $field ); ?> | |
| 903 | - <?php echo ( $field['multiple'] ? ' multiple="MULTIPLE"' : '' ); ?> | |
| 904 | - autocomplete="off" | |
| 905 | - ><?php | |
| 906 | - | |
| 907 | - foreach ( (array) $field['options'] as $option_value => $option_title ) { | |
| 908 | - | |
| 909 | - $option_parameters = array(); | |
| 910 | - if ( is_array( $option_title ) ) { | |
| 911 | - $option_parameters = $option_title; | |
| 912 | - $option_title = ( ! empty( $option_title['title'] ) ) ? $option_title['title'] : ''; | |
| 913 | - } | |
| 914 | - | |
| 915 | - | |
| 916 | -// array( | |
| 917 | -// 'title' => 'Option Group Title' // Title | |
| 918 | -// , 'optgroup' => true // Use only if you need to show OPTGROUP - Also need to use 'title' of start, end 'close' for END | |
| 919 | -// , 'close' => false | |
| 920 | -// ) | |
| 856 | + /** | |
| 857 | + * Static Radio buttons field row | |
| 858 | + * | |
| 859 | + * @param string $field_name - name of field | |
| 860 | + * @param array $field - parameters | |
| 861 | + * @param boolean $echo - show or return reaults {default true} | |
| 862 | + * | |
| 863 | + * @return string - html || nothing | |
| 864 | + */ | |
| 865 | + public static function field_radio_row_static( $field_name, $field, $echo = true ) { | |
| 921 | 866 | |
| 922 | - if ( ! empty( $option_parameters['optgroup'] ) ) { // OPTGROUP | |
| 867 | + $defaults = array( | |
| 868 | + 'title' => '', | |
| 869 | + 'label' => '', | |
| 870 | + 'disabled' => false, | |
| 871 | + 'disabled_options' => array(), | |
| 872 | + 'class' => '', | |
| 873 | + 'css' => '', | |
| 874 | + 'type' => 'radio', | |
| 875 | + 'description' => '', | |
| 876 | + 'attr' => array(), | |
| 877 | + 'options' => array(), | |
| 878 | + 'group' => 'general', | |
| 879 | + 'tr_class' => '', | |
| 880 | + 'only_field' => false, | |
| 881 | + 'is_new_line' => false, | |
| 882 | + 'description_tag' => 'span' | |
| 883 | + ); | |
| 923 | 884 | |
| 924 | - if ( ! $option_parameters['close'] ) { | |
| 925 | - ?><optgroup label="<?php echo esc_attr( $option_parameters['title'] ); ?>"><?php | |
| 926 | - } else { | |
| 927 | - ?></optgroup><?php | |
| 928 | - } | |
| 929 | - } else { | |
| 930 | - | |
| 931 | - | |
| 932 | - ?><option value="<?php echo esc_attr( $option_value ); ?>" | |
| 933 | - <?php | |
| 934 | - if ( ( is_array( $field['value'] ) ) && ( in_array( $option_value, $field['value'] ) ) ) { | |
| 935 | - selected( true ); | |
| 936 | - } else { | |
| 937 | - if ( ! is_array( $field['value'] ) ) { //FixIn: 8.1.1.2 | |
| 938 | - selected( $option_value, $field['value'] ); | |
| 939 | - } | |
| 940 | - } | |
| 941 | - ?> | |
| 942 | - <?php disabled( in_array($option_value, $field['disabled_options'] ), true ); ?> | |
| 943 | - <?php echo self::get_custom_attr_static( $option_parameters ); ?> | |
| 944 | - ><?php echo ( $option_title ); ?></option><?php | |
| 945 | - } | |
| 946 | - } ?> | |
| 947 | - </select> | |
| 948 | - <?php echo self::description_static( $field, $field['description_tag'] ); ?> | |
| 949 | - <?php | |
| 950 | - if ( ! $field['only_field'] ) { | |
| 951 | - ?> | |
| 952 | - </fieldset></td> | |
| 953 | - </tr> | |
| 954 | - <?php | |
| 955 | - } | |
| 956 | - | |
| 957 | - if ( ! $echo ) { | |
| 958 | - return ob_get_clean(); | |
| 959 | - } | |
| 960 | - } | |
| 961 | - | |
| 962 | - | |
| 963 | - /** | |
| 964 | - * Static Checkbox field row | |
| 965 | - * | |
| 966 | - * @param string $field_name - name of field | |
| 967 | - * @param array $field - parameters | |
| 968 | - * @param boolean $echo - show or return reaults {default true} | |
| 969 | - * @return string - html || nothing | |
| 970 | - */ | |
| 971 | - public static function field_checkbox_row_static( $field_name, $field, $echo = true ) { | |
| 972 | - | |
| 973 | - $defaults = array( | |
| 974 | - 'title' => '', | |
| 975 | - 'label' => '', | |
| 976 | - 'disabled' => false, | |
| 977 | - 'class' => '', | |
| 978 | - 'css' => '', | |
| 979 | - 'type' => 'checkbox', | |
| 980 | - 'description' => '', | |
| 981 | - 'attr' => array(), | |
| 982 | - 'group' => 'general', | |
| 983 | - 'tr_class' => '', | |
| 984 | - 'only_field' => false, | |
| 985 | - 'is_new_line' => true, | |
| 986 | - 'description_tag' => 'span' | |
| 987 | - ); | |
| 885 | + $field = wp_parse_args( $field, $defaults ); | |
| 988 | 886 | |
| 989 | - $field = wp_parse_args( $field, $defaults ); | |
| 990 | - | |
| 991 | - if ( ! $echo ) { | |
| 992 | - ob_start(); | |
| 993 | - } | |
| 994 | - if ( ! $field['only_field'] ) { | |
| 995 | - ?> | |
| 996 | - <tr valign="top" class="wpbc_tr_<?php echo esc_attr( $field_name ), ' ', esc_attr( $field['tr_class'] ); ?>"> | |
| 997 | - <th scope="row"> | |
| 998 | - <?php echo self::label_static( $field_name, $field ); ?> | |
| 999 | - </th> | |
| 1000 | - <td><fieldset><?php | |
| 1001 | - } | |
| 887 | + if ( ! $echo ) { | |
| 888 | + ob_start(); | |
| 889 | + } | |
| 890 | + if ( ! $field['only_field'] ) { | |
| 891 | + ?> | |
| 892 | + <tr valign="top" class="wpbc_tr_<?php | |
| 893 | + echo esc_attr( $field_name ), ' ', esc_attr( $field['tr_class'] ); ?>"> | |
| 894 | + <th scope="row"> | |
| 895 | + <?php | |
| 896 | + echo wp_kses_post( self::label_static( $field_name, $field ) ); ?> | |
| 897 | + </th> | |
| 898 | + <td><fieldset><?php | |
| 899 | + } | |
| 900 | + ?> | |
| 901 | + <legend class="screen-reader-text"><span><?php | |
| 902 | + echo wp_kses_post( $field['title'] ); ?></span></legend> | |
| 903 | + <?php | |
| 904 | + foreach ( $field['options'] as $option_value => $option_title ) { | |
| 1002 | 905 | |
| 906 | + $option_parameters = array(); | |
| 907 | + if ( is_array( $option_title ) ) { | |
| 908 | + $option_parameters = $option_title; | |
| 909 | + $option_title = $option_title['title']; | |
| 910 | + } | |
| 911 | + | |
| 912 | + ?><label class="wpbc-form-radio" title="<?php | |
| 913 | + echo esc_attr( $option_title ); ?>"> | |
| 914 | + <input type="radio" | |
| 915 | + name="<?php | |
| 916 | + echo esc_attr( $field_name ); ?>" | |
| 917 | + value="<?php | |
| 918 | + echo esc_attr( $option_value ); ?>" | |
| 919 | + class="<?php | |
| 920 | + echo esc_attr( $field['class'] ); ?>" | |
| 921 | + style="<?php | |
| 922 | + echo esc_attr( $field['css'] ); ?>" | |
| 923 | + <?php | |
| 924 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 925 | + echo self::get_custom_attr_static( $field ); ?> | |
| 926 | + <?php | |
| 927 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 928 | + echo self::get_custom_attr_static( $option_parameters ); ?> | |
| 929 | + <?php | |
| 930 | + checked( $field['value'], $option_value ); ?> | |
| 931 | + <?php | |
| 932 | + disabled( $field['disabled'], true ); ?> | |
| 933 | + <?php | |
| 934 | + disabled( in_array( $option_value, $field['disabled_options'] ), true ); ?> | |
| 935 | + autocomplete="off" | |
| 936 | + /> <?php | |
| 937 | + echo wp_kses_post( $option_title ); ?></label><?php | |
| 938 | + echo ( $field['is_new_line'] ) ? '<br/>' : ' '; | |
| 939 | + | |
| 940 | + if ( isset( $option_parameters['html'] ) ) { | |
| 941 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 942 | + echo $option_parameters['html'] ; | |
| 943 | + } | |
| 944 | + } ?> | |
| 945 | + <?php | |
| 946 | + echo wp_kses_post( self::description_static( $field, $field['description_tag'] ) ); ?> | |
| 947 | + <?php | |
| 948 | + if ( ! $field['only_field'] ) { | |
| 949 | + ?> | |
| 950 | + </fieldset></td> | |
| 951 | + </tr> | |
| 952 | + <?php | |
| 953 | + } | |
| 954 | + | |
| 955 | + if ( ! $echo ) { | |
| 956 | + return ob_get_clean(); | |
| 957 | + } | |
| 958 | + } | |
| 959 | + | |
| 960 | + | |
| 961 | + /** | |
| 962 | + * Static Selectbox field row | |
| 963 | + * | |
| 964 | + * @param string $field_name - name of field | |
| 965 | + * @param array $field - parameters | |
| 966 | + * @param boolean $echo - show or return reaults {default true} | |
| 967 | + * | |
| 968 | + * @return string - html || nothing | |
| 969 | + */ | |
| 970 | + public static function field_select_row_static( $field_name, $field, $echo = true ) { | |
| 971 | + | |
| 972 | + $defaults = array( | |
| 973 | + 'title' => '', | |
| 974 | + 'label' => '', | |
| 975 | + 'disabled' => false, | |
| 976 | + 'disabled_options' => array(), | |
| 977 | + 'class' => '', | |
| 978 | + 'css' => '', | |
| 979 | + 'type' => 'select', | |
| 980 | + 'description' => '', | |
| 981 | + 'multiple' => false, | |
| 982 | + 'attr' => array(), | |
| 983 | + 'options' => array(), | |
| 984 | + 'group' => 'general', | |
| 985 | + 'tr_class' => '', | |
| 986 | + 'only_field' => false, | |
| 987 | + 'description_tag' => 'span' | |
| 988 | + ); | |
| 989 | + | |
| 990 | + $field = wp_parse_args( $field, $defaults ); | |
| 991 | + | |
| 992 | + if ( ! $echo ) { | |
| 993 | + ob_start(); | |
| 994 | + } | |
| 995 | + | |
| 996 | + if ( ! $field['only_field'] ) { | |
| 997 | + ?> | |
| 998 | + <tr valign="top" class="wpbc_tr_<?php | |
| 999 | + echo esc_attr( $field_name ), ' ', esc_attr( $field['tr_class'] ); ?>"> | |
| 1000 | + <th scope="row"> | |
| 1001 | + <?php | |
| 1002 | + echo wp_kses_post( self::label_static( $field_name, $field ) ); ?> | |
| 1003 | + </th> | |
| 1004 | + <td><fieldset> | |
| 1005 | + <?php | |
| 1006 | + } | |
| 1007 | + ?> | |
| 1008 | + <legend class="screen-reader-text"><span><?php | |
| 1009 | + echo wp_kses_post( $field['title'] ); ?></span></legend> | |
| 1010 | + <select | |
| 1011 | + id="<?php | |
| 1012 | + echo esc_attr( $field_name ); ?>" | |
| 1013 | + name="<?php | |
| 1014 | + echo esc_attr( $field_name ); | |
| 1015 | + echo( $field['multiple'] ? '[]' : '' ); ?>" | |
| 1016 | + class="<?php | |
| 1017 | + echo esc_attr( $field['class'] ); ?>" | |
| 1018 | + style="<?php | |
| 1019 | + echo esc_attr( $field['css'] ); ?>" | |
| 1020 | + <?php | |
| 1021 | + disabled( $field['disabled'], true ); ?> | |
| 1022 | + <?php | |
| 1023 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 1024 | + echo self::get_custom_attr_static( $field ); ?> | |
| 1025 | + <?php | |
| 1026 | + echo( $field['multiple'] ? ' multiple="MULTIPLE"' : '' ); ?> | |
| 1027 | + autocomplete="off" | |
| 1028 | + ><?php | |
| 1029 | + | |
| 1030 | + foreach ( (array) $field['options'] as $option_value => $option_title ) { | |
| 1031 | + | |
| 1032 | + $option_parameters = array(); | |
| 1033 | + if ( is_array( $option_title ) ) { | |
| 1034 | + $option_parameters = $option_title; | |
| 1035 | + $option_title = ( ! empty( $option_title['title'] ) ) ? $option_title['title'] : ''; | |
| 1036 | + } | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + // array( | |
| 1040 | + // 'title' => 'Option Group Title' // Title | |
| 1041 | + // , 'optgroup' => true // Use only if you need to show OPTGROUP - Also need to use 'title' of start, end 'close' for END | |
| 1042 | + // , 'close' => false | |
| 1043 | + // ) | |
| 1044 | + | |
| 1045 | + if ( ! empty( $option_parameters['optgroup'] ) ) { // OPTGROUP | |
| 1046 | + | |
| 1047 | + if ( ! $option_parameters['close'] ) { | |
| 1048 | + ?><optgroup label="<?php | |
| 1049 | + echo esc_attr( $option_parameters['title'] ); ?>"><?php | |
| 1050 | + } else { | |
| 1051 | + ?></optgroup><?php | |
| 1052 | + } | |
| 1053 | + } else { | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + ?> | |
| 1057 | + <option value="<?php | |
| 1058 | + echo esc_attr( $option_value ); ?>" | |
| 1059 | + <?php | |
| 1060 | + if ( ( is_array( $field['value'] ) ) && ( in_array( $option_value, $field['value'] ) ) ) { | |
| 1061 | + selected( true ); | |
| 1062 | + } else { | |
| 1063 | + if ( ! is_array( $field['value'] ) ) { // FixIn: 8.1.1.2. | |
| 1064 | + selected( $option_value, $field['value'] ); | |
| 1065 | + } | |
| 1066 | + } | |
| 1067 | + ?> | |
| 1068 | + <?php | |
| 1069 | + disabled( in_array( $option_value, $field['disabled_options'] ), true ); ?> | |
| 1070 | + <?php | |
| 1071 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 1072 | + echo self::get_custom_attr_static( $option_parameters ); ?> | |
| 1073 | + ><?php | |
| 1074 | + echo wp_kses_post( $option_title ); ?></option><?php | |
| 1075 | + } | |
| 1076 | + } ?> | |
| 1077 | + </select> | |
| 1078 | + <?php | |
| 1079 | + echo wp_kses_post( self::description_static( $field, $field['description_tag'] ) ); ?> | |
| 1080 | + <?php | |
| 1081 | + if ( ! $field['only_field'] ) { | |
| 1082 | + ?> | |
| 1083 | + </fieldset></td> | |
| 1084 | + </tr> | |
| 1085 | + <?php | |
| 1086 | + } | |
| 1087 | + | |
| 1088 | + if ( ! $echo ) { | |
| 1089 | + return ob_get_clean(); | |
| 1090 | + } | |
| 1091 | + } | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + /** | |
| 1095 | + * Static Checkbox field row | |
| 1096 | + * | |
| 1097 | + * @param string $field_name - name of field | |
| 1098 | + * @param array $field - parameters | |
| 1099 | + * @param boolean $echo - show or return reaults {default true} | |
| 1100 | + * | |
| 1101 | + * @return string - html || nothing | |
| 1102 | + */ | |
| 1103 | + public static function field_checkbox_row_static( $field_name, $field, $echo = true ) { | |
| 1104 | + | |
| 1105 | + $defaults = array( | |
| 1106 | + 'title' => '', | |
| 1107 | + 'label' => '', | |
| 1108 | + 'disabled' => false, | |
| 1109 | + 'class' => '', | |
| 1110 | + 'css' => '', | |
| 1111 | + 'type' => 'checkbox', | |
| 1112 | + 'description' => '', | |
| 1113 | + 'attr' => array(), | |
| 1114 | + 'group' => 'general', | |
| 1115 | + 'tr_class' => '', | |
| 1116 | + 'only_field' => false, | |
| 1117 | + 'is_new_line' => true, | |
| 1118 | + 'description_tag' => 'span' | |
| 1119 | + ); | |
| 1120 | + | |
| 1121 | + $field = wp_parse_args( $field, $defaults ); | |
| 1122 | + | |
| 1123 | + if ( ! $echo ) { | |
| 1124 | + ob_start(); | |
| 1125 | + } | |
| 1126 | + if ( ! $field['only_field'] ) { | |
| 1127 | + ?> | |
| 1128 | + <tr valign="top" class="wpbc_tr_<?php | |
| 1129 | + echo esc_attr( $field_name ), ' ', esc_attr( $field['tr_class'] ); ?>"> | |
| 1130 | + <th scope="row"> | |
| 1131 | + <?php | |
| 1132 | + echo wp_kses_post( self::label_static( $field_name, $field ) ); ?> | |
| 1133 | + </th> | |
| 1134 | + <td><fieldset><?php | |
| 1135 | + } | |
| 1136 | + | |
| 1003 | 1137 | // Show toggles in Settings pages |
| 1004 | - if ( 1 ) { | |
| 1138 | + if ( 1 ) { | |
| 1005 | 1139 | |
| 1006 | - $field['label'] = str_replace( '<span', '<i style="font-style: normal;"', $field['label']); | |
| 1007 | - $field['label'] = str_replace( '/span>', '/i>' , $field['label']); | |
| 1140 | + $field['label'] = str_replace( '<span', '<i style="font-style: normal;"', $field['label'] ); | |
| 1141 | + $field['label'] = str_replace( '/span>', '/i>', $field['label'] ); | |
| 1008 | 1142 | |
| 1009 | 1143 | $params_checkbox = array( |
| 1010 | - 'id' => $field_name // HTML ID of element | |
| 1011 | - , 'name' => $field_name | |
| 1012 | - , 'label' => array( 'title' => wp_kses_post( $field['label'] ) , 'position' => 'right' ) //FixIn: 9.6.1.5 | |
| 1013 | - , 'toggle_style' => $field['css'] // CSS of select element | |
| 1014 | - , 'class' => $field['class'] // CSS Class of select element | |
| 1015 | - , 'disabled' => $field['disabled'] | |
| 1016 | - , 'attr' => $field['attr'] // Any additional attributes, if this radio | checkbox element | |
| 1017 | - , 'legend' => wp_kses_post( $field['title'] ) // aria-label parameter | |
| 1018 | - , 'value' => $field['value'] // Some Value from optins array that selected by default | |
| 1019 | - , 'selected' => ( ( 'On' == $field['value'] ) ? true : false ) // Selected or not | |
| 1144 | + 'id' => $field_name | |
| 1145 | + // HTML ID of element | |
| 1146 | + , | |
| 1147 | + 'name' => $field_name, | |
| 1148 | + 'label' => array( 'title' => wp_kses_post( $field['label'] ), 'position' => 'right' ) | |
| 1149 | + // FixIn: 9.6.1.5. | |
| 1150 | + , | |
| 1151 | + 'toggle_style' => $field['css'] | |
| 1152 | + // CSS of select element | |
| 1153 | + , | |
| 1154 | + 'class' => $field['class'] | |
| 1155 | + // CSS Class of select element | |
| 1156 | + , | |
| 1157 | + 'disabled' => $field['disabled'], | |
| 1158 | + 'attr' => $field['attr'] | |
| 1159 | + // Any additional attributes, if this radio | checkbox element | |
| 1160 | + , | |
| 1161 | + 'legend' => wp_kses_post( $field['title'] ) | |
| 1162 | + // aria-label parameter | |
| 1163 | + , | |
| 1164 | + 'value' => $field['value'] | |
| 1165 | + // Some Value from optins array that selected by default | |
| 1166 | + , | |
| 1167 | + 'selected' => ( ( 'On' == $field['value'] ) ? true : false ) | |
| 1168 | + // Selected or not | |
| 1020 | 1169 | |
| 1021 | - //, 'onfocus' => "console.log( 'ON FOCUS:', jQuery( this ).is(':checked') , 'in element:' , jQuery( this ) );" // JavaScript code | |
| 1022 | - //, 'onchange' => "wpbc_ajx_booking_send_search_request_with_params( {'ui_usr__send_emails': (jQuery( this ).is(':checked') ? 'send' : 'not_send') } );" // JavaScript code | |
| 1023 | - //, 'hint' => array( 'title' => __('Send email notification to customer about this operation' ,'booking') , 'position' => 'top' ) | |
| 1024 | - ); | |
| 1025 | - $params_checkbox = wp_parse_args( $params_checkbox, $field ); | |
| 1170 | + //, 'onfocus' => "console.log( 'ON FOCUS:', jQuery( this ).is(':checked') , 'in element:' , jQuery( this ) );" // JavaScript code | |
| 1171 | + //, 'onchange' => "wpbc_ajx_booking_send_search_request_with_params( {'ui_usr__send_emails': (jQuery( this ).is(':checked') ? 'send' : 'not_send') } );" // JavaScript code | |
| 1172 | + //, 'hint' => array( 'title' => __('Send email notification to customer about this operation' ,'booking') , 'position' => 'top' ) | |
| 1173 | + ); | |
| 1174 | + $params_checkbox = wp_parse_args( $params_checkbox, $field ); | |
| 1026 | 1175 | wpbc_flex_toggle( $params_checkbox ); |
| 1027 | 1176 | |
| 1028 | - ?><legend class="screen-reader-text"><span><?php echo wp_kses_post( $field['title'] ); ?></span></legend><?php | |
| 1177 | + ?> | |
| 1178 | + <legend class="screen-reader-text"><span><?php | |
| 1179 | + echo wp_kses_post( $field['title'] ); ?></span></legend><?php | |
| 1029 | 1180 | |
| 1030 | 1181 | echo ( $field['is_new_line'] ) ? '<br/>' : ' '; |
| 1031 | - echo self::description_static( $field, $field['description_tag'] ); | |
| 1182 | + echo wp_kses_post( self::description_static( $field, $field['description_tag'] ) ); | |
| 1032 | 1183 | |
| 1033 | 1184 | } else { |
| 1034 | 1185 | |
| 1035 | - ?><legend class="screen-reader-text"><span><?php echo wp_kses_post( $field['title'] ); ?></span></legend> | |
| 1036 | - <label class="wpbc-form-checkbox" for="<?php echo esc_attr( $field_name ); ?>"> | |
| 1037 | - <input type="checkbox" | |
| 1038 | - id="<?php echo esc_attr( $field_name ); ?>" | |
| 1039 | - name="<?php echo esc_attr( $field_name ); ?>" | |
| 1040 | - value="<?php echo esc_attr( $field['value'] ); ?>" | |
| 1041 | - class="<?php echo esc_attr( $field['class'] ); ?>" | |
| 1042 | - style="<?php echo esc_attr( $field['css'] ); ?>" | |
| 1043 | - <?php echo self::get_custom_attr_static( $field ); ?> | |
| 1044 | - <?php checked( $field['value'], 'On' ); ?> | |
| 1045 | - <?php disabled( $field['disabled'], true ); ?> | |
| 1046 | - autocomplete="off" | |
| 1047 | - /> <?php echo wp_kses_post( $field['label'] ); ?></label><?php echo ( $field['is_new_line'] ) ? '<br/>' : ' '; ?> | |
| 1048 | - <?php echo self::description_static( $field, $field['description_tag'] ); ?><?php | |
| 1186 | + ?> | |
| 1187 | + <legend class="screen-reader-text"><span><?php | |
| 1188 | + echo wp_kses_post( $field['title'] ); ?></span></legend> | |
| 1189 | + <label class="wpbc-form-checkbox" for="<?php | |
| 1190 | + echo esc_attr( $field_name ); ?>"> | |
| 1191 | + <input type="checkbox" | |
| 1192 | + id="<?php | |
| 1193 | + echo esc_attr( $field_name ); ?>" | |
| 1194 | + name="<?php | |
| 1195 | + echo esc_attr( $field_name ); ?>" | |
| 1196 | + value="<?php | |
| 1197 | + echo esc_attr( $field['value'] ); ?>" | |
| 1198 | + class="<?php | |
| 1199 | + echo esc_attr( $field['class'] ); ?>" | |
| 1200 | + style="<?php | |
| 1201 | + echo esc_attr( $field['css'] ); ?>" | |
| 1202 | + <?php | |
| 1203 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 1204 | + echo self::get_custom_attr_static( $field ); ?> | |
| 1205 | + <?php | |
| 1206 | + checked( $field['value'], 'On' ); ?> | |
| 1207 | + <?php | |
| 1208 | + disabled( $field['disabled'], true ); ?> | |
| 1209 | + autocomplete="off" | |
| 1210 | + /> <?php | |
| 1211 | + echo wp_kses_post( $field['label'] ); ?></label><?php | |
| 1212 | + echo ( $field['is_new_line'] ) ? '<br/>' : ' '; ?> | |
| 1213 | + <?php | |
| 1214 | + echo wp_kses_post( self::description_static( $field, $field['description_tag'] ) ); ?><?php | |
| 1049 | 1215 | } |
| 1050 | 1216 | |
| 1051 | - if ( ! $field['only_field'] ) { | |
| 1052 | - ?></fieldset></td> | |
| 1053 | - </tr><?php | |
| 1054 | - | |
| 1055 | - } | |
| 1217 | + if ( ! $field['only_field'] ) { | |
| 1218 | + ?></fieldset></td> | |
| 1219 | + </tr><?php | |
| 1056 | 1220 | |
| 1057 | - if ( ! $echo ) { | |
| 1058 | - return ob_get_clean(); | |
| 1059 | - } | |
| 1060 | - } | |
| 1221 | + } | |
| 1061 | 1222 | |
| 1062 | - | |
| 1063 | - //////////////////////////////////////////////////////////////////////////// | |
| 1064 | - // Text, Help, HTML, JS Elements | |
| 1065 | - //////////////////////////////////////////////////////////////////////////// | |
| 1066 | - | |
| 1067 | - | |
| 1068 | - /** | |
| 1069 | - * Help Info Row | |
| 1070 | - * | |
| 1071 | - * @param string $field_name - name of field | |
| 1072 | - * @param array $field - parameters | |
| 1073 | - * @param boolean $echo - show or return reaults {default true} | |
| 1074 | - * @return string - html || nothing | |
| 1075 | - */ | |
| 1076 | - public function field_help_row( $field_name, $field, $echo = true ) { | |
| 1077 | - if ( ! $echo ) | |
| 1078 | - return self::field_help_row_static( $field_name, $field, $echo ); | |
| 1079 | - else | |
| 1080 | - self::field_help_row_static( $field_name, $field, $echo ); | |
| 1081 | - } | |
| 1082 | - | |
| 1083 | - | |
| 1084 | - /** | |
| 1085 | - * Static Help Info Row | |
| 1086 | - * | |
| 1087 | - * @param string $field_name - name of field | |
| 1088 | - * @param array $field - parameters | |
| 1089 | - * @param boolean $echo - show or return reaults {default true} | |
| 1090 | - * @return string - html || nothing | |
| 1091 | - */ | |
| 1092 | - public static function field_help_row_static( $field_name, $field, $echo = true ) { | |
| 1093 | - | |
| 1094 | - $defaults = array( | |
| 1095 | - 'value' => array(), | |
| 1096 | - 'class' => '', | |
| 1097 | - 'css' => '', | |
| 1098 | - 'description' => '', | |
| 1099 | - 'cols' => 1, | |
| 1100 | - 'group' => 'general', | |
| 1101 | - 'tr_class' => '', | |
| 1102 | - 'description_tag' => 'span', | |
| 1103 | - 'only_field' => false | |
| 1104 | - ); | |
| 1223 | + if ( ! $echo ) { | |
| 1224 | + return ob_get_clean(); | |
| 1225 | + } | |
| 1226 | + } | |
| 1105 | 1227 | |
| 1106 | - $field = wp_parse_args( $field, $defaults ); | |
| 1107 | - | |
| 1108 | - if ( ! $echo ) { | |
| 1109 | - ob_start(); | |
| 1110 | - } | |
| 1228 | + | |
| 1229 | + // ----------------------------------------------------------------------------------------------------------------- | |
| 1230 | + // Text, Help, HTML, JS Elements | |
| 1231 | + // ----------------------------------------------------------------------------------------------------------------- | |
| 1232 | + /** | |
| 1233 | + * Help Info Row | |
| 1234 | + * | |
| 1235 | + * @param string $field_name - name of field | |
| 1236 | + * @param array $field - parameters | |
| 1237 | + * @param boolean $echo - show or return reaults {default true} | |
| 1238 | + * | |
| 1239 | + * @return string - html || nothing | |
| 1240 | + */ | |
| 1241 | + public function field_help_row( $field_name, $field, $echo = true ) { | |
| 1242 | + if ( ! $echo ) { | |
| 1243 | + return self::field_help_row_static( $field_name, $field, $echo ); | |
| 1244 | + } else { | |
| 1245 | + self::field_help_row_static( $field_name, $field, $echo ); | |
| 1246 | + } | |
| 1247 | + } | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + /** | |
| 1251 | + * Static Help Info Row | |
| 1252 | + * | |
| 1253 | + * @param string $field_name - name of field | |
| 1254 | + * @param array $field - parameters | |
| 1255 | + * @param boolean $echo - show or return reaults {default true} | |
| 1256 | + * | |
| 1257 | + * @return string - html || nothing | |
| 1258 | + */ | |
| 1259 | + public static function field_help_row_static( $field_name, $field, $echo = true ) { | |
| 1260 | + | |
| 1261 | + $defaults = array( | |
| 1262 | + 'value' => array(), | |
| 1263 | + 'class' => '', | |
| 1264 | + 'css' => '', | |
| 1265 | + 'description' => '', | |
| 1266 | + 'cols' => 1, | |
| 1267 | + 'group' => 'general', | |
| 1268 | + 'tr_class' => '', | |
| 1269 | + 'description_tag' => 'span', | |
| 1270 | + 'only_field' => false | |
| 1271 | + ); | |
| 1272 | + | |
| 1273 | + $field = wp_parse_args( $field, $defaults ); | |
| 1274 | + | |
| 1275 | + if ( ! $echo ) { | |
| 1276 | + ob_start(); | |
| 1277 | + } | |
| 1111 | 1278 | if ( ! $field['only_field'] ) { |
| 1112 | 1279 | |
| 1113 | - ?><tr valign="top" class="wpbc_tr_<?php echo esc_attr( $field_name ), ' ', esc_attr( $field['tr_class'] ); ?>"> | |
| 1114 | - <?php if ( $field['cols'] == 1 ) { ?> | |
| 1115 | - <th scope="row"></th> | |
| 1116 | - <td> | |
| 1117 | - <?php } else { ?> | |
| 1118 | - <td colspan="2"> | |
| 1119 | - <?php } | |
| 1280 | + ?><tr valign="top" class="wpbc_tr_<?php | |
| 1281 | + echo esc_attr( $field_name ), ' ', esc_attr( $field['tr_class'] ); ?>"> | |
| 1282 | + <?php | |
| 1283 | + if ( $field['cols'] == 1 ) { ?> | |
| 1284 | + <th scope="row"></th> | |
| 1285 | + <td> | |
| 1286 | + <?php | |
| 1287 | + } else { ?> | |
| 1288 | + <td colspan="2"> | |
| 1289 | + <?php | |
| 1290 | + } | |
| 1120 | 1291 | } |
| 1121 | - ?><div class="wpbc-help-message <?php echo esc_attr( $field['class'] ); ?>" style="margin-top:10px; <?php echo esc_attr( $field['css'] ); ?>"> | |
| 1122 | - <?php | |
| 1123 | - $field['value'] = (array) $field['value']; | |
| 1292 | + ?> | |
| 1293 | + <div class="wpbc-help-message <?php | |
| 1294 | + echo esc_attr( $field['class'] ); ?>" style="margin-top:10px; <?php | |
| 1295 | + echo esc_attr( $field['css'] ); ?>"> | |
| 1296 | + <?php | |
| 1297 | + $field['value'] = (array) $field['value']; | |
| 1124 | 1298 | |
| 1125 | - foreach ( $field['value'] as $help_text ) { | |
| 1126 | - ?><p class="description" style="font-weight: 400;"><?php | |
| 1299 | + foreach ( $field['value'] as $help_text ) { | |
| 1300 | + ?><p class="description" style="font-weight: 400;"><?php | |
| 1301 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 1302 | + echo $help_text; | |
| 1127 | 1303 | |
| 1128 | - echo $help_text; | |
| 1304 | + ?></p><?php | |
| 1305 | + } | |
| 1306 | + ?> | |
| 1307 | + </div> | |
| 1308 | + <?php | |
| 1309 | + echo wp_kses_post( self::description_static( $field, $field['description_tag'] ) ); ?> | |
| 1310 | + <?php | |
| 1311 | + if ( ! $field['only_field'] ) { ?> | |
| 1312 | + </td> | |
| 1313 | + </tr> | |
| 1314 | + <?php | |
| 1315 | + } | |
| 1129 | 1316 | |
| 1130 | - ?></p><?php | |
| 1131 | - } | |
| 1132 | - ?> | |
| 1133 | - </div> | |
| 1134 | - <?php echo self::description_static( $field, $field['description_tag'] ); ?> | |
| 1135 | - <?php if ( ! $field['only_field'] ) { ?> | |
| 1136 | - </td> | |
| 1137 | - </tr> | |
| 1138 | - <?php | |
| 1139 | - } | |
| 1317 | + if ( ! $echo ) { | |
| 1318 | + return ob_get_clean(); | |
| 1319 | + } | |
| 1320 | + } | |
| 1140 | 1321 | |
| 1141 | - if ( ! $echo ) { | |
| 1142 | - return ob_get_clean(); | |
| 1143 | - } | |
| 1144 | - } | |
| 1145 | 1322 | |
| 1146 | - | |
| 1147 | - /** | |
| 1148 | - * Horizontal Separator | |
| 1149 | - * | |
| 1150 | - * @param string $field_name - name of field | |
| 1151 | - * @param array $field - parameters | |
| 1152 | - * @param boolean $echo - show or return reaults {default true} | |
| 1153 | - * @return string - html || nothing | |
| 1154 | - */ | |
| 1155 | - public function field_hr_row( $field_name, $field, $echo = true ) { | |
| 1156 | - if ( ! $echo ) | |
| 1157 | - return self::field_hr_row_static( $field_name, $field, $echo ); | |
| 1158 | - else | |
| 1159 | - self::field_hr_row_static( $field_name, $field, $echo ); | |
| 1160 | - } | |
| 1161 | - | |
| 1162 | - | |
| 1163 | - /** | |
| 1164 | - * Static Horizontal Separator | |
| 1165 | - * | |
| 1166 | - * @param string $field_name - name of field | |
| 1167 | - * @param array $field - parameters | |
| 1168 | - * @param boolean $echo - show or return reaults {default true} | |
| 1169 | - * @return string - html || nothing | |
| 1170 | - */ | |
| 1171 | - public static function field_hr_row_static( $field_name, $field, $echo = true ) { | |
| 1172 | - | |
| 1173 | - $defaults = array( | |
| 1174 | - 'class' => '', | |
| 1175 | - 'css' => '', | |
| 1176 | - 'group' => 'general', | |
| 1177 | - 'tr_class' => '' | |
| 1178 | - ); | |
| 1323 | + /** | |
| 1324 | + * Horizontal Separator | |
| 1325 | + * | |
| 1326 | + * @param string $field_name - name of field | |
| 1327 | + * @param array $field - parameters | |
| 1328 | + * @param boolean $echo - show or return reaults {default true} | |
| 1329 | + * | |
| 1330 | + * @return string - html || nothing | |
| 1331 | + */ | |
| 1332 | + public function field_hr_row( $field_name, $field, $echo = true ) { | |
| 1333 | + if ( ! $echo ) { | |
| 1334 | + return self::field_hr_row_static( $field_name, $field, $echo ); | |
| 1335 | + } else { | |
| 1336 | + self::field_hr_row_static( $field_name, $field, $echo ); | |
| 1337 | + } | |
| 1338 | + } | |
| 1179 | 1339 | |
| 1180 | - $field = wp_parse_args( $field, $defaults ); | |
| 1181 | - | |
| 1182 | - if ( ! $echo ) { | |
| 1183 | - ob_start(); | |
| 1184 | - } | |
| 1185 | - ?> | |
| 1186 | - <tr valign="top" class="wpbc_tr_<?php echo esc_attr( $field_name ), ' ', esc_attr( $field['tr_class'] ); ?>"> | |
| 1187 | - <td style="padding:10px 0px; " colspan="2"> | |
| 1188 | - <div class="<?php echo esc_attr( $field['class'] ); ?>" style="border-bottom:1px solid #cccccc;<?php echo esc_attr( $field['css'] ); ?>" ></div> | |
| 1189 | - </td> | |
| 1190 | - </tr> | |
| 1191 | - <?php | |
| 1192 | 1340 | |
| 1193 | - if ( ! $echo ) { | |
| 1194 | - return ob_get_clean(); | |
| 1195 | - } | |
| 1196 | - } | |
| 1341 | + /** | |
| 1342 | + * Static Horizontal Separator | |
| 1343 | + * | |
| 1344 | + * @param string $field_name - name of field | |
| 1345 | + * @param array $field - parameters | |
| 1346 | + * @param boolean $echo - show or return reaults {default true} | |
| 1347 | + * | |
| 1348 | + * @return string - html || nothing | |
| 1349 | + */ | |
| 1350 | + public static function field_hr_row_static( $field_name, $field, $echo = true ) { | |
| 1197 | 1351 | |
| 1198 | - | |
| 1199 | - /** | |
| 1200 | - * HTML Row - show any html. Warning parameter html do not escaped, check it before assign. | |
| 1201 | - * | |
| 1202 | - * @param string $field_name - name of field | |
| 1203 | - * @param array $field - parameters | |
| 1204 | - * @param boolean $echo - show or return reaults {default true} | |
| 1205 | - * @return string - html || nothing | |
| 1206 | - */ | |
| 1207 | - public function field_html_row( $field_name, $field, $echo = true ) { | |
| 1208 | - if ( ! $echo ) | |
| 1209 | - return self::field_html_row_static( $field_name, $field, $echo ); | |
| 1210 | - else | |
| 1211 | - self::field_html_row_static( $field_name, $field, $echo ); | |
| 1212 | - } | |
| 1213 | - | |
| 1214 | - | |
| 1215 | - /** | |
| 1216 | - * Static HTML Row - show any html. Warning parameter html do not escaped, check it before assign. | |
| 1217 | - * | |
| 1218 | - * @param string $field_name - name of field | |
| 1219 | - * @param array $field - parameters | |
| 1220 | - * @param boolean $echo - show or return reaults {default true} | |
| 1221 | - * @return string - html || nothing | |
| 1222 | - */ | |
| 1223 | - public static function field_html_row_static( $field_name, $field, $echo = true ) { | |
| 1224 | - | |
| 1225 | - $defaults = array( | |
| 1226 | - 'html' => '', | |
| 1227 | - 'cols' => 1, | |
| 1228 | - 'group' => 'general', | |
| 1229 | - 'tr_class' => '' | |
| 1230 | - ); | |
| 1352 | + $defaults = array( | |
| 1353 | + 'class' => '', | |
| 1354 | + 'css' => '', | |
| 1355 | + 'group' => 'general', | |
| 1356 | + 'tr_class' => '' | |
| 1357 | + ); | |
| 1231 | 1358 | |
| 1232 | - $field = wp_parse_args( $field, $defaults ); | |
| 1233 | - | |
| 1234 | - if ( ! $echo ) { | |
| 1235 | - ob_start(); | |
| 1236 | - } | |
| 1237 | - ?> | |
| 1238 | - <tr valign="top" class="wpbc_tr_<?php echo esc_attr( $field_name ), ' ', esc_attr( $field['tr_class'] ); ?>"> | |
| 1239 | - <?php if ( $field['cols'] == 1 ) { ?> | |
| 1240 | - <th scope="row"></th> | |
| 1241 | - <td> | |
| 1242 | - <?php } else { ?> | |
| 1243 | - <td colspan="2"> | |
| 1244 | - <?php }?> | |
| 1245 | - <?php echo $field['html']; ?> | |
| 1246 | - </td> | |
| 1247 | - </tr> | |
| 1248 | - <?php | |
| 1359 | + $field = wp_parse_args( $field, $defaults ); | |
| 1249 | 1360 | |
| 1250 | - if ( ! $echo ) { | |
| 1251 | - return ob_get_clean(); | |
| 1252 | - } | |
| 1253 | - } | |
| 1254 | - | |
| 1255 | - | |
| 1256 | - /** | |
| 1257 | - * HTML - show only this html, Without any Table Rows. Warning parameter html do not escaped, check it before assign. | |
| 1258 | - * | |
| 1259 | - * @param string $field_name - name of field | |
| 1260 | - * @param array $field - parameters | |
| 1261 | - * @param boolean $echo - show or return reaults {default true} | |
| 1262 | - * @return string - html || nothing | |
| 1263 | - */ | |
| 1264 | - public function field_pure_html_row( $field_name, $field, $echo = true ) { | |
| 1265 | - if ( ! $echo ) | |
| 1266 | - return self::field_pure_html_row_static( $field_name, $field, $echo ); | |
| 1267 | - else | |
| 1268 | - self::field_pure_html_row_static( $field_name, $field, $echo ); | |
| 1269 | - } | |
| 1270 | - | |
| 1271 | - | |
| 1272 | - /** | |
| 1273 | - * Static HTML - show only this html, Without any Table Rows. Warning parameter html do not escaped, check it before assign. | |
| 1274 | - * | |
| 1275 | - * @param string $field_name - name of field | |
| 1276 | - * @param array $field - parameters | |
| 1277 | - * @param boolean $echo - show or return reaults {default true} | |
| 1278 | - * @return string - html || nothing | |
| 1279 | - */ | |
| 1280 | - public static function field_pure_html_row_static( $field_name, $field, $echo = true ) { | |
| 1281 | - | |
| 1282 | - $defaults = array( | |
| 1283 | - 'html' => '', | |
| 1284 | - 'group' => 'general' | |
| 1285 | - ); | |
| 1361 | + if ( ! $echo ) { | |
| 1362 | + ob_start(); | |
| 1363 | + } | |
| 1364 | + ?> | |
| 1365 | + <tr valign="top" class="wpbc_tr_<?php | |
| 1366 | + echo esc_attr( $field_name ), ' ', esc_attr( $field['tr_class'] ); ?>"> | |
| 1367 | + <td style="padding:10px 0px; " colspan="2"> | |
| 1368 | + <div class="<?php | |
| 1369 | + echo esc_attr( $field['class'] ); ?>" style="border-bottom:1px solid #cccccc;<?php | |
| 1370 | + echo esc_attr( $field['css'] ); ?>"></div> | |
| 1371 | + </td> | |
| 1372 | + </tr> | |
| 1373 | + <?php | |
| 1286 | 1374 | |
| 1287 | - $field = wp_parse_args( $field, $defaults ); | |
| 1288 | - | |
| 1289 | - if ( ! $echo ) { | |
| 1290 | - ob_start(); | |
| 1291 | - } | |
| 1292 | - | |
| 1293 | - echo $field['html']; | |
| 1294 | - | |
| 1295 | - if ( ! $echo ) { | |
| 1296 | - return ob_get_clean(); | |
| 1297 | - } | |
| 1298 | - } | |
| 1299 | - | |
| 1300 | - | |
| 1301 | - /** | |
| 1302 | - * JavaScript Row - insert JavaScript | |
| 1303 | - * | |
| 1304 | - * @param string $field_name - name of field | |
| 1305 | - * @param array $field - parameters | |
| 1306 | - * @param boolean $echo - show or return reaults {default true} | |
| 1307 | - * @return string - html || nothing | |
| 1308 | - */ | |
| 1309 | - public function field_js_row( $field_name, $field, $echo = true ) { | |
| 1310 | - if ( ! $echo ) | |
| 1311 | - return self::field_js_row_static( $field_name, $field, $echo ); | |
| 1312 | - else | |
| 1313 | - self::field_js_row_static( $field_name, $field, $echo ); | |
| 1314 | - } | |
| 1315 | - | |
| 1316 | - | |
| 1317 | - /** | |
| 1318 | - * Static JavaScript Row - insert JavaScript | |
| 1319 | - * | |
| 1320 | - * @param string $field_name - name of field | |
| 1321 | - * @param array $field - parameters | |
| 1322 | - * @param boolean $echo - show or return reaults {default true} | |
| 1323 | - * @return string - html || nothing | |
| 1324 | - */ | |
| 1325 | - public static function field_js_row_static( $field_name, $field, $echo = true ) { | |
| 1326 | - | |
| 1327 | - $defaults = array( | |
| 1328 | - 'js' => '', | |
| 1329 | - 'group' => 'general' | |
| 1330 | - ); | |
| 1375 | + if ( ! $echo ) { | |
| 1376 | + return ob_get_clean(); | |
| 1377 | + } | |
| 1378 | + } | |
| 1331 | 1379 | |
| 1332 | - $field = wp_parse_args( $field, $defaults ); | |
| 1333 | - | |
| 1334 | - if ( ! $echo ) { | |
| 1335 | - ob_start(); | |
| 1336 | - } | |
| 1337 | - ?> | |
| 1338 | - <script type="text/javascript"> | |
| 1339 | - <?php echo $field['js']; ?> | |
| 1340 | - </script> | |
| 1341 | - <?php | |
| 1342 | 1380 | |
| 1343 | - if ( ! $echo ) { | |
| 1344 | - return ob_get_clean(); | |
| 1345 | - } | |
| 1346 | - } | |
| 1347 | - | |
| 1348 | - | |
| 1349 | - //////////////////////////////////////////////////////////////////////////// | |
| 1350 | - // Support functions | |
| 1351 | - //////////////////////////////////////////////////////////////////////////// | |
| 1352 | - | |
| 1353 | - /** | |
| 1354 | - * Get custom attributes | |
| 1355 | - * | |
| 1356 | - * @param array $field | |
| 1357 | - * @return string | |
| 1358 | - */ | |
| 1359 | - public static function get_custom_attr_static( $field ) { | |
| 1381 | + /** | |
| 1382 | + * HTML Row - show any html. Warning parameter html do not escaped, check it before assign. | |
| 1383 | + * | |
| 1384 | + * @param string $field_name - name of field | |
| 1385 | + * @param array $field - parameters | |
| 1386 | + * @param boolean $echo - show or return reaults {default true} | |
| 1387 | + * | |
| 1388 | + * @return string - html || nothing | |
| 1389 | + */ | |
| 1390 | + public function field_html_row( $field_name, $field, $echo = true ) { | |
| 1391 | + if ( ! $echo ) { | |
| 1392 | + return self::field_html_row_static( $field_name, $field, $echo ); | |
| 1393 | + } else { | |
| 1394 | + self::field_html_row_static( $field_name, $field, $echo ); | |
| 1395 | + } | |
| 1396 | + } | |
| 1360 | 1397 | |
| 1361 | - $attributes = array(); | |
| 1362 | 1398 | |
| 1363 | - if ( ! empty( $field['attr'] ) && is_array( $field['attr'] ) ) { | |
| 1399 | + /** | |
| 1400 | + * Static HTML Row - show any html. Warning parameter html do not escaped, check it before assign. | |
| 1401 | + * | |
| 1402 | + * @param string $field_name - name of field | |
| 1403 | + * @param array $field - parameters | |
| 1404 | + * @param boolean $echo - show or return reaults {default true} | |
| 1405 | + * | |
| 1406 | + * @return string - html || nothing | |
| 1407 | + */ | |
| 1408 | + public static function field_html_row_static( $field_name, $field, $echo = true ) { | |
| 1364 | 1409 | |
| 1365 | - foreach ( $field['attr'] as $attr => $attr_v ) { | |
| 1366 | - $attributes[] = esc_attr( $attr ) . '="' . esc_attr( $attr_v ) . '"'; | |
| 1367 | - } | |
| 1368 | - } | |
| 1410 | + $defaults = array( | |
| 1411 | + 'html' => '', | |
| 1412 | + 'cols' => 1, | |
| 1413 | + 'group' => 'general', | |
| 1414 | + 'tr_class' => '' | |
| 1415 | + ); | |
| 1369 | 1416 | |
| 1370 | - return implode( ' ', $attributes ); | |
| 1371 | - } | |
| 1372 | - | |
| 1373 | - | |
| 1374 | - /** | |
| 1417 | + $field = wp_parse_args( $field, $defaults ); | |
| 1418 | + | |
| 1419 | + if ( ! $echo ) { | |
| 1420 | + ob_start(); | |
| 1421 | + } | |
| 1422 | + ?> | |
| 1423 | + <tr valign="top" class="wpbc_tr_<?php | |
| 1424 | + echo esc_attr( $field_name ), ' ', esc_attr( $field['tr_class'] ); ?>"> | |
| 1425 | + <?php | |
| 1426 | + if ( $field['cols'] == 1 ) { ?> | |
| 1427 | + <th scope="row"></th> | |
| 1428 | + <td> | |
| 1429 | + <?php | |
| 1430 | + } else { ?> | |
| 1431 | + <td colspan="2"> | |
| 1432 | + <?php | |
| 1433 | + } ?> | |
| 1434 | + <?php | |
| 1435 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 1436 | + echo $field['html']; | |
| 1437 | + ?> | |
| 1438 | + </td> | |
| 1439 | + </tr> | |
| 1440 | + <?php | |
| 1441 | + | |
| 1442 | + if ( ! $echo ) { | |
| 1443 | + return ob_get_clean(); | |
| 1444 | + } | |
| 1445 | + } | |
| 1446 | + | |
| 1447 | + | |
| 1448 | + /** | |
| 1449 | + * HTML - show only this html, Without any Table Rows. Warning parameter html do not escaped, check it before assign. | |
| 1450 | + * | |
| 1451 | + * @param string $field_name - name of field | |
| 1452 | + * @param array $field - parameters | |
| 1453 | + * @param boolean $echo - show or return reaults {default true} | |
| 1454 | + * | |
| 1455 | + * @return string - html || nothing | |
| 1456 | + */ | |
| 1457 | + public function field_pure_html_row( $field_name, $field, $echo = true ) { | |
| 1458 | + if ( ! $echo ) { | |
| 1459 | + return self::field_pure_html_row_static( $field_name, $field, $echo ); | |
| 1460 | + } else { | |
| 1461 | + self::field_pure_html_row_static( $field_name, $field, $echo ); | |
| 1462 | + } | |
| 1463 | + } | |
| 1464 | + | |
| 1465 | + | |
| 1466 | + /** | |
| 1467 | + * Static HTML - show only this html, Without any Table Rows. Warning parameter html do not escaped, check it before assign. | |
| 1468 | + * | |
| 1469 | + * @param string $field_name - name of field | |
| 1470 | + * @param array $field - parameters | |
| 1471 | + * @param boolean $echo - show or return reaults {default true} | |
| 1472 | + * | |
| 1473 | + * @return string - html || nothing | |
| 1474 | + */ | |
| 1475 | + public static function field_pure_html_row_static( $field_name, $field, $echo = true ) { | |
| 1476 | + | |
| 1477 | + $defaults = array( | |
| 1478 | + 'html' => '', | |
| 1479 | + 'group' => 'general' | |
| 1480 | + ); | |
| 1481 | + | |
| 1482 | + $field = wp_parse_args( $field, $defaults ); | |
| 1483 | + | |
| 1484 | + if ( ! $echo ) { | |
| 1485 | + ob_start(); | |
| 1486 | + } | |
| 1487 | + | |
| 1488 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 1489 | + echo $field['html'] ; | |
| 1490 | + | |
| 1491 | + if ( ! $echo ) { | |
| 1492 | + return ob_get_clean(); | |
| 1493 | + } | |
| 1494 | + } | |
| 1495 | + | |
| 1496 | + | |
| 1497 | + /** | |
| 1498 | + * JavaScript Row - insert JavaScript | |
| 1499 | + * | |
| 1500 | + * @param string $field_name - name of field | |
| 1501 | + * @param array $field - parameters | |
| 1502 | + * @param boolean $echo - show or return reaults {default true} | |
| 1503 | + * | |
| 1504 | + * @return string - html || nothing | |
| 1505 | + */ | |
| 1506 | + public function field_js_row( $field_name, $field, $echo = true ) { | |
| 1507 | + if ( ! $echo ) { | |
| 1508 | + return self::field_js_row_static( $field_name, $field, $echo ); | |
| 1509 | + } else { | |
| 1510 | + self::field_js_row_static( $field_name, $field, $echo ); | |
| 1511 | + } | |
| 1512 | + } | |
| 1513 | + | |
| 1514 | + | |
| 1515 | + /** | |
| 1516 | + * Static JavaScript Row - insert JavaScript | |
| 1517 | + * | |
| 1518 | + * @param string $field_name - name of field | |
| 1519 | + * @param array $field - parameters | |
| 1520 | + * @param boolean $echo - show or return reaults {default true} | |
| 1521 | + * | |
| 1522 | + * @return string - html || nothing | |
| 1523 | + */ | |
| 1524 | + public static function field_js_row_static( $field_name, $field, $echo = true ) { | |
| 1525 | + | |
| 1526 | + $defaults = array( | |
| 1527 | + 'js' => '', | |
| 1528 | + 'group' => 'general' | |
| 1529 | + ); | |
| 1530 | + | |
| 1531 | + $field = wp_parse_args( $field, $defaults ); | |
| 1532 | + | |
| 1533 | + if ( ! $echo ) { | |
| 1534 | + ob_start(); | |
| 1535 | + } | |
| 1536 | + ?> | |
| 1537 | + <script type="text/javascript"> | |
| 1538 | + <?php | |
| 1539 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 1540 | + echo $field['js']; ?> | |
| 1541 | + </script> | |
| 1542 | + <?php | |
| 1543 | + | |
| 1544 | + if ( ! $echo ) { | |
| 1545 | + return ob_get_clean(); | |
| 1546 | + } | |
| 1547 | + } | |
| 1548 | + | |
| 1549 | + | |
| 1550 | + // ----------------------------------------------------------------------------------------------------------------- | |
| 1551 | + // Support functions | |
| 1552 | + // ----------------------------------------------------------------------------------------------------------------- | |
| 1553 | + /** | |
| 1554 | + * Get custom attributes | |
| 1555 | + * | |
| 1556 | + * @param array $field | |
| 1557 | + * | |
| 1558 | + * @return string | |
| 1559 | + */ | |
| 1560 | + public static function get_custom_attr_static( $field ) { | |
| 1561 | + | |
| 1562 | + $attributes = array(); | |
| 1563 | + | |
| 1564 | + if ( ! empty( $field['attr'] ) && is_array( $field['attr'] ) ) { | |
| 1565 | + | |
| 1566 | + foreach ( $field['attr'] as $attr => $attr_v ) { | |
| 1567 | + $attributes[] = esc_attr( $attr ) . '="' . esc_attr( $attr_v ) . '"'; | |
| 1568 | + } | |
| 1569 | + } | |
| 1570 | + | |
| 1571 | + return implode( ' ', $attributes ); | |
| 1572 | + } | |
| 1573 | + | |
| 1574 | + | |
| 1575 | + /** | |
| 1375 | 1576 | * Get Description |
| 1376 | - * | |
| 1377 | - * @param array $field | |
| 1378 | - * @param string $html_tag - HTML element, which will be used as separator. Default - 'p' | |
| 1379 | - * @return string | |
| 1380 | - */ | |
| 1381 | - public static function description_static( $field, $html_tag = 'p' ) { | |
| 1382 | - if ( empty( $html_tag ) ) | |
| 1383 | - $html_tag = 'p'; | |
| 1384 | - | |
| 1385 | - return $field['description'] ? '<'.$html_tag.' class="description">' . wp_kses_post( $field['description'] ) . '</'.$html_tag.'>' . "\n" : ''; | |
| 1386 | - } | |
| 1577 | + * | |
| 1578 | + * @param array $field | |
| 1579 | + * @param string $html_tag - HTML element, which will be used as separator. Default - 'p' | |
| 1580 | + * | |
| 1581 | + * @return string | |
| 1582 | + */ | |
| 1583 | + public static function description_static( $field, $html_tag = 'p' ) { | |
| 1584 | + if ( empty( $html_tag ) ) { | |
| 1585 | + $html_tag = 'p'; | |
| 1586 | + } | |
| 1387 | 1587 | |
| 1388 | - public static function label_static( $field_name, $field ) { | |
| 1588 | + return $field['description'] | |
| 1589 | + ? '<' . $html_tag . ' class="description">' . wp_kses_post( $field['description'] ) . '</' . $html_tag . '>' . "\n" | |
| 1590 | + : ''; | |
| 1591 | + } | |
| 1389 | 1592 | |
| 1390 | - if ( empty( $field['title'] ) ) | |
| 1391 | - return ''; | |
| 1392 | - | |
| 1393 | - $defaults = array( | |
| 1394 | - 'title' => '', | |
| 1395 | - 'label_class' => '', | |
| 1396 | - 'label_css' => '', | |
| 1397 | - 'type' => '' | |
| 1398 | - ); | |
| 1399 | - $field = wp_parse_args( $field, $defaults ); | |
| 1400 | - | |
| 1401 | - if ( ! empty($field['type'] ) ) | |
| 1402 | - $field['label_class'] .= ' wpbc-form-' . $field['type']; | |
| 1403 | - | |
| 1404 | - if ( ! empty( $field['label_css'] ) ) | |
| 1405 | - $field['label_css'] = ' style="' . $field['label_css'] . '"'; | |
| 1406 | - | |
| 1407 | - return '<label for="' . esc_attr( $field_name ) . '" class="' . $field['label_class'] . '"'.$field['label_css'].'>' . wp_kses_post( $field['title'] ) . '</label>'; | |
| 1408 | - } | |
| 1409 | - | |
| 1410 | - // </editor-fold> | |
| 1593 | + public static function label_static( $field_name, $field ) { | |
| 1411 | 1594 | |
| 1595 | + if ( empty( $field['title'] ) ) { | |
| 1596 | + return ''; | |
| 1597 | + } | |
| 1598 | + | |
| 1599 | + $defaults = array( | |
| 1600 | + 'title' => '', | |
| 1601 | + 'label_class' => '', | |
| 1602 | + 'label_css' => '', | |
| 1603 | + 'type' => '' | |
| 1604 | + ); | |
| 1605 | + $field = wp_parse_args( $field, $defaults ); | |
| 1606 | + | |
| 1607 | + if ( ! empty( $field['type'] ) ) { | |
| 1608 | + $field['label_class'] .= ' wpbc-form-' . $field['type']; | |
| 1609 | + } | |
| 1610 | + | |
| 1611 | + if ( ! empty( $field['label_css'] ) ) { | |
| 1612 | + $field['label_css'] = ' style="' . $field['label_css'] . '"'; | |
| 1613 | + } | |
| 1614 | + | |
| 1615 | + return '<label for="' . esc_attr( $field_name ) . '" class="' . $field['label_class'] . '"' . $field['label_css'] . '>' . wp_kses_post( $field['title'] ) . '</label>'; | |
| 1616 | + } | |
| 1617 | + | |
| 1618 | + // </editor-fold> | |
| 1619 | + | |
| 1412 | 1620 | |
| 1413 | - //////////////////////////////////////////////////////////////////////////// | |
| 1621 | + // ----------------------------------------------------------------------------------------------------------------- | |
| 1414 | 1622 | // Validate POSTs |
| 1415 | - //////////////////////////////////////////////////////////////////////////// | |
| 1416 | - | |
| 1623 | + // ----------------------------------------------------------------------------------------------------------------- | |
| 1417 | 1624 | /** |
| 1418 | 1625 | * Validate Settings Field Data. |
| 1419 | 1626 | * |
| 1420 | 1627 | * Validate the data on the "Settings" form. |
| @@ -1455,8 +1662,9 @@ | ||
| 1455 | 1662 | $this->validated_fields[ $k ] = $field; |
| 1456 | 1663 | |
| 1457 | 1664 | // Default to text |
| 1458 | 1665 | } else { |
| 1666 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing | |
| 1459 | 1667 | if ( isset( $_POST[ $this->id . '_' . $k ] ) ) { //Check this for non Fields elements, like simple HTML or TEXT or JS |
| 1460 | 1668 | $field = $this->{'validate_text_post'}( $this->id . '_' . $k ); |
| 1461 | 1669 | $this->validated_fields[ $k ] = $field; |
| 1462 | 1670 | } |
| @@ -1477,11 +1685,46 @@ | ||
| 1477 | 1685 | */ |
| 1478 | 1686 | public function validate_text_post( $post_key ) { |
| 1479 | 1687 | return self::validate_text_post_static( $post_key ); |
| 1480 | 1688 | } |
| 1481 | - | |
| 1482 | - | |
| 1689 | + | |
| 1690 | + // FixIn: 10.14.2.2 | |
| 1483 | 1691 | /** |
| 1692 | + * Validate Color: '#ff00ff' in POST request - escape data correctly. | |
| 1693 | + * | |
| 1694 | + * @param string $post_key - key for POST | |
| 1695 | + * @return string | false, if no such POST | |
| 1696 | + */ | |
| 1697 | + public function validate_color_post( $post_key ) { | |
| 1698 | + return self::validate_color_static( $post_key ); | |
| 1699 | + } | |
| 1700 | + | |
| 1701 | + | |
| 1702 | + // FixIn: 10.14.2.2 | |
| 1703 | + /** | |
| 1704 | + * Static Validate Color field in POST request - escape data correctly. | |
| 1705 | + * | |
| 1706 | + * @param string $post_key - key for POST | |
| 1707 | + * @return string | false, if no such POST | |
| 1708 | + */ | |
| 1709 | + public static function validate_color_static( $post_key ) { | |
| 1710 | + | |
| 1711 | + $value = ''; | |
| 1712 | + | |
| 1713 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing | |
| 1714 | + if ( isset( $_POST[ $post_key ] ) ) { | |
| 1715 | + // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 1716 | + $value = sanitize_hex_color( trim( stripslashes( $_POST[ $post_key ] ) ) ); | |
| 1717 | + if ( null === $value ) { | |
| 1718 | + $value = ''; | |
| 1719 | + } | |
| 1720 | + } | |
| 1721 | + | |
| 1722 | + return $value; | |
| 1723 | + } | |
| 1724 | + | |
| 1725 | + | |
| 1726 | + /** | |
| 1484 | 1727 | * Static Validate Text in POST request - escape data correctly. |
| 1485 | 1728 | * |
| 1486 | 1729 | * @param string $post_key - key for POST |
| 1487 | 1730 | * @return string | false, if no such POST |
| @@ -1488,13 +1731,16 @@ | ||
| 1488 | 1731 | */ |
| 1489 | 1732 | public static function validate_text_post_static( $post_key, $post_index = false ) { |
| 1490 | 1733 | |
| 1491 | 1734 | $value = false; |
| 1492 | - //FixIn: 9.2.4.2 | |
| 1735 | + // FixIn: 9.2.4.2. | |
| 1736 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing | |
| 1493 | 1737 | if ( isset( $_POST[ $post_key ] ) ) { |
| 1494 | 1738 | if ( $post_index !== false ) { |
| 1739 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.InputNotValidated | |
| 1495 | 1740 | $post_value = $_POST[ $post_key ][ $post_index ]; |
| 1496 | 1741 | } else { |
| 1742 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.InputNotValidated | |
| 1497 | 1743 | $post_value = $_POST[ $post_key ]; |
| 1498 | 1744 | } |
| 1499 | 1745 | } |
| 1500 | 1746 | |
| @@ -1527,9 +1773,11 @@ | ||
| 1527 | 1773 | public static function validate_email_post_static( $post_key ) { |
| 1528 | 1774 | |
| 1529 | 1775 | $value = false; |
| 1530 | 1776 | |
| 1777 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing | |
| 1531 | 1778 | if ( isset( $_POST[ $post_key ] ) ) { |
| 1779 | + // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 1532 | 1780 | $value = sanitize_email( trim( stripslashes( $_POST[ $post_key ] ) ) ); |
| 1533 | 1781 | } |
| 1534 | 1782 | |
| 1535 | 1783 | return $value; |
| @@ -1556,10 +1804,12 @@ | ||
| 1556 | 1804 | public static function validate_textarea_post_static( $post_key ) { |
| 1557 | 1805 | |
| 1558 | 1806 | $value = false; |
| 1559 | 1807 | |
| 1808 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing | |
| 1560 | 1809 | if ( isset( $_POST[ $post_key ] ) ) { |
| 1561 | 1810 | |
| 1811 | + // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 1562 | 1812 | $value = wp_kses( trim( stripslashes( $_POST[ $post_key ] ) ), |
| 1563 | 1813 | array_merge( |
| 1564 | 1814 | array( |
| 1565 | 1815 | 'iframe' => array( 'src' => true, 'style' => true, 'id' => true, 'class' => true ) |
| @@ -1619,8 +1869,9 @@ | ||
| 1619 | 1869 | public static function validate_checkbox_post_static( $post_key ) { |
| 1620 | 1870 | |
| 1621 | 1871 | $status = 'Off'; |
| 1622 | 1872 | |
| 1873 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing | |
| 1623 | 1874 | if ( isset( $_POST[ $post_key ] ) && ( in_array( $_POST[ $post_key ], array( 'On', 'Off' ) ) ) ) { |
| 1624 | 1875 | $status = 'On'; |
| 1625 | 1876 | } |
| 1626 | 1877 | |
| @@ -1648,13 +1899,17 @@ | ||
| 1648 | 1899 | public static function validate_select_post_static( $post_key ) { |
| 1649 | 1900 | |
| 1650 | 1901 | $value = false; |
| 1651 | 1902 | |
| 1903 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing | |
| 1652 | 1904 | if ( isset( $_POST[ $post_key ] ) ) { |
| 1653 | 1905 | |
| 1906 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing | |
| 1654 | 1907 | if ( is_array( $_POST[ $post_key ] ) ) { |
| 1908 | + // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 1655 | 1909 | $value = array_map( 'sanitize_text_field', array_map( 'stripslashes', (array) $_POST[ $post_key ] ) ); |
| 1656 | 1910 | } else { |
| 1911 | + // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 1657 | 1912 | $value = sanitize_text_field( stripslashes( $_POST[ $post_key ] ) ); |
| 1658 | 1913 | } |
| 1659 | 1914 | } |
| 1660 | 1915 | |
| @@ -1688,12 +1943,11 @@ | ||
| 1688 | 1943 | } |
| 1689 | 1944 | |
| 1690 | 1945 | // </editor-fold> |
| 1691 | 1946 | |
| 1692 | - //////////////////////////////////////////////////////////////////////////// | |
| 1947 | + // ----------------------------------------------------------------------------------------------------------------- | |
| 1693 | 1948 | // Save | Get from DB |
| 1694 | - //////////////////////////////////////////////////////////////////////////// | |
| 1695 | - | |
| 1949 | + // ----------------------------------------------------------------------------------------------------------------- | |
| 1696 | 1950 | /** |
| 1697 | 1951 | * Save Setting Options to DB, then Reinit Settings Fields with these new Values... |
| 1698 | 1952 | * |
| 1699 | 1953 | * @param string $settings_id - ID of the settings |
| @@ -1798,12 +2052,11 @@ | ||
| 1798 | 2052 | } |
| 1799 | 2053 | |
| 1800 | 2054 | |
| 1801 | 2055 | |
| 1802 | - //////////////////////////////////////////////////////////////////////////// | |
| 2056 | + // ----------------------------------------------------------------------------------------------------------------- | |
| 1803 | 2057 | // Install | Uninstall |
| 1804 | - //////////////////////////////////////////////////////////////////////////// | |
| 1805 | - | |
| 2058 | + // ----------------------------------------------------------------------------------------------------------------- | |
| 1806 | 2059 | /** Actiovation of Plugin. Save to DB initial values of Settings Fields. */ |
| 1807 | 2060 | public function activate() { |
| 1808 | 2061 | |
| 1809 | 2062 | $settings_id = $this->get_id(); |