*/ /* ======================================================================================================== * Set Up * ======================================================================================================== */ /* ---- load files ---------------*/ require(get_template_directory() . '/library/blogBox_post_functions.php'); require(get_template_directory() . '/widgets/blogBox_social_widget.php'); /** * Customizer additions. */ require get_template_directory() . '/library/kha-customizer.php'; /* ---- Set content width --------*/ if(!isset( $content_width )) $content_width = 600; function blogBox_theme_supports(){ //enable translation load_theme_textdomain('blogBox', get_template_directory() . '/language'); /* ------------editor-style -------------------- */ add_editor_style(); // ADD POST FORMATS add_theme_support( 'post-formats', array( 'aside', 'audio', 'chat', 'gallery', 'image', 'link', 'quote', 'status', 'video' ) ); //Custom Backgrounds add_theme_support('custom-background'); //custom header $bB_header_args = array( 'flex-width' => true, 'width' => 960, 'flex-height' => true, 'height' => 320, 'header-text' => false, 'default-image' => '', 'uploads' => true, ); add_theme_support('custom-header',$bB_header_args); //feeds add_theme_support('automatic-feed-links'); //thumbnails add_theme_support('post-thumbnails'); add_image_size('wide_thumbnail',180,120); add_theme_support('title-tag'); add_theme_support( 'html5', array( 'comment-list', 'comment-form', 'search-form', 'gallery', 'caption' ) ); } add_action('after_setup_theme', 'blogBox_theme_supports'); /* ********* Set up Menu in Dashboard under Appearance ************** */ function blogBox_register_menu() { register_nav_menu('primary-nav','Primary Menu'); } add_action( 'init', 'blogBox_register_menu' ); /** * Register Side bars * Thanks to Justin Tadlock for the post on sidebars * @link http://justintadlock.com/archives/2010/11/08/sidebars-in-wordpress */ if (!function_exists ( 'blogBox_register_sidebars' )) { function blogBox_register_sidebars() { // Sidebars and footer areas register_sidebar(array( 'id' => 'blogbox_default_sidebar', 'name'=>'Default-Sidebar', 'description' => esc_html__( 'Default sidebar', 'blogBox' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

' ) ); register_sidebar(array( 'id' => 'blogbox_header_sidebar', 'name'=>'Header-Sidebar', 'description' => esc_html__( 'Placed in upper right hand corner of header', 'blogBox' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

' ) ); register_sidebar(array( 'id' => 'blogbox_feature', 'name'=>'Feature Area', 'description' => esc_html__( 'Feature widgetized area', 'blogBox' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

' ) ); register_sidebar(array( 'id' => 'blogbox_left_sidebar', 'name'=>'Left-Sidebar', 'description' => esc_html__( 'Sidebar for left side of page', 'blogBox' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

' ) ); register_sidebar(array( 'id' => 'blogbox_left_sidebar_2', 'name'=>'Left-Sidebar 2', 'description' => esc_html__( 'Sidebar for left side page 2', 'blogBox' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

' ) ); register_sidebar(array( 'id' => 'blogbox_right_sidebar', 'name'=>'Right-Sidebar', 'description' => esc_html__( 'Sidebar for right side of page', 'blogBox' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

' ) ); register_sidebar(array( 'id' => 'blogbox_right_sidebar_2', 'name'=>'Right-Sidebar 2', 'description' => esc_html__( 'Sidebar for right side page 2', 'blogBox' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

' ) ); register_sidebar(array( 'id' => 'blogbox_contact_sidebar', 'name'=>'Contact-Sidebar', 'description' => esc_html__( 'Sidebar for contact page', 'blogBox' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

' ) ); register_sidebar(array( 'id' => 'blogbox_404_sidebar', 'name'=>'Sidebar-404', 'description' => esc_html__( 'Sidebar for 404 page', 'blogBox' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

' ) ); register_sidebar(array( 'id' => 'blogbox_footer_a', 'name'=>'Footer A', 'description' => esc_html__( 'Use this for the first footer column', 'blogBox' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

' ) ); register_sidebar(array( 'id' => 'blogbox_footer_b', 'name'=>'Footer B', 'description' => esc_html__( 'Use this for the second footer column', 'blogBox' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

' ) ); register_sidebar(array( 'id' => 'blogbox_footer_c', 'name'=>'Footer C', 'description' => esc_html__( 'Use this for the third footer column', 'blogBox' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

' ) ); register_sidebar(array( 'id' => 'blogbox_footer_d', 'name'=>'Footer D', 'description' => esc_html__( 'Use this for the fourth footer column', 'blogBox' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

' ) ); } add_action( 'widgets_init', 'blogBox_register_sidebars' ); } /* ======================================================================================================== * Scripts and Styles * ======================================================================================================== */ if ( !function_exists ('blogBox_load_js')){ function blogBox_load_js() { if(!is_admin()){ global $blogBox_options; wp_enqueue_script( 'superfish', get_template_directory_uri() . '/js/superfish/superfish.min.js', array( 'jquery' ), '' ); wp_enqueue_script( 'easing', get_template_directory_uri() . '/js/jquery.easing.1.3.js', array( 'jquery' ), '' ); wp_enqueue_script( 'slides', get_template_directory_uri() . '/js/nivo-slider/jquery.nivo.slider.pack.js', array( 'jquery' ), '' ); wp_enqueue_script( 'blogBox_custom', get_template_directory_uri() . '/js/doc_ready_scripts.js', array( 'jquery' ), '' ); if ( $blogBox_options['bB_disable_fitvids'] != 1 ) { wp_enqueue_script( 'blogBox_fitvids', get_template_directory_uri() . '/js/jquery.fitvids.js', array( 'jquery' ), '' ); wp_enqueue_script( 'blogBox_fitvids_doc_ready', get_template_directory_uri() . '/js/fitvids-doc-ready.js', array( 'jquery' ), '' ); } wp_enqueue_script( 'mobile_doc_ready', get_template_directory_uri() . '/js/mobile-doc-ready.js', array( 'jquery' ), '' ); if ( $blogBox_options['bB_disable_colorbox'] != 1 ) { wp_enqueue_script( 'colorbox', get_template_directory_uri() . '/js/colorbox/jquery.colorbox-min.js', array( 'jquery' ), '' ); wp_enqueue_script( 'colorbox_doc_ready', get_template_directory_uri() . '/js/colorbox/colorbox_doc_ready.js', array( 'jquery' ), '' ); } } } add_action('init', 'blogBox_load_js'); } if ( !function_exists ('blogBox_styles')) { function blogBox_styles() { global $blogBox_options; wp_enqueue_style( 'blogBox_main_style' , get_stylesheet_uri() ); wp_enqueue_style( 'nivo_style',get_template_directory_uri() . '/js/nivo-slider/nivo-slider.css',array() ); wp_enqueue_style( 'nivo_style_theme',get_template_directory_uri() . '/js/nivo-slider/themes/default/default.css',array() ); wp_enqueue_style( 'superfish_style',get_template_directory_uri() . '/js/superfish/superfish.css',array() ); wp_enqueue_style( 'font_awesome_style',get_template_directory_uri() . '/font-awesome/css/font-awesome.min.css',array() ); if ( $blogBox_options['bB_disable_colorbox'] != 1 ) { wp_register_style( 'colorbox_style',get_template_directory_uri() . '/js/colorbox/colorbox.css',array() ); wp_enqueue_style( 'colorbox_style' ); } } add_action('wp_enqueue_scripts', 'blogBox_styles'); } if ( !function_exists ('blogBox_setup')){// load custom styles and fonts function blogbox_setup(){ include( get_template_directory() . '/library/custom-fonts.php' ); include( get_template_directory() . '/library/custom-styles.php' ); } add_action( 'wp_print_styles', 'blogbox_setup' ); } /* ======================================================================================================== * Comments and Pingbacks * ======================================================================================================== */ /** * Javascript setup for threaded comments */ if ( !function_exists ('blogBox_enqueue_comment_reply_script')){//enque of enque reply script as per http://make.wordpress.org/themes/tag/guidelines/ function blogBox_enqueue_comment_reply_script() { if (is_singular() && comments_open() && (get_option('thread_comments') == 1)) { wp_enqueue_script( 'comment-reply' ); } } add_action( 'wp_enqueue_scripts', 'blogBox_enqueue_comment_reply_script' ); } if ( !function_exists ('blogBox_cleanPings')){// clean pingbacks and trackbacks function blogBox_cleanPings($comment, $args, $depth) { $GLOBALS['comment'] = $comment; echo '
  • '; echo comment_author_link().'  '; edit_comment_link('Edit'); echo '

  • '; } } /* ======================================================================================================== * Filters * ======================================================================================================== */ /* THE_EXCERT modified from http://wordpress.org/support/topic/dynamic-the_excerpt?replies=22 */ if ( !function_exists ('blogBox_the_excerpt_dynamic')){// Outputs an excerpt of variable length (in characters) function blogBox_the_excerpt_dynamic($length) { global $post; $text = $post->post_excerpt; if ( '' == $text ) { $text = get_the_content(''); $text = apply_filters('the_content', $text); $text = str_replace(']]>', ']]>', $text); } //I'm checking for my own conatct-pizazz plug-in here so that you can include the shortcodes I know about. if (function_exists('content_pizazz_list_func()')) { $text = do_shortcode($text); } else { strip_shortcodes($text); } $text = strip_tags($text,'



    1. '); $output = strlen($text); if($output > $length ) { $break_pos = strpos($text, ' ', $length);//find next space after desired length if($break_pos == '')$break_pos = $length; $text = substr($text,0,$break_pos); $text = $text.' [...]'; $text = force_balance_tags($text); } echo apply_filters('the_excerpt',$text); } } if ( !function_exists ('blogBox_portfolio_titles')){//function to limit characters in portfolio titles function blogBox_portfolio_titles($content,$limit){ $content = strip_tags($content); if(strlen($content) > $limit){ $visible = substr($content, 0, $limit); $visible = $visible.' ...'; } else { $visible = $content; } //return $visible; echo strip_tags(apply_filters('the_excerpt',$visible)); } } if ( !function_exists ('blogBox_portfolio_feature_description')){//function to limit characters in portfolio titles function blogBox_portfolio_feature_description($content,$limit){ $content = do_shortcode($content); $content = strip_tags($content,'


      1. '); if(strlen($content) > $limit){ $break_pos = strpos($content, ' ', $limit);//find next space after desired length if($break_pos == '')$break_pos = $limit; $visible = substr($content, 0, $break_pos); $visible = $visible.' ...'; $visible = force_balance_tags($visible); } else { $visible = $content; } echo apply_filters('the_content',$visible); } } /* ======================================================================================================== * Miscelaneous * ======================================================================================================== */ /** * blogBox exclude categories * * This helper function is used in page-home-blog.php and index.php. * It returns an exclusion string for $wp-query, and is based on user settings to * eclude the Feature and Portfolio categories. * * @return $exclude_categories */ if ( !function_exists ('blogBox_exclude_categories')){//Exclude categories helper function blogBox_exclude_categories () { global $blogBox_options; $exclude_categories = "'"; $feature_cat_ID = get_cat_ID('Feature'); $portfolioA_cat_ID = get_cat_ID(sanitize_text_field($blogBox_options['bB_portfolioA_category'])); $portfolioB_cat_ID = get_cat_ID(sanitize_text_field($blogBox_options['bB_portfolioB_category'])); $portfolioC_cat_ID = get_cat_ID(sanitize_text_field($blogBox_options['bB_portfolioC_category'])); $portfolioD_cat_ID = get_cat_ID(sanitize_text_field($blogBox_options['bB_portfolioD_category'])); $portfolioE_cat_ID = get_cat_ID(sanitize_text_field($blogBox_options['bB_portfolioE_category'])); if ($feature_cat_ID !== 0 && $blogBox_options['bB_showfeaturepost'] == 0) $exclude_categories = $exclude_categories . "-" . $feature_cat_ID; if ($portfolioA_cat_ID !== 0 && $blogBox_options['bB_showfeatureApost'] == 0 && $exclude_categories !== "'") { $exclude_categories = $exclude_categories . ",-" . $portfolioA_cat_ID; } elseif ($portfolioA_cat_ID !== 0 && $blogBox_options['bB_showfeatureApost'] == 0 && $exclude_categories == "'") { $exclude_categories = $exclude_categories . "-" . $portfolioA_cat_ID; } if ($portfolioB_cat_ID !== 0 && $blogBox_options['bB_showfeatureBpost'] == 0 && $exclude_categories !== "'") { $exclude_categories = $exclude_categories . ",-" . $portfolioB_cat_ID; } elseif ($portfolioB_cat_ID !== 0 && $blogBox_options['bB_showfeatureBpost'] == 0 && $exclude_categories == "'") { $exclude_categories = $exclude_categories . "-" . $portfolioB_cat_ID; } if ($portfolioC_cat_ID !== 0 && $blogBox_options['bB_showfeatureCpost'] == 0 && $exclude_categories !== "'") { $exclude_categories = $exclude_categories . ",-" . $portfolioC_cat_ID; } elseif ($portfolioC_cat_ID !== 0 && $blogBox_options['bB_showfeatureCpost'] == 0 && $exclude_categories == "'") { $exclude_categories = $exclude_categories . "-" . $portfolioC_cat_ID; } if ($portfolioD_cat_ID !== 0 && $blogBox_options['bB_showfeatureDpost'] == 0 && $exclude_categories !== "'") { $exclude_categories = $exclude_categories . ",-" . $portfolioD_cat_ID; } elseif ($portfolioD_cat_ID !== 0 && $blogBox_options['bB_showfeatureDpost'] == 0 && $exclude_categories == "'") { $exclude_categories = $exclude_categories . "-" . $portfolioD_cat_ID; } if ($portfolioE_cat_ID !==0 && $blogBox_options['bB_showfeatureEpost'] == 0 && $exclude_categories !== "'") { $exclude_categories = $exclude_categories . ",-" . $portfolioE_cat_ID; } elseif ($portfolioE_cat_ID !== 0 && $blogBox_options['bB_showfeatureEpost'] == 0 && $exclude_categories == "'") { $exclude_categories = $exclude_categories . "-" . $portfolioE_cat_ID; } $exclude_categories = $exclude_categories . "'" ; return $exclude_categories; } } if ( !function_exists ('blogBox_feature_slider')){ function blogBox_feature_slider() { global $blogBox_options; $feature_option = sanitize_text_field($blogBox_options['bB_home1feature_options']); $use_feature_widget_area = $blogBox_options['bB_use_feature_widget']; echo '
        '; if( $feature_option == "Full feature slides" ) { echo '
        '; echo '
        '; echo '
        '; } elseif ( $feature_option == "Full feature slides-thumbnails" ) { echo '
        '; echo '
        '; echo '
        '; } elseif ( $feature_option == "Full feature slides-nonav" ) { echo '
        '; echo '
        '; echo '
        '; } elseif ( $feature_option == "Small slides and feature text box" ) { echo '
        '; echo '
        '; echo '
        '; } elseif ( $feature_option == "Small slides and feature text box-thumbnails" ) { echo '
        '; echo '
        '; echo '
        '; } elseif ( $feature_option == "Small slides and feature text box-nonav" ) { echo '
        '; echo '
        '; echo '
        '; } elseif ( $feature_option == "Small single image and feature text box" ) { $category_ID = get_cat_ID('Feature'); global $post; $args = array('category'=>$category_ID,'numberposts'=>1); $custom_posts = get_posts($args); if ($category_ID !== 0 && $custom_posts){ $post = $custom_posts[0]; echo '
        '; if (has_post_thumbnail()) { $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID),'full') ; $image_url = $thumb[0]; $title = get_post(get_post_thumbnail_id())->post_excerpt; echo ''; echo ''.$title.''; echo ''; } else { echo '
        '; echo '

        '.esc_html__('Error: There were no feature images found?','blogBox').'

        '; echo '
        '; return; } echo '
        '; } else { echo ''; } } elseif ( $feature_option == "Full single image" ) { $category_ID = get_cat_ID('Feature'); global $post; $args = array('category'=>$category_ID,'numberposts'=>1); $custom_posts = get_posts($args); if ($category_ID !== 0 && $custom_posts){ $post = $custom_posts[0]; echo '
        '; if (has_post_thumbnail()) { $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID),'full') ; $image_url = $thumb[0]; $title = get_post(get_post_thumbnail_id())->post_excerpt; echo ''; echo ''.$title.''; echo ''; } else { echo '
        '; echo '

        '.esc_html__('Error: There were no feature images found?','blogBox').'

        '; echo '
        '; return; } echo '
        '; } else { echo 'Default Feature Slide'; } } if ( $feature_option != 'Small single image and feature text box' && $feature_option != 'Full single image') { $category_ID = get_cat_ID('Feature'); global $post; $args = array('category'=>$category_ID,'numberposts'=>999); $custom_posts = get_posts($args); if ($category_ID !== 0 && $custom_posts){ foreach($custom_posts as $post) : setup_postdata($post); if (has_post_thumbnail()) { if ($feature_option == 'Small slides and feature text box-thumbnails' || $feature_option == 'Full feature slides-thumbnails') { $thumb1 = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID),'wide_thumbnail') ; $thumb_url = $thumb1[0]; } $thumb2 = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID),'full') ; $image_url = $thumb2[0]; $title = get_post(get_post_thumbnail_id())->post_excerpt; echo ''; if( $feature_option == "Full feature slides" || $feature_option == "Small slides and feature text box" ) { echo ''.$title.''; } elseif( $feature_option == "Full feature slides-thumbnails" || $feature_option == "Small slides and feature text box-thumbnails" ) { echo ''.$title.''; } else { echo ''.$title.''; } echo ''; } endforeach; } else { if( $feature_option == "Full feature slides" || $feature_option == "Full feature slides-thumbnails" ) { echo 'Default Feature Slide'; } else { echo 'Default Feature Slide'; } } echo '
        '; echo '
        '; } if( $feature_option == "Small slides and feature text box" || $feature_option == "Small slides and feature text box-thumbnails" || $feature_option == "Small single image and feature text box" || $feature_option == "Small slides and feature text box-nonav" ) { echo '
        '; if( $use_feature_widget_area != 1 ) { echo "

        ".esc_html( stripslashes($blogBox_options['bB_left_feature_title'] ) )."

        "; echo "".wp_kses_post(stripcslashes($blogBox_options['bB_left_feature_text'])).""; } else { if ( !dynamic_sidebar('Feature Area') ) : endif; } echo '
        '; } echo '
        '; } } if ( !function_exists ('blogBox_home_sections')){ function blogBox_home_sections() { global $blogBox_options; if ($blogBox_options['bB_home1section1_onoroff'] == 1) { ?>

        ">
        Service 1 Image'; ?> '.esc_html( stripslashes( $blogBox_options['bB_home1service1_title'] ) ).''; ?> '.wp_kses_post( stripslashes( $blogBox_options['bB_home1service1_text'] ) ).'

        '; ?>
        Service 2 Image'; ?> '.esc_html( stripslashes( $blogBox_options['bB_home1service2_title'] ) ).''; ?> '.wp_kses_post( stripslashes( $blogBox_options['bB_home1service2_text'] ) ).'

        '; ?>
        Service 3 Image'; ?> '.esc_textarea( stripslashes( $blogBox_options['bB_home1service3_title'] ) ).''; ?> '.wp_kses_post( stripslashes( $blogBox_options['bB_home1service3_text'] ) ).'

        '; ?>

        'primary-nav', 'container_class' => 'main-nav', 'container_id' => 'main-menu-right-noborder', 'menu_class' => 'sf-menu', 'menu_id' => 'main_menu_ul', 'fallback_cb' => 'wp_page_menu' ) ); } } else if ( $blogBox_options['bB_menu_loc'] == 'left' ) { if(has_nav_menu('primary-nav')){ wp_nav_menu( array( 'theme_location' => 'primary-nav', 'container_class' => 'main-nav', 'container_id' => 'main-menu-left-noborder', 'menu_class' => 'sf-menu', 'menu_id' => 'main_menu_ul', 'fallback_cb' => 'wp_page_menu' ) ); } } else { If ( $blogBox_options['bB_menu_border'] == 'menu only' ) { if(has_nav_menu('primary-nav')){ wp_nav_menu( array( 'theme_location' => 'primary-nav', 'container_class' => 'main-nav', 'container_id' => 'main-menu-center-border', 'menu_class' => 'sf-menu', 'menu_id' => 'main_menu_ul', 'fallback_cb' => 'wp_page_menu' ) ); } } else { if(has_nav_menu('primary-nav')){ wp_nav_menu( array( 'theme_location' => 'primary-nav', 'container_class' => 'main-nav', 'container_id' => 'main-menu-center-noborder', 'menu_class' => 'sf-menu', 'menu_id' => 'main_menu_ul', 'fallback_cb' => 'wp_page_menu' ) ); } } } } } //Add title attribute back to gallery images function blogBox_image_titles($atts,$img) { $atts['title'] = trim(strip_tags( $img->post_excerpt )); return $atts; } add_filter('wp_get_attachment_image_attributes','blogBox_image_titles',10,2);