= 4.0 ) {
// Layout
$wp_customize->add_panel( 'coeur_layout', array(
'priority' => 40,
'capability' => 'edit_theme_options',
'theme_supports' => '',
'title' => __('Layout Options', 'coeur'),
'description' => '',
));
}
/*
* Sections
*/
// Post Content
$wp_customize->add_section( 'coeur_postcontent' , array(
'title' => __( 'Post Options', 'coeur' ),
'priority' => 30,
));
// -----------------------------------------------------------------------------
// Font Options
$wp_customize->add_section( 'coeur_fonts' , array(
'title' => __( 'Font Options', 'coeur' ),
'priority' => 40,
));
// -----------------------------------------------------------------------------
// Meta Options
$wp_customize->add_section( 'coeur_meta' , array(
'title' => __( 'Meta Options', 'coeur' ),
'priority' => 50,
));
// -----------------------------------------------------------------------------
// Container Width
$wp_customize->add_section( 'coeur_container_width' , array(
'title' => __( 'Container Width', 'coeur' ),
'priority' => 10,
'panel' => 'coeur_layout',
));
// -----------------------------------------------------------------------------
// Blog Layout
$wp_customize->add_section( 'coeur_bloglayout' , array(
'title' => __( 'Blog Layout', 'coeur' ),
'priority' => 20,
'panel' => 'coeur_layout',
));
// -----------------------------------------------------------------------------
// Post Layout
$wp_customize->add_section( 'coeur_postlayout' , array(
'title' => __( 'Post Layout', 'coeur' ),
'priority' => 30,
'panel' => 'coeur_layout',
));
// -----------------------------------------------------------------------------
// Page Layout
$wp_customize->add_section( 'coeur_pagelayout' , array(
'title' => __( 'Page Layout', 'coeur' ),
'priority' => 40,
'panel' => 'coeur_layout',
));
// -----------------------------------------------------------------------------
// Coeur Comments
$wp_customize->add_section( 'coeur_comments' , array(
'title' => __( 'Comments', 'coeur' ),
'priority' => 70, ));
// -----------------------------------------------------------------------------
// Coeur Logo
$wp_customize->add_section( 'coeur_logo' , array(
'title' => __( 'Logo', 'coeur' ),
'priority' => 70, ));
// -----------------------------------------------------------------------------
/**
* Menu on single post pages
* @author Frenchtastic
* @since Coeur 1.6
*/
$wp_customize->add_setting('single_menu_header', array(
'default' => 'no',
'capability' => 'edit_theme_options',
'type' => 'option',
'sanitize_callback' => 'coeur_sanitize_menusingle',
));
$wp_customize->add_control('single_menu_header', array(
'label' => __('Display menu on single post pages', 'coeur'),
'section' => 'nav',
'settings' => 'single_menu_header',
'description' => 'Display menu on single post pages instead of post navigation and comment count.',
'type' => 'select',
'choices' => array(
'yes'=> 'Yes',
'no' => 'No'
),
));
// -----------------------------------------------------------------------------
/**
* Inverse Navbar
* @author Frenchtastic
* @since Coeur 1.7
*/
$wp_customize->add_setting( 'coeur_inverse_navbar', array(
'sanitize_callback' => 'coeur_sanitize_checkbox',
));
$wp_customize->add_control(
'coeur_inverse_navbar',
array(
'description' => 'This option will turn the navigation bar black, it looks great when a photo is set as header background.',
'type' => 'checkbox',
'label' => 'Inverse navbar',
'section' => 'nav',
'std' => '1'
));
// -----------------------------------------------------------------------------
/**
* Show/Hide categories on posts
* @author Frenchtastic
* @since Coeur 1.7
*/
$wp_customize->add_setting( 'coeur_show_cat', array(
'sanitize_callback' => 'coeur_sanitize_checkbox',
));
$wp_customize->add_control(
'coeur_show_cat',
array(
'description' => 'Show categories on posts?',
'type' => 'checkbox',
'label' => 'Show categories',
'section' => 'coeur_meta',
'std' => '0'
));
// -----------------------------------------------------------------------------
/**
* Show/Hide author on posts
* @author Frenchtastic
* @since Coeur 1.7
*/
$wp_customize->add_setting( 'coeur_show_author', array(
'sanitize_callback' => 'coeur_sanitize_checkbox',
));
$wp_customize->add_control(
'coeur_show_author',
array(
'description' => 'Show the post author on articles?',
'type' => 'checkbox',
'label' => 'Show post author',
'section' => 'coeur_meta',
'std' => '1'
));
// -----------------------------------------------------------------------------
/**
* Show/Hide date on posts
* @author Frenchtastic
* @since Coeur 2.0.6
*/
$wp_customize->add_setting( 'coeur_show_date', array(
'sanitize_callback' => 'coeur_sanitize_checkbox',
));
$wp_customize->add_control(
'coeur_show_date',
array(
'description' => 'Show the date on articles?',
'type' => 'checkbox',
'label' => 'Show date',
'section' => 'coeur_meta',
'std' => '1'
));
// -----------------------------------------------------------------------------
/**
* Change text preceding date
* @author Frenchtastic
* @since Coeur 1.7
*/
$wp_customize->add_setting('coeur_meta_posted', array(
'default' => 'Posted on',
'capability' => 'edit_theme_options',
'type' => 'option',
'transport' => 'refresh',
'sanitize_callback' => 'sanitize_text_field',
));
$wp_customize->add_control('coeur_meta_posted', array(
'label' => __('Posted on', 'coeur'),
'section' => 'coeur_meta',
'settings' => 'coeur_meta_posted',
'description' => 'Change the text preceding the post date. Set to "posted on" by default.'
));
// -----------------------------------------------------------------------------
/**
* Excerpt or content
*/
$wp_customize->add_setting('post_content', array(
'default' => 'excerpt',
'capability' => 'edit_theme_options',
'type' => 'option',
'transport' => 'refresh', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
'sanitize_callback' => 'coeur_sanitize_content',
));
$wp_customize->add_control('coeur_postcontent', array(
'label' => __('Post Content', 'coeur'),
'section' => 'coeur_postcontent',
'settings' => 'post_content',
'description' => 'Show content will show the whole post content while show excerpt will only show the first few lines',
'type' => 'radio',
'choices' => array(
'content' => 'Show content',
'excerpt' => 'Show excerpt'
),
));
// -----------------------------------------------------------------------------
/**
* Thumbnail link to post?
* @author Frenchtastic
* @since Coeur 2.0.7
*/
$wp_customize->add_setting('thumbnail_link', array(
'default' => 'yes',
'capability' => 'edit_theme_options',
'type' => 'theme_mod',
'transport' => 'refresh',
'sanitize_callback' => 'coeur_sanitize_thumbnail_link',
));
$wp_customize->add_control('thumbnail_link', array(
'label' => __('Thumbnail Link', 'coeur'),
'section' => 'coeur_postcontent',
'settings' => 'thumbnail_link',
'description' => __('Do you want thumbnails to be linked to their article?', 'coeur'),
'type' => 'radio',
'choices' => array(
'yes'=> __('Yes', 'coeur'),
'no' => __('No', 'coeur')
),
));
// -----------------------------------------------------------------------------
/**
* Tagline color
* @author Frenchtastic
* @since Coeur 2.0.4
*/
$wp_customize->add_setting( 'tagline_color' , array(
'default' => '#555',
'transport' => 'postMessage',
'sanitize_callback' => 'sanitize_hex_color',
));
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'coeur_tagline_color', array(
'label' => __( 'Tagline Color', 'coeur' ),
'section' => 'colors',
'settings' => 'tagline_color',
)));
// -----------------------------------------------------------------------------
/*
* Heading Link Color
*/
$wp_customize->add_setting( 'heading_linkcolor',
array(
'default' => '#333', //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' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
'sanitize_callback' => 'sanitize_hex_color',
)
);
$wp_customize->add_control( new WP_Customize_Color_Control( //Instantiate the color control class
$wp_customize, //Pass the $wp_customize object (required)
'coeur_heading_linkcolor', //Set a unique ID for the control
array(
'label' => __( 'Headings Link Color', 'mytheme' ), //Admin-visible name of the control
'section' => 'colors', //ID of the section this control should render in (can be one of yours, or a WordPress default section)
'settings' => 'heading_linkcolor', //Which setting to load and manipulate (serialized is okay)
'priority' => 10, //Determines the order this control appears in for the specified section
)
));
// -----------------------------------------------------------------------------
/**
* Primary color
* @author Frenchtastic
* @since Coeur 1.0
*/
$wp_customize->add_setting( 'primary_color' , array(
'default' => '#00c9bf',
'transport' => 'postMessage',
'sanitize_callback' => 'sanitize_hex_color',
));
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'coeur_primary_color', array(
'label' => __( 'Primary Color', 'coeur' ),
'section' => 'colors',
'settings' => 'primary_color',
)));
// -----------------------------------------------------------------------------
/*
* Link Color
*/
$wp_customize->add_setting( 'link_textcolor',
array(
'default' => '#00c9bf', //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' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
'sanitize_callback' => 'sanitize_hex_color',
));
$wp_customize->add_control( new WP_Customize_Color_Control( //Instantiate the color control class
$wp_customize, //Pass the $wp_customize object (required)
'coeur_link_textcolor', //Set a unique ID for the control
array(
'label' => __( 'Link Color', 'coeur' ), //Admin-visible name of the control
'section' => 'colors', //ID of the section this control should render in (can be one of yours, or a WordPress default section)
'settings' => 'link_textcolor', //Which setting to load and manipulate (serialized is okay)
'priority' => 10, //Determines the order this control appears in for the specified section
)
));
// -----------------------------------------------------------------------------
/*
* Header Background Color
*/
$wp_customize->add_setting( 'header_background_color',
array(
'default' => '#FFF', //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' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
'sanitize_callback' => 'sanitize_hex_color',
));
$wp_customize->add_control( new WP_Customize_Color_Control( //Instantiate the color control class
$wp_customize, //Pass the $wp_customize object (required)
'coeur_header_background_color', //Set a unique ID for the control
array(
'label' => __( 'Header Background Color', 'coeur' ), //Admin-visible name of the control
'section' => 'colors', //ID of the section this control should render in (can be one of yours, or a WordPress default section)
'settings' => 'header_background_color', //Which setting to load and manipulate (serialized is okay)
'priority' => 10, //Determines the order this control appears in for the specified section
)
));
// -----------------------------------------------------------------------------
/*
* Blog Layout
*/
$wp_customize->add_setting('bloglayout', array(
'default' => 'right',
'capability' => 'edit_theme_options',
'type' => 'option',
'sanitize_callback' => 'coeur_sanitize_layout',
));
$wp_customize->add_control('coeur_option_bloglayout', array(
'label' => __('Layout', 'eiffel'),
'section' => 'coeur_bloglayout',
'settings' => 'bloglayout',
'description' => '',
'type' => 'radio',
'choices' => array(
'left' => 'Left',
'full_width' => 'Content Full Width / No sidebar',
'right' => 'Right'
),
));
// -----------------------------------------------------------------------------
/*
* Post Layout
*/
$wp_customize->add_setting('postlayout', array(
'default' => 'right',
'capability' => 'edit_theme_options',
'type' => 'option',
'sanitize_callback' => 'coeur_sanitize_layout',
));
$wp_customize->add_control('coeur_option_postlayout', array(
'label' => __('Layout', 'eiffel'),
'section' => 'coeur_postlayout',
'settings' => 'postlayout',
'description' => '',
'type' => 'radio',
'choices' => array(
'left' => 'Left',
'full_width' => 'Content Full Width / No sidebar',
'right' => 'Right'
),
));
// -----------------------------------------------------------------------------
/*
* Page Layout
*/
$wp_customize->add_setting('pagelayout', array(
'default' => 'right',
'capability' => 'edit_theme_options',
'type' => 'option',
'sanitize_callback' => 'coeur_sanitize_layout',
));
$wp_customize->add_control('coeur_option_pagelayout', array(
'label' => __('Layout', 'eiffel'),
'section' => 'coeur_pagelayout',
'settings' => 'pagelayout',
'description' => '',
'type' => 'radio',
'choices' => array(
'left' => 'Left',
'full_width' => 'Content Full Width / No sidebar',
'right' => 'Right'
),
));
// -----------------------------------------------------------------------------
/**
* Container width
* @author Frenchtastic
* @since Coeur 2.0
*/
$wp_customize->add_setting('container_width', array(
'default' => '970px',
'capability' => 'edit_theme_options',
'type' => 'theme_mod',
'sanitize_callback' => 'coeur_sanitize_width',
));
$wp_customize->add_control('coeur_option_container_width', array(
'label' => __('Width', 'coeur'),
'section' => 'coeur_container_width',
'settings' => 'container_width',
'description' => 'Choose site width.
Please note: This option will not make any changes to your site as you site in customizer because the view is too small.',
'type' => 'select',
'choices' => array(
'970px' => 'Standard site width',
'1170px' => 'Wider site width'
),
));
// -----------------------------------------------------------------------------
/**
* Headings
* @author Frenchtastic
* @since Coeur 2.0
*/
$wp_customize->add_setting('headings_weight', array(
'default' => '100',
'capability' => 'edit_theme_options',
'type' => 'theme_mod',
'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
'sanitize_callback' => 'coeur_sanitize_weight',
));
$wp_customize->add_control('coeur_headings_weight', array(
'label' => __('Headings', 'coeur'),
'section' => 'coeur_fonts',
'settings' => 'headings_weight',
'description' => 'Make headings/titles bolder.',
'type' => 'select',
'choices' => array(
'100' => 'Thin',
'200' => 'Bold',
'400' => 'Bolder'
),
));
// -----------------------------------------------------------------------------
/**
* Body Font
* @author Frenchtastic
* @since Coeur 2.0
*/
$wp_customize->add_setting('body_font', array(
'default' => 'Helvetica Neue',
'capability' => 'edit_theme_options',
'type' => 'theme_mod',
'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
'sanitize_callback' => 'coeur_sanitize_fontfamily',
));
$wp_customize->add_control('coeur_body_font', array(
'label' => __('Body Font', 'coeur'),
'section' => 'coeur_fonts',
'settings' => 'body_font',
'description' => 'Pick a font for body text.',
'type' => 'select',
'choices' => array(
'Helvetica Neue' => 'Helvetica Neue',
'Open Sans' => 'Open Sans',
'Arial' => 'Arial',
'Comic Sans MS' => 'Comic Sans MS',
'Times New Roman' => 'Times New Roman',
'Verdana' => 'Verdana',
'Fantasy' => 'Fantasy',
'Monospace' => 'Monospace',
'Cursive' => 'Cursive',
'Serif' => 'Serif',
'Courier' => 'Courier',
'Monaco' => 'Monaco'
),
));
// -----------------------------------------------------------------------------
/**
* Headings
* @author Frenchtastic
* @since Coeur 2?0
*/
$wp_customize->add_setting('headings_font', array(
'default' => 'Helvetica Neue',
'capability' => 'edit_theme_options',
'type' => 'theme_mod',
'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
'sanitize_callback' => 'coeur_sanitize_fontfamily',
));
$wp_customize->add_control('coeur_headings_font', array(
'label' => __('Heading Font', 'coeur'),
'section' => 'coeur_fonts',
'settings' => 'headings_font',
'description' => 'Pick a font for all headings.',
'type' => 'select',
'choices' => array(
'Helvetica Neue' => 'Helvetica Neue',
'Open Sans' => 'Open Sans',
'Arial' => 'Arial',
'Comic Sans MS' => 'Comic Sans MS',
'Times New Roman' => 'Times New Roman',
'Verdana' => 'Verdana',
'Fantasy' => 'Fantasy',
'Monospace' => 'Monospace',
'Cursive' => 'Cursive',
'Serif' => 'Serif',
'Courier' => 'Courier',
'Monaco' => 'Monaco'
),
));
// -----------------------------------------------------------------------------
/**
* Logo
* @author Frenchtastic
* @since Coeur 1.6
*/
$wp_customize->add_setting( 'coeur_logo', array(
'sanitize_callback' => 'esc_url_raw',
));
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'coeur_logo_option', array(
'label' => __( 'Logo', 'coeur' ),
'section' => 'coeur_logo',
'settings' => 'coeur_logo',
)));
// -----------------------------------------------------------------------------
/**
* Comment dropdown
*
* @author Frenchtastic
* @since Coeur 2.0.6
*/
$wp_customize->add_setting('coeur_comment_dropdown', array(
'default' => 'none',
'capability' => 'edit_theme_options',
'type' => 'option',
'transport' => 'refresh', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
'sanitize_callback' => 'coeur_sanitize_comment_dropdown',
));
$wp_customize->add_control('coeur_comment_dropdown', array(
'label' => __('Comment dropdown', 'coeur'),
'section' => 'coeur_comments',
'settings' => 'coeur_comment_dropdown',
'description' => 'Only show comments once the user has clicked the link "# comments" on posts and pages.',
'type' => 'radio',
'choices' => array(
'none' => 'Yes',
'block' => 'No'
),
));
// -----------------------------------------------------------------------------
/**
* Show/Hide Site Title when logo is displayed
* @author Frenchtastic
* @since Coeur 1.7
*/
$wp_customize->add_setting( 'coeur_hide_site_title', array(
'sanitize_callback' => 'coeur_sanitize_checkbox',
));
$wp_customize->add_control(
'coeur_hide_site_title',
array(
'description' => 'This option will only work if you have uploaded a logo.',
'type' => 'checkbox',
'label' => 'Replace title with logo',
'section' => 'title_tagline',
'std' => '0'
));
// -----------------------------------------------------------------------------
/**
* Footer copyright text
* @author Frenchtastic
* @since Coeur 1.0
*/
$wp_customize->add_setting('footer_copyright', array(
'default' => 'Design by Frenchtastic.eu',
'capability' => 'edit_theme_options',
'type' => 'option',
'transport' => 'refresh',
'sanitize_callback' => 'coeur_sanitize_footer',
));
$wp_customize->add_control('coeur_footer_copyright', array(
'label' => __('Footer Copyright', 'coeur'),
'section' => 'title_tagline',
'settings' => 'footer_copyright'
));
// -----------------------------------------------------------------------------
//4. We can also change built-in settings by modifying properties. For instance, let's make some stuff use live preview JS...
$wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
$wp_customize->get_setting( 'header_textcolor' )->transport = 'refresh';
$wp_customize->get_setting( 'heading_linkcolor' )->transport = 'postMessage';
$wp_customize->get_setting( 'header_background_color' )->transport = 'postMessage';
$wp_customize->get_setting( 'primary_color' )->transport = 'postMessage';
$wp_customize->get_setting( 'tagline_color' )->transport = 'postMessage';
$wp_customize->get_setting( 'background_color' )->transport = 'postMessage';
$wp_customize->get_setting( 'headings_weight' )->transport = 'postMessage';
$wp_customize->get_setting( 'headings_font' )->transport = 'postMessage';
$wp_customize->get_setting( 'body_font' )->transport = 'postMessage';
}
/**
* This will output the custom WordPress settings to the live theme's WP head.
*
* Used by hook: 'wp_head'
*
* @see add_action('wp_head',$func)
* @since Coeur 2.0
*/
public static function header_output() {
?>
'postMessage' instead of the default 'transport'
* => 'refresh'
*
* Used by hook: 'customize_preview_init'
*
* @see add_action('customize_preview_init',$func)
* @since Coeur 2.0
*/
public static function live_preview() {
wp_enqueue_script( 'theme-customizer', get_template_directory_uri() . '/framework/js/theme-customizer.js', array( 'jquery', 'customize-preview' ), '', true);
}
/**
* This will generate a line of CSS for use in header output. If the setting
* ($mod_name) has no defined value, the CSS will not be output.
*
* @uses get_theme_mod()
* @param string $selector CSS selector
* @param string $style The name of the CSS *property* to modify
* @param string $mod_name The name of the 'theme_mod' option to fetch
* @param string $prefix Optional. Anything that needs to be output before the CSS property
* @param string $postfix Optional. Anything that needs to be output after the CSS property
* @param bool $echo Optional. Whether to print directly to the page (default: true).
* @return string Returns a single line of CSS with selectors and a property.
* @since Coeur 2.0
*/
public static function generate_css( $selector, $style, $mod_name, $prefix='', $postfix='', $echo=true ) {
$return = '';
$mod = get_theme_mod($mod_name);
if ( ! empty( $mod ) ) {
$return = sprintf('%s { %s:%s; }',
$selector,
$style,
$prefix.$mod.$postfix
);
if ( $echo ) {
echo $return;
}
}
return $return;
}
}
// Setup the Theme Customizer settings and controls...
add_action( 'customize_register' , array( 'Coeur_Customize' , 'register' ) );
// Output custom CSS to live site
add_action( 'wp_head' , array( 'Coeur_Customize' , 'header_output' ) );
// Enqueue live preview javascript in Theme Customizer admin screen
add_action( 'customize_preview_init' , array( 'Coeur_Customize' , 'live_preview' ) );