← All changes
|
frameworks/codestar-framework/classes/customize-options.class.php
+261
-261
2.3.4
→
2.4.0
View file →
| @@ -1,261 +1,261 @@ | ||
| 1 | -<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly. | |
| 2 | -/** | |
| 3 | - * | |
| 4 | - * Customize Options Class | |
| 5 | - * | |
| 6 | - * @since 1.0.0 | |
| 7 | - * @version 1.0.0 | |
| 8 | - * | |
| 9 | - */ | |
| 10 | -if ( ! class_exists( 'CSF_Customize_Options' ) ) { | |
| 11 | - class CSF_Customize_Options extends CSF_Abstract { | |
| 12 | - | |
| 13 | - // constans | |
| 14 | - public $unique = ''; | |
| 15 | - public $abstract = 'customize'; | |
| 16 | - public $options = array(); | |
| 17 | - public $sections = array(); | |
| 18 | - public $pre_fields = array(); | |
| 19 | - public $pre_sections = array(); | |
| 20 | - public $priority = 10; | |
| 21 | - public $args = array( | |
| 22 | - 'database' => 'option', | |
| 23 | - 'transport' => 'refresh', | |
| 24 | - 'capability' => 'manage_options', | |
| 25 | - 'save_defaults' => true, | |
| 26 | - 'enqueue_webfont' => true, | |
| 27 | - 'async_webfont' => false, | |
| 28 | - 'output_css' => true, | |
| 29 | - 'defaults' => array() | |
| 30 | - ); | |
| 31 | - | |
| 32 | - // run customize construct | |
| 33 | - public function __construct( $key, $params ) { | |
| 34 | - | |
| 35 | - $this->unique = $key; | |
| 36 | - $this->args = apply_filters( "csf_{$this->unique}_args", wp_parse_args( $params['args'], $this->args ), $this ); | |
| 37 | - $this->sections = apply_filters( "csf_{$this->unique}_sections", $params['sections'], $this ); | |
| 38 | - $this->pre_fields = $this->pre_fields( $this->sections ); | |
| 39 | - $this->pre_sections = $this->pre_sections_customize( $this->sections ); | |
| 40 | - | |
| 41 | - $this->get_options(); | |
| 42 | - $this->save_defaults(); | |
| 43 | - | |
| 44 | - add_action( 'customize_register', array( $this, 'add_customize_options' ) ); | |
| 45 | - add_action( 'customize_save_after', array( $this, 'add_customize_save_after' ) ); | |
| 46 | - | |
| 47 | - // Get options for enqueue actions | |
| 48 | - if ( is_customize_preview() ) { | |
| 49 | - add_action( 'wp_enqueue_scripts', array( $this, 'get_options' ) ); | |
| 50 | - } | |
| 51 | - | |
| 52 | - // wp enqeueu for typography and output css | |
| 53 | - parent::__construct(); | |
| 54 | - | |
| 55 | - } | |
| 56 | - | |
| 57 | - // instance | |
| 58 | - public static function instance( $key, $params = array() ) { | |
| 59 | - return new self( $key, $params ); | |
| 60 | - } | |
| 61 | - | |
| 62 | - public function add_customize_save_after( $wp_customize ) { | |
| 63 | - do_action( "csf_{$this->unique}_save_before", $this->get_options(), $this, $wp_customize ); | |
| 64 | - do_action( "csf_{$this->unique}_saved", $this->get_options(), $this, $wp_customize ); | |
| 65 | - do_action( "csf_{$this->unique}_save_after", $this->get_options(), $this, $wp_customize ); | |
| 66 | - } | |
| 67 | - | |
| 68 | - // get default value | |
| 69 | - public function get_default( $field ) { | |
| 70 | - | |
| 71 | - $default = ( isset( $field['default'] ) ) ? $field['default'] : ''; | |
| 72 | - $default = ( isset( $this->args['defaults'][$field['id']] ) ) ? $this->args['defaults'][$field['id']] : $default; | |
| 73 | - | |
| 74 | - return $default; | |
| 75 | - | |
| 76 | - } | |
| 77 | - | |
| 78 | - // get option | |
| 79 | - public function get_options() { | |
| 80 | - | |
| 81 | - if ( $this->args['database'] === 'theme_mod' ) { | |
| 82 | - $this->options = get_theme_mod( $this->unique, array() ); | |
| 83 | - } else { | |
| 84 | - $this->options = get_option( $this->unique, array() ); | |
| 85 | - } | |
| 86 | - | |
| 87 | - if ( empty( $this->options ) ) { | |
| 88 | - $this->options = array(); | |
| 89 | - } | |
| 90 | - | |
| 91 | - return $this->options; | |
| 92 | - | |
| 93 | - } | |
| 94 | - | |
| 95 | - // save defaults and set new fields value to main options | |
| 96 | - public function save_defaults() { | |
| 97 | - | |
| 98 | - $tmp_options = $this->options; | |
| 99 | - | |
| 100 | - if ( ! empty( $this->pre_fields ) ) { | |
| 101 | - foreach ( $this->pre_fields as $field ) { | |
| 102 | - if ( ! empty( $field['id'] ) ) { | |
| 103 | - $this->options[$field['id']] = ( isset( $this->options[$field['id']] ) ) ? $this->options[$field['id']] : $this->get_default( $field ); | |
| 104 | - } | |
| 105 | - } | |
| 106 | - } | |
| 107 | - | |
| 108 | - if ( $this->args['save_defaults'] && empty( $this->args['show_in_customizer'] ) && empty( $tmp_options ) ) { | |
| 109 | - | |
| 110 | - if ( $this->args['database'] === 'theme_mod' ) { | |
| 111 | - set_theme_mod( $this->unique, $this->options ); | |
| 112 | - } else { | |
| 113 | - update_option( $this->unique, $this->options ); | |
| 114 | - } | |
| 115 | - | |
| 116 | - } | |
| 117 | - | |
| 118 | - } | |
| 119 | - | |
| 120 | - public function pre_sections_customize( $sections ) { | |
| 121 | - | |
| 122 | - $result = array(); | |
| 123 | - $parents = array(); | |
| 124 | - | |
| 125 | - foreach ( $sections as $key => $section ) { | |
| 126 | - if ( ! empty( $section['parent'] ) ) { | |
| 127 | - $parents[$section['parent']][] = $section; | |
| 128 | - unset( $sections[$key] ); | |
| 129 | - } | |
| 130 | - } | |
| 131 | - | |
| 132 | - foreach ( $sections as $key => $section ) { | |
| 133 | - if ( ! empty( $section['id'] ) && ! empty( $parents[$section['id']] ) ) { | |
| 134 | - $section['subs'] = $parents[$section['id']]; | |
| 135 | - } | |
| 136 | - $result[] = $section; | |
| 137 | - } | |
| 138 | - | |
| 139 | - return $result; | |
| 140 | - | |
| 141 | - } | |
| 142 | - | |
| 143 | - public function add_customize_options( $wp_customize ) { | |
| 144 | - | |
| 145 | - if ( ! class_exists( 'WP_Customize_Panel_CSF' ) ) { | |
| 146 | - CSF::include_plugin_file( 'functions/customize.php' ); | |
| 147 | - } | |
| 148 | - | |
| 149 | - foreach ( $this->pre_sections as $section ) { | |
| 150 | - | |
| 151 | - if ( ! empty( $section['subs'] ) ) { | |
| 152 | - | |
| 153 | - $panel_id = ( isset( $section['id'] ) ) ? $section['id'] : $this->unique .'-panel-'. $this->priority; | |
| 154 | - | |
| 155 | - $wp_customize->add_panel( new WP_Customize_Panel_CSF( $wp_customize, $panel_id, array( | |
| 156 | - 'title' => ( isset( $section['title'] ) ) ? $section['title'] : null, | |
| 157 | - 'description' => ( isset( $section['description'] ) ) ? $section['description'] : null, | |
| 158 | - 'priority' => ( isset( $section['priority'] ) ) ? $section['priority'] : null, | |
| 159 | - ) ) ); | |
| 160 | - | |
| 161 | - $this->priority++; | |
| 162 | - | |
| 163 | - foreach ( $section['subs'] as $sub_section ) { | |
| 164 | - | |
| 165 | - $section_id = ( isset( $sub_section['id'] ) ) ? $sub_section['id'] : $this->unique .'-section-'. $this->priority; | |
| 166 | - | |
| 167 | - $this->add_section( $wp_customize, $section_id, $sub_section, $panel_id ); | |
| 168 | - | |
| 169 | - $this->priority++; | |
| 170 | - | |
| 171 | - } | |
| 172 | - | |
| 173 | - } else { | |
| 174 | - | |
| 175 | - $section_id = ( isset( $section['id'] ) ) ? $section['id'] : $this->unique .'-section-'. $this->priority; | |
| 176 | - | |
| 177 | - $this->add_section( $wp_customize, $section_id, $section, false ); | |
| 178 | - | |
| 179 | - $this->priority++; | |
| 180 | - | |
| 181 | - } | |
| 182 | - | |
| 183 | - } | |
| 184 | - | |
| 185 | - } | |
| 186 | - | |
| 187 | - // add customize section | |
| 188 | - public function add_section( $wp_customize, $section_id, $section_args, $panel_id ) { | |
| 189 | - | |
| 190 | - if ( ! empty( $section_args['assign'] ) ) { | |
| 191 | - | |
| 192 | - $section_id = $section_args['assign']; | |
| 193 | - | |
| 194 | - } else { | |
| 195 | - | |
| 196 | - $wp_customize->add_section( new WP_Customize_Section_CSF( $wp_customize, $section_id, array( | |
| 197 | - 'title' => ( isset( $section_args['title'] ) ) ? $section_args['title'] : '', | |
| 198 | - 'description' => ( isset( $section_args['description'] ) ) ? $section_args['description'] : '', | |
| 199 | - 'priority' => ( isset( $section_args['priority'] ) ) ? $section_args['priority'] : '', | |
| 200 | - 'panel' => ( $panel_id ) ? $panel_id : '', | |
| 201 | - ) ) ); | |
| 202 | - | |
| 203 | - } | |
| 204 | - | |
| 205 | - if ( ! empty( $section_args['fields'] ) ) { | |
| 206 | - | |
| 207 | - $field_key = 1; | |
| 208 | - | |
| 209 | - foreach ( $section_args['fields'] as $field ) { | |
| 210 | - | |
| 211 | - if ( isset( $field['id'] ) ) { | |
| 212 | - $field['default'] = $this->get_default( $field ); | |
| 213 | - } | |
| 214 | - | |
| 215 | - $field_id = ( isset( $field['id'] ) ) ? $field['id'] : '_nonce-'. $section_id .'-'. $field_key; | |
| 216 | - $setting_args = ( isset( $field['setting_args'] ) ) ? $field['setting_args'] : array(); | |
| 217 | - $control_args = ( isset( $field['control_args'] ) ) ? $field['control_args'] : array(); | |
| 218 | - $field_transport = ( isset( $field['transport'] ) ) ? $field['transport'] : $this->args['transport']; | |
| 219 | - $field_sanitize = ( isset( $field['sanitize'] ) ) ? $field['sanitize'] : ''; | |
| 220 | - $field_validate = ( isset( $field['validate'] ) ) ? $field['validate'] : ''; | |
| 221 | - $field_default = ( isset( $field['default'] ) ) ? $field['default'] : ''; | |
| 222 | - $field_customize = ( ( isset( $field['selectors'] ) || isset( $field['selector'] ) ) && ! isset( $field['transport'] ) ) ? true : false; | |
| 223 | - $has_selective = ( isset( $field['selective_refresh'] ) && isset( $wp_customize->selective_refresh ) ) ? true : false; | |
| 224 | - | |
| 225 | - $setting_id = $this->unique .'['. $field_id .']'; | |
| 226 | - $transport = ( $has_selective || $field_customize ) ? 'postMessage' : $field_transport; | |
| 227 | - | |
| 228 | - $wp_customize->add_setting( $setting_id, | |
| 229 | - wp_parse_args( $setting_args, array( | |
| 230 | - 'default' => $field_default, | |
| 231 | - 'type' => $this->args['database'], | |
| 232 | - 'capability' => $this->args['capability'], | |
| 233 | - 'transport' => $transport, | |
| 234 | - 'sanitize_callback' => $field_sanitize, | |
| 235 | - 'validate_callback' => $field_validate | |
| 236 | - ) ) | |
| 237 | - ); | |
| 238 | - | |
| 239 | - $wp_customize->add_control( new WP_Customize_Control_CSF( $wp_customize, $setting_id, | |
| 240 | - wp_parse_args( $control_args, array( | |
| 241 | - 'unique' => $this->unique, | |
| 242 | - 'field' => $field, | |
| 243 | - 'section' => $section_id, | |
| 244 | - 'settings' => $setting_id | |
| 245 | - ) ) | |
| 246 | - ) ); | |
| 247 | - | |
| 248 | - if ( $has_selective ) { | |
| 249 | - $wp_customize->selective_refresh->add_partial( $setting_id, $field['selective_refresh'] ); | |
| 250 | - } | |
| 251 | - | |
| 252 | - $field_key++; | |
| 253 | - } | |
| 254 | - | |
| 255 | - } | |
| 256 | - | |
| 257 | - | |
| 258 | - } | |
| 259 | - | |
| 260 | - } | |
| 261 | -} | |
| 1 | +<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly. | |
| 2 | +/** | |
| 3 | + * | |
| 4 | + * Customize Options Class | |
| 5 | + * | |
| 6 | + * @since 1.0.0 | |
| 7 | + * @version 1.0.0 | |
| 8 | + * | |
| 9 | + */ | |
| 10 | +if ( ! class_exists( 'CSF_Customize_Options' ) ) { | |
| 11 | + class CSF_Customize_Options extends CSF_Abstract { | |
| 12 | + | |
| 13 | + // constans | |
| 14 | + public $unique = ''; | |
| 15 | + public $abstract = 'customize'; | |
| 16 | + public $options = array(); | |
| 17 | + public $sections = array(); | |
| 18 | + public $pre_fields = array(); | |
| 19 | + public $pre_sections = array(); | |
| 20 | + public $priority = 10; | |
| 21 | + public $args = array( | |
| 22 | + 'database' => 'option', | |
| 23 | + 'transport' => 'refresh', | |
| 24 | + 'capability' => 'manage_options', | |
| 25 | + 'save_defaults' => true, | |
| 26 | + 'enqueue_webfont' => true, | |
| 27 | + 'async_webfont' => false, | |
| 28 | + 'output_css' => true, | |
| 29 | + 'defaults' => array() | |
| 30 | + ); | |
| 31 | + | |
| 32 | + // run customize construct | |
| 33 | + public function __construct( $key, $params ) { | |
| 34 | + | |
| 35 | + $this->unique = $key; | |
| 36 | + $this->args = apply_filters( "csf_{$this->unique}_args", wp_parse_args( $params['args'], $this->args ), $this ); | |
| 37 | + $this->sections = apply_filters( "csf_{$this->unique}_sections", $params['sections'], $this ); | |
| 38 | + $this->pre_fields = $this->pre_fields( $this->sections ); | |
| 39 | + $this->pre_sections = $this->pre_sections_customize( $this->sections ); | |
| 40 | + | |
| 41 | + $this->get_options(); | |
| 42 | + $this->save_defaults(); | |
| 43 | + | |
| 44 | + add_action( 'customize_register', array( $this, 'add_customize_options' ) ); | |
| 45 | + add_action( 'customize_save_after', array( $this, 'add_customize_save_after' ) ); | |
| 46 | + | |
| 47 | + // Get options for enqueue actions | |
| 48 | + if ( is_customize_preview() ) { | |
| 49 | + add_action( 'wp_enqueue_scripts', array( $this, 'get_options' ) ); | |
| 50 | + } | |
| 51 | + | |
| 52 | + // wp enqeueu for typography and output css | |
| 53 | + parent::__construct(); | |
| 54 | + | |
| 55 | + } | |
| 56 | + | |
| 57 | + // instance | |
| 58 | + public static function instance( $key, $params = array() ) { | |
| 59 | + return new self( $key, $params ); | |
| 60 | + } | |
| 61 | + | |
| 62 | + public function add_customize_save_after( $wp_customize ) { | |
| 63 | + do_action( "csf_{$this->unique}_save_before", $this->get_options(), $this, $wp_customize ); | |
| 64 | + do_action( "csf_{$this->unique}_saved", $this->get_options(), $this, $wp_customize ); | |
| 65 | + do_action( "csf_{$this->unique}_save_after", $this->get_options(), $this, $wp_customize ); | |
| 66 | + } | |
| 67 | + | |
| 68 | + // get default value | |
| 69 | + public function get_default( $field ) { | |
| 70 | + | |
| 71 | + $default = ( isset( $field['default'] ) ) ? $field['default'] : ''; | |
| 72 | + $default = ( isset( $this->args['defaults'][$field['id']] ) ) ? $this->args['defaults'][$field['id']] : $default; | |
| 73 | + | |
| 74 | + return $default; | |
| 75 | + | |
| 76 | + } | |
| 77 | + | |
| 78 | + // get option | |
| 79 | + public function get_options() { | |
| 80 | + | |
| 81 | + if ( $this->args['database'] === 'theme_mod' ) { | |
| 82 | + $this->options = get_theme_mod( $this->unique, array() ); | |
| 83 | + } else { | |
| 84 | + $this->options = get_option( $this->unique, array() ); | |
| 85 | + } | |
| 86 | + | |
| 87 | + if ( empty( $this->options ) ) { | |
| 88 | + $this->options = array(); | |
| 89 | + } | |
| 90 | + | |
| 91 | + return $this->options; | |
| 92 | + | |
| 93 | + } | |
| 94 | + | |
| 95 | + // save defaults and set new fields value to main options | |
| 96 | + public function save_defaults() { | |
| 97 | + | |
| 98 | + $tmp_options = $this->options; | |
| 99 | + | |
| 100 | + if ( ! empty( $this->pre_fields ) ) { | |
| 101 | + foreach ( $this->pre_fields as $field ) { | |
| 102 | + if ( ! empty( $field['id'] ) ) { | |
| 103 | + $this->options[$field['id']] = ( isset( $this->options[$field['id']] ) ) ? $this->options[$field['id']] : $this->get_default( $field ); | |
| 104 | + } | |
| 105 | + } | |
| 106 | + } | |
| 107 | + | |
| 108 | + if ( $this->args['save_defaults'] && empty( $this->args['show_in_customizer'] ) && empty( $tmp_options ) ) { | |
| 109 | + | |
| 110 | + if ( $this->args['database'] === 'theme_mod' ) { | |
| 111 | + set_theme_mod( $this->unique, $this->options ); | |
| 112 | + } else { | |
| 113 | + update_option( $this->unique, $this->options ); | |
| 114 | + } | |
| 115 | + | |
| 116 | + } | |
| 117 | + | |
| 118 | + } | |
| 119 | + | |
| 120 | + public function pre_sections_customize( $sections ) { | |
| 121 | + | |
| 122 | + $result = array(); | |
| 123 | + $parents = array(); | |
| 124 | + | |
| 125 | + foreach ( $sections as $key => $section ) { | |
| 126 | + if ( ! empty( $section['parent'] ) ) { | |
| 127 | + $parents[$section['parent']][] = $section; | |
| 128 | + unset( $sections[$key] ); | |
| 129 | + } | |
| 130 | + } | |
| 131 | + | |
| 132 | + foreach ( $sections as $key => $section ) { | |
| 133 | + if ( ! empty( $section['id'] ) && ! empty( $parents[$section['id']] ) ) { | |
| 134 | + $section['subs'] = $parents[$section['id']]; | |
| 135 | + } | |
| 136 | + $result[] = $section; | |
| 137 | + } | |
| 138 | + | |
| 139 | + return $result; | |
| 140 | + | |
| 141 | + } | |
| 142 | + | |
| 143 | + public function add_customize_options( $wp_customize ) { | |
| 144 | + | |
| 145 | + if ( ! class_exists( 'WP_Customize_Panel_CSF' ) ) { | |
| 146 | + CSF::include_plugin_file( 'functions/customize.php' ); | |
| 147 | + } | |
| 148 | + | |
| 149 | + foreach ( $this->pre_sections as $section ) { | |
| 150 | + | |
| 151 | + if ( ! empty( $section['subs'] ) ) { | |
| 152 | + | |
| 153 | + $panel_id = ( isset( $section['id'] ) ) ? $section['id'] : $this->unique .'-panel-'. $this->priority; | |
| 154 | + | |
| 155 | + $wp_customize->add_panel( new WP_Customize_Panel_CSF( $wp_customize, $panel_id, array( | |
| 156 | + 'title' => ( isset( $section['title'] ) ) ? $section['title'] : null, | |
| 157 | + 'description' => ( isset( $section['description'] ) ) ? $section['description'] : null, | |
| 158 | + 'priority' => ( isset( $section['priority'] ) ) ? $section['priority'] : null, | |
| 159 | + ) ) ); | |
| 160 | + | |
| 161 | + $this->priority++; | |
| 162 | + | |
| 163 | + foreach ( $section['subs'] as $sub_section ) { | |
| 164 | + | |
| 165 | + $section_id = ( isset( $sub_section['id'] ) ) ? $sub_section['id'] : $this->unique .'-section-'. $this->priority; | |
| 166 | + | |
| 167 | + $this->add_section( $wp_customize, $section_id, $sub_section, $panel_id ); | |
| 168 | + | |
| 169 | + $this->priority++; | |
| 170 | + | |
| 171 | + } | |
| 172 | + | |
| 173 | + } else { | |
| 174 | + | |
| 175 | + $section_id = ( isset( $section['id'] ) ) ? $section['id'] : $this->unique .'-section-'. $this->priority; | |
| 176 | + | |
| 177 | + $this->add_section( $wp_customize, $section_id, $section, false ); | |
| 178 | + | |
| 179 | + $this->priority++; | |
| 180 | + | |
| 181 | + } | |
| 182 | + | |
| 183 | + } | |
| 184 | + | |
| 185 | + } | |
| 186 | + | |
| 187 | + // add customize section | |
| 188 | + public function add_section( $wp_customize, $section_id, $section_args, $panel_id ) { | |
| 189 | + | |
| 190 | + if ( ! empty( $section_args['assign'] ) ) { | |
| 191 | + | |
| 192 | + $section_id = $section_args['assign']; | |
| 193 | + | |
| 194 | + } else { | |
| 195 | + | |
| 196 | + $wp_customize->add_section( new WP_Customize_Section_CSF( $wp_customize, $section_id, array( | |
| 197 | + 'title' => ( isset( $section_args['title'] ) ) ? $section_args['title'] : '', | |
| 198 | + 'description' => ( isset( $section_args['description'] ) ) ? $section_args['description'] : '', | |
| 199 | + 'priority' => ( isset( $section_args['priority'] ) ) ? $section_args['priority'] : '', | |
| 200 | + 'panel' => ( $panel_id ) ? $panel_id : '', | |
| 201 | + ) ) ); | |
| 202 | + | |
| 203 | + } | |
| 204 | + | |
| 205 | + if ( ! empty( $section_args['fields'] ) ) { | |
| 206 | + | |
| 207 | + $field_key = 1; | |
| 208 | + | |
| 209 | + foreach ( $section_args['fields'] as $field ) { | |
| 210 | + | |
| 211 | + if ( isset( $field['id'] ) ) { | |
| 212 | + $field['default'] = $this->get_default( $field ); | |
| 213 | + } | |
| 214 | + | |
| 215 | + $field_id = ( isset( $field['id'] ) ) ? $field['id'] : '_nonce-'. $section_id .'-'. $field_key; | |
| 216 | + $setting_args = ( isset( $field['setting_args'] ) ) ? $field['setting_args'] : array(); | |
| 217 | + $control_args = ( isset( $field['control_args'] ) ) ? $field['control_args'] : array(); | |
| 218 | + $field_transport = ( isset( $field['transport'] ) ) ? $field['transport'] : $this->args['transport']; | |
| 219 | + $field_sanitize = ( isset( $field['sanitize'] ) ) ? $field['sanitize'] : ''; | |
| 220 | + $field_validate = ( isset( $field['validate'] ) ) ? $field['validate'] : ''; | |
| 221 | + $field_default = ( isset( $field['default'] ) ) ? $field['default'] : ''; | |
| 222 | + $field_customize = ( ( isset( $field['selectors'] ) || isset( $field['selector'] ) ) && ! isset( $field['transport'] ) ) ? true : false; | |
| 223 | + $has_selective = ( isset( $field['selective_refresh'] ) && isset( $wp_customize->selective_refresh ) ) ? true : false; | |
| 224 | + | |
| 225 | + $setting_id = $this->unique .'['. $field_id .']'; | |
| 226 | + $transport = ( $has_selective || $field_customize ) ? 'postMessage' : $field_transport; | |
| 227 | + | |
| 228 | + $wp_customize->add_setting( $setting_id, | |
| 229 | + wp_parse_args( $setting_args, array( | |
| 230 | + 'default' => $field_default, | |
| 231 | + 'type' => $this->args['database'], | |
| 232 | + 'capability' => $this->args['capability'], | |
| 233 | + 'transport' => $transport, | |
| 234 | + 'sanitize_callback' => $field_sanitize, | |
| 235 | + 'validate_callback' => $field_validate | |
| 236 | + ) ) | |
| 237 | + ); | |
| 238 | + | |
| 239 | + $wp_customize->add_control( new WP_Customize_Control_CSF( $wp_customize, $setting_id, | |
| 240 | + wp_parse_args( $control_args, array( | |
| 241 | + 'unique' => $this->unique, | |
| 242 | + 'field' => $field, | |
| 243 | + 'section' => $section_id, | |
| 244 | + 'settings' => $setting_id | |
| 245 | + ) ) | |
| 246 | + ) ); | |
| 247 | + | |
| 248 | + if ( $has_selective ) { | |
| 249 | + $wp_customize->selective_refresh->add_partial( $setting_id, $field['selective_refresh'] ); | |
| 250 | + } | |
| 251 | + | |
| 252 | + $field_key++; | |
| 253 | + } | |
| 254 | + | |
| 255 | + } | |
| 256 | + | |
| 257 | + | |
| 258 | + } | |
| 259 | + | |
| 260 | + } | |
| 261 | +} | |