'', 'label' => '', 'description' => '', 'type' => '', 'mime_type' => '', 'choices' => array(), 'input_attrs' => array(), // 'sanitize' => '', 'transport' => 'refresh', 'partial' => array(), ); return array_merge( $defaults, $args ); } /** * 設定追加 * $customizer = $wp_customize */ public static function add( $section = '', $id = '', $args = array(), $Classname = '' ) { if ( '' === $id ) return; global $wp_customize; $customizer = $wp_customize; $DEFAULT = \Arkhe::get_default_setting(); $default = $DEFAULT[ $id ]; $args = self::set_args( $args ); $customize_id = \Arkhe::DB_NAMES['customizer'] . '[' . $id . ']'; $type = $args['type']; $partial = $args['partial']; // setting 用 $setting_args = array( 'default' => $default, 'type' => 'option', 'transport' => $args['transport'], 'sanitize_callback' => isset( $args['sanitize'] ) ? $args['sanitize'] : Sanitize::get_sanitize_name( $type ), ); // partialありの時、settingオプション追加 if ( ! empty( $partial ) ) { $setting_args['transport'] = 'postMessage'; } // add setting $customizer->add_setting( $customize_id, $setting_args ); // control用 $control_args = array( 'label' => $args['label'], 'description' => $args['description'], 'section' => $section, 'settings' => $customize_id, 'type' => $type, 'classname' => $args['classname'], ); $control_instance = null; // 追加処理 if ( 'color' === $type ) { $control_instance = new Color_Control( $customizer, $customize_id, $control_args ); } elseif ( 'image' === $type ) { $control_instance = new Image_Control( $customizer, $customize_id, $control_args ); } elseif ( 'media' === $type ) { $control_args['mime_type'] = $args['mime_type']; $control_instance = new Media_Control( $customizer, $customize_id, $control_args ); } elseif ( 'radio' === $type || 'select' === $type ) { $control_args['choices'] = $args['choices']; } elseif ( 'number' === $type ) { $control_args['input_attrs'] = $args['input_attrs']; } elseif ( 'code_editor' === $type ) { $control_args['code_type'] = $args['code_type']; } // インスタンスまだなければ Base_Control で生成 if ( null === $control_instance ) $control_instance = new Base_Control( $customizer, $customize_id, $control_args ); // add control $customizer->add_control( $control_instance ); // add partial if ( ! empty( $partial ) ) { $customizer->selective_refresh->add_partial( $customize_id, $partial ); } } /** * カスタマイザーの大タイトル * $customizer = $wp_customize */ public static function big_title( $section = '', $id = '', $args = array() ) { if ( '' === $id ) return; global $wp_customize; $customizer = $wp_customize; $args = self::set_args( $args ); $control_args = array( 'label' => $args['label'], 'description' => $args['description'], 'section' => $section, 'classname' => $args['classname'], ); $customizer->add_setting( 'big_ttl_' . $id, array() ); $customizer->add_control( new Big_Title( $customizer, 'big_ttl_' . $id . '', $control_args ) ); } /** * カスタマイザーのサブタイトル * $customizer = $wp_customize */ public static function sub_title( $section = '', $id = '', $args = array() ) { if ( '' === $id ) return; global $wp_customize; $customizer = $wp_customize; $args = self::set_args( $args ); $control_args = array( 'label' => $args['label'], 'description' => $args['description'], 'section' => $section, 'classname' => $args['classname'], ); $customizer->add_setting( 'sub_ttl_' . $id, array() ); $customizer->add_control( new Sub_Title( $customizer, 'sub_ttl_' . $id . '', $control_args ) ); } }