description ) ) { ?>
  • description ); ?>
  • value() ) . '" target="_blank">' . esc_attr( $this->label ) .''; } } // class Cryout_Customize_Link_Control class Cryout_Customize_About_Control extends WP_Customize_Control { public $type = 'about'; public function render_content() { if ( ! empty( $this->label ) ) { ?> label ) ?> description ) ) { ?> description ) ?> value() ) ?> fonts = cryout_get_theme_structure('fonts'); ?> link() ) ?> value="value() ) ?>" class="slider" step="input_attrs['step']) ?>" min="input_attrs['min']) ?>" max="input_attrs['max'] ) ?>" />
    description ) ) : ?> description ) ?> link() ); ?> value="value() ); ?>" class="slidertwo" step="input_attrs['step'] ) ?>" min="input_attrs['min'] ) ?>" max="input_attrs['max'] ) ?>" size="input_attrs['total'] ) ?>"/>
    description ) ) : ?> description ) ?> choices ) ) return; $name = '_customize-imageradio-' . $this->id; ?> label ) ) { ?> label ) ?>
    choices as $value => $data ) : $data['url'] = esc_url( sprintf( $data['url'], get_template_directory_uri(), get_stylesheet_directory_uri() ) ); ?> " link() ); checked( $this->value(), $value ); ?> />
    description ) ) { ?> description ); ?> add_panel( 'cryout-about-theme', array( 'priority' => 0, 'title' => sprintf( __( 'About %s', 'cryout' ), ucwords(_CRYOUT_THEME_NAME) ), 'description' => sprintf( __( '%1$s by %1$s', 'cryout' ), ucwords(_CRYOUT_THEME_NAME), 'Cryout Creations' ), ) ); $section_priority = 10; foreach ($cryout_theme_settings['info_sections'] as $iid=>$info): $wp_customize->add_section( $iid, array( 'title' => $info['title'], 'description' => $info['desc'], 'priority' => $section_priority++, 'panel' => 'cryout-about-theme', ) ); endforeach; endif; //!empty foreach ($cryout_theme_settings['info_settings'] as $iid => $info): $wp_customize->add_setting( $iid, array( 'default' => $info['default'], 'capability' => 'edit_theme_options', 'sanitize_callback' => 'cryout_customizer_sanitize_blank' ) ); $wp_customize->add_control( new Cryout_Customize_About_Control( $wp_customize, $iid, array( 'label' => $info['label'], 'description' => $info['desc'], 'section' => $info['section'], 'default' => $info['default'], 'settings' => $iid, 'priority' => 10, ) ) ); endforeach; ////////// end about panel ////////// add custom theme options panels ////////// $priority = 45; foreach ($cryout_theme_settings['panels'] as $panel): $identifier = ( !empty($panel['identifier'])? $panel['identifier'] : 'cryout-' ); $wp_customize->add_panel( $identifier . $panel['id'], array( 'title' => $panel['title'], 'description' => '', 'priority' => $priority+=5, ) ); endforeach; ////////// add custom theme options sections, settings and empty placeholder control ////////// $section_priority = 60; foreach ($cryout_theme_settings['sections'] as $section): // override section id to make it uniquely identifiable $wp_customize->add_section( 'cryout-' . $section['id'], array( 'title' => $section['title'], 'description' => '', //__( '', 'cryout' ), 'priority' => ( isset($section['priority']) ? $section['priority'] : $section_priority+=5 ), 'panel' => ($section['sid']?'cryout-' . $section['sid']:''), ) ); $wp_customize->add_setting( 'placeholder_'.$section_priority, array( 'default' => '', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'cryout_customizer_sanitize_blank' ) ); // override section id to make it uniquely identifiable $wp_customize->add_control( new Cryout_Customize_Blank_Control( $wp_customize, 'placeholder_'.$section_priority, array( 'section' => 'cryout-' . $section['id'], 'settings' => 'placeholder_'.$section_priority, 'priority' => 10, ) ) ); endforeach; ////////// end option panels/sections ////////// override built-in wordpress customizer panels, if set ////////// if (!empty($cryout_theme_settings['panel_overrides'])) foreach ($cryout_theme_settings['panel_overrides'] as $poid => $pover): if (empty($pover['priority2'])) $pover['priority2'] = 60; // failsafe switch ($pover['type']): case 'remove': // remove bult-in setting/panel switch( $pover['section'] ): case 'panel': $wp_customize->remove_panel( $pover['replaces']); break; case 'section': $wp_customize->remove_section( $pover['replaces']); break; case 'setting': default: $wp_customize->remove_setting( $pover['replaces']); break; endswitch; break; case 'section': // move built-in setting to theme panel $wp_customize->get_section( $pover['replaces'] )->panel = $pover['section']; $wp_customize->get_section( $pover['replaces'] )->priority = $pover['priority2']; break; case 'panel': default: // add custom panel to replace built-in panel $wp_customize->add_panel( 'cryout-' . $poid, array( 'priority' => $pover['priority'], 'title' => $pover['title'], 'description' => $pover['desc'], ) ); $wp_customize->get_section( $pover['replaces'] )->panel = 'cryout-' . $poid; $wp_customize->get_section( $pover['replaces'] )->priority = $pover['priority2']; break; endswitch; endforeach; ////////// add custom theme option controls, based on option type ////////// foreach ($cryout_theme_settings['options'] as $opt): // check if option should be visible on this wp version if ( !empty( $opt['disable_if'] ) ) { if ( function_exists($opt['disable_if']) ) continue; } if ( !empty( $opt['require_fn'] ) ) { if ( ! function_exists($opt['require_fn']) ) continue; } ////////// sanitizer function callback select switch ($opt['type']): case 'number': case 'slider': case 'range': $sanitize_callback = 'cryout_customizer_sanitize_number'; break; case 'checkbox': $sanitize_callback = 'cryout_customizer_sanitize_checkbox'; break; case 'url': $sanitize_callback = 'cryout_customizer_sanitize_url'; break; case 'color': $sanitize_callback = 'cryout_customizer_sanitize_color'; break; case 'googlefont': $sanitize_callback = 'cryout_customizer_sanitize_googlefont'; break; case 'media': case 'media-image': $sanitize_callback = 'cryout_customizer_sanitize_number'; break; case 'blank': $sanitize_callback = 'cryout_customizer_sanitize_blank'; break; case 'text': case 'tel': case 'email': case 'search': case 'radio': case 'time': case 'date': case 'datetime': case 'week': case 'textarea': $sanitize_callback = 'cryout_customizer_sanitize_textarea'; break; default: $sanitize_callback = 'cryout_customizer_sanitize_generic'; break; endswitch; ////////// guess theme options variable name if (function_exists('cryout_get_theme_options_name')) { $theme_options_array = cryout_get_theme_options_name(); } else { $theme_options_array = _CRYOUT_THEME_NAME . '_settings'; }; $opid = $theme_options_array . '[' . $opt['id'] . ']'; // override section id to make it uniquely identifiable $opt['section'] = 'cryout-' . $opt['section']; ////////// add settings $wp_customize->add_setting( $opid, array( 'type' => 'option', 'default' => ( isset( $cryout_theme_defaults[$opt['id']] ) ? $cryout_theme_defaults[$opt['id']] : '' ), 'capability' => 'edit_theme_options', 'sanitize_callback' => $sanitize_callback, ) ); ////////// cycle through and add appropriate control types switch ($opt['type']): // control selector case 'text': case 'number': case 'url': case 'tel': case 'email': case 'search:': case 'time': case 'date': case 'datetime': case 'week': case 'textarea': case 'checkbox': $wp_customize->add_control( $opid, array( 'label' => $opt['label'], 'description' => $opt['desc'], 'section' => $opt['section'], 'settings' => $opid, 'input_attrs' => (!empty($opt['input_attrs'])?$opt['input_attrs']:array()), 'type' => $opt['type'], 'priority' => (isset($opt['priority'])?$opt['priority']:2), ) ); break; case 'googlefont': $wp_customize->add_control( $opid, array( 'label' => $opt['label'], 'description' => $opt['desc'], 'section' => $opt['section'], 'settings' => $opid, 'input_attrs' => (!empty($opt['input_attrs'])?$opt['input_attrs']:array()), 'type' => 'text', 'priority' => (isset($opt['priority'])?$opt['priority']:2), ) ); break; case 'radio': case 'select': if (empty($opt['labels'])) $opt['labels'] = $opt['values']; $wp_customize->add_control( $opid, array( 'label' => $opt['label'], 'description' => $opt['desc'], 'section' => $opt['section'], 'settings' => $opid, 'type' => $opt['type'], 'priority' => (isset($opt['priority'])?$opt['priority']:2), 'choices' => (isset($opt['choices'])?$opt['choices']:array_combine($opt['values'],$opt['labels'])) ) ); break; case 'range': $wp_customize->add_control( $opid, array( 'label' => $opt['label'], 'description' => $opt['desc'], 'section' => $opt['section'], 'settings' => $opid, 'type' => $opt['type'], 'priority' => (isset($opt['priority'])?$opt['priority']:2), 'input_attrs' => array( 'min' => $opt['min'], 'max' => $opt['max'], 'step' => (isset($opt['step'])?$opt['step']:10) ), ) ); break; case 'slider': $wp_customize->add_control( new Cryout_Customize_Slider_Control( $wp_customize, $opid, array( 'label' => $opt['label'], 'description' => $opt['desc'], 'section' => $opt['section'], 'settings' => $opid, 'type' => $opt['type'], 'priority' => (isset($opt['priority'])?$opt['priority']:2), 'input_attrs' => array( 'min' => $opt['min'], 'max' => $opt['max'], 'step' => (isset($opt['step'])?$opt['step']:10), 'um' => (isset($opt['um'])?$opt['um']:'') ), ) ) ); break; case 'slidertwo': $wp_customize->add_control( new Cryout_Customize_SliderTwo_Control( $wp_customize, $opid, array( 'label' => $opt['label'], 'description' => $opt['desc'], 'section' => $opt['section'], 'settings' => $opid, 'type' => $opt['type'], 'priority' => (isset($opt['priority'])?$opt['priority']:2), 'input_attrs' => array( 'min' => $opt['min'], 'max' => $opt['max'], 'step' => (isset($opt['step'])?$opt['step']:10), 'total' => (isset($opt['total'])?$opt['total']:0), 'um' => (isset($opt['um'])?$opt['um']:'') ), ) ) ); break; case 'radioimage': $wp_customize->add_control( new Cryout_Customize_RadioImage_Control( $wp_customize, $opid, array( 'label' => $opt['label'], 'description' => $opt['desc'], 'section' => $opt['section'], 'settings' => $opid, 'type' => $opt['type'], 'priority' => (isset($opt['priority'])?$opt['priority']:2), 'choices' => (isset($opt['choices'])?$opt['choices']:array_combine($opt['values'],$opt['labels'])) ) ) ); break; case 'color': $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, $opid, array( 'label' => $opt['label'], 'description' => $opt['desc'], 'section' => $opt['section'], 'priority' => (isset($opt['priority'])?$opt['priority']:2), ) ) ); break; case 'font': $wp_customize->add_control( new Cryout_Customize_Font_Control( $wp_customize, $opid, array( 'label' => $opt['label'], 'description' => $opt['desc'], 'section' => $opt['section'], 'priority' => (isset($opt['priority'])?$opt['priority']:2), ) ) ); break; case 'media-image': $wp_customize->add_control( new WP_Customize_Media_Control( $wp_customize, $opid, array( 'label' => $opt['label'], 'description' => $opt['desc'], 'section' => $opt['section'], 'mime_type' => 'image', 'priority' => (isset($opt['priority'])?$opt['priority']:2), ) ) ); break; case 'media': $wp_customize->add_control( new WP_Customize_Media_Control( $wp_customize, $opid, array( 'label' => $opt['label'], 'description' => $opt['desc'], 'section' => $opt['section'], 'priority' => (isset($opt['priority'])?$opt['priority']:2), ) ) ); break; case 'blank': default: $wp_customize->add_control( new Cryout_Customize_Blank_Control( $wp_customize, $opid, array( 'label' => $opt['label'], 'description' => $opt['desc'], 'section' => $opt['section'], 'settings' => $opid, 'priority' => (isset($opt['priority'])?$opt['priority']:2), ) ) ); break; endswitch; endforeach; ////////// end options sections } // register() } // class Cryout_Customizer ////////// external resources ////////// function cryout_customizer_enqueue_scripts() { wp_enqueue_style( 'cryout-customizer-css', get_template_directory_uri() . '/cryout/css/customizer.css', array(), _CRYOUT_FRAMEWORK_VERSION ); wp_enqueue_script( 'cryout-customizer-js', get_template_directory_uri() . '/cryout/js/customizer.js', array( 'jquery' ), _CRYOUT_FRAMEWORK_VERSION, true ); } add_action('customize_controls_enqueue_scripts', 'cryout_customizer_enqueue_scripts'); ////////// FIN! //////////