get_setting( 'blogname' )->transport = 'postMessage'; $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage'; } add_action( 'customize_register', 'bookinspiration_customize_register' ); /** * Binds JS handlers to make Theme Customizer preview reload changes asynchronously. * * Since bookinspiration v1.6 * */ function bookinspiration_customize_preview_js() { wp_enqueue_script( 'bookinspiration_customizer', get_template_directory_uri() . '/javascripts/customizer.js', array( 'customize-preview' ), '20130916', true ); } add_action( 'customize_preview_init', 'bookinspiration_customize_preview_js' ); /** * bookinspiration TextArea Control Class * * Since bookinspiration v0.5 **/ if ( class_exists( 'WP_Customize_Control' ) ) { # Adds textarea support to the theme customizer class bookinspirationTextAreaControl extends WP_Customize_Control { public $type = 'textarea'; # can change to 'number' for input[type=number] field public function __construct( $manager, $id, $args = array() ) { $this->statuses = array( '' => __( 'Default', 'bookinspiration' ) ); parent::__construct( $manager, $id, $args ); } public function render_content() { echo ''; } } } /** * bookinspiration Category Drop Down List Class * * modified dropdown-pages from wp-includes/class-wp-customize-control.php * * @since bookinspiration v1.0 */ if ( class_exists( 'WP_Customize_Control' ) ) { class WP_Customize_Dropdown_Categories_Control extends WP_Customize_Control { public $type = 'dropdown-categories'; public function render_content() { $dropdown = wp_dropdown_categories( array( 'name' => '_customize-dropdown-categories-' . $this->id, 'echo' => 0, 'hide_empty' => false, 'show_option_none' => '— ' . __('Select', 'reactor') . ' —', 'hide_if_empty' => false, 'selected' => $this->value(), ) ); $dropdown = str_replace('get_link(), $dropdown ); printf( '', $this->label, $dropdown ); } } } /** * Returns the options array for bookinspiration * @since bookinspiration 1.3.5 */ function bookinspiration_options($name, $default = false) { $options = ( get_option( 'bookinspiration_options' ) ) ? get_option( 'bookinspiration_options' ) : null; // return the option if it exists if ( isset( $options[ $name ] ) ) { return apply_filters( 'bookinspiration_options_$name', $options[ $name ] ); } // return default if nothing else return apply_filters( 'bookinspiration_options_$name', $default ); } /** * bookinspiration's Theme Customizer Settings * * Since bookinspiration v0.5 * **/ add_action( 'customize_register', 'bookinspiration_customizer' ); function bookinspiration_customizer($wp_customize){ /** * Remove default WP Customize sections * * @since 1.6 * */ $wp_customize->remove_section('background_image'); $wp_customize->remove_section('header_image'); $wp_customize->remove_section('static_front_page'); # General Settings $wp_customize->add_section('bookinspiration_general_settings', array( 'title' => 'General Settings', 'description' => __('Website General Settings', 'bookinspiration'), 'priority' => 59, 'transport' => 'postMessage', )); $wp_customize->add_setting('blogname', array( 'default' => get_option('blogname'), 'type' => 'option', 'capability' => 'manage_options', 'transport' => 'postMessage', ) ); $wp_customize->add_control('blogname', array( 'label' => __('Site Title', 'bookinspiration'), 'section' => 'bookinspiration_general_settings', 'priority' => 1, ) ); $wp_customize->add_setting('blogdescription', array( 'default' => get_option('blogdescription'), 'type' => 'option', 'capability' => 'manage_options', 'transport' => 'postMessage', ) ); $wp_customize->add_control('blogdescription', array( 'label' => __('Tagline', 'bookinspiration'), 'section' => 'bookinspiration_general_settings', 'priority' => 2, ) ); $wp_customize->add_setting('display_header_text', array( 'default' => 1, 'type' => 'option', 'capability' => 'manage_options', 'transport' => 'postMessage', ) ); $wp_customize->add_setting('bookinspiration_options[favicon]', array( 'default' => '', 'type' => 'option', 'capability' => 'manage_options', ) ); $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'bookinspiration_favicon', array( 'label' => __('Favicon', 'bookinspiration'), 'section' => 'bookinspiration_general_settings', 'settings' => 'bookinspiration_options[favicon]', 'priority' => 5, ) ) ); $wp_customize->add_control( 'display_header_text', array( 'settings' => 'header_textcolor', 'label' => __( 'Show Title & Tagline', 'bookinspiration' ), 'section' => 'bookinspiration_general_settings', 'type' => 'checkbox', 'priority' => 4, ) ); $wp_customize->add_section( 'header_image', array( 'title' => __( 'Header Settings', 'bookinspiration' ), 'theme_supports' => 'custom-header', 'priority' => 60, ) ); $wp_customize->add_section( 'background_image', array( 'title' => __( 'Background Settings', 'bookinspiration' ), 'theme_supports' => 'custom-background', 'priority' => 80, ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'header_textcolor', array( 'label' => __( 'Header Text Color', 'bookinspiration' ), 'section' => 'header_image', ) ) ); $wp_customize->add_setting( 'background_color', array( 'default' => get_theme_support( 'custom-background', 'default-color' ), 'theme_supports' => 'custom-background', 'sanitize_callback' => 'sanitize_hex_color_no_hash', 'sanitize_js_callback' => 'maybe_hash_hex_color', ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'background_color', array( 'label' => __( 'Background Color', 'bookinspiration' ), 'section' => 'background_image', ) ) ); # Orbit Slider as Featured Slider $wp_customize->add_section('bookinspiration_featured_categories', array( 'title' => 'Featured Posts Slider', 'priority' => 81, 'description' => __('Orbit Slider Configuration', 'bookinspiration'), 'transport' => 'postMessage', )); $wp_customize->add_setting('bookinspiration_options[featured_category]', array( 'default' => '', 'type' => 'option', 'capability' => 'manage_options', ) ); $wp_customize->add_control( new WP_Customize_Dropdown_Categories_Control( $wp_customize, 'bookinspiration_featured_category', array( 'label' => __('Featured Category
The slides are responsive but make sure your image has at least 640x290.', 'bookinspiration'), 'section' => 'bookinspiration_featured_categories', 'type' => 'dropdown-categories', 'settings' => 'bookinspiration_options[featured_category]', 'priority' => 1, ) ) ); $wp_customize->add_setting( 'bookinspiration_options[number_slide]', array( 'default' => '5', 'type' => 'option', 'capability' => 'manage_options', 'transport' => 'postMessage', ) ); $wp_customize->add_control( 'bookinspiration_options[number_slide]', array( 'label' => __('Number Slide', 'bookinspiration'), 'section' => 'bookinspiration_featured_categories', 'type' => 'text', 'priority' => 2, ) ); # Orbit Slide Indicator $wp_customize->add_setting('bookinspiration_options[slide_indicator]', array( 'capability' => 'edit_theme_options', 'type' => 'option', ) ); $wp_customize->add_control('bookinspiration_options[slide_indicator]', array( 'settings' => 'bookinspiration_options[slide_indicator]', 'label' => __('Slide Indicator', 'bookinspiration'), 'section' => 'bookinspiration_featured_categories', 'type' => 'checkbox', 'transport' => 'postMessage', 'priority' => 3, ) ); # Use default image for slides without featured post image $wp_customize->add_setting('bookinspiration_options[default_slides_image]', array( 'capability' => 'edit_theme_options', 'default' => '1', 'type' => 'option', ) ); $wp_customize->add_control('bookinspiration_options[default_slides_image]', array( 'settings' => 'bookinspiration_options[default_slides_image]', 'label' => __('Use built in default image for post without featured image.', 'bookinspiration'), 'section' => 'bookinspiration_featured_categories', 'type' => 'checkbox', 'priority' => 4, ) ); # Display Top Bar Title $wp_customize->add_setting('bookinspiration_options[show_topbar_title]', array( 'capability' => 'edit_theme_options', 'type' => 'option', ) ); $wp_customize->add_control('bookinspiration_options[show_topbar_title]', array( 'settings' => 'bookinspiration_options[show_topbar_title]', 'label' => __('Display Top Bar Title', 'bookinspiration'), 'section' => 'nav', 'type' => 'checkbox', 'transport' => 'postMessage', 'priority' => 0, ) ); # Top Bar Title $wp_customize->add_setting( 'bookinspiration_options[topbar_title]', array( 'default' => get_bloginfo('name'), 'type' => 'option', 'capability' => 'manage_options', 'transport' => 'postMessage', ) ); $wp_customize->add_control( 'bookinspiration_options[topbar_title]', array( 'label' => __('Top Bar Title', 'bookinspiration'), 'section' => 'nav', 'type' => 'text', 'priority' => 1, ) ); $wp_customize->add_setting( 'bookinspiration_options[topbar_title_url]', array( 'default' => home_url(), 'type' => 'option', 'capability' => 'manage_options', ) ); $wp_customize->add_control( 'bookinspiration_options[topbar_title_url]', array( 'label' => __('Top Bar URL', 'bookinspiration'), 'section' => 'nav', 'type' => 'text', 'priority' => 2, ) ); # Sticky Top Bar Option $wp_customize->add_setting('bookinspiration_options[sticky_topbar]', array( 'capability' => 'edit_theme_options', 'type' => 'option', ) ); $wp_customize->add_control('bookinspiration_options[sticky_topbar]', array( 'settings' => 'bookinspiration_options[sticky_topbar]', 'label' => __('Sticky Top Bar', 'bookinspiration'), 'section' => 'nav', 'type' => 'checkbox', 'transport' => 'postMessage', 'priority' => 3, ) ); # Contain Top Bar Layout Width $wp_customize->add_setting('bookinspiration_options[contain2grid]', array( 'capability' => 'manage_options', 'type' => 'option', ) ); $wp_customize->add_control('bookinspiration_options[contain2grid]', array( 'settings' => 'bookinspiration_options[contain2grid]', 'label' => __('Contain Top Bar Layout Width', 'bookinspiration'), 'section' => 'nav', 'type' => 'checkbox', 'transport' => 'postMessage', 'priority' => 4, ) ); # Top Bar Search Form $wp_customize->add_setting('bookinspiration_options[search_form]', array( 'default' => '1', 'capability' => 'manage_options', 'type' => 'option', ) ); $wp_customize->add_control('bookinspiration_options[search_form]', array( 'type' => 'checkbox', 'label' => __('Top Bar Search Form', 'bookinspiration'), 'section' => 'nav', 'priority' => 5, ) ); # Front Page Settings $wp_customize->add_section( 'static_front_page', array( 'title' => __( 'Front Page Settings', 'bookinspiration' ), 'priority' => 120, 'description' => __( 'Your theme supports a static front page.', 'bookinspiration'), ) ); $wp_customize->add_setting( 'bookinspiration_options[sidebar_position]', array( 'default' => 'left', 'capability' => 'edit_theme_options', 'type' => 'option', ) ); $wp_customize->add_control( 'bookinspiration_options[sidebar_position]', array( 'type' => 'radio', 'label' => 'Sidebar Position', 'section' => 'static_front_page', 'priority' => 1, 'choices' => array( 'left' => 'Left', 'right' => 'Right', ), ) ); # Force display post excerpt with custom length $wp_customize->add_setting('bookinspiration_options[excerpt_length]', array( 'default' => '0', 'type' => 'option', 'capability'=> 'manage_options', ) ); $wp_customize->add_control('bookinspiration_options[excerpt_length]', array( 'label' => __('Force excerpt instead content. Custom length count by words, set 0 mean disable this feature.', 'bookinspiration'), 'section' => 'static_front_page', 'type' => 'text', 'priority' => 5, ) ); # Custom Read More Text $wp_customize->add_setting('bookinspiration_options[post_readmore]', array( 'default' => __('Read More »', 'bookinspiration'), 'type' => 'option', 'capability' => 'manage_options', 'transport' => 'postMessage', ) ); $wp_customize->add_control('bookinspiration_options[post_readmore]', array( 'label' => __('Read More Text', 'bookinspiration'), 'section' => 'static_front_page', 'type' => 'text', 'priority' => 6, ) ); $wp_customize->add_setting( 'show_on_front', array( 'default' => get_option( 'show_on_front' ), 'capability' => 'manage_options', 'type' => 'option', // 'theme_supports' => 'static-front-page', ) ); $wp_customize->add_control( 'show_on_front', array( 'label' => __( 'Front page displays', 'bookinspiration' ), 'section' => 'static_front_page', 'type' => 'radio', 'choices' => array( 'posts' => __( 'Your latest posts', 'bookinspiration' ), 'page' => __( 'A static page', 'bookinspiration' ), ), ) ); $wp_customize->add_setting( 'page_on_front', array( 'type' => 'option', 'capability' => 'manage_options', ) ); $wp_customize->add_control( 'page_on_front', array( 'label' => __( 'Front page', 'bookinspiration' ), 'section' => 'static_front_page', 'type' => 'dropdown-pages', ) ); $wp_customize->add_setting( 'page_for_posts', array( 'type' => 'option', 'capability' => 'manage_options', // 'theme_supports' => 'static-front-page', ) ); $wp_customize->add_control( 'page_for_posts', array( 'label' => __( 'Posts page', 'bookinspiration' ), 'section' => 'static_front_page', 'type' => 'dropdown-pages', ) ); # Singular Settings $wp_customize->add_section( 'singular_settings', array( 'title' => __( 'Post Settings', 'bookinspiration' ), 'priority' => 130, 'description' => __( 'In this section, you can turn on/off post features like: meta, tags, post navigation, author information...', 'bookinspiration'), ) ); # Breadcrumb Control $wp_customize->add_setting('bookinspiration_options[breadcrumb]', array( 'capability' => 'manage_options', 'type' => 'option', ) ); $wp_customize->add_control('bookinspiration_options[breadcrumb]', array( 'type' => 'checkbox', 'label' => __('Display Breadcrumb','bookinspiration'), 'section' => 'singular_settings', 'transport' => 'postMessage', 'priority' => 1, ) ); $wp_customize->add_setting( 'bookinspiration_options[post_meta]', array( 'default' => '1', 'capability' => 'edit_theme_options', 'type' => 'option', ) ); $wp_customize->add_control( 'bookinspiration_options[post_meta]', array( 'settings' => 'bookinspiration_options[post_meta]', 'label' => 'Show Post meta.', 'section' => 'singular_settings', 'priority' => 2, 'type' => 'checkbox', ) ); $wp_customize->add_setting( 'bookinspiration_options[display_tags]', array( 'default' => '1', 'capability' => 'edit_theme_options', 'type' => 'option', ) ); $wp_customize->add_control( 'bookinspiration_options[display_tags]', array( 'settings' => 'bookinspiration_options[display_tags]', 'label' => 'Display post tags.', 'section' => 'singular_settings', 'priority' => 3, 'type' => 'checkbox', ) ); $wp_customize->add_setting( 'bookinspiration_options[posts_navigation]', array( 'default' => '1', 'capability' => 'edit_theme_options', 'type' => 'option', ) ); $wp_customize->add_control( 'bookinspiration_options[posts_navigation]', array( 'settings' => 'bookinspiration_options[posts_navigation]', 'label' => 'Post navigation.', 'section' => 'singular_settings', 'priority' => 4, 'type' => 'checkbox', ) ); $wp_customize->add_setting( 'bookinspiration_options[post_author]', array( 'default' => '1', 'capability' => 'edit_theme_options', 'type' => 'option', ) ); $wp_customize->add_control( 'bookinspiration_options[post_author]', array( 'settings' => 'bookinspiration_options[post_author]', 'label' => 'Display author bio.', 'section' => 'singular_settings', 'priority' => 5, 'type' => 'checkbox', ) ); } /** * Widgetable for Sidebar, Footer * Since bookinspiration v1.1 */ $sidebars = array('Sidebar'); foreach ($sidebars as $sidebar) { register_sidebar(array('name'=> $sidebar, 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

' )); } $sidebars = array('Footer'); foreach ($sidebars as $sidebar) { register_sidebar(array('name'=> $sidebar, 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

' )); } /** * Get number of active WordPress widgets in a footer widget area * Since bookinspiration v1.5 */ function bookinspiration_widgets_count( $sidebar_id ) { # Default Foundation Grid is 12 columns $total_columns = '12'; $sidebars_widgets = wp_get_sidebars_widgets(); // if sidebar doesn't exist return error if ( !isset( $sidebars_widgets[$sidebar_id] ) ) { return __('Invalid sidebar ID', 'bookinspiration'); } # return (int) count( (array) $sidebars_widgets[ $sidebar_id ] ); $count_widgets = count( $sidebars_widgets[ $sidebar_id ] ); /* count number of widgets in the sidebar and do some simple math to calculate the columns */ switch( $count_widgets ) { case 1 : $count_widgets = $columns; break; case 2 : $count_widgets = $total_columns / 2; break; case 3 : $count_widgets = $total_columns / 3; break; case 4 : $count_widgets = $total_columns / 4; break; case 5 : $count_widgets = $total_columns / 5; break; case 6 : $count_widgets = $total_columns / 6; break; case 7 : $count_widgets = $total_columns / 7; break; case 8 : $count_widgets = $total_columns / 8; break; } return $count_widgets = ceil( $count_widgets ); } /** * Footer Naviagation * Since bookinspiration v1.1 */ if (!function_exists('bookinspiration_footer_navigation')) : function bookinspiration_footer_navigation() { $menu = wp_nav_menu(array( 'echo' => false, 'items_wrap' => '
%3$s
', 'theme_location' => 'footer_navigation', 'container' => false, 'menu_class' => 'sub-nav right' )); $search = array('', '', 'current-menu-item'); $replace = array('', '', 'active'); echo str_replace($search, $replace, $menu); } endif; ?>