GC_Customize_Manager::add_setting()
最后更新于:2021-11-27 00:48:17
GC_Customize_Manager::add_setting( GC_Customize_Setting|string$id, array$args=array())Add a customize setting.
参数
- $id
-
(GC_Customize_Setting|string) (Required) Customize Setting object, or ID.
- $args
-
(array) (Optional) Array of properties for the new Setting object. See GC_Customize_Setting::__construct() for information on accepted arguments.
Default value: array()
响应
(GC_Customize_Setting) The instance of the setting that was added.
源文件
文件: gc-includes/class-gc-customize-manager.php
public function add_setting( $id, $args = array() ) {
if ( $id instanceof GC_Customize_Setting ) {
$setting = $id;
} else {
$class = 'GC_Customize_Setting';
/** This filter is documented in gc-includes/class-gc-customize-manager.php */
$args = apply_filters( 'customize_dynamic_setting_args', $args, $id );
/** This filter is documented in gc-includes/class-gc-customize-manager.php */
$class = apply_filters( 'customize_dynamic_setting_class', $class, $id, $args );
$setting = new $class( $this, $id, $args );
}
$this->settings[ $setting->id ] = $setting;
return $setting;
}