* add_action( 'after_setup_theme', 'my_child_theme_setup' ); * function my_child_theme_setup() { * // We are providing our own filter for excerpt_length (or using the unfiltered value) * remove_filter( 'excerpt_length', 'bootstrapcanvaswp_excerpt_length' ); * ... * } * * * For more information on hooks, actions, and filters, see http://codex.wordpress.org/Plugin_API. * * @package Bootstrap Canvas WP * @since Bootstrap Canvas WP 1.0 */ /* * Set the content width based on the theme's design and stylesheet. * * Used to set the width of images and content. Should be equal to the width the theme * is designed for, generally via the style.css stylesheet. */ global $content_width; if ( ! isset( $content_width ) ) $content_width = 900; /* Tell WordPress to run bootstrapcanvaswp_setup() when the 'after_setup_theme' hook is run. */ add_action( 'after_setup_theme', 'bootstrapcanvaswp_setup' ); if ( ! function_exists( 'bootstrapcanvaswp_setup' ) ): /** * Set up theme defaults and registers support for various WordPress features. * * Note that this function is hooked into the after_setup_theme hook, which runs * before the init hook. The init hook is too late for some features, such as indicating * support post thumbnails. * * To override bootstrapcanvaswp_setup() in a child theme, add your own bootstrapcanvaswp_setup to your child theme's * functions.php file. * * @uses add_theme_support() To add support for post thumbnails, custom headers and backgrounds, and automatic feed links. * @uses register_nav_menus() To add support for navigation menus. * @uses add_editor_style() To style the visual editor. * @uses load_theme_textdomain() For translation/localization support. * @uses register_default_headers() To register the default custom header images provided with the theme. * @uses set_post_thumbnail_size() To set a custom post thumbnail size. * * @since Bootstrap Canvas WP 1.0 */ function bootstrapcanvaswp_setup() { // This theme styles the visual editor with editor-style.css to match the theme style. add_editor_style( 'editor-style.css' ); // Post Format support. add_theme_support( 'post-formats', array( 'aside', 'gallery', 'link', 'image', 'quote', 'status', 'video', 'audio', 'chat' ) ); // This theme uses post thumbnails add_theme_support( 'post-thumbnails' ); // Add default posts and comments RSS feed links to head add_theme_support( 'automatic-feed-links' ); /* * Make theme available for translation. * Translations can be filed in the /languages/ directory */ load_theme_textdomain( 'bootstrapcanvaswp', get_template_directory() . '/languages' ); // Register Custom Navigation Walker require_once('inc/wp_bootstrap_navwalker.php'); // This theme uses wp_nav_menu() in one location. register_nav_menus( array( 'primary' => __( 'Primary Menu', 'bootstrapcanvaswp' ), ) ); // This theme allows users to set a custom background. $args = array( // Let WordPress know what our default background color is. 'default-color' => 'fff', ); add_theme_support( 'custom-background', $args ); // The custom header business starts here. $args = array( // The height and width of our custom header. 'width' => '980', 'height' => '170', // Support flexible widths and heights. 'flex-height' => true, 'flex-width' => true, // Let WordPress know what our default text color is. 'default-text-color' => '333', ); add_theme_support( 'custom-header', $args ); } add_action( 'after_setup_theme', 'bootstrapcanvaswp_setup' ); endif; /** * Enqueue scripts and styles for front-end. * * @since Bootstrap Canvas WP 1.0 */ function bootstrapcanvaswp_scripts() { wp_enqueue_style( 'style-css', get_stylesheet_uri() ); wp_enqueue_style( 'animate.css', get_template_directory_uri() . '/css/animate.css' ); wp_enqueue_style( 'bootstrap-css', get_template_directory_uri() . '/css/bootstrap.css', '3.3.0' ); wp_enqueue_style( 'blog-css', get_template_directory_uri() . '/css/blog.css' ); wp_enqueue_script( 'bootstrap-js', get_template_directory_uri() . '/js/bootstrap.js', array( 'jquery' ), '3.3.0', true ); wp_enqueue_script( 'bootstrapcanvaswp-js', get_template_directory_uri() . '/js/bootstrapcanvaswp.js', array( 'jquery' ), '3.3.0', true ); wp_enqueue_script( 'html5shiv-js', get_template_directory_uri() . '/js/html5shiv.js', array( 'jquery' ), '3.7.2' ); wp_enqueue_script( 'ie-10-viewport-bug-workaround-js', get_template_directory_uri() . '/js/ie10-viewport-bug-workaround.js', array( 'jquery' ), '3.3.0', true ); wp_enqueue_script( 'jquery.viewportchecker.js', get_template_directory_uri() . '/js/jquery.viewportchecker.js', array( 'jquery' ), '1.5.0' ); wp_enqueue_script( 'respond-js', get_template_directory_uri() . '/js/respond.js', array( 'jquery' ), '1.4.2' ); } add_action( 'wp_enqueue_scripts', 'bootstrapcanvaswp_scripts' ); /** * Register widgetized areas, including main sidebar and three widget-ready columns in the footer. * * To override bootstrapcanvaswp_widgets_init() in a child theme, remove the action hook and add your own * function tied to the init hook. * * @since Bootstrap Canvas WP 1.0 * * @uses register_sidebar() */ function bootstrapcanvaswp_widgets_init() { // Area 1, located at the top of the sidebar. register_sidebar( array( 'name' => __( 'Primary Widget Area', 'bootstrapcanvaswp' ), 'id' => 'primary-widget-area', 'description' => __( 'Add widgets here to appear in your sidebar.', 'bootstrapcanvaswp' ), 'before_widget' => '
', 'before_title' => '
', 'bootstrapcanvaswp'), //Descriptive tooltip
)
);
//2. Register new settings to the WP database...
$wp_customize->add_setting( 'donationbutton', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
array(
'default' => '', //Default setting/value to save
'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'?
'capability' => '', //Optional. Special permissions for accessing this setting.
'transport' => 'refresh', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
'sanitize_callback' => 'esc_attr',
)
);
//3. Finally, we define the control itself (which links a setting to a section and renders the HTML controls)...
$wp_customize->add_control( new WP_Customize_Control( //Instantiate the color control class
$wp_customize, //Pass the $wp_customize object (required)
'bootstrapcanvaswp_donationbutton', //Set a unique ID for the control
array(
'label' => __( '', 'bootstrapcanvaswp' ), //Admin-visible name of the control
'section' => 'bootstrapcanvaswp_donation', //ID of the section this control should render in (can be one of yours, or a WordPress default section)
'settings' => 'donationbutton', //Which setting to load and manipulate (serialized is okay)
'priority' => 1, //Determines the order this control appears in for the specified section
'type' => 'hidden',
)
) );
//1. Define a new section (if desired) to the Theme Customizer
$wp_customize->add_section( 'title_tagline',
array(
'title' => __( 'Site Title & Tagline', 'bootstrapcanvaswp' ), //Visible title of section
'priority' => 2, //Determines what order this appears in
'capability' => 'edit_theme_options', //Capability needed to tweak
'description' => __('', 'bootstrapcanvaswp'), //Descriptive tooltip
)
);
//1. Define a new section (if desired) to the Theme Customizer
$wp_customize->add_section( 'bootstrapcanvaswp_copyright',
array(
'title' => __( 'Copyright', 'bootstrapcanvaswp' ), //Visible title of section
'priority' => 3, //Determines what order this appears in
'capability' => 'edit_theme_options', //Capability needed to tweak
'description' => __('', 'bootstrapcanvaswp'), //Descriptive tooltip
)
);
//2. Register new settings to the WP database...
$wp_customize->add_setting( 'copyrighttext', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
array(
'default' => '', //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_text_field',
)
);
//3. Finally, we define the control itself (which links a setting to a section and renders the HTML controls)...
$wp_customize->add_control( new WP_Customize_Control( //Instantiate the color control class
$wp_customize, //Pass the $wp_customize object (required)
'bootstrapcanvaswp_copyrighttext', //Set a unique ID for the control
array(
'label' => __( 'Copyright', 'bootstrapcanvaswp' ), //Admin-visible name of the control
'section' => 'bootstrapcanvaswp_copyright', //ID of the section this control should render in (can be one of yours, or a WordPress default section)
'settings' => 'copyrighttext', //Which setting to load and manipulate (serialized is okay)
'priority' => 1, //Determines the order this control appears in for the specified section
'type' => 'text',
)
) );
//3. Finally, we define the control itself (which links a setting to a section and renders the HTML controls)...
$wp_customize->add_control( new WP_Customize_Color_Control( //Instantiate the color control class
$wp_customize, //Pass the $wp_customize object (required)
'header_textcolor', //Set a unique ID for the control
array(
'label' => __( 'Header Text Color', 'bootstrapcanvaswp' ), //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_textcolor', //Which setting to load and manipulate (serialized is okay)
'priority' => 1, //Determines the order this control appears in for the specified section
)
) );
//2. Register new settings to the WP database...
$wp_customize->add_setting( 'body_textcolor', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
array(
'default' => '#555', //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',
)
);
//3. Finally, we define the control itself (which links a setting to a section and renders the HTML controls)...
$wp_customize->add_control( new WP_Customize_Color_Control( //Instantiate the color control class
$wp_customize, //Pass the $wp_customize object (required)
'bootstrapcanvaswp_body_textcolor', //Set a unique ID for the control
array(
'label' => __( 'Text Color', 'bootstrapcanvaswp' ), //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' => 'body_textcolor', //Which setting to load and manipulate (serialized is okay)
'priority' => 2, //Determines the order this control appears in for the specified section
)
) );
//2. Register new settings to the WP database...
$wp_customize->add_setting( 'link_textcolor', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
array(
'default' => '#428bca', //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',
)
);
//3. Finally, we define the control itself (which links a setting to a section and renders the HTML controls)...
$wp_customize->add_control( new WP_Customize_Color_Control( //Instantiate the color control class
$wp_customize, //Pass the $wp_customize object (required)
'bootstrapcanvaswp_link_textcolor', //Set a unique ID for the control
array(
'label' => __( 'Link Color', 'bootstrapcanvaswp' ), //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' => 3, //Determines the order this control appears in for the specified section
)
) );
//2. Register new settings to the WP database...
$wp_customize->add_setting( 'hover_textcolor', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
array(
'default' => '#23527c', //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' => 'refresh', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
'sanitize_callback' => 'sanitize_hex_color',
)
);
//3. Finally, we define the control itself (which links a setting to a section and renders the HTML controls)...
$wp_customize->add_control( new WP_Customize_Color_Control( //Instantiate the color control class
$wp_customize, //Pass the $wp_customize object (required)
'bootstrapcanvaswp_hover_textcolor', //Set a unique ID for the control
array(
'label' => __( 'Hover Link Color', 'bootstrapcanvaswp' ), //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' => 'hover_textcolor', //Which setting to load and manipulate (serialized is okay)
'priority' => 4, //Determines the order this control appears in for the specified section
)
) );
//2. Register new settings to the WP database...
$wp_customize->add_setting( 'headings_textcolor', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
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',
)
);
//3. Finally, we define the control itself (which links a setting to a section and renders the HTML controls)...
$wp_customize->add_control( new WP_Customize_Color_Control( //Instantiate the color control class
$wp_customize, //Pass the $wp_customize object (required)
'bootstrapcanvaswp_headings_textcolor', //Set a unique ID for the control
array(
'label' => __( 'Headings Color', 'bootstrapcanvaswp' ), //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' => 'headings_textcolor', //Which setting to load and manipulate (serialized is okay)
'priority' => 5, //Determines the order this control appears in for the specified section
)
) );
//2. Register new settings to the WP database...
$wp_customize->add_setting( 'primary_menucolor', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
array(
'default' => '#428bca', //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',
)
);
//3. Finally, we define the control itself (which links a setting to a section and renders the HTML controls)...
$wp_customize->add_control( new WP_Customize_Color_Control( //Instantiate the color control class
$wp_customize, //Pass the $wp_customize object (required)
'bootstrapcanvaswp_primary_menucolor', //Set a unique ID for the control
array(
'label' => __( 'Primary Menu Color', 'bootstrapcanvaswp' ), //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' => 'primary_menucolor', //Which setting to load and manipulate (serialized is okay)
'priority' => 6, //Determines the order this control appears in for the specified section
)
) );
//2. Register new settings to the WP database...
$wp_customize->add_setting( 'primary_linkcolor', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
array(
'default' => '#cdddeb', //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',
)
);
//3. Finally, we define the control itself (which links a setting to a section and renders the HTML controls)...
$wp_customize->add_control( new WP_Customize_Color_Control( //Instantiate the color control class
$wp_customize, //Pass the $wp_customize object (required)
'bootstrapcanvaswp_primary_linkcolor', //Set a unique ID for the control
array(
'label' => __( 'Primary Link Color', 'bootstrapcanvaswp' ), //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' => 'primary_linkcolor', //Which setting to load and manipulate (serialized is okay)
'priority' => 7, //Determines the order this control appears in for the specified section
)
) );
//2. Register new settings to the WP database...
$wp_customize->add_setting( 'primary_hovercolor', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
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' => 'refresh', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
'sanitize_callback' => 'sanitize_hex_color',
)
);
//3. Finally, we define the control itself (which links a setting to a section and renders the HTML controls)...
$wp_customize->add_control( new WP_Customize_Color_Control( //Instantiate the color control class
$wp_customize, //Pass the $wp_customize object (required)
'bootstrapcanvaswp_primary_hovercolor', //Set a unique ID for the control
array(
'label' => __( 'Primary Hover Link Color', 'bootstrapcanvaswp' ), //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' => 'primary_hovercolor', //Which setting to load and manipulate (serialized is okay)
'priority' => 8, //Determines the order this control appears in for the specified section
)
) );
//2. Register new settings to the WP database...
$wp_customize->add_setting( 'primary_activecolor', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
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',
)
);
//3. Finally, we define the control itself (which links a setting to a section and renders the HTML controls)...
$wp_customize->add_control( new WP_Customize_Color_Control( //Instantiate the color control class
$wp_customize, //Pass the $wp_customize object (required)
'bootstrapcanvaswp_primary_activecolor', //Set a unique ID for the control
array(
'label' => __( 'Primary Active Link Color', 'bootstrapcanvaswp' ), //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' => 'primary_activecolor', //Which setting to load and manipulate (serialized is okay)
'priority' => 9, //Determines the order this control appears in for the specified section
)
) );
//2. Register new settings to the WP database...
$wp_customize->add_setting( 'primary_activebackground', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
array(
'default' => '#428bca', //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',
)
);
//3. Finally, we define the control itself (which links a setting to a section and renders the HTML controls)...
$wp_customize->add_control( new WP_Customize_Color_Control( //Instantiate the color control class
$wp_customize, //Pass the $wp_customize object (required)
'bootstrapcanvaswp_primary_activebackground', //Set a unique ID for the control
array(
'label' => __( 'Primary Active Background Color', 'bootstrapcanvaswp' ), //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' => 'primary_activebackground', //Which setting to load and manipulate (serialized is okay)
'priority' => 10, //Determines the order this control appears in for the specified section
)
) );
//2. Register new settings to the WP database...
$wp_customize->add_setting( 'dropdown_menucolor', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
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',
)
);
//3. Finally, we define the control itself (which links a setting to a section and renders the HTML controls)...
$wp_customize->add_control( new WP_Customize_Color_Control( //Instantiate the color control class
$wp_customize, //Pass the $wp_customize object (required)
'bootstrapcanvaswp_dropdown_menucolor', //Set a unique ID for the control
array(
'label' => __( 'Dropdown Menu Color', 'bootstrapcanvaswp' ), //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' => 'dropdown_menucolor', //Which setting to load and manipulate (serialized is okay)
'priority' => 11, //Determines the order this control appears in for the specified section
)
) );
//2. Register new settings to the WP database...
$wp_customize->add_setting( 'dropdown_linkcolor', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
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',
)
);
//3. Finally, we define the control itself (which links a setting to a section and renders the HTML controls)...
$wp_customize->add_control( new WP_Customize_Color_Control( //Instantiate the color control class
$wp_customize, //Pass the $wp_customize object (required)
'bootstrapcanvaswp_dropdown_linkcolor', //Set a unique ID for the control
array(
'label' => __( 'Dropdown Link Color', 'bootstrapcanvaswp' ), //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' => 'dropdown_linkcolor', //Which setting to load and manipulate (serialized is okay)
'priority' => 12, //Determines the order this control appears in for the specified section
)
) );
//2. Register new settings to the WP database...
$wp_customize->add_setting( 'dropdown_hovercolor', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
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' => 'refresh', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
'sanitize_callback' => 'sanitize_hex_color',
)
);
//3. Finally, we define the control itself (which links a setting to a section and renders the HTML controls)...
$wp_customize->add_control( new WP_Customize_Color_Control( //Instantiate the color control class
$wp_customize, //Pass the $wp_customize object (required)
'bootstrapcanvaswp_dropdown_hovercolor', //Set a unique ID for the control
array(
'label' => __( 'Dropdown Hover Link Color', 'bootstrapcanvaswp' ), //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' => 'dropdown_hovercolor', //Which setting to load and manipulate (serialized is okay)
'priority' => 13, //Determines the order this control appears in for the specified section
)
) );
//2. Register new settings to the WP database...
$wp_customize->add_setting( 'dropdown_hoverbackground', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
array(
'default' => '#f5f5f5', //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' => 'refresh', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
'sanitize_callback' => 'sanitize_hex_color',
)
);
//3. Finally, we define the control itself (which links a setting to a section and renders the HTML controls)...
$wp_customize->add_control( new WP_Customize_Color_Control( //Instantiate the color control class
$wp_customize, //Pass the $wp_customize object (required)
'bootstrapcanvaswp_dropdown_hoverbackground', //Set a unique ID for the control
array(
'label' => __( 'Dropdown Hover Background Color', 'bootstrapcanvaswp' ), //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' => 'dropdown_hoverbackground', //Which setting to load and manipulate (serialized is okay)
'priority' => 14, //Determines the order this control appears in for the specified section
)
) );
//2. Register new settings to the WP database...
$wp_customize->add_setting( 'dropdown_activecolor', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
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',
)
);
//3. Finally, we define the control itself (which links a setting to a section and renders the HTML controls)...
$wp_customize->add_control( new WP_Customize_Color_Control( //Instantiate the color control class
$wp_customize, //Pass the $wp_customize object (required)
'bootstrapcanvaswp_dropdown_activecolor', //Set a unique ID for the control
array(
'label' => __( 'Dropdown Active Link Color', 'bootstrapcanvaswp' ), //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' => 'dropdown_activecolor', //Which setting to load and manipulate (serialized is okay)
'priority' => 15, //Determines the order this control appears in for the specified section
)
) );
//2. Register new settings to the WP database...
$wp_customize->add_setting( 'dropdown_activebackground', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
array(
'default' => '#080808', //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',
)
);
//3. Finally, we define the control itself (which links a setting to a section and renders the HTML controls)...
$wp_customize->add_control( new WP_Customize_Color_Control( //Instantiate the color control class
$wp_customize, //Pass the $wp_customize object (required)
'bootstrapcanvaswp_dropdown_activebackground', //Set a unique ID for the control
array(
'label' => __( 'Dropdown Active Background Color', 'bootstrapcanvaswp' ), //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' => 'dropdown_activebackground', //Which setting to load and manipulate (serialized is okay)
'priority' => 16, //Determines the order this control appears in for the specified section
)
) );
//2. Register new settings to the WP database...
$wp_customize->add_setting( 'footer_textcolor', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
array(
'default' => '#999', //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',
)
);
//3. Finally, we define the control itself (which links a setting to a section and renders the HTML controls)...
$wp_customize->add_control( new WP_Customize_Color_Control( //Instantiate the color control class
$wp_customize, //Pass the $wp_customize object (required)
'bootstrapcanvaswp_footer_textcolor', //Set a unique ID for the control
array(
'label' => __( 'Footer Text Color', 'bootstrapcanvaswp' ), //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' => 'footer_textcolor', //Which setting to load and manipulate (serialized is okay)
'priority' => 17, //Determines the order this control appears in for the specified section
)
) );
//2. Register new settings to the WP database...
$wp_customize->add_setting( 'footer_linkcolor', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
array(
'default' => '#428bca', //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',
)
);
//3. Finally, we define the control itself (which links a setting to a section and renders the HTML controls)...
$wp_customize->add_control( new WP_Customize_Color_Control( //Instantiate the color control class
$wp_customize, //Pass the $wp_customize object (required)
'bootstrapcanvaswp_footer_linkcolor', //Set a unique ID for the control
array(
'label' => __( 'Footer Link Color', 'bootstrapcanvaswp' ), //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' => 'footer_linkcolor', //Which setting to load and manipulate (serialized is okay)
'priority' => 18, //Determines the order this control appears in for the specified section
)
) );
//2. Register new settings to the WP database...
$wp_customize->add_setting( 'footer_hovercolor', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
array(
'default' => '#23527c', //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' => 'refresh', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
'sanitize_callback' => 'sanitize_hex_color',
)
);
//3. Finally, we define the control itself (which links a setting to a section and renders the HTML controls)...
$wp_customize->add_control( new WP_Customize_Color_Control( //Instantiate the color control class
$wp_customize, //Pass the $wp_customize object (required)
'bootstrapcanvaswp_footer_hovercolor', //Set a unique ID for the control
array(
'label' => __( 'Footer Hover Link Color', 'bootstrapcanvaswp' ), //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' => 'footer_hovercolor', //Which setting to load and manipulate (serialized is okay)
'priority' => 19, //Determines the order this control appears in for the specified section
)
) );
//2. Register new settings to the WP database...
$wp_customize->add_setting( 'footer_backgroundcolor', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
array(
'default' => '#f9f9f9', //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',
)
);
//3. Finally, we define the control itself (which links a setting to a section and renders the HTML controls)...
$wp_customize->add_control( new WP_Customize_Color_Control( //Instantiate the color control class
$wp_customize, //Pass the $wp_customize object (required)
'bootstrapcanvaswp_footer_backgroundcolor', //Set a unique ID for the control
array(
'label' => __( 'Footer Background Color', 'bootstrapcanvaswp' ), //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' => 'footer_backgroundcolor', //Which setting to load and manipulate (serialized is okay)
'priority' => 20, //Determines the order this control appears in for the specified section
)
) );
//3. Finally, we define the control itself (which links a setting to a section and renders the HTML controls)...
$wp_customize->add_control( new WP_Customize_Color_Control( //Instantiate the color control class
$wp_customize, //Pass the $wp_customize object (required)
'bootstrapcanvaswp_background_color', //Set a unique ID for the control
array(
'label' => __( 'Background Color', 'bootstrapcanvaswp' ), //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' => 'background_color', //Which setting to load and manipulate (serialized is okay)
'priority' => 21, //Determines the order this control appears in for the specified section
)
) );
//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->add_setting( 'display_header_text' , array( 'default' => true, 'sanitize_callback' => 'bootstrapcanvaspro_sanitize_checkboxes' ) );
$wp_customize->get_setting( 'display_header_text' )->transport = 'postMessage';
$wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage';
$wp_customize->get_setting( 'background_color' )->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 Bootstrap Canvas WP 1.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 Bootstrap Canvas WP 1.0
*/
public static function live_preview() {
wp_enqueue_script(
'bootstrapcanvaswp-themecustomizer', // Give the script a unique ID
get_template_directory_uri() . '/js/theme-customizer.js', // Define the path to the JS file
array( 'jquery', 'customize-preview' ), // Define dependencies
'', // Define a version (optional)
true // Specify whether to put in footer (leave this 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 Bootstrap Canvas WP 1.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( 'Bootstrap_Canvas_WP_Customize' , 'register' ) );
// Output custom CSS to live site
add_action( 'wp_head' , array( 'Bootstrap_Canvas_WP_Customize' , 'header_output' ) );
// Enqueue live preview javascript in Theme Customizer admin screen
add_action( 'customize_preview_init' , array( 'Bootstrap_Canvas_WP_Customize' , 'live_preview' ) );
/**
* Sanitize Customizer Selections
*/
function bootstrapcanvaspro_sanitize_choices( $input, $setting ) {
global $wp_customize;
$control = $wp_customize->get_control( $setting->id );
if ( array_key_exists( $input, $control->choices ) ) {
return $input;
} else {
return $setting->default;
}
}
add_action( 'sanitize_option_theme_mods_bootstrapcanvaspro', 'bootstrapcanvaspro_sanitize_choices' );
/**
* Sanitize Customizer Checkboxes
*/
function bootstrapcanvaspro_sanitize_checkboxes( $input, $setting ) {
global $wp_customize;
$control = $wp_customize->get_control( $setting->id );
if ( !isset( $input, $control->checkbox ) ) {
return $input;
} else {
return $setting->default;
}
}
add_action( 'sanitize_option_theme_mods_bootstrapcanvaspro', 'bootstrapcanvaspro_sanitize_checkboxes' );