get_setting( 'blogname' )->transport = 'postMessage';
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
$wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage';
$wp_customize->get_section( 'colors' )->priority = '65';
$wp_customize->get_section( 'title_tagline' )->title = __('Header', 'ablog');
if ( isset( $wp_customize->selective_refresh ) ) {
$wp_customize->selective_refresh->add_partial( 'blogname', array(
'selector' => '.site-title a',
'render_callback' => 'ablog_customize_partial_blogname',
) );
$wp_customize->selective_refresh->add_partial( 'blogdescription', array(
'selector' => '.site-description',
'render_callback' => 'ablog_customize_partial_blogdescription',
) );
}
/*--------------------------------------------------------------
# Divider
--------------------------------------------------------------*/
class ablog_divider extends WP_Customize_Control {
public $type = 'divider';
public $label = '';
public function render_content() { ?>
label ); ?>
add_section(
'ablog_general',
array(
'title' => __('General', 'ablog'),
'priority' => 8,
)
);
## Layout ##
$wp_customize->add_setting(
'layout',
array(
'default' => __('1170','ablog'),
'sanitize_callback' => 'absint',
)
);
$wp_customize->add_control(
'layout',
array(
'label' => __( 'Layout Setting', 'ablog' ),
'section' => 'ablog_general',
'type' => 'number',
'description' => __('Site Width (container 1170)', 'ablog'),
'priority' => 10,
'input_attrs' => array(
'min' => 300,
'max' => 1920,
'step' => 1,
),
)
);
## Margin - Top ##
$wp_customize->add_setting(
'margin_top',
array(
'default' => __('60','ablog'),
'sanitize_callback' => 'absint',
)
);
$wp_customize->add_control(
'margin_top',
array(
'label' => __( 'Top Margin', 'ablog' ),
'section' => 'ablog_general',
'type' => 'number',
'description' => __('Top Margin for the page wrapper (the space between the header) ', 'ablog'),
'priority' => 10,
'input_attrs' => array(
'min' => 0,
'max' => 200,
'step' => 1,
),
)
);
## Margin - Bottom ##
$wp_customize->add_setting(
'margin_bottom',
array(
'default' => __('60','ablog'),
'sanitize_callback' => 'absint',
)
);
$wp_customize->add_control(
'margin_bottom',
array(
'label' => __( 'Bottom Margin', 'ablog' ),
'section' => 'ablog_general',
'type' => 'number',
'description' => __('Bottom Margin for the page wrapper (the space between the Footer) ', 'ablog'),
'priority' => 10,
'input_attrs' => array(
'min' => 0,
'max' => 200,
'step' => 1,
),
)
);
/*--------------------------------------------------------------
# Header
--------------------------------------------------------------*/
## Divider ##
$wp_customize->add_setting('ablog_options[divider]', array(
'type' => 'divider_control',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'esc_attr',
)
);
$wp_customize->add_control( new ablog_divider( $wp_customize, 'SocialSearch', array(
'label' => __('Social & Search', 'ablog'),
'priority' => 5,
'section' => 'title_tagline',
'settings' => 'ablog_options[divider]'
) )
);
## Social & Search ##
$wp_customize->add_setting(
'social_enable',
array(
'default' => __('1','ablog'),
'sanitize_callback' => 'ablog_sanitize_checkbox',
)
);
$wp_customize->add_control(
'social_enable',
array(
'label' => __( 'Social Enable', 'ablog' ),
'section' => 'title_tagline',
'type' => 'checkbox',
'description' => __('## Go Back to social setting. ##', 'ablog'),
'priority' => 5
)
);
## Social & Search ##
$wp_customize->add_setting(
'search_enable',
array(
'default' => __('1','ablog'),
'sanitize_callback' => 'ablog_sanitize_checkbox',
)
);
$wp_customize->add_control(
'search_enable',
array(
'label' => __( 'Search Enable', 'ablog' ),
'section' => 'title_tagline',
'type' => 'checkbox',
'priority' => 5
)
);
## Divider ##
$wp_customize->add_control( new ablog_divider( $wp_customize, 'logo', array(
'label' => __('Logo', 'ablog'),
'priority' => 5,
'section' => 'title_tagline',
'settings' => 'ablog_options[divider]'
) )
);
$wp_customize->add_control( new ablog_divider( $wp_customize, 'favicon', array(
'label' => __('favicon', 'ablog'),
'priority' => 40,
'section' => 'title_tagline',
'settings' => 'ablog_options[divider]'
) )
);
/*--------------------------------------------------------------
# Color
--------------------------------------------------------------*/
## Divider ##
$wp_customize->add_control( new ablog_divider( $wp_customize, 'general_color', array(
'label' => __('General Color', 'ablog'),
'priority' => 5,
'section' => 'colors',
'settings' => 'ablog_options[divider]'
) )
);
## Body Text Color ##
$wp_customize->add_setting(
'body_text_color',
array(
'default' => '#000',
'sanitize_callback' => 'sanitize_hex_color'
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'body_text_color',
array(
'label' => __('Body Color', 'ablog'),
'section' => 'colors'
)
)
);
## Link Color ##
$wp_customize->add_setting(
'link_color',
array(
'default' => '#b4b4b4',
'sanitize_callback' => 'sanitize_hex_color'
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'link_color',
array(
'label' => __('Link Color', 'ablog'),
'section' => 'colors'
)
)
);
## Link Hover Color ##
$wp_customize->add_setting(
'link_hover_color',
array(
'default' => '#000',
'sanitize_callback' => 'sanitize_hex_color'
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'link_hover_color',
array(
'label' => __('Link Hover Color', 'ablog'),
'section' => 'colors'
)
)
);
## Heading Color ##
$wp_customize->add_setting(
'heading_color',
array(
'default' => '#000',
'sanitize_callback' => 'sanitize_hex_color'
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'heading_color',
array(
'label' => __('Heading Color', 'ablog'),
'section' => 'colors'
)
)
);
## Divider ##
$wp_customize->add_control( new ablog_divider( $wp_customize, 'menu_colors', array(
'label' => __('Menu Color', 'ablog'),
'priority' => 10,
'section' => 'colors',
'settings' => 'ablog_options[divider]'
) )
);
## Menu Background Color ##
$wp_customize->add_setting(
'menu_bg_color',
array(
'default' => '#000',
'sanitize_callback' => 'sanitize_hex_color'
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'menu_bg_color',
array(
'label' => __('Container Background Color', 'ablog'),
'section' => 'colors'
)
)
);
## Menu Link Color ##
$wp_customize->add_setting(
'menu_color',
array(
'default' => '#fff',
'sanitize_callback' => 'sanitize_hex_color'
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'menu_color',
array(
'label' => __('Link Color', 'ablog'),
'section' => 'colors'
)
)
);
## Menu Link Hover Color ##
$wp_customize->add_setting(
'menu_hover_color',
array(
'default' => '#666',
'sanitize_callback' => 'sanitize_hex_color'
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'menu_hover_color',
array(
'label' => __('Link Hover Color', 'ablog'),
'section' => 'colors'
)
)
);
## Divider ##
$wp_customize->add_control( new ablog_divider( $wp_customize, 'footer_color', array(
'label' => __('Footer Color', 'ablog'),
'section' => 'colors',
'settings' => 'ablog_options[divider]'
) )
);
## Footer Background Color ##
$wp_customize->add_setting(
'footer_bg_color',
array(
'default' => '#e1e3e2',
'sanitize_callback' => 'sanitize_hex_color'
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'footer_bg_color',
array(
'label' => __('Background Color', 'ablog'),
'section' => 'colors'
)
)
);
## Footer Color ##
$wp_customize->add_setting(
'footer_link_color',
array(
'default' => '#000',
'sanitize_callback' => 'sanitize_hex_color'
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'footer_link_color',
array(
'label' => __('Text/Link Color', 'ablog'),
'section' => 'colors'
)
)
);
## Footer Hover Color ##
$wp_customize->add_setting(
'footer_link_hover_color',
array(
'default' => '#333333',
'sanitize_callback' => 'sanitize_hex_color'
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'footer_link_hover_color',
array(
'label' => __('Link Hover Color', 'ablog'),
'section' => 'colors'
)
)
);
## Divider ##
$wp_customize->add_control( new ablog_divider( $wp_customize, 'button_color', array(
'label' => __('Default Button Color', 'ablog'),
'section' => 'colors',
'settings' => 'ablog_options[divider]'
) )
);
$wp_customize->add_setting(
'default_text_color',
array(
'default' => '#fff',
'sanitize_callback' => 'sanitize_hex_color'
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'default_text_color',
array(
'label' => __('Text Color', 'ablog'),
'section' => 'colors'
)
)
);
$wp_customize->add_setting(
'default_bg_color',
array(
'default' => '#000',
'sanitize_callback' => 'sanitize_hex_color'
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'default_bg_color',
array(
'label' => __('Background Color', 'ablog'),
'section' => 'colors'
)
)
);
$wp_customize->add_setting(
'default_border_color',
array(
'default' => '#000',
'sanitize_callback' => 'sanitize_hex_color'
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'default_border_color',
array(
'label' => __('Border Color', 'ablog'),
'section' => 'colors'
)
)
);
$wp_customize->add_setting(
'default_hover_text_color',
array(
'default' => '#fff',
'sanitize_callback' => 'sanitize_hex_color'
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'default_hover_text_color',
array(
'label' => __('Hover Text Color', 'ablog'),
'section' => 'colors'
)
)
);
$wp_customize->add_setting(
'default_hover_bg_color',
array(
'default' => '#333',
'sanitize_callback' => 'sanitize_hex_color'
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'default_hover_bg_color',
array(
'label' => __('Hover BG Color', 'ablog'),
'section' => 'colors',
'priority' => 10
)
)
);
$wp_customize->add_setting(
'default_hover_border_color',
array(
'default' => '#333',
'sanitize_callback' => 'sanitize_hex_color'
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'default_hover_border_color',
array(
'label' => __('Hover Border Color', 'ablog'),
'section' => 'colors'
)
)
);
/*--------------------------------------------------------------
# Typography
--------------------------------------------------------------*/
$wp_customize->add_section(
'typography',
array(
'title' => __('Typography', 'ablog'),
'priority' => 65,
'description' => __('Google Fonts can be found here: https://fonts.google.com', 'ablog'),
)
);
## Divider ##
$wp_customize->add_control( new ablog_divider( $wp_customize, 'general_color', array(
'label' => __('General Fonts', 'ablog'),
'priority' => 5,
'section' => 'typography',
'settings' => 'ablog_options[divider]'
) )
);
## Body Fonts ##
$wp_customize->add_setting(
'body_font_name',
array(
'default' => 'Lato:400,700',
'sanitize_callback' => 'ablog_sanitize_text',
)
);
$wp_customize->add_control(
'body_font_name',
array(
'label' => __( 'Font Name', 'ablog' ),
'description' => __( 'body Font', 'ablog' ),
'section' => 'typography',
'type' => 'text'
)
);
## Body Fonts Family ##
$wp_customize->add_setting(
'body_font_family',
array(
'default' => '\'Lato\', sans-serif',
'sanitize_callback' => 'ablog_sanitize_text',
)
);
$wp_customize->add_control(
'body_font_family',
array(
'label' => __( 'Font Family', 'ablog' ),
'description' => __( 'body Font Family', 'ablog' ),
'section' => 'typography',
'type' => 'text'
)
);
## Body weight ##
$wp_customize->add_setting(
'body_font_weight',
array(
'default' => '400',
'sanitize_callback' => 'absint',
)
);
$wp_customize->add_control(
'body_font_weight',
array(
'label' => __( 'Font Weight', 'ablog' ),
'description' => __( 'body Font weight', 'ablog' ),
'section' => 'typography',
'type' => 'number'
)
);
## Body size ##
$wp_customize->add_setting(
'body_font_size',
array(
'default' => '16',
'sanitize_callback' => 'absint',
)
);
$wp_customize->add_control(
'body_font_size',
array(
'label' => __( 'Font Size', 'ablog' ),
'description' => __( 'body Font size', 'ablog' ),
'section' => 'typography',
'type' => 'number'
)
);
## Divider ##
$wp_customize->add_control( new ablog_divider( $wp_customize, 'heading_fonts_size', array(
'label' => __('Heading Fonts & Size', 'ablog'),
'section' => 'typography',
'settings' => 'ablog_options[divider]'
) )
);
## Heading Fonts ##
$wp_customize->add_setting(
'heading_font_name',
array(
'default' => 'Playfair+Display:400,700',
'sanitize_callback' => 'ablog_sanitize_text',
)
);
$wp_customize->add_control(
'heading_font_name',
array(
'label' => __( 'Font Name', 'ablog' ),
'description' => __( 'Heading Font', 'ablog' ),
'section' => 'typography',
'type' => 'text'
)
);
## Heading Fonts Family ##
$wp_customize->add_setting(
'heading_font_family',
array(
'default' => '\'Playfair Display\', serif',
'sanitize_callback' => 'ablog_sanitize_text',
)
);
$wp_customize->add_control(
'heading_font_family',
array(
'label' => __( 'Fonts Family', 'ablog' ),
'description' => __( 'Fonts Family', 'ablog' ),
'section' => 'typography',
'type' => 'text'
)
);
## Heading weight ##
$wp_customize->add_setting(
'heading_font_weight',
array(
'default' => '700',
'sanitize_callback' => 'absint',
)
);
$wp_customize->add_control(
'heading_font_weight',
array(
'label' => __( 'Font Weight', 'ablog' ),
'description' => __( 'Font weight', 'ablog' ),
'section' => 'typography',
'type' => 'number'
)
);
## Heading h1 ##
$wp_customize->add_setting(
'heading_size_h1',
array(
'default' => '40',
'sanitize_callback' => 'absint',
)
);
$wp_customize->add_control(
'heading_size_h1',
array(
'label' => __( 'H1', 'ablog' ),
'section' => 'typography',
'type' => 'number'
)
);
## Heading h2 ##
$wp_customize->add_setting(
'heading_size_h2',
array(
'default' => '36',
'sanitize_callback' => 'absint',
)
);
$wp_customize->add_control(
'heading_size_h2',
array(
'label' => __( 'H2', 'ablog' ),
'section' => 'typography',
'type' => 'number'
)
);
## Heading h3 ##
$wp_customize->add_setting(
'heading_size_h3',
array(
'default' => '30',
'sanitize_callback' => 'absint',
)
);
$wp_customize->add_control(
'heading_size_h3',
array(
'label' => __( 'H3', 'ablog' ),
'section' => 'typography',
'type' => 'number'
)
);
## Heading h4 ##
$wp_customize->add_setting(
'heading_size_h4',
array(
'default' => '24',
'sanitize_callback' => 'absint',
)
);
$wp_customize->add_control(
'heading_size_h4',
array(
'label' => __( 'H4', 'ablog' ),
'section' => 'typography',
'type' => 'number'
)
);
## Heading h5 ##
$wp_customize->add_setting(
'heading_size_h5',
array(
'default' => '18',
'sanitize_callback' => 'absint',
)
);
$wp_customize->add_control(
'heading_size_h5',
array(
'label' => __( 'H5', 'ablog' ),
'section' => 'typography',
'type' => 'number'
)
);
## Heading h6 ##
$wp_customize->add_setting(
'heading_size_h6',
array(
'default' => '15',
'sanitize_callback' => 'absint',
)
);
$wp_customize->add_control(
'heading_size_h6',
array(
'label' => __( 'H6', 'ablog' ),
'section' => 'typography',
'type' => 'number'
)
);
/*--------------------------------------------------------------
# Social
--------------------------------------------------------------*/
$wp_customize->add_section(
'social_settings',
array(
'title' => __('Social Media', 'ablog'),
'priority' => 70
)
);
## Divider ##
$wp_customize->add_control( new ablog_divider( $wp_customize, 'social_media', array(
'label' => __('Header', 'ablog'),
'priority' => 10,
'section' => 'social_settings',
'settings' => 'ablog_options[divider]'
) )
);
## Header Social ##
$wp_customize->add_setting( 'header_fb', array(
'default' => '',
'sanitize_callback' => 'esc_url_raw',
) );
$wp_customize->add_control( 'header_fb', array(
'label' => __( 'Facebook', 'ablog' ),
'type' => 'text',
'section' => 'social_settings',
'settings' => 'header_fb'
) );
$wp_customize->add_setting( 'header_tw', array(
'default' => '',
'sanitize_callback' => 'esc_url_raw',
) );
$wp_customize->add_control( 'header_tw', array(
'label' => __( 'Twitter', 'ablog' ),
'type' => 'text',
'section' => 'social_settings',
'settings' => 'header_tw'
) );
$wp_customize->add_setting( 'header_li', array(
'default' => '',
'sanitize_callback' => 'esc_url_raw',
) );
$wp_customize->add_control( 'header_li', array(
'label' => __( 'Linkedin', 'ablog' ),
'type' => 'text',
'section' => 'social_settings',
'settings' => 'header_li'
) );
$wp_customize->add_setting( 'header_pint', array(
'default' => '',
'sanitize_callback' => 'esc_url_raw',
) );
$wp_customize->add_control( 'header_pint', array(
'label' => __( 'Pinterest', 'ablog' ),
'type' => 'text',
'section' => 'social_settings',
'settings' => 'header_pint'
) );
$wp_customize->add_setting( 'header_ins', array(
'default' => '',
'sanitize_callback' => 'esc_url_raw',
) );
$wp_customize->add_control( 'header_ins', array(
'label' => __( 'Instagram', 'ablog' ),
'type' => 'text',
'section' => 'social_settings',
'settings' => 'header_ins'
) );
$wp_customize->add_setting( 'header_dri', array(
'default' => '',
'sanitize_callback' => 'esc_url_raw',
) );
$wp_customize->add_control( 'header_dri', array(
'label' => __( 'Dribbble', 'ablog' ),
'type' => 'text',
'section' => 'social_settings',
'settings' => 'header_dri'
) );
$wp_customize->add_setting( 'header_plus', array(
'default' => '',
'sanitize_callback' => 'esc_url_raw',
) );
$wp_customize->add_control( 'header_plus', array(
'label' => __( 'Plus Google', 'ablog' ),
'type' => 'text',
'section' => 'social_settings',
'settings' => 'header_plus'
) );
$wp_customize->add_setting( 'header_you', array(
'default' => '',
'sanitize_callback' => 'esc_url_raw',
) );
$wp_customize->add_control( 'header_you', array(
'label' => __( 'YouTube', 'ablog' ),
'type' => 'text',
'section' => 'social_settings',
'settings' => 'header_you'
) );
/*--------------------------------------------------------------
# Blog
--------------------------------------------------------------*/
$wp_customize->add_section(
'blog_settings',
array(
'title' => __('Blog', 'ablog'),
'priority' => 80
)
);
## Divider ##
$wp_customize->add_control( new ablog_divider( $wp_customize, 'blog_profile', array(
'label' => __('Blog Profile', 'ablog'),
'section' => 'blog_settings',
'settings' => 'ablog_options[divider]'
) )
);
## Profile Image ##
$wp_customize->add_setting(
'blog_profile_image',
array(
'default' => get_template_directory_uri() . '/assets/images/profile.png',
'sanitize_callback' => 'esc_url_raw',
)
);
$wp_customize->add_control(
new WP_Customize_Image_Control(
$wp_customize,
'blog_profile_image',
array(
'label' => __( 'Profile Image', 'ablog' ),
'section' => 'blog_settings',
'settings' => 'blog_profile_image'
)
)
);
## Profile Title ##
$wp_customize->add_setting(
'blog_profile_title',
array(
'default' => 'Hello, I am ablog :) ',
'sanitize_callback' => 'ablog_sanitize_text',
)
);
$wp_customize->add_control(
'blog_profile_title',
array(
'label' => __( 'Profile Title', 'ablog' ),
'section' => 'blog_settings',
'type' => 'text'
)
);
## Profile Short Note ##
$wp_customize->add_setting(
'blog_profile_short_note',
array(
'default' => 'Thank you for hanging around my online Portfolio for awhile.',
'sanitize_callback' => 'ablog_sanitize_text',
)
);
$wp_customize->add_control(
'blog_profile_short_note',
array(
'label' => __( 'Profile Short Note', 'ablog' ),
'section' => 'blog_settings',
'type' => 'textarea'
)
);
## Divider ##
$wp_customize->add_control( new ablog_divider( $wp_customize, 'blog_content_excerpt', array(
'label' => __('Content / excerpt', 'ablog'),
'section' => 'blog_settings',
'settings' => 'ablog_options[divider]'
) )
);
## Blog Excerpt ##
$wp_customize->add_setting(
'blog_excerpt',
array(
'default' => __( '45','ablog' ),
'sanitize_callback' => 'absint',
)
);
$wp_customize->add_control(
'blog_excerpt',
array(
'label' => __( 'Excerpt length', 'ablog' ),
'type' => 'number',
'description' => __('Set your excerpt length. Default: 60 words', 'ablog'),
'section' => 'blog_settings',
'priority' => 10,
)
);
## Divider ##
$wp_customize->add_control( new ablog_divider( $wp_customize, 'blog_content_excerpt', array(
'label' => __('Layout', 'ablog'),
'section' => 'blog_settings',
'settings' => 'ablog_options[divider]'
) )
);
## Blog Layout ##
$wp_customize->add_setting(
'blog_layout',
array(
'default' => 'classic',
'sanitize_callback' => 'ablog_sanitize_blog',
)
);
$wp_customize->add_control(
'blog_layout',
array(
'label' => __( 'Blog Layout', 'ablog' ),
'section' => 'blog_settings',
'type' => 'radio',
'choices' => array(
'classic' => 'Classic Style',
'masonry' => 'Masonry (Grid Style)'
),
)
);
}
add_action( 'customize_register', 'ablog_customize_register' );
/**
* Render the site title for the selective refresh partial.
*
* @return void
*/
function ablog_customize_partial_blogname() {
bloginfo( 'name' );
}
/**
* Render the site tagline for the selective refresh partial.
*
* @return void
*/
function ablog_customize_partial_blogdescription() {
bloginfo( 'description' );
}
/**
* Sanitize
* @param $input
* @return string
*/
function ablog_sanitize_text( $input ) {
return wp_kses_post( force_balance_tags( $input ) );
}
function ablog_sanitize_checkbox( $input ) {
if ( $input == 1 ) {
return 1;
} else {
return '';
}
}
/**
* Sanitize
* @param $input
* @return string
*/
function ablog_sanitize_blog( $input ) {
$valid = array(
'classic' => __( 'Classic', 'ablog' ),
'masonry' => __( 'Masonry (Grid Style)', 'ablog' )
);
if ( array_key_exists( $input, $valid ) ) {
return $input;
} else {
return '';
}
}
/**
* Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
*/
function ablog_customize_preview_js() {
wp_enqueue_script( 'ablog-customizer', get_template_directory_uri() . '/assets/js/customizer.js', array( 'customize-preview' ), '20151215', true );
}
add_action( 'customize_preview_init', 'ablog_customize_preview_js' );