'#333333',
'basepress_text_color' => '#333333',
'basepress_accent_color' => '#cb2027',
'basepress_footer_background_color' => '#ffffff',
'basepress_footer_heading_color' => '#333333',
'basepress_footer_text_color' => '#333333',
'basepress_footer_link_color' => '#cb2027',
'basepress_layout' => 'right',
'background_color' => 'f5f5f5',
) );
}
/**
* Adds a value to each basepress setting if one isn't already present.
*
* @uses get_basepress_default_setting_values()
*/
public function default_theme_mod_values() {
foreach ( self::get_basepress_default_setting_values() as $mod => $val ) {
add_filter( 'theme_mod_' . $mod, array( $this, 'get_theme_mod_value' ), 10 );
}
}
/**
* Get theme mod value.
*
* @param string $value
* @return string
*/
public function get_theme_mod_value( $value ) {
$key = substr( current_filter(), 10 );
$set_theme_mods = get_theme_mods();
if ( isset( $set_theme_mods[ $key ] ) ) {
return $value;
}
$values = $this->get_basepress_default_setting_values();
return isset( $values[ $key ] ) ? $values[ $key ] : $value;
}
/**
* Set Customizer setting defaults.
* These defaults need to be applied separately as child themes can filter basepress_setting_default_values
*
* @param array $wp_customize the Customizer object.
* @uses get_basepress_default_setting_values()
*/
public function edit_default_customizer_settings( $wp_customize ) {
foreach ( self::get_basepress_default_setting_values() as $mod => $val ) {
if (! empty( $wp_customize->get_setting( $mod )->default ) ) {
$wp_customize->get_setting( $mod )->default = $val;
} else {
echo $mod . '
';
}
}
}
/**
* Register Theme Customize
*
* @param WP_Customize_Manager $wp_customize Theme Customizer object.
* @since 1.0.0
* @return void
*/
public function customize_register( $wp_customize ) {
// Move background color setting alongside background image.
$wp_customize->get_control( 'background_color' )->section = 'background_image';
$wp_customize->get_control( 'background_color' )->priority = 20;
// Change background image section title & priority.
$wp_customize->get_section( 'background_image' )->title = __( 'Background', 'basepress' );
$wp_customize->get_section( 'background_image' )->priority = 30;
// Change header image section title & priority.
$wp_customize->get_section( 'header_image' )->title = __( 'Header', 'basepress' );
$wp_customize->get_section( 'header_image' )->priority = 25;
// Selective refresh.
if ( function_exists( 'add_partial' ) ) {
$wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
$wp_customize->selective_refresh->add_partial( 'custom_logo', array(
'selector' => '.site-branding',
'render_callback' => array( $this, 'get_site_logo' ),
) );
$wp_customize->selective_refresh->add_partial( 'blogname', array(
'selector' => '.site-title.beta a',
'render_callback' => array( $this, 'get_site_name' ),
) );
$wp_customize->selective_refresh->add_partial( 'blogdescription', array(
'selector' => '.site-description',
'render_callback' => array( $this, 'get_site_description' ),
) );
}
/**
* Custom controls
*/
require_once dirname( __FILE__ ) . '/class-basepress-customizer-control-radio-image.php';
require_once dirname( __FILE__ ) . '/class-basepress-customizer-control-arbitrary.php';
/**
* Add the typography section
*/
$wp_customize->add_section( 'basepress_typography' , array(
'title' => __( 'Color', 'basepress' ),
'priority' => 45,
) );
/**
* Heading color
*/
$wp_customize->add_setting( 'basepress_heading_color', array(
'default' => apply_filters( 'basepress_default_heading_color', '#333333' ),
'sanitize_callback' => 'sanitize_hex_color',
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'basepress_heading_color', array(
'label' => __( 'Primary color', 'basepress' ),
'section' => 'basepress_typography',
'settings' => 'basepress_heading_color',
'priority' => 20,
) ) );
/**
* Accent Color
*/
$wp_customize->add_setting( 'basepress_accent_color', array(
'default' => apply_filters( 'basepress_default_accent_color', '#cb2027' ),
'sanitize_callback' => 'sanitize_hex_color',
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'basepress_accent_color', array(
'label' => __( 'Secondary color', 'basepress' ),
'section' => 'basepress_typography',
'settings' => 'basepress_accent_color',
'priority' => 30,
) ) );
/**
* Text Color
*/
$wp_customize->add_setting( 'basepress_text_color', array(
'default' => apply_filters( 'basepress_default_text_color', '#333333' ),
'sanitize_callback' => 'sanitize_hex_color',
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'basepress_text_color', array(
'label' => __( 'Body text color', 'basepress' ),
'section' => 'basepress_typography',
'settings' => 'basepress_text_color',
'priority' => 40,
) ) );
$wp_customize->add_control( new Arbitrary_BasePress_Control( $wp_customize, 'basepress_header_image_heading', array(
'section' => 'header_image',
'type' => 'heading',
'label' => __( 'Header background image', 'basepress' ),
'priority' => 6,
) ) );
/**
* Footer section
*/
$wp_customize->add_section( 'basepress_footer' , array(
'title' => __( 'Footer', 'basepress' ),
'priority' => 28,
'description' => __( 'Customise the look & feel of your web site footer.', 'basepress' ),
) );
/**
* Footer Background
*/
$wp_customize->add_setting( 'basepress_footer_background_color', array(
'default' => apply_filters( 'basepress_default_footer_background_color', '#ffffff' ),
'sanitize_callback' => 'sanitize_hex_color',
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'basepress_footer_background_color', array(
'label' => __( 'Background color', 'basepress' ),
'section' => 'basepress_footer',
'settings' => 'basepress_footer_background_color',
'priority' => 10,
) ) );
/**
* Footer heading color
*/
$wp_customize->add_setting( 'basepress_footer_heading_color', array(
'default' => apply_filters( 'basepress_default_footer_heading_color', '#333333' ),
'sanitize_callback' => 'sanitize_hex_color',
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'basepress_footer_heading_color', array(
'label' => __( 'Title heading color', 'basepress' ),
'section' => 'basepress_footer',
'settings' => 'basepress_footer_heading_color',
'priority' => 20,
) ) );
/**
* Footer text color
*/
$wp_customize->add_setting( 'basepress_footer_text_color', array(
'default' => apply_filters( 'basepress_default_footer_text_color', '#3333333' ),
'sanitize_callback' => 'sanitize_hex_color',
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'basepress_footer_text_color', array(
'label' => __( 'Body text color', 'basepress' ),
'section' => 'basepress_footer',
'settings' => 'basepress_footer_text_color',
'priority' => 30,
) ) );
/**
* Footer link color
*/
$wp_customize->add_setting( 'basepress_footer_link_color', array(
'default' => apply_filters( 'basepress_default_footer_link_color', '#cb2027' ),
'sanitize_callback' => 'sanitize_hex_color',
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'basepress_footer_link_color', array(
'label' => __( 'Link color', 'basepress' ),
'section' => 'basepress_footer',
'settings' => 'basepress_footer_link_color',
'priority' => 40,
) ) );
/**
* Layout
*/
$wp_customize->add_section( 'basepress_layout' , array(
'title' => __( 'Layout', 'basepress' ),
'priority' => 50,
) );
$wp_customize->add_setting( 'basepress_layout', array(
'default' => apply_filters( 'basepress_default_layout', $layout = is_rtl() ? 'left' : 'right' ),
'sanitize_callback' => 'basepress_sanitize_choices',
) );
$wp_customize->add_control( new basepress_Custom_Radio_Image_Control( $wp_customize, 'basepress_layout', array(
'settings' => 'basepress_layout',
'section' => 'basepress_layout',
'label' => __( 'General Layout', 'basepress' ),
'priority' => 1,
'choices' => array(
'left' => get_template_directory_uri() . '/assets/images/customizer/controls/left.png',
'none' => get_template_directory_uri() . '/assets/images/customizer/controls/none.png',
'right' => get_template_directory_uri() . '/assets/images/customizer/controls/right.png',
),
) ) );
}
/**
*
*
* @since 1.0.0
*
*/
public function layout_class( $classes ) {
$left_or_right = get_theme_mod( 'basepress_layout' );
$classes[] = $left_or_right . '-sidebar';
return $classes;
}
/**
* Assign basepress styles to individual theme mods.
*
* @since 1.0.0
* @return void
*/
public function set_basepress_style_theme_mods() {
set_theme_mod( 'basepress_styles', $this->get_css() );
//set_theme_mod( 'basepress_woocommerce_styles', $this->get_woocommerce_css() );
}
/**
* Add CSS in