Skip to content
Permalink
master
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
<?php
/**
* 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', 'https://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'
)
)
);
?>