/** * Get a default value from plugin's config * * @param $val * @param string $default * @return string * @uses basicbootstrap_get_config() * @since WP_Basic_Bootstrap 1.0 */ public function getDefault($val, $default = '') { if (empty($this->defaults)) { $this->defaults = basicbootstrap_get_config('defaults'); } return isset($this->defaults[$val]) ? $this->defaults[$val] : $default; }
<?php /** * This file defines the default customizer configuration of the theme * * WARNING - Translation files are not yet loaded here so the translation process * must be done on data loading. * * @package WP_Basic_Bootstrap * @since WP_Basic_Bootstrap 1.0 */ $available_fonts = basicbootstrap_get_config('available_fonts'); /** * The customizer configuration table * * ## Map * * - theme styling: colors, fonts, background image, header image, navbar * - theme layout: pages layout, show/hide * - theme templating: content options * */ global $basicbootstrap_customizer_config; $basicbootstrap_customizer_config = array('title_tagline' => array('object' => 'settings', array('id' => 'blogname', 'transport' => 'postMessage'), array('id' => 'blogdescription', 'transport' => 'postMessage'), array('id' => 'copyright_text', 'label' => __('Copyright text', 'basicbootstrap'), 'sanitize_callback' => 'sanitize_simple_html_field', 'priority' => 52)), 'basicbootstrap_fonts' => array('object' => 'section', 'title' => __('Fonts', 'basicbootstrap'), 'settings' => array(array('id' => 'body_fontfamily', 'label' => __('Body Text Font', 'basicbootstrap'), 'control_type' => 'select', 'choices' => $available_fonts, 'sanitize_callback' => 'sanitize_font_selection'), array('id' => 'headings_fontfamily', 'label' => __('Headings Font', 'basicbootstrap'), 'control_type' => 'select', 'choices' => $available_fonts, 'sanitize_callback' => 'sanitize_font_selection'), array('id' => 'menu_fontfamily', 'label' => __('Menu Font', 'basicbootstrap'), 'control_type' => 'select', 'choices' => $available_fonts, 'sanitize_callback' => 'sanitize_font_selection'))), 'colors' => array('object' => 'settings', array('id' => 'header_textcolor', 'transport' => 'postMessage', 'section' => 'colors'), array('id' => 'body_textcolor', 'label' => __('Text Color', 'basicbootstrap'), 'control_type' => 'color'), array('id' => 'link_textcolor', 'label' => __('Link Color', 'basicbootstrap'), 'control_type' => 'color'), array('id' => 'hover_textcolor', 'label' => __('Hover Link Color', 'basicbootstrap'), 'control_type' => 'color'), array('id' => 'headings_textcolor', 'label' => __('Headings Color', 'basicbootstrap'), 'control_type' => 'color'), array('id' => 'primary_menucolor', 'label' => __('Primary Menu Color', 'basicbootstrap'), 'control_type' => 'color'), array('id' => 'primary_linkcolor', 'label' => __('Primary Link Color', 'basicbootstrap'), 'control_type' => 'color'), array('id' => 'primary_hovercolor', 'label' => __('Primary Hover Link Color', 'basicbootstrap'), 'control_type' => 'color'), array('id' => 'primary_hoverbackground', 'label' => __('Primary Hover Background Color', 'basicbootstrap'), 'control_type' => 'color'), array('id' => 'primary_activecolor', 'label' => __('Primary Active Link Color', 'basicbootstrap'), 'control_type' => 'color'), array('id' => 'primary_activebackground', 'label' => __('Primary Active Background Color', 'basicbootstrap'), 'control_type' => 'color'), array('id' => 'dropdown_menucolor', 'label' => __('Dropdown Menu Color', 'basicbootstrap'), 'control_type' => 'color'), array('id' => 'dropdown_linkcolor', 'label' => __('Dropdown Link Color', 'basicbootstrap'), 'control_type' => 'color'), array('id' => 'dropdown_hovercolor', 'label' => __('Dropdown Hover Link Color', 'basicbootstrap'), 'control_type' => 'color'), array('id' => 'dropdown_hoverbackground', 'label' => __('Dropdown Hover Background Color', 'basicbootstrap'), 'transport' => 'refresh', 'control_type' => 'color'), array('id' => 'dropdown_activecolor', 'label' => __('Dropdown Active Link Color', 'basicbootstrap'), 'control_type' => 'color'), array('id' => 'dropdown_activebackground', 'label' => __('Dropdown Active Background Color', 'basicbootstrap'), 'control_type' => 'color'), array('id' => 'footer_textcolor', 'label' => __('Footer Text Color', 'basicbootstrap'), 'control_type' => 'color'), array('id' => 'footer_linkcolor', 'label' => __('Footer Link Color', 'basicbootstrap'), 'control_type' => 'color'), array('id' => 'footer_hovercolor', 'label' => __('Footer Hover Link Color', 'basicbootstrap'), 'control_type' => 'color'), array('id' => 'footer_backgroundcolor', 'label' => __('Footer Background Color', 'basicbootstrap'), 'control_type' => 'color')), 'basicbootstrap_layout_page' => array('object' => 'section', 'title' => __('Pages Layout', 'basicbootstrap'), 'description' => __('You can set here the default layouts used for blog pages (any post page) and others (any page that is not a post: home, pages, search ...).', 'basicbootstrap'), 'priority' => 1, 'settings' => array(array('id' => 'blog_pages_layout', 'label' => __('Blog Pages Default Template', 'basicbootstrap'), 'description' => __('Select here the default template for BLOG PAGES.', 'basicbootstrap'), 'control_type' => 'select', 'choices' => array('full_width' => __('Full Width', 'basicbootstrap'), 'full_width_offset' => __('Full Width With Offset', 'basicbootstrap'), 'left_sidebar' => __('Left Sidebar', 'basicbootstrap'), 'right_sidebar' => __('Right Sidebar', 'basicbootstrap')), 'transport' => 'refresh'), array('id' => 'not_blog_pages_layout', 'label' => __('Other Pages Default Template', 'basicbootstrap'), 'description' => __('Select here the default template for NON-BLOG PAGES.', 'basicbootstrap'), 'control_type' => 'select', 'choices' => array('full_width' => __('Full Width', 'basicbootstrap'), 'full_width_offset' => __('Full Width With Offset', 'basicbootstrap'), 'left_sidebar' => __('Left Sidebar', 'basicbootstrap'), 'right_sidebar' => __('Right Sidebar', 'basicbootstrap')), 'transport' => 'refresh'), array('id' => 'posts_lists_layout', 'label' => __('Posts Lists Template', 'basicbootstrap'), 'description' => __('Select here the number of columns used for posts lists.', 'basicbootstrap'), 'control_type' => 'select', 'choices' => array('1_col' => __('One Column', 'basicbootstrap'), '2_cols' => __('Two Columns', 'basicbootstrap'), '3_cols' => __('Three Columns', 'basicbootstrap')), 'transport' => 'refresh'))), 'basicbootstrap_layout_navbar' => array('object' => 'section', 'title' => __('Navbar Layout', 'basicbootstrap'), 'description' => __('You can set here the default layouts your website main navigation bar.', 'basicbootstrap'), 'priority' => 2, 'settings' => array(array('id' => 'navbar_type', 'label' => __('Navbar Position', 'basicbootstrap'), 'description' => __('You can define here the type of your navbar (for more info, see <a href="http://getbootstrap.com/components/#navbar">getbootstrap.com</a>).', 'basicbootstrap'), 'control_type' => 'select', 'choices' => array('default' => __('Default Classic Navbar', 'basicbootstrap'), 'fixed_top' => __('Fixed to Top Navbar', 'basicbootstrap'), 'fixed_bottom' => __('Fixed to Bottom Navbar', 'basicbootstrap'), 'static_top' => __('Static Top Navbar', 'basicbootstrap')), 'transport' => 'refresh'), array('id' => 'navbar_style', 'label' => __('Navbar Styling', 'basicbootstrap'), 'description' => __('You can define here the style of your navbar (for more info, see <a href="http://getbootstrap.com/components/#navbar">getbootstrap.com</a>).', 'basicbootstrap'), 'control_type' => 'select', 'choices' => array('default' => __('Default Classic Navbar', 'basicbootstrap'), 'inverse' => __('Inverted Navbar', 'basicbootstrap'), 'custom' => __('Custom Navbar (navbar-custom class)', 'basicbootstrap')), 'transport' => 'refresh'), array('id' => 'show_navbar_brand', 'label' => __('Show Navbar Brand', 'basicbootstrap'), 'description' => __('This will display the site name as first information of the navigation bar.', 'basicbootstrap'), 'control_type' => 'checkbox', 'transport' => 'refresh'))), 'basicbootstrap_templating_body' => array('object' => 'section', 'title' => __('Content Templating', 'basicbootstrap'), 'description' => __('You can here define the look of your pages main contents.', 'basicbootstrap'), 'settings' => array(array('id' => 'show_protected_posts', 'label' => __('Show Protected Posts in Lists', 'basicbootstrap'), 'control_type' => 'checkbox', 'transport' => 'refresh'), array('id' => 'visible_breadcrumb', 'label' => __('Visible Breadcrumb (hidden otherwise)', 'basicbootstrap'), 'control_type' => 'checkbox', 'transport' => 'refresh'), array('id' => 'show_post_excerpt', 'label' => __('Use Post Excerpts as Intro', 'basicbootstrap'), 'description' => __('This will show the excerpt as the introduction of a post on the post page if it is defined.', 'basicbootstrap'), 'control_type' => 'checkbox', 'transport' => 'refresh'), array('id' => 'excerpt_max_length', 'label' => __('Excerpt Length', 'basicbootstrap'), 'description' => __('This will set the number of words extracted from a post content to generate its excerpt in posts list.', 'basicbootstrap'), 'control_type' => 'select', 'choices' => array('55' => '55', '75' => '75', '100' => '100', '120' => '120', '140' => '140', '160' => '160', '180' => '180', '200' => '200'), 'transport' => 'refresh'), array('id' => 'read_more', 'label' => __('Read More Text', 'basicbootstrap'), 'transport' => 'refresh'), array('id' => 'show_read_more_buttons', 'label' => __('Show Read More Buttons', 'basicbootstrap'), 'description' => __('Add a "read more" button to posts excerpts in lists.', 'basicbootstrap'), 'control_type' => 'checkbox', 'transport' => 'refresh'), array('id' => 'sticky_posts_to_show', 'label' => __('Sticky Posts To Show', 'basicbootstrap'), 'description' => __('This will set the number of sticky posts shown as featured (0 will disable this feature).', 'basicbootstrap'), 'control_type' => 'select', 'choices' => array('0' => '0', '1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', '10' => '10'), 'transport' => 'refresh'), array('id' => 'sticky_posts_excerpt_max_length', 'label' => __('Sticky Excerpt Length', 'basicbootstrap'), 'description' => __('This will set the number of words extracted from a sticky post content to generate its excerpt on the sticky post view.', 'basicbootstrap'), 'control_type' => 'select', 'choices' => array('55' => '55', '75' => '75', '100' => '100', '120' => '120', '140' => '140', '160' => '160', '180' => '180', '200' => '200'), 'transport' => 'refresh'), array('id' => 'numerical_pagination_limit', 'label' => __('Pagination Limit', 'basicbootstrap'), 'description' => __('This will set the number of pages to show before AND after current one in numerical pagination.', 'basicbootstrap'), 'control_type' => 'select', 'choices' => array('1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', '10' => '10'), 'transport' => 'refresh'), array('id' => 'show_sharing_links_page', 'label' => __('Show Sharing Links on Pages', 'basicbootstrap'), 'control_type' => 'checkbox', 'transport' => 'refresh'), array('id' => 'show_sharing_links_post', 'label' => __('Show Sharing Links on Posts', 'basicbootstrap'), 'control_type' => 'checkbox', 'transport' => 'refresh'), array('id' => 'show_sharing_links_attachment', 'label' => __('Show Sharing Links on Attachments', 'basicbootstrap'), 'control_type' => 'checkbox', 'transport' => 'refresh'))), 'basicbootstrap_templating_header_footer' => array('object' => 'section', 'title' => __('Header & Footer Templating', 'basicbootstrap'), 'description' => __('You can here show or hide some of the blocks of the default header and footer templating construction.', 'basicbootstrap'), 'settings' => array(array('id' => 'display_header_text', 'delete' => true), array('id' => 'display_header', 'label' => __('Display Header Identity Block', 'basicbootstrap'), 'control_type' => 'checkbox', 'transport' => 'refresh'), array('id' => 'display_header_logo', 'label' => __('Display Header Logo', 'basicbootstrap'), 'control_type' => 'checkbox', 'transport' => 'refresh'), array('id' => 'display_header_searchbox', 'label' => __('Display Header Searchbox', 'basicbootstrap'), 'control_type' => 'checkbox', 'transport' => 'refresh'), array('id' => 'display_footer_copyright', 'label' => __('Display Footer Copyright', 'basicbootstrap'), 'control_type' => 'checkbox', 'transport' => 'refresh'))), 'basicbootstrap_templating_meta_data' => array('object' => 'section', 'title' => __('Contents Meta-Data', 'basicbootstrap'), 'description' => __('You can here show or hide some of your website contents meta-data.', 'basicbootstrap'), 'settings' => array(array('id' => 'show_author_meta', 'label' => __('Show Author', 'basicbootstrap'), 'control_type' => 'checkbox', 'transport' => 'refresh'), array('id' => 'show_pubdate_meta', 'label' => __('Show Publication Date', 'basicbootstrap'), 'control_type' => 'checkbox', 'transport' => 'refresh'), array('id' => 'show_moddate_meta', 'label' => __('Show Last Update Date', 'basicbootstrap'), 'control_type' => 'checkbox', 'transport' => 'refresh'), array('id' => 'show_post_format_meta', 'label' => __('Show Post Format', 'basicbootstrap'), 'control_type' => 'checkbox', 'transport' => 'refresh'), array('id' => 'show_post_cats', 'label' => __('Show Post Categories', 'basicbootstrap'), 'control_type' => 'checkbox', 'transport' => 'refresh'), array('id' => 'show_post_tags', 'label' => __('Show Post Tags', 'basicbootstrap'), 'control_type' => 'checkbox', 'transport' => 'refresh'), array('id' => 'show_comments_link', 'label' => __('Show Comments Link', 'basicbootstrap'), 'control_type' => 'checkbox', 'transport' => 'refresh'), array('id' => 'show_permalink', 'label' => __('Show Permalink', 'basicbootstrap'), 'control_type' => 'checkbox', 'transport' => 'refresh'), array('id' => 'show_edit_links', 'label' => __('Show Edit Links', 'basicbootstrap'), 'control_type' => 'checkbox', 'transport' => 'refresh'), array('id' => 'show_edit_comment_links', 'label' => __('Show Edit Comment Links', 'basicbootstrap'), 'control_type' => 'checkbox', 'transport' => 'refresh'), array('id' => 'show_attachment_mime_type', 'label' => __('Show Attachments MIME Types', 'basicbootstrap'), 'control_type' => 'checkbox', 'transport' => 'refresh'), array('id' => 'show_attachment_sizes', 'label' => __('Show Attachment Sizes', 'basicbootstrap'), 'control_type' => 'checkbox', 'transport' => 'refresh'), array('id' => 'show_attachment_link', 'label' => __('Show Attachment Link', 'basicbootstrap'), 'control_type' => 'checkbox', 'transport' => 'refresh'), array('id' => 'show_author_posts_number', 'label' => __('Show Author Posts Number', 'basicbootstrap'), 'control_type' => 'checkbox', 'transport' => 'refresh'))), 'basicbootstrap_styling' => array('object' => 'panel', 'title' => __('Theme Styling', 'basicbootstrap'), 'description' => __('You can here define some style options of your theme.', 'basicbootstrap'), 'priority' => 121, 'sections' => array(array('id' => 'basicbootstrap_fonts'), array('id' => 'colors'), array('id' => 'header_image'), array('id' => 'background_image'))), 'basicbootstrap_templating' => array('object' => 'panel', 'title' => __('Theme Templating', 'basicbootstrap'), 'description' => __('You can here show or hide some of the blocks of the default templating construction. You can also define the look of the navigation bar.', 'basicbootstrap'), 'priority' => 122, 'sections' => array(array('id' => 'basicbootstrap_templating_header_footer'), array('id' => 'basicbootstrap_templating_body'), array('id' => 'basicbootstrap_templating_meta_data'))), 'basicbootstrap_layout' => array('object' => 'panel', 'title' => __('Theme Layout', 'basicbootstrap'), 'description' => __('You can set here various settings to customize your website global rendering.', 'basicbootstrap'), 'priority' => 123, 'sections' => array(array('id' => 'basicbootstrap_layout_page'), array('id' => 'basicbootstrap_layout_navbar'))), 'social_links' => array('object' => 'section', 'priority' => 90, 'title' => __('Social Links', 'basicbootstrap'), 'description' => __('Settings for the social icons navbar menu. If you want to hide an icon then leave it blank.', 'basicbootstrap'), 'settings' => array(array('id' => 'display_social_icons', 'label' => __('Display Automatic Social Icons', 'basicbootstrap'), 'description' => __('Disable this to use a custom user menu instead.', 'basicbootstrap'), 'control_type' => 'checkbox', 'transport' => 'refresh'), 'facebook_url' => array('label' => __('Facebook URL', 'basicbootstrap'), 'sanitize_callback' => 'esc_url_raw'), 'twitter_url' => array('label' => __('Twitter URL', 'basicbootstrap'), 'sanitize_callback' => 'esc_url_raw'), 'google_plus_url' => array('label' => __('Google+ URL', 'basicbootstrap'), 'sanitize_callback' => 'esc_url_raw'), 'linkedin_url' => array('label' => __('LinkedIn URL', 'basicbootstrap'), 'sanitize_callback' => 'esc_url_raw'), 'skype_url' => array('label' => __('Skype URL', 'basicbootstrap'), 'sanitize_callback' => 'esc_url_raw'), 'pinterest_url' => array('label' => __('Pinterest URL', 'basicbootstrap'), 'sanitize_callback' => 'esc_url_raw'), 'youtube_url' => array('label' => __('YouTube URL', 'basicbootstrap'), 'sanitize_callback' => 'esc_url_raw'), 'vimedo_url' => array('label' => __('Vimeo URL', 'basicbootstrap'), 'sanitize_callback' => 'esc_url_raw'), 'dribbble_url' => array('label' => __('Dribbble URL', 'basicbootstrap'), 'sanitize_callback' => 'esc_url_raw'), 'flickr_url' => array('label' => __('Flickr URL', 'basicbootstrap'), 'sanitize_callback' => 'esc_url_raw'), 'tumblr_url' => array('label' => __('Tumblr URL', 'basicbootstrap'), 'sanitize_callback' => 'esc_url_raw'), 'github_url' => array('label' => __('Github URL', 'basicbootstrap'), 'sanitize_callback' => 'esc_url_raw'), 'instagram_url' => array('label' => __('Instagram URL', 'basicbootstrap'), 'sanitize_callback' => 'esc_url_raw'), 'stack_overflow_url' => array('label' => __('Stack Overflow URL', 'basicbootstrap'), 'sanitize_callback' => 'esc_url_raw'), 'stack_exchange_url' => array('label' => __('Stack Exchange URL', 'basicbootstrap'), 'sanitize_callback' => 'esc_url_raw'), 'diaspora_url' => array('label' => __('Diaspora URL', 'basicbootstrap'), 'sanitize_callback' => 'esc_url_raw'), 'rss_url' => array('label' => __('RSS URL', 'basicbootstrap'), 'sanitize_callback' => 'esc_url_raw', 'description' => __('By default it should be <code>/feed/</code>', 'basicbootstrap'), 'default' => '/feed/'))), 'custom_css_section' => array('object' => 'section', 'title' => __('Custom Code', 'basicbootstrap'), 'description' => __('Use this section to enter your custom CSS code. It will be included in the head section of the site.', 'basicbootstrap'), 'priority' => 200, 'settings' => array(array('id' => 'custom_css', 'sanitize_callback' => 'wp_filter_nohtml_kses', 'label' => __('Custom CSS', 'basicbootstrap'), 'control_type' => 'textarea', 'transport' => 'refresh'))));
/** * Retrieve a configuration entry for image sizes * * Returned array is like: * * array( * 0 => <width> * width => <width> * 1 => <height> * height => <height> * ) * * @param string $type * @return array */ function get_basicbootsrap_image_sizes($type = 'post_thumbnails') { $config = basicbootstrap_get_config('image_sizes'); $data = array(0 => null, 1 => null, 'width' => null, 'height' => null); if (is_array($config) && isset($config[$type]) && is_array($config[$type])) { if (isset($config[$type]['width'])) { $data[0] = $config[$type]['width']; $data['width'] = $config[$type]['width']; } if (isset($config[$type]['width'])) { $data[1] = $config[$type]['height']; $data['height'] = $config[$type]['height']; } } return $data; }
/** * Sanitize Customizer Font Selections */ function sanitize_font_selection($input) { $available_fonts = basicbootstrap_get_config('available_fonts'); if (array_key_exists($input, $available_fonts)) { return $input; } else { return key($available_fonts); } }
/** * Register widgetized areas, including main sidebar and three widget-ready columns in the footer. * * @uses register_sidebar() */ public static function widgetsInit() { // register sidebars foreach (basicbootstrap_get_config('sidebars') as $sidebar) { foreach (array('name', 'description') as $item) { if (isset($sidebar[$item])) { $sidebar[$item] = __($sidebar[$item], 'basicbootstrap'); } } register_sidebar($sidebar); } // replace the recent_posts widget unregister_widget('WP_Widget_Recent_Posts'); basicbootstrap_load_class('WP_Basic_Bootstrap_Widget_Recent_Posts'); register_widget('WP_Basic_Bootstrap_Widget_Recent_Posts'); // replace the recent_comments widget unregister_widget('WP_Widget_Recent_Comments'); basicbootstrap_load_class('WP_Basic_Bootstrap_Widget_Recent_Comments'); register_widget('WP_Basic_Bootstrap_Widget_Recent_Comments'); // replace the archives widget unregister_widget('WP_Widget_Archives'); basicbootstrap_load_class('WP_Basic_Bootstrap_Widget_Archives'); register_widget('WP_Basic_Bootstrap_Widget_Archives'); // new author block widget basicbootstrap_load_class('WP_Basic_Bootstrap_Widget_Author_Block'); register_widget('WP_Basic_Bootstrap_Widget_Author_Block'); // adapt dropdowns add_filter('widget_categories_dropdown_args', function ($args) { if (!isset($args['class'])) { $args['class'] = ''; } $args['class'] .= ' form-control'; return $args; }); add_filter('widget_archives_dropdown_args', function ($args) { if (!isset($args['class'])) { $args['class'] = ''; } $args['class'] .= ' form-control'; return $args; }); }