=$limit) { array_pop($excerpt); $excerpt = implode(" ",$excerpt).'...'; } else { $excerpt = implode(" ",$excerpt); } $excerpt = preg_replace('`\[[^\]]*\]`','',$excerpt); return $excerpt; } function the_title_limit($length, $replacer = '...') { $string = the_title('','',FALSE); if(strlen($string) > $length) $string = (preg_match('/^(.*)\W.*$/', substr($string, 0, $length+1), $matches) ? $matches[1] : substr($string, 0, $length)) . $replacer; echo $string; } function backyard_setup() { // Register wp_nav_menu() menus (http://codex.wordpress.org/Function_Reference/register_nav_menus) register_nav_menus(array( 'primary_navigation' => __('Primary Navigation', 'backyard'), /*'secondary_navigation' => __('Secondary Navigation', 'backyard'), 'mobile_navigation' => __('Mobile Navigation', 'backyard'), 'topbar_navigation' => __('Topbar Navigation', 'backyard'), 'footer_navigation' => __('Footer Navigation', 'backyard'),*/ )); add_theme_support( 'post-formats', array( 'aside', 'audio', 'chat', 'gallery', 'image', 'link', 'quote', 'status', 'video' ) ); add_theme_support('content-width', 770); add_theme_support( 'title-tag' ); add_theme_support('post-thumbnails'); add_image_size( 'widget-thumb', 80, 50, true ); add_image_size('featured_categories', 263, 190, true ); add_image_size( 'popular-thumb', 256, 151, true ); add_image_size( 'page-thumb', 750, 387, true ); add_image_size('full-grid', 550, 350, true ); add_post_type_support( 'attachment', 'page-atBackyards' ); add_theme_support( 'automatic-feed-links' ); ///add_editor_style('/assets/css/editor-style.css'); add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption' ) ); $args = array( 'default-text-color' => 'da4453', 'default-image' => '', 'height' => 250, 'width' => 1060, 'max-width' => 2000, 'flex-height' => true, 'flex-width' => true, 'random-default' => false, 'wp-head-callback' =>'backyard_header_style', ); add_theme_support('custom-header', $args); } add_action('after_setup_theme', 'backyard_setup'); // Backwards compatibility for older than PHP 5.3.0 if (!defined('__DIR__')) { define('__DIR__', dirname(__FILE__)); } function backyard_fav_output(){ // Keep for fallback global $backyard; if(isset($backyard['favion_id']) && $backyard['favion_id']==1) { if(isset($backyard['favion_icon_upload']) && !empty($backyard['favion_icon_upload']) ) { echo ''; } } } add_action('wp_head', 'backyard_fav_output'); //front end add_action('admin_head', 'backyard_fav_output'); //admin end function remove_admin_bar() { if ((is_user_logged_in()) && (!current_user_can('administrator') && !is_admin())) { global $backyard; if(isset($backyard['disable_wp_adminbar_id']) && $backyard['disable_wp_adminbar_id']==1) { show_admin_bar(true); }else { show_admin_bar(false); } } } add_action('after_setup_theme', 'remove_admin_bar'); //* Add custom body class to the head add_filter( 'body_class', 'sp_body_class' ); function sp_body_class( $classes ) { if (!is_front_page() || is_home()) $classes[] = 'inner-page'; return $classes; } /*Start Content Limit Function*/ /*End Content Limit Function*/ /*Start Popular Posts Function*/ function wpb_set_post_views($postID) { $count_key = 'wpb_post_views_count'; $count = get_post_meta($postID, $count_key, true); if($count==''){ $count = 0; delete_post_meta($postID, $count_key); add_post_meta($postID, $count_key, '0'); }else{ $count++; update_post_meta($postID, $count_key, $count); } } //To keep the count accurate, lets get rid of prefetching remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0); function wpb_track_post_views ($post_id) { if ( !is_single() ) return; if ( empty ( $post_id) ) { global $post; $post_id = $post->ID; } wpb_set_post_views($post_id); } add_action( 'wp_head', 'wpb_track_post_views'); function wpb_get_post_views($postID){ $count_key = 'wpb_post_views_count'; $count = get_post_meta($postID, $count_key, true); if($count==''){ delete_post_meta($postID, $count_key); add_post_meta($postID, $count_key, '0'); return "0 View"; } return $count.' Views'; } /*End Popular Posts Function*/ add_filter( 'comments_open', 'my_comments_open', 10, 2 ); function my_comments_open( $open, $post_id ) { $post = get_post( $post_id ); if (get_post_meta($post->ID, 'Allow Comments', true)) {$open = true;} return $open; } /*Start Search Form Hook*/ function backyard_search_form( $form ) { $form = ''; return $form; } add_filter( 'get_search_form', 'backyard_search_form'); /*End Search Form Hook*/ function makeClickableLinks($s) { return preg_replace('@(https?://([-\w\.]+[-\w])+(:\d+)?(/([\w/_\.#-]*(\?\S+)?[^\.\s])?)?)@', '$1', $s); } if(!function_exists('Backyard_comment_nav')) : function backyard_comment_nav() { // Are there comments to navigate through? if ( get_comment_pages_count() > 1 && get_option('page_comments') ) : ?> 'Secondary Image', 'id' => 'secondary-image', 'post_type' => $type ) ); } } add_filter('comment_post_redirect', 'redirect_after_comment'); function redirect_after_comment($location) { $comment_id = get_comment_ID(); return $_SERVER["HTTP_REFERER"]. '#comment-'.$comment_id; } /* Start tribute front page setting */ function tribute_front_page_template( $template ) { return is_home() ? '' : $template; } add_filter('frontpage_template', 'tribute_front_page_template' ); /* End tribute front page setting */ if ( ! isset( $content_width ) ) { $content_width = 770; } function backyard_header_style() { $text_color = esc_html(get_header_textcolor()); ?>