=$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('content-width', 770); add_theme_support( 'title-tag' ); add_theme_support('post-thumbnails'); add_image_size( 'backyard-widget-thumb', 80, 50, true ); add_image_size('backyard-related-post', 230, 166, true); add_image_size('backyard-featured-categories', 263, 190, true ); add_image_size('backyard-popular-thumb', 256, 151, true ); add_image_size('backyard-post-thumb', 750, 387, true ); add_image_size('backyard-full-grid', 550, 350, true ); add_theme_support( 'automatic-feed-links' ); add_editor_style( array( 'editor-style.css', backyard_fonts_url())); 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'); //* 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 backyard_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 backyard_track_post_views ($post_id) { if ( !is_single() ) return; if ( empty ( $post_id) ) { global $post; $post_id = $post->ID; } backyard_set_post_views($post_id); } add_action( 'wp_head', 'backyard_track_post_views'); function backyard_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') ) : ?>