-
Notifications
You must be signed in to change notification settings - Fork 15
Adding New Builder
TruongSa edited this page Dec 17, 2017
·
1 revision
<?php
// Register header builder
Customify_Customizer_Layout_Builder()->register_builder( 'header', new Customify_Builder_Header() );
class Customify_Builder_Header extends Customify_Customizer_Builder_Panel{
public $id = 'header';
function get_config(){
return array(
'id' => $this->id,
'title' => __( 'Header Builder', 'customify' ),
'control_id' => 'header_builder_panel',
'panel' => 'header_settings',
'section' => 'header_builder_panel',
'devices' => array(
'desktop' => __( 'Desktop', 'customify' ),
'mobile' => __( 'Mobile/Tablet', 'customify' ),
),
);
}
function get_rows_config(){
return array(
'top' => __( 'Header Top', 'customify' ),
'main' => __( 'Header Main', 'customify' ),
'bottom' => __( 'Header Bottom', 'customify' ),
'sidebar' => __( 'Mobile Sidebar', 'customify' ),
);
}
function customize( ){
$fn = 'customify_customize_render_header';
$config = array(
array(
'name' => 'header_settings',
'type' => 'panel',
'theme_supports' => '',
'title' => __( 'Header', 'customify' ),
),
array(
'name' => 'header_builder_panel',
'type' => 'section',
'panel' => 'header_settings',
'title' => __( 'Header Builder', 'customify' ),
),
array(
'name' => 'header_builder_panel',
'type' => 'js_raw',
'section' => 'header_builder_panel',
'theme_supports' => '',
'title' => __( 'Header Builder', 'customify' ),
'selector' => '#masthead',
'render_callback' => $fn,
'container_inclusive' => true
),
);
return $config;
}
function row_config( $section = false, $section_name = false ){
if ( ! $section ) {
$section = 'header_top';
}
if ( ! $section_name ) {
$section_name = __( 'Header Top', 'customify' );
}
$selector = '#cb-row--'.str_replace('_', '-', $section );
$fn = 'customify_customize_render_header';
$selector_all = '#masthead';
$config = array(
array(
'name' => $section,
'type' => 'section',
'panel' => 'header_settings',
'theme_supports' => '',
'title' => $section_name,
),
array(
'name' => $section.'_layout',
'type' => 'select',
'section' => $section,
'title' => __( 'Layout', 'customify' ),
'selector' => $selector_all,
'render_callback' => $fn,
'choices' => array(
'default' => __( 'Default', 'customify' ),
'fullwidth' => __( 'Full Width', 'customify' ),
'boxed' => __( 'Boxed', 'customify' ),
)
),
array(
'name' => $section.'_height',
'type' => 'slider',
'section' => $section,
'theme_supports' => '',
'device_settings' => false,
'max' => 250,
//'selector' => $selector.' .customify-grid, '.$selector,
'selector' => $selector.' .customify-grid',
'css_format' => 'min-height: {{value}};',
'title' => __( 'Height', 'customify' ),
),
);
return $config;
}
function row_sidebar_config( $section , $section_name ){
$selector = '#mobile-header-panel-inner';
$config = array(
array(
'name' => $section,
'type' => 'section',
'panel' => 'header_settings',
'theme_supports' => '',
'title' => $section_name,
),
array(
'name' => $section.'_padding',
'type' => 'css_ruler',
'section' => $section,
'selector' => $selector,
'css_format' => array(
'top' => 'padding-top: {{value}};',
'right' => 'padding-right: {{value}};',
'bottom' => 'padding-bottom: {{value}};',
'left' => 'padding-left: {{value}};',
),
'title' => __( 'Padding', 'customify' ),
),
);
return $config;
}
}