Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
1c92807c95
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
executable file 280 lines (251 sloc) 9.13 KB
<?php
/**
* cornerstone Theme Customizer
*
* @package cornerstone
*/
/**
* Add postMessage support for site title and description for the Theme Customizer.
*
* @param WP_Customize_Manager $wp_customize Theme Customizer object.
*/
function cs_customize_register( $wp_customize ) {
$wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
$wp_customize->get_setting( 'header_textcolor' )->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'
)
);
$wp_customize->add_setting( 'headingColor', //Give it a SERIALIZED name (so all theme settings can live under one db record)
array(
'default' => 'blue', //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'
)
);
$wp_customize->add_control('headingColor', array(
'type' => 'radio',
'label' => 'Site Title Color',
'section' => 'colors',
'choices' => array(
'blue'=>'Blue',
'black' => 'Black',
'darkgrey' => 'Dark Grey',
'lightgrey' => 'Light Grey',
'white' => 'White'
)
)
);
}
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()
{
?>
<div class="button sliderAddRow" title="Add New Row">+ Row</div><div class="button sliderDeleteRow" title="Remove Last Row">– Row</div><div class="sliders"></div><div class="button sliderDeleteColumn disabled" title="Remove Column Divider"><div class="dashicons dashicons-minus"></div></div>
<?php
}
}
/**
* Class to create the custom heading
*/
class Heading_Custom_Control extends WP_Customize_Control
{
public $description = '';
/**
* Render the content on the theme customizer page
*/
public function render_content()
{
echo '<h4>'.$this->label.'</h4>';
if(strlen($this->description) > 0) echo '<p>'.$this->description.'</p>';
}
}
$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' );
?>