get_section( 'header_image' )->panel = 'appworx_header_panel';
$wp_customize->get_section( 'header_image' )->priority = '13';
$wp_customize->remove_control( 'display_header_text' );
$wp_customize->get_section( 'colors' )->title = __('General', 'appworx');
$wp_customize->get_section( 'colors' )->panel = 'appworx_colors_panel';
$wp_customize->get_section( 'colors' )->priority = '10';
//Divider
class appworx_Divider extends WP_Customize_Control {
public function render_content() {
echo '
';
}
}
//Titles
class appworx_Info extends WP_Customize_Control {
public $type = 'info';
public $label = '';
public function render_content() {
?>
label ); ?>
add_section(
'appworx_general',
array(
'title' => __('General', 'appworx'),
'priority' => 8,
)
);
//Top padding
$wp_customize->add_setting(
'wrapper_top_padding',
array(
'default' => __('80','appworx'),
'sanitize_callback' => 'absint',
)
);
$wp_customize->add_control(
'wrapper_top_padding',
array(
'label' => __( 'Top padding for page content', 'appworx' ),
'section' => 'appworx_general',
'type' => 'number',
'description' => __('Space between the header and the page content', 'appworx'),
'priority' => 10,
'input_attrs' => array(
'min' => 0,
'max' => 160,
'step' => 1,
),
)
);
//Bottom padding
$wp_customize->add_setting(
'wrapper_bottom_padding',
array(
'default' => __('100','appworx'),
'sanitize_callback' => 'absint',
)
);
$wp_customize->add_control(
'wrapper_bottom_padding',
array(
'label' => __( 'Bottom padding for page content', 'appworx' ),
'section' => 'appworx_general',
'type' => 'number',
'description' => __('Space between the footer and the page content', 'appworx'),
'priority' => 10,
'input_attrs' => array(
'min' => 0,
'max' => 160,
'step' => 1,
),
)
);
//___Header section___//
$wp_customize->add_panel( 'appworx_header_panel', array(
'priority' => 10,
'capability' => 'edit_theme_options',
'theme_supports' => '',
'title' => __('Header section', 'appworx'),
) );
//___Header type___//
$wp_customize->add_section(
'appworx_header_type',
array(
'title' => __('Header type', 'appworx'),
'priority' => 10,
'panel' => 'appworx_header_panel',
'description' => __('You can select your header type from here.', 'appworx'),
)
);
//Front page
$wp_customize->add_setting(
'front_header_type',
array(
'default' => 'image',
'sanitize_callback' => 'appworx_sanitize_header_type',
)
);
$wp_customize->add_control(
'front_header_type',
array(
'type' => 'radio',
'label' => __('Front page header type', 'appworx'),
'section' => 'appworx_header_type',
'description' => __('Select the header type for your front page', 'appworx'),
'choices' => array(
'image' => __('Image', 'appworx'),
'core-video'=> __('Video', 'appworx'),
),
)
);
//___Other Header___//
$wp_customize->add_section(
'appworx_other_header',
array(
'title' => __('Other page header', 'appworx'),
'priority' => 10,
'panel' => 'appworx_header_panel',
'description' => __('You can customize your header for other pages from here.', 'appworx'),
)
);
$wp_customize->add_setting(
'hide_breadcrumb',
array(
'default' => 0,
'sanitize_callback' => 'appworx_sanitize_checkbox',
)
);
$wp_customize->add_control(
new WP_Customize_Image_Control(
$wp_customize,
'hide_breadcrumb',
array(
'label' => __( 'Hide breadcrumb', 'appworx' ),
'type' => 'checkbox',
'section' => 'appworx_other_header',
'settings' => 'hide_breadcrumb',
'priority' => 3,
)
)
);
//___Colors___//
$wp_customize->add_panel( 'appworx_colors_panel', array(
'priority' => 19,
'capability' => 'edit_theme_options',
'theme_supports' => '',
'title' => __('Colors', 'appworx'),
) );
$wp_customize->add_section(
'colors_header',
array(
'title' => __('Header', 'appworx'),
'priority' => 11,
'panel' => 'appworx_colors_panel',
)
);
$wp_customize->add_section(
'colors_footer',
array(
'title' => __('Footer', 'appworx'),
'priority' => 13,
'panel' => 'appworx_colors_panel',
)
);
//Primary color
$wp_customize->add_setting(
'primary_color',
array(
'default' => '#a6d1fa',
'sanitize_callback' => 'sanitize_hex_color',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'primary_color',
array(
'label' => __('Primary color', 'appworx'),
'section' => 'colors',
'settings' => 'primary_color',
'priority' => 11
)
)
);
//Body text
$wp_customize->add_setting(
'body_text_color',
array(
'default' => '#8e88aa',
'sanitize_callback' => 'sanitize_hex_color',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'body_text_color',
array(
'label' => __('Body text color', 'appworx'),
'section' => 'colors',
'settings' => 'body_text_color',
'priority' => 12
)
)
);
//___Header Background___//
$wp_customize->add_section(
'appworx_background',
array(
'title' => __('Header Background', 'appworx'),
'description' => __('You can add image for the header background.', 'appworx'),
'priority' => 11,
'panel' => 'appworx_header_panel',
)
);
$wp_customize->add_setting(
'background_image_1',
array(
'default' => get_stylesheet_directory_uri() . '/images/head1.jpg',
'sanitize_callback' => 'esc_url_raw',
)
);
$wp_customize->add_control(
new WP_Customize_Image_Control(
$wp_customize,
'background_image_1',
array(
'label' => __( 'Upload your image for the background', 'appworx' ),
'type' => 'image',
'section' => 'appworx_background',
'settings' => 'background_image_1',
'priority' => 1,
)
)
);
//banner right side image
$wp_customize->add_setting(
'background_image_right',
array(
'default' => get_stylesheet_directory_uri() . '/images/banner-img-01.png',
'sanitize_callback' => 'esc_url_raw',
)
);
$wp_customize->add_control(
new WP_Customize_Image_Control(
$wp_customize,
'background_image_right',
array(
'label' => __( 'Upload your image for the banner right', 'appworx' ),
'type' => 'image',
'section' => 'appworx_background',
'settings' => 'background_image_right',
'priority' => 1,
)
)
);
//Title
$wp_customize->add_setting(
'header_title_1',
array(
'default' => __('Welcome to Appworx','appworx'),
'sanitize_callback' => 'wp_filter_nohtml_kses',
)
);
$wp_customize->add_control(
'header_title_1',
array(
'label' => __( 'Title for the background image', 'appworx' ),
'section' => 'appworx_background',
'type' => 'text',
'priority' => 2
)
);
//Subtitle
$wp_customize->add_setting(
'header_subtitle_1',
array(
'default' => __('Delivers more than expected','appworx'),
'sanitize_callback' => 'wp_filter_nohtml_kses',
)
);
$wp_customize->add_control(
'header_subtitle_1',
array(
'label' => __( 'Subtitle for the background image', 'appworx' ),
'section' => 'appworx_background',
'type' => 'text',
'priority' => 3
)
);
//Subpera
$wp_customize->add_setting(
'header_subpera_1',
array(
'default' => __('Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi imperdiet ullamcorper erat,','appworx'),
'sanitize_callback' => 'wp_filter_nohtml_kses',
)
);
$wp_customize->add_control(
'header_subpera_1',
array(
'label' => __( 'Subpera for the background image', 'appworx' ),
'section' => 'appworx_background',
'type' => 'text',
'priority' => 3
)
);
//Button1
$wp_customize->add_setting(
'banner_button1',
array(
'default' => __('Ready to start','appworx'),
'sanitize_callback' => 'wp_filter_nohtml_kses',
)
);
$wp_customize->add_control(
'banner_button1',
array(
'label' => __( 'Text on the button 1', 'appworx' ),
'section' => 'appworx_background',
'type' => 'text',
'priority' => 3
)
);
//Button URL1
$wp_customize->add_setting(
'banner_button_url1',
array(
'default' => __('#','appworx'),
'sanitize_callback' => 'esc_url_raw',
)
);
$wp_customize->add_control(
'banner_button_url1',
array(
'label' => __( 'URL for the banner button 1', 'appworx' ),
'section' => 'appworx_background',
'type' => 'text',
'priority' => 3
)
);
//Button2
$wp_customize->add_setting(
'banner_button2',
array(
'default' => __('Ready to start','appworx'),
'sanitize_callback' => 'wp_filter_nohtml_kses',
)
);
$wp_customize->add_control(
'banner_button2',
array(
'label' => __( 'Text on the button 2', 'appworx' ),
'section' => 'appworx_background',
'type' => 'text',
'priority' => 4
)
);
//Button URL2
$wp_customize->add_setting(
'banner_button_url2',
array(
'default' => __('#','appworx'),
'sanitize_callback' => 'esc_url_raw',
)
);
$wp_customize->add_control(
'banner_button_url2',
array(
'label' => __( 'URL for the banner button 2', 'appworx' ),
'section' => 'appworx_background',
'type' => 'text',
'priority' => 4
)
);
//Header background size
$wp_customize->add_setting(
'header_bg_size',
array(
'default' => 'cover',
'sanitize_callback' => 'appworx_sanitize_bg_size',
)
);
$wp_customize->add_control(
'header_bg_size',
array(
'type' => 'radio',
'priority' => 4,
'label' => __('Header background size', 'appworx'),
'section' => 'appworx_background',
'choices' => array(
'cover' => __('Cover', 'appworx'),
'contain' => __('Contain', 'appworx'),
),
)
);
//Header height
$wp_customize->add_setting(
'header_height',
array(
'default' => __('700', 'appworx'),
'sanitize_callback' => 'absint',
)
);
$wp_customize->add_control( 'header_height', array(
'type' => 'number',
'priority' => 5,
'section' => 'appworx_background',
'label' => __('Header height [default: 700px]', 'appworx'),
'input_attrs' => array(
'min' => 250,
'max' => 1000,
'step' => 5,
),
) );
//___Blog options___//
$wp_customize->add_section(
'blog_options',
array(
'title' => __('Blog options', 'appworx'),
'priority' => 13,
)
);
// Blog layout
$wp_customize->add_setting('appworx_options[info]', array(
'type' => 'info_control',
'sanitize_callback' => 'esc_attr',
)
);
$wp_customize->add_control( new appworx_Info( $wp_customize, 'layout', array(
'label' => __('Layout', 'appworx'),
'section' => 'blog_options',
'settings' => 'appworx_options[info]',
'priority' => 10
) )
);
$wp_customize->add_setting(
'blog_layout',
array(
'default' => 'classic-alt',
'sanitize_callback' => 'appworx_sanitize_blog_layout'
)
);
$wp_customize->add_control(
'blog_layout',
array(
'type' => 'radio',
'label' => __('Blog layout', 'appworx'),
'section' => 'blog_options',
'priority' => 11,
'choices' => array(
'classic' => __( 'Classic', 'appworx' ),
'classic-alt' => __( 'Appworx Alternative', 'appworx' ),
'fullwidth' => __( 'Full width (no sidebar)', 'appworx' )
),
)
);
//Full width singles
$wp_customize->add_setting(
'fullwidth_single',
array(
'default' => 0,
'sanitize_callback' => 'appworx_sanitize_checkbox',
)
);
$wp_customize->add_control(
'fullwidth_single',
array(
'type' => 'checkbox',
'label' => __('Full width single posts?', 'appworx'),
'section' => 'blog_options',
'priority' => 12,
)
);
//Content/excerpt
$wp_customize->add_setting('appworx_options[info]', array(
'type' => 'info_control',
'sanitize_callback' => 'esc_attr',
)
);
$wp_customize->add_control( new appworx_Info( $wp_customize, 'content', array(
'label' => __('Content/excerpt', 'appworx'),
'section' => 'blog_options',
'settings' => 'appworx_options[info]',
'priority' => 13
) )
);
//Full content posts
$wp_customize->add_setting(
'full_content_home',
array(
'default' => 0,
'sanitize_callback' => 'appworx_sanitize_checkbox',
)
);
$wp_customize->add_control(
'full_content_home',
array(
'type' => 'checkbox',
'label' => __('Check this box to display full content of blog posts on post page', 'appworx'),
'section' => 'blog_options',
'priority' => 14,
)
);
$wp_customize->add_setting(
'full_content_archives',
array(
'default' => 0,
'sanitize_callback' => 'appworx_sanitize_checkbox',
)
);
$wp_customize->add_control(
'full_content_archives',
array(
'type' => 'checkbox',
'label' => __('Check this box to display full content of blog posts on all archives.', 'appworx'),
'section' => 'blog_options',
'priority' => 15,
)
);
//Excerpt
$wp_customize->add_setting(
'exc_lenght',
array(
'default' => '55',
'sanitize_callback' => 'absint',
)
);
$wp_customize->add_control( 'exc_lenght', array(
'type' => 'number',
'priority' => 16,
'section' => 'blog_options',
'label' => __('Excerpt lenght', 'appworx'),
'description' => __('Choose your excerpt length. Default: 55 words', 'appworx'),
'input_attrs' => array(
'min' => 10,
'max' => 200,
'step' => 5,
),
) );
//___Footer___//
$wp_customize->add_section(
'appworx_footer',
array(
'title' => __('Footer', 'appworx'),
'priority' => 18,
)
);
//Front page
$wp_customize->add_setting(
'footer_widget_areas',
array(
'default' => '3',
'sanitize_callback' => 'appworx_sanitize_widget_area',
)
);
$wp_customize->add_control(
'footer_widget_areas',
array(
'type' => 'radio',
'label' => __('Footer widget area', 'appworx'),
'section' => 'appworx_footer',
'description' => __('Choose the number of widgets you want to display in footer. After that, go to Appearance > Widgets and add your widgets.', 'appworx'),
'choices' => array(
'1' => __('One', 'appworx'),
'2' => __('Two', 'appworx'),
'3' => __('Three', 'appworx'),
'4' => __('Four', 'appworx')
),
)
);
}
add_action( 'customize_register', 'appworx_customize_register' );
/**
* Sanitize callback functions
*/
//Header type
function appworx_sanitize_header_type( $value ){
$valid = array(
'image' => __('Image', 'appworx'),
'core-video'=> __('Video', 'appworx'),
);
return ( array_key_exists( $value, $valid ) ? $value : '' );
}
function appworx_sanitize_menu( $value ){
$valid = array(
'sticky' => __('Sticky', 'appworx'),
'static' => __('Static', 'appworx'),
);
return ( array_key_exists( $value, $valid ) ? $value : '' );
}
function appworx_sanitize_bg_size( $value ){
$valid = array(
'cover' => __('Cover', 'appworx'),
'contain' => __('Contain', 'appworx'),
);
return ( array_key_exists( $value, $valid ) ? $value : '' );
}
function appworx_sanitize_blog_layout( $value ){
$valid = array(
'classic' => __( 'Classic', 'appworx' ),
'classic-alt' => __( 'Appworx Alternative', 'appworx' ),
'fullwidth' => __( 'Full width (no sidebar)', 'appworx' )
);
return ( array_key_exists( $value, $valid ) ? $value : '' );
}
function appworx_sanitize_checkbox( $value ) {
//returns true if checkbox is checked
return ( $value == 1 ? 1 : '' );
}
function appworx_sanitize_widget_area($value){
$valid = array(
'1' => __('One', 'appworx'),
'2' => __('Two', 'appworx'),
'3' => __('Three', 'appworx'),
'4' => __('Four', 'appworx')
);
return ( array_key_exists( $value, $valid ) ? $value : '' );
}
function appworx_sanitize_wc_content($value){
$valid = array(
'left' => __('Left', 'appworx'),
'right' => __('Right', 'appworx'),
);
return ( array_key_exists( $value, $valid ) ? $value : '' );
}
function appworx_sanitize_image( $input ){
/* default output */
$value = '';
/* check file type */
$filetype = wp_check_filetype( $input );
$mime_type = $filetype['type'];
/* only mime type "image" allowed */
if ( strpos( $mime_type, 'image' ) !== false ){
$value = $input;
}
return $value;
}