B3_URI . '/images/b3-logo.png')); register_nav_menus(array('primary' => __('Primary Menu', 'b3'),)); add_theme_support('post-formats', array('aside', 'image', 'video', 'quote', 'link')); add_theme_support('custom-background', apply_filters('b3_custom_background_args', array('default-color' => 'ffffff', 'default-image' => '',) )); add_theme_support('post-thumbnails'); add_filter('wp_nav_menu_container_allowedtags', 'b3_empty_array'); add_filter('wp_nav_menu_args', 'b3_wp_nav_menu_args'); require B3_PATH . '/inc/options.php'; add_action('admin_init', 'b3_admin_init'); register_post_type('b3_slide', array( 'label' => __('Slides', 'b3'), 'description' => '', 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'capability_type' => 'post', 'hierarchical' => false, 'rewrite' => array('slug' => ''), 'query_var' => true, 'supports' => array('title', 'editor', 'thumbnail',), 'labels' => array ( 'name' => __('Slides', 'b3'), 'singular_name' => __('Slide', 'b3'), 'menu_name' => __('B3 Slides', 'b3'), 'add_new' => __('Add Slide', 'b3'), 'add_new_item' => __('Add New Slide', 'b3'), 'edit' => __('Edit', 'b3'), 'edit_item' => __('Edit Slide', 'b3'), 'new_item' => __('New Slide', 'b3'), 'view' => __('View Slide', 'b3'), 'view_item' => __('View Slide', 'b3'), 'search_items' => __('Search Slides', 'b3'), 'not_found' => __('No Slides Found', 'b3'), 'not_found_in_trash' => __('No Slides Found in Trash', 'b3'), ))); } add_action('after_setup_theme', 'b3_setup'); if ( !isset( $content_width ) ) { $content_width = 970; } /* $content_width not really used currently in this theme but required by Wordpress theme autochecker. Content width is calculated and being set by Bootstrap. */ function b3_empty_array($arr) { return array(); } function b3_add_slide_metaboxes() { add_meta_box('b3-slide-uri', __('Slide URL', 'b3'), 'b3_slide_uri_metabox', 'b3_slide', 'normal', 'core'); } add_action('add_meta_boxes', 'b3_add_slide_metaboxes'); function b3_slide_uri_metabox($post) { wp_nonce_field('b3_inner_custom_box', 'b3_inner_custom_box_nonce'); ?>

ID . '&type=image&TB_iframe=1&width=640&height=285') . '" class="thickbox">' . __('to set the Featured Image', 'b3') . ' '; printf(__('Don't forget %1$s as it is the slide picture.', 'b3'), $set_featured); ?>

$post_id, 'post_type' => 'b3_slide', 'post_excerpt' => $slide_uri, )); add_action('save_post', 'b3_save_slide_postdata'); } add_action('save_post', 'b3_save_slide_postdata'); function b3_option($key) { global $b3_options; if (isset($b3_options[$key])) { return $b3_options[$key]; } return ''; } function b3_wp_nav_menu_args($args) { $args['container'] = false; return $args; } function b3_wp_page_menu($args) { $pages = get_pages(); foreach($pages as $key=>$page) { $pages[$key]->db_id = $page->ID; $pages[$key]->menu_item_parent = $page->post_parent; $pages[$key]->url = get_page_link($page->ID); } $pages = b3_wp_nav_menu_objects($pages); $out = ''; return $out; } add_filter('wp_nav_menu_objects', 'b3_wp_nav_menu_objects'); function b3_wp_nav_menu_objects ($menu_items) { foreach($menu_items as $key => $item) { $sort_num_of[$item->db_id] = $key; } foreach($menu_items as $key => $item) { if ($item->menu_item_parent) { $menu_items[ $sort_num_of[$item->menu_item_parent] ]->has_children = 1; } } return $menu_items; } class Tb3_Walker_Nav_Menu extends Walker_Nav_Menu { function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { $has_children = empty($item->has_children) ? false : true; $indent = ( $depth ) ? str_repeat( "\t", $depth ) : ''; $class_names = $value = ''; $classes = empty( $item->classes ) ? array() : (array) $item->classes; $classes[] = 'menu-item-' . $item->ID; if($has_children) { if ($depth ) { $classes[] = 'dropdown-submenu'; } else { $classes[] = 'dropdown'; } } $classes[] = 'depth-'.$depth; if (!is_object($args)) { $args = (object)array_merge(array('link_before' => '', 'link_after' => '', 'before' => '', 'after' => ''), $args); } $class_names = join(' ', apply_filters('nav_menu_css_class', array_filter( $classes ), $item, $args ) ); $class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : ''; $id = apply_filters('nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args); $id = $id ? ' id="' . esc_attr( $id ) . '"' : ''; $output .= $indent . ''; $attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : ''; $attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : ''; $attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : ''; $attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : ''; $item_output = $args->before; $item_output .= 'has_children) ? ' class="dropdown-toggle" data-toggle="dropdown"' :'') . '>'; $item_output .= $args->link_before . apply_filters('the_title', !empty($item->post_title) ? $item->post_title : $item->title, $item->ID) . $args->link_after; $item_output .= (!empty($item->has_children) && !$depth) ? ' ' :''; $item_output .= ''; $item_output .= $args->after; $output .= apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args ); } } function b3_widgets_init() { if ('Y' == b3_option('panel_widget')) { $args= array( 'before_widget' => '', 'before_title' => '', 'after_title' => '', // see b3_panel_widget_title() ); } else { $args= array( 'before_widget' => '', 'before_title' => '

', 'after_title' => '

', ); } $args['name'] = __('Sidebar 1', 'b3'); $args['id'] = 'sidebar-1'; register_sidebar($args); register_sidebar(array( 'name' => __('Top Sidebar', 'b3'), 'id' => 'sidebar-top', 'before_widget' => '', 'before_title' => '

', 'after_title' => '

', )); register_sidebar( array( 'name' => __('Bottom Sidebar', 'b3'), 'id' => 'sidebar-bottom', 'before_widget' => '', 'before_title' => '

', 'after_title' => '

', )); } add_action('widgets_init', 'b3_widgets_init'); function b3_panel_widget_title($title) { if ('Y' == b3_option('panel_widget')) { if (!$title) { $title = ' '; } $out = '

' . $title . '

'; } else { $out = $title ? '

' . $title . '

' : $title; } return $out; } /** * Enqueue scripts and styles */ function b3_enqueue_scripts() { $src = ('cdn' == b3_option('bootstrap_src')) ? '//netdna.bootstrapcdn.com/bootstrap/3.0.2' : B3_URI . '/bootstrap'; wp_enqueue_script('bootstrap', $src . '/js/bootstrap.min.js', array('jquery'), null, true ); wp_enqueue_script('b3', B3_URI . '/js/b3.js', array('jquery'), null, true ); if ( is_singular() && comments_open() && get_option('thread_comments') ) { wp_enqueue_script('comment-reply'); } if (is_singular() && wp_attachment_is_image()) { wp_enqueue_script('b3-keyboard-image-navigation', B3_URI . '/js/keyboard-image-navigation.js', array('jquery'), '20120202'); } } add_action('wp_enqueue_scripts', 'b3_enqueue_scripts'); function b3_enqueue_styles() { $src = ('cdn' == b3_option('bootstrap_src')) ? '//netdna.bootstrapcdn.com/bootstrap/3.0.2' : B3_URI . '/bootstrap'; wp_enqueue_style('bootstrap', $src . '/css/bootstrap.min.css'); wp_enqueue_style('b3-style', B3_URI . '/style.css'); wp_add_inline_style('b3-style', b3_options_css()); // add_editor_style(); /* the Bootstrap and custom theme css settings are not used in admin area so adding editor style is moot point yet. */ } add_action('wp_enqueue_scripts', 'b3_enqueue_styles'); function b3_admin_enqueue_scripts() { wp_enqueue_script('wp-color-picker', '', array('jquery')); wp_enqueue_script('b3-admin', B3_URI . '/js/b3-admin.js', array('wp-color-picker'), null, true); wp_localize_script('b3-admin', 'b3_admin', b3_admin_localize()); wp_enqueue_style('wp-color-picker'); wp_enqueue_style('b3-admin', B3_URI . '/css/b3-admin.css'); } add_action('admin_enqueue_scripts', 'b3_admin_enqueue_scripts'); function b3_options_css() { $out = ''; if ('left' == b3_option('sidebar_main')) { $out .= '#secondary {float: left;} #primary {float: right;} '; } if (($css = b3_option('text_color')) && $css != '#333333') { $out .= 'body {color:'. $css . ';} '; $out .= '.entry-meta {color:'. b3_option('text_color2') . ';} '; } if ($css = b3_option('headers_color')) { $out .= 'h1,h2,h3,h4,h5,h6 {color:'. $css . ';} '; } if ($css = b3_option('link_color')) { $out .= 'a, a:visited {color:'. $css . ';} '; } if ($css = b3_option('link_hover_color')) { $out .= 'a:hover {color:'. $css . ';} '; } if (($css = b3_option('navbar_color')) && '#F8F8F8' != $css) { $color2 = b3_option('navbar_color2'); $out .= '.navbar-b3 {background-color: '. $css .'; background-image: linear-gradient(to bottom, ' . $css . ' 0px, '. $color2 .' 100%); ' // . 'filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=' . $css. ',endColorstr=' . $color2 . ');' // (dropdown menu in IE8 doesn't work with filter ) // .'-ms-filter:"progid:DXImageTransform.Microsoft.gradient(startColorstr=' . $css .',endColorstr=' . $color2 .')";' .' border: ' . b3_option('navbar_border') .' solid 1px;}'; } if (($css = b3_option('navbar_link_color')) && '#777777' != $css) { $out .= '.navbar-nav > li > a, .navbar-nav > li > a:visited, a.navbar-brand {color:'. $css . ' !important;} '; $out .= '.navbar-nav > li > a:hover, a.navbar-brand:hover {color:'. b3_option('navbar_link_color2') . ' !important;} '; } return $out; } function b3_comment_form_before() { echo '
'; } function b3_comment_form_after() { echo '
'; } function b3_post_class($classes) { if ('Y'==b3_option('panel_post')) { $classes[]= 'panel-body'; } $classes[]= 'clearfix'; return $classes; } function b3_content_wrap_class() { $classes = array(); if ('Y'==b3_option('panel_post')) { $classes[]= 'panel'; } if ($classes) { echo 'class="' . implode(' ', $classes) . '"'; } } add_filter('post_class', 'b3_post_class'); add_action('comment_form_before', 'b3_comment_form_before'); add_action('comment_form_after', 'b3_comment_form_after'); function b3_carousel() { $case = b3_option('carousel'); if ('N' == $case) { return; } else { if ('Y' == $case) { $slides = get_posts(array('post_type' => 'b3_slide')); } else { include B3_PATH . '/inc/demo-slides.php'; } if ( $total = count($slides) ) { ?> 1) { ?>
'; printf( __('You have no slides yet. You can add your slides or activate demo slides. The optimum image width/height ratio is %2$s, the best image size: %3$s.', 'b3'), admin_url('post-new.php?post_type=b3_slide'), '17:5', '1140 × 300 pixel'); echo ''; } } } require B3_PATH . '/inc/template-tags.php'; require B3_PATH . '/inc/extras.php'; require B3_PATH . '/inc/customizer.php'; require B3_PATH . '/inc/jetpack.php'; function b3_footer_script() { if ('Y' == b3_option('image_rounded')) { ?> __('All theme settings will be replaced by default dettings. Continue?', 'b3'), 'upload' => __('Theme settings will be replaced by settings from the uploaded file. Continue?', 'b3'), ); return $out; }