From 9bba75af199156adb77c61b7ac3a6c615c801720 Mon Sep 17 00:00:00 2001 From: andrewmbacon Date: Fri, 29 May 2015 15:41:04 -0400 Subject: [PATCH] reorganizing the cornerstone customizer --- inc/customizer-colors.php | 56 +++ ...zer.php => customizer-homepage-layout.php} | 379 ++++++------------ inc/customizer-nav.php | 21 + inc/customizer-titlebar.php | 37 ++ 4 files changed, 241 insertions(+), 252 deletions(-) create mode 100644 inc/customizer-colors.php rename inc/{customizer.php => customizer-homepage-layout.php} (52%) create mode 100644 inc/customizer-nav.php create mode 100644 inc/customizer-titlebar.php diff --git a/inc/customizer-colors.php b/inc/customizer-colors.php new file mode 100644 index 0000000..b0cd2d8 --- /dev/null +++ b/inc/customizer-colors.php @@ -0,0 +1,56 @@ +add_setting( 'h1_color' , array( + 'default' => 'inherit', + 'transport' => 'refresh', + ) ); + $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'h1_color', array( + 'label' => __( 'Header 1 Color', 'cornerstone' ), + 'section' => 'colors', + 'settings' => 'h1_color', + ) ) ); + $wp_customize->add_setting( 'h2_color' , array( + 'default' => 'inherit', + 'transport' => 'refresh', + ) ); + $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'h2_color', array( + 'label' => __( 'Header 2 Color', 'cornerstone' ), + 'section' => 'colors', + 'settings' => 'h2_color', + ) ) ); + $wp_customize->add_setting( 'text_color' , array( + 'default' => 'inherit', + 'transport' => 'refresh', + ) ); + $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'text_color', array( + 'label' => __( 'Text Color', 'cornerstone' ), + 'section' => 'colors', + 'settings' => 'text_color', + ) ) ); + $wp_customize->add_setting( 'a_color' , array( + 'default' => 'inherit', + 'transport' => 'refresh', + ) ); + $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'a_color', array( + 'label' => __( 'Link Color', 'cornerstone' ), + 'section' => 'colors', + 'settings' => 'a_color', + ) ) ); + $wp_customize->add_setting( 'ahover_color' , array( + 'default' => 'inherit', + 'transport' => 'refresh', + ) ); + $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'ahover_color', array( + 'label' => __( 'Link Hover Color', 'cornerstone' ), + 'section' => 'colors', + 'settings' => 'ahover_color', + ) ) ); + $wp_customize->add_setting( 'avisited_color' , array( + 'default' => 'inherit', + 'transport' => 'refresh', + ) ); + $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'avisited_color', array( + 'label' => __( 'Link Visited Color', 'cornerstone' ), + 'section' => 'colors', + 'settings' => 'avisited_color', + ) ) ); +?> \ No newline at end of file diff --git a/inc/customizer.php b/inc/customizer-homepage-layout.php similarity index 52% rename from inc/customizer.php rename to inc/customizer-homepage-layout.php index a6f696e..1114b9f 100644 --- a/inc/customizer.php +++ b/inc/customizer-homepage-layout.php @@ -1,253 +1,128 @@ -get_setting( 'blogname' )->transport = 'postMessage'; - $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; -} -add_action( 'customize_register', 'cs_customize_register' ); - -/** - * Binds JS handlers to make Theme Customizer preview reload changes asynchronously. - */ -function cs_customize_preview_js() { - wp_enqueue_script( 'cs_customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), '20130508', true ); -} -add_action( 'customize_preview_init', 'cs_customize_preview_js' ); - - - - -define( 'NO_HEADER_TEXT', true ); - - - -/* Hale refugees */ - -function huskypress_parentSite_register( $wp_customize ) -{ - - $wp_customize->get_section( 'title_tagline' )->title = 'Title Bar'; - $wp_customize->remove_control('blogdescription');// removes tagline form field. - - $wp_customize->add_setting( 'parentSiteTitle', - array( - 'type' => 'option', - 'capability' => 'edit_theme_options', - 'transport' => 'refresh' - ) - ); - $wp_customize->add_control('parentSiteTitle', - array( - 'type' => 'text', - 'priority' => '100', - 'label' => 'Parent Site Title', - 'section' => 'title_tagline' - ) - ); - $wp_customize->add_setting( 'parentSiteLink', - array( - 'type' => 'option', - 'capability' => 'edit_theme_options', - 'transport' => 'refresh' - ) - ); - $wp_customize->add_control('parentSiteLink', - array( - 'type' => 'text', - 'priority' => '101', - 'label' => 'Parent Site Link', - 'section' => 'title_tagline' - ) - ); - -} -add_action( 'customize_register', 'huskypress_parentSite_register' ); - -/**/ - - -function huskypress_navoption_register( $wp_customize ) -{ - $wp_customize->add_setting( 'navoption1', //Give it a SERIALIZED name (so all theme settings can live under one db record) - array( - 'default' => 'textnav', //Default setting/value to save - 'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'? - 'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting. - 'transport' => 'refresh', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)? - ) - ); - $wp_customize->add_control('navoption1', array( - 'type' => 'select', - 'label' => 'Navigation Option 1', - 'section' => 'nav', - 'choices' => array( - 'textnav'=>'Text', - 'bar' => 'Bar', - 'stack-top'=>'Tabs' - ) - ) - ); - $wp_customize->add_setting( 'navoption2', //Give it a SERIALIZED name (so all theme settings can live under one db record) - array( - 'default' => 'with-drop', //Default setting/value to save - 'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'? - 'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting. - 'transport' => 'refresh', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)? - ) - ); - $wp_customize->add_control('navoption2', array( - 'type' => 'select', - 'label' => 'Navigation Option 2', - 'section' => 'nav', - 'choices' => array( - 'with-drop'=>'Dropdowns', - 'with-left' => 'Left Nav' - ) - ) - ); -} - add_action( 'customize_register', 'huskypress_navoption_register' ); - -function huskypress_layoutoption_register( $wp_customize ) -{ - - /** - * Class to create the layout builder - */ - class Slider_Custom_Control extends WP_Customize_Control - { - /** - * Enqueue the styles and scripts - */ - public function enqueue() - { - wp_enqueue_script( 'layoutbuilder', get_template_directory_uri() . '/js/layoutbuilder.js', array( 'jquery' )); - wp_enqueue_script( 'jquery-ui-slider' ); - wp_enqueue_style('jquery-style', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css'); - } - - /** - * Render the content on the theme customizer page - */ - public function render_content() - { - - ?> -
+ Row
– Row
- '.$this->label.''; - if(strlen($this->description) > 0) echo '

'.$this->description.'

'; - } - } - $wp_customize->add_section( 'layout_builder', - array( - 'title' => __( 'Homepage Layout', 'mytheme' ), //Visible title of section - 'priority' => 999, //Determines what order this appears in - 'capability' => 'edit_theme_options', //Capability needed to tweak - 'description' => __('Allows you to customize homepage layout', 'huskypress'), //Descriptive tooltip - ) - ); - $wp_customize->add_setting( 'homepagerows', //Give it a SERIALIZED name (so all theme settings can live under one db record) - array( - 'default' => '2', //Default setting/value to save - 'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'? - 'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting. - 'transport' => 'refresh', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)? - ) - ); - $wp_customize->add_control('homepagerows', array( - 'type' => 'hidden', - 'label' => 'Rows', - 'section' => 'layout_builder', - 'priority' => 9 - ) - ); - //Add row settings/controls - for($i=0;$i<5;$i++){ - $wp_customize->add_setting( 'homepage_'.$i, //Give it a SERIALIZED name (so all theme settings can live under one db record) - array( - 'default' => '12', //Default setting/value to save - 'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'? - 'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting. - 'transport' => 'refresh', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)? - ) - ); - $wp_customize->add_control('homepage_'.$i, array( - 'type' => 'hidden', - 'label' => 'Row '.$i.' Width', - 'section' => 'layout_builder', - 'setting' => 'setting', - 'priority' => ($i+10), - 'class' => 'column' - ) - ); - } - $wp_customize->add_setting( 'slider', //Give it a SERIALIZED name (so all theme settings can live under one db record) - array( - 'default' => '0', //Default setting/value to save - 'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'? - 'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting. - 'transport' => 'refresh', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)? - ) - ); - $wp_customize->add_control( - new Slider_Custom_Control( - $wp_customize, - 'slider', - array( - 'label' => 'Slider', - 'priority' => 1, - 'section' => 'layout_builder' - ) - ) - ); - - - $wp_customize->add_setting( 'parentText', //Give it a SERIALIZED name (so all theme settings can live under one db record) - array( - 'default' => '', //Default setting/value to save - 'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'? - 'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting. - 'transport' => 'refresh', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)? - ) - ); - $wp_customize->add_control( - new Heading_Custom_Control( - $wp_customize, - 'parentText', - array( - 'label' => 'Parent Site', - 'description' => 'Optional. Enter the title and web address of a parent School, College, Divison, or Department.', - 'priority' => 99, - 'section' => 'title_tagline' - ) - ) - ); -} -add_action( 'customize_register', 'huskypress_layoutoption_register' ); - + +
+ Row
– Row
+ '.$this->label.''; + if(strlen($this->description) > 0) echo '

'.$this->description.'

'; + } + } + $wp_customize->add_section( 'layout_builder', + array( + 'title' => __( 'Homepage Layout', 'mytheme' ), //Visible title of section + 'priority' => 999, //Determines what order this appears in + 'capability' => 'edit_theme_options', //Capability needed to tweak + 'description' => __('Allows you to customize homepage layout', 'huskypress'), //Descriptive tooltip + ) + ); + $wp_customize->add_setting( 'homepagerows', //Give it a SERIALIZED name (so all theme settings can live under one db record) + array( + 'default' => '2', //Default setting/value to save + 'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'? + 'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting. + 'transport' => 'refresh', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)? + ) + ); + $wp_customize->add_control('homepagerows', array( + 'type' => 'hidden', + 'label' => 'Rows', + 'section' => 'layout_builder', + 'priority' => 9 + ) + ); + //Add row settings/controls + for($i=0;$i<5;$i++){ + $wp_customize->add_setting( 'homepage_'.$i, //Give it a SERIALIZED name (so all theme settings can live under one db record) + array( + 'default' => '12', //Default setting/value to save + 'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'? + 'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting. + 'transport' => 'refresh', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)? + ) + ); + $wp_customize->add_control('homepage_'.$i, array( + 'type' => 'hidden', + 'label' => 'Row '.$i.' Width', + 'section' => 'layout_builder', + 'setting' => 'setting', + 'priority' => ($i+10), + 'class' => 'column' + ) + ); + } + $wp_customize->add_setting( 'slider', //Give it a SERIALIZED name (so all theme settings can live under one db record) + array( + 'default' => '0', //Default setting/value to save + 'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'? + 'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting. + 'transport' => 'refresh', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)? + ) + ); + $wp_customize->add_control( + new Slider_Custom_Control( + $wp_customize, + 'slider', + array( + 'label' => 'Slider', + 'priority' => 1, + 'section' => 'layout_builder' + ) + ) + ); + + + $wp_customize->add_setting( 'parentText', //Give it a SERIALIZED name (so all theme settings can live under one db record) + array( + 'default' => '', //Default setting/value to save + 'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'? + 'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting. + 'transport' => 'refresh', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)? + ) + ); + $wp_customize->add_control( + new Heading_Custom_Control( + $wp_customize, + 'parentText', + array( + 'label' => 'Parent Site', + 'description' => 'Optional. Enter the title and web address of a parent School, College, Divison, or Department.', + 'priority' => 99, + 'section' => 'title_tagline' + ) + ) + ); ?> \ No newline at end of file diff --git a/inc/customizer-nav.php b/inc/customizer-nav.php new file mode 100644 index 0000000..951a99e --- /dev/null +++ b/inc/customizer-nav.php @@ -0,0 +1,21 @@ +add_setting( 'navoption1', //Give it a SERIALIZED name (so all theme settings can live under one db record) + array( + 'default' => 'drop', //Default setting/value to save + 'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'? + 'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting. + 'transport' => 'refresh', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)? + ) + ); + $wp_customize->add_control('navoption1', array( + 'type' => 'select', + 'label' => 'Navigation Option 1', + 'section' => 'nav', + 'choices' => array( + 'drop'=>'Dropdowns', + 'drop-multi' => 'Multi-level Dropdowns', + 'tabs'=>'Tabs' + ) + ) + ); +?> \ No newline at end of file diff --git a/inc/customizer-titlebar.php b/inc/customizer-titlebar.php new file mode 100644 index 0000000..7a4ba06 --- /dev/null +++ b/inc/customizer-titlebar.php @@ -0,0 +1,37 @@ +get_section( 'title_tagline' )->title = 'Title Bar'; + $wp_customize->remove_control('blogdescription');// removes tagline form field. + + $wp_customize->add_setting( 'parentSiteTitle', + array( + 'type' => 'option', + 'capability' => 'edit_theme_options', + 'transport' => 'refresh' + ) + ); + $wp_customize->add_control('parentSiteTitle', + array( + 'type' => 'text', + 'priority' => '100', + 'label' => 'Parent Site Title', + 'section' => 'title_tagline' + ) + ); + $wp_customize->add_setting( 'parentSiteLink', + array( + 'type' => 'option', + 'capability' => 'edit_theme_options', + 'transport' => 'refresh' + ) + ); + $wp_customize->add_control('parentSiteLink', + array( + 'type' => 'text', + 'priority' => '101', + 'label' => 'Parent Site Link', + 'section' => 'title_tagline' + ) + ); + + +?> \ No newline at end of file