__( 'Primary', 'tracks' ), 'secondary' => __( 'Secondary', 'tracks' ), 'footer' => __( 'Footer', 'tracks' ) ) ); // adds theme options page require_once( trailingslashit( get_template_directory() ) . 'theme-options.php' ); // add inc folder files foreach ( glob( trailingslashit( get_template_directory() ) . 'inc/*.php' ) as $filename ) { include $filename; } // add license folder files foreach ( glob( trailingslashit( get_template_directory() ) . 'licenses/*.php' ) as $filename ) { include $filename; } // add license/functions folder files foreach ( glob( trailingslashit( get_template_directory() ) . 'licenses/functions/*.php' ) as $filename ) { include $filename; } // load text domain load_theme_textdomain( 'tracks', get_template_directory() . '/languages' ); } } add_action( 'after_setup_theme', 'ct_tracks_theme_setup', 10 ); function ct_tracks_register_widget_areas(){ /* register after post content widget area */ register_sidebar( array( 'name' => __( 'After Post Content', 'tracks' ), 'id' => 'after-post-content', 'description' => __( 'Widgets in this area will be shown after post content before the prev/next post links', 'tracks' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

' ) ); /* register after page content widget area */ register_sidebar( array( 'name' => __( 'After Page Content', 'tracks' ), 'id' => 'after-page-content', 'description' => __( 'Widgets in this area will be shown after page content', 'tracks' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

' ) ); /* register footer widget area */ register_sidebar( array( 'name' => __( 'Footer', 'tracks' ), 'id' => 'footer', 'description' => __( 'Widgets in this area will be shown in the footer', 'tracks' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

' ) ); } add_action('widgets_init','ct_tracks_register_widget_areas'); /* added to customize the comments. Same as default except -> added use of gravatar images for comment authors */ if( ! function_exists( 'ct_tracks_customize_comments' ) ) { function ct_tracks_customize_comments( $comment, $args, $depth ) { $GLOBALS['comment'] = $comment; global $post; ?>
  • id="li-comment-">
    __( 'Reply', 'tracks' ), 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
    comment_approved == '0' ) : ?>

    '; $fields['email'] = '

    '; $fields['url'] = '

    '; return $fields; } } add_filter('comment_form_default_fields','ct_tracks_update_fields'); if( ! function_exists( 'ct_tracks_update_comment_field' ) ) { function ct_tracks_update_comment_field( $comment_field ) { $comment_field = '

    '; return $comment_field; } } add_filter('comment_form_field_comment','ct_tracks_update_comment_field'); // remove allowed tags text after comment form if( ! function_exists( 'ct_tracks_remove_comments_notes_after' ) ) { function ct_tracks_remove_comments_notes_after( $defaults ) { $defaults['comment_notes_after'] = ''; return $defaults; } } add_action('comment_form_defaults', 'ct_tracks_remove_comments_notes_after'); // excerpt handling if( ! function_exists( 'ct_tracks_excerpt' ) ) { function ct_tracks_excerpt() { // make post variable available global $post; // get the 'show full post' setting $setting = get_theme_mod( 'premium_layouts_full_width_full_post' ); // check for the more tag $ismore = strpos( $post->post_content, '' ); // if show full post is on and not on a search results page if ( ( $setting == 'yes' ) && get_theme_mod( 'premium_layouts_setting' ) == 'full-width' && ! is_search() ) { // use the read more link if present if ( $ismore ) { the_content( __( 'Read More', 'tracks' ) . " " . get_the_title() . "" ); } else { the_content(); } } // use the read more link if present elseif ( $ismore ) { the_content( __( 'Read More', 'tracks' ) . "" . get_the_title() . "" ); } // otherwise the excerpt is automatic, so output it else { the_excerpt(); } } } // filter the link on excerpts if( ! function_exists( 'ct_tracks_excerpt_read_more_link' ) ) { function ct_tracks_excerpt_read_more_link( $output ) { global $post; return $output . "

    " . __( 'Read the Post', 'tracks' ) . "" . get_the_title() . "

    "; } } add_filter('the_excerpt', 'ct_tracks_excerpt_read_more_link'); // change the length of the excerpts if( ! function_exists( 'ct_tracks_custom_excerpt_length' ) ) { function ct_tracks_custom_excerpt_length( $length ) { $new_excerpt_length = get_theme_mod( 'additional_options_excerpt_length_settings' ); // if there is a new length set and it's not 15, change it if ( ! empty( $new_excerpt_length ) && $new_excerpt_length != 15 ) { return $new_excerpt_length; } // return 0 if user explicitly sets it to 0 elseif ( $new_excerpt_length === 0 ) { return 0; } else { return 15; } } } add_filter( 'excerpt_length', 'ct_tracks_custom_excerpt_length', 999 ); // switch [...] to ellipsis on automatic excerpt if( ! function_exists( 'ct_tracks_new_excerpt_more' ) ) { function ct_tracks_new_excerpt_more( $more ) { // get user set excerpt length $new_excerpt_length = get_theme_mod('additional_options_excerpt_length_settings'); // if set to 0, return nothing if ( $new_excerpt_length === 0 ) { return ''; } // else add the ellipsis else { return '…'; } } } add_filter('excerpt_more', 'ct_tracks_new_excerpt_more'); // turns of the automatic scrolling to the read more link if( ! function_exists( 'ct_tracks_remove_more_link_scroll' ) ) { function ct_tracks_remove_more_link_scroll( $link ) { $link = preg_replace( '|#more-[0-9]+|', '', $link ); return $link; } } add_filter( 'the_content_more_link', 'ct_tracks_remove_more_link_scroll' ); // for displaying featured images including mobile versions and default versions if( ! function_exists( 'ct_tracks_featured_image' ) ) { function ct_tracks_featured_image() { // get post object global $post; // set default to no image $has_image = false; // final output $featured_image = ''; // image url $image = ''; // get the current layout $premium_layout = get_theme_mod( 'premium_layouts_setting' ); // if the post has a featured image if ( has_post_thumbnail( $post->ID ) ) { // get the large version if on archive and not one of the full-width layouts if ( ( is_archive() || is_home() ) && $premium_layout != 'full-width' && $premium_layout != 'full-width-images' ) { $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'large' ); } // otherwise get the full-size version else { $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); } // set to image URL $image = $image[0]; // post has an image $has_image = true; } // if the post has a featured image if ( $has_image == true ) { // if lazy loading is enabled if ( get_theme_mod( 'additional_options_lazy_load_settings' ) == 'yes' && ( is_archive() || is_home() ) ) { $featured_image = ""; } // if lazy loading is NOT enabled else { $featured_image = ""; } } // allow videos to be added $featured_image = apply_filters( 'ct_tracks_featured_image', $featured_image, $image, $has_image ); if( $featured_image ) { echo $featured_image; } } } /* add conditional classes for premium layouts */ function ct_tracks_body_class( $classes ) { global $post; $premium_layout_setting = get_theme_mod('premium_layouts_setting'); if ( is_singular() ) { $classes[] = 'singular'; if ( is_singular('page') ) { $classes[] = 'singular-page'; $classes[] = 'singular-page-' . $post->ID; } elseif ( is_singular('post') ) { $classes[] = 'singular-post'; $classes[] = 'singular-post-' . $post->ID; } elseif ( is_singular('attachment') ) { $classes[] = 'singular-attachment'; $classes[] = 'singular-attachment-' . $post->ID; } } if ( ! is_front_page() ) { $classes[] = 'not-front'; } if (get_theme_mod('ct_tracks_header_color_setting') == 'dark'){ $classes[] = 'dark-header'; } if( empty( $premium_layout_setting ) || $premium_layout_setting == 'standard') { $classes[] = 'standard'; } if( $premium_layout_setting == 'full-width'){ $classes[] = 'full-width'; if(get_theme_mod('premium_layouts_full_width_full_post') == 'yes'){ $classes[] = 'full-post'; } } elseif( $premium_layout_setting == 'full-width-images'){ // maintain standard layout on search pages if( !is_search() ) { $classes[] = 'full-width-images'; } if( ( is_home() || is_archive() ) && get_theme_mod('premium_layouts_full_width_image_height') == '2:1-ratio'){ $classes[] = 'ratio'; } if( is_singular() && get_theme_mod('premium_layouts_full_width_image_height_post') == '2:1-ratio'){ $classes[] = 'ratio'; } if(get_theme_mod('premium_layouts_full_width_image_style') == 'title'){ $classes[] = 'title-below'; } } elseif( $premium_layout_setting == 'two-column'){ $classes[] = 'two-column'; } elseif( $premium_layout_setting == 'two-column-images'){ // maintain standard layout on search pages if( !is_search() ) { $classes[] = 'two-column-images'; } } if(get_theme_mod( 'ct_tracks_background_image_setting')){ $classes[] = 'background-image-active'; } if(get_theme_mod( 'ct_tracks_texture_display_setting') == 'yes'){ $classes[] = 'background-texture-active'; } return $classes; } add_filter( 'body_class', 'ct_tracks_body_class' ); // calls pages for menu if menu not set function ct_tracks_wp_page_menu() { wp_page_menu(array( "menu_class" => "menu-unset" ) ); } function ct_tracks_add_editor_styles() { add_editor_style( 'styles/custom-editor-style.css' ); } add_action( 'admin_init', 'ct_tracks_add_editor_styles' ); function ct_tracks_post_class_update($classes){ global $post; // if on blog, add excerpt class and zoom class if ( ! is_singular() ) { $classes[] = 'excerpt'; // add image zoom class $setting = get_theme_mod('additional_options_image_zoom_settings'); if( $setting != 'no-zoom' ) { $classes[] = 'zoom'; } } if ( is_singular() ) { $classes[] = 'entry'; } // add class for posts with Featured Videos if( get_post_meta( $post->ID, 'ct_tracks_video_key', true ) ) { // only add on blog/archive if enabled if( is_home() || is_archive() ) { $display_setting = get_post_meta( $post->ID, 'ct_tracks_video_display_key', true ); // if post has video enabled on blog if( $display_setting == 'blog' || $display_setting == 'both' ) { $classes[] = 'has-video'; } } else { $classes[] = 'has-video'; } } // if < 3.9 if( version_compare( get_bloginfo('version'), '3.9', '<') ) { // add the has-post-thumbnail class if( has_post_thumbnail() ) { $classes[] = 'has-post-thumbnail'; } } return $classes; } add_filter( 'post_class', 'ct_tracks_post_class_update' ); /* add a smaller size for the portfolio page */ if( function_exists('add_image_size')){ add_image_size('blog', 700, 350); } function ct_tracks_odd_even_post_class( $classes ) { // access the post object global $wp_query; // add even/odd class $classes[] = ($wp_query->current_post % 2 == 0) ? 'odd' : 'even'; // add post # class $classes[] = "excerpt-" . ($wp_query->current_post + 1); return $classes; } add_filter ( 'post_class' , 'ct_tracks_odd_even_post_class' ); // array of social media site names if ( !function_exists( 'ct_tracks_social_site_list' ) ) { function ct_tracks_social_site_list() { $social_sites = array( 'twitter', 'facebook', 'google-plus', 'flickr', 'pinterest', 'youtube', 'vimeo', 'tumblr', 'dribbble', 'rss', 'linkedin', 'instagram', 'reddit', 'soundcloud', 'spotify', 'vine', 'yahoo', 'behance', 'codepen', 'delicious', 'stumbleupon', 'deviantart', 'digg', 'git', 'hacker-news', 'steam', 'vk', 'weibo', 'tencent-weibo', 'email' ); return apply_filters( 'ct_tracks_social_site_list_filter', $social_sites ); } } // for above the post titles if( ! function_exists( 'ct_tracks_category_link' ) ) { function ct_tracks_category_link() { $category = get_the_category(); $category_link = get_category_link( $category[0]->term_id ); $category_name = $category[0]->cat_name; $html = "" . $category_name . ""; echo $html; } } function ct_tracks_custom_css_output(){ $custom_css = get_theme_mod('ct_tracks_custom_css_setting'); /* output custom css */ if($custom_css) { $custom_css = wp_filter_nohtml_kses( $custom_css ); wp_add_inline_style('style', $custom_css); } } add_action('wp_enqueue_scripts','ct_tracks_custom_css_output', 20); function ct_tracks_background_image_output(){ $background_image = get_theme_mod( 'ct_tracks_background_image_setting'); if($background_image){ $background_image_css = " .background-image { background-image: url('$background_image'); } "; wp_add_inline_style('style', $background_image_css); } } add_action('wp_enqueue_scripts','ct_tracks_background_image_output', 20); function ct_tracks_background_texture_output(){ $background_texture = get_theme_mod( 'ct_tracks_background_texture_setting'); $background_texture_display = get_theme_mod('ct_tracks_texture_display_setting'); if($background_texture && $background_texture_display == 'yes'){ $background_texture_css = " .overflow-container { background-image: url('" . plugins_url() . "/tracks-background-textures/textures/$background_texture.png'); } "; wp_add_inline_style('style', $background_texture_css); } } add_action('wp_enqueue_scripts','ct_tracks_background_texture_output', 20); // green checkmark icon used in Post Video input function ct_tracks_green_checkmark_svg() { $svg = ' green checkmark icon '; return $svg; } // loading indicator used in Post Video input function ct_tracks_loading_indicator_svg() { $svg = ' loading icon '; return $svg; } if ( ! function_exists( '_wp_render_title_tag' ) ) : function ct_tracks_add_title_tag() { ?> <?php wp_title( ' | ' ); ?> "; $post = ""; } $featured_image = $pre . '' . $post; } return $featured_image; } add_filter( 'ct_tracks_featured_image', 'ct_tracks_two_column_images_featured_image', 10, 3 ); function ct_tracks_full_width_images_featured_image($featured_image, $image, $has_image) { // if there is a featured image and two column images layout is active if( $has_image && get_theme_mod( 'premium_layouts_setting' ) == 'full-width-images' ) { // setup vars for content surrounding image $pre = ''; $post = ''; // if singular, add container if( is_singular() ) { $pre = ""; } // get image type to check if img will be needed $blog_image_type = get_theme_mod( 'premium_layouts_full_width_image_height' ); $post_image_type = get_theme_mod( 'premium_layouts_full_width_image_height_post' ); // if blog/archive and image-based height, or post/page and image-based height if( // if archive/blog and image type is set to image or not set yet ( ( is_archive() || is_home() ) && ( empty($blog_image_type) || $blog_image_type == 'image' ) ) // or if is post and post height type is set to image or not set yet || ( is_singular() && ( empty($post_image_type) || $post_image_type == 'image' ) ) ){ $featured_image = ''; } $featured_image = $pre . $featured_image . $post; } return $featured_image; } add_filter( 'ct_tracks_featured_image', 'ct_tracks_full_width_images_featured_image', 10, 3 ); function ct_tracks_loop_pagination(){ global $wp_query; // If there's not more than one page, return nothing. if ( 1 >= $wp_query->max_num_pages ) { return; } /* Set up some default arguments for the paginate_links() function. */ $defaults = array( 'base' => add_query_arg( 'paged', '%#%' ), 'format' => '', 'mid_size' => 1 ); $loop_pagination = ''; return $loop_pagination; } // Adds useful meta tags function ct_tracks_add_meta_elements() { $meta_elements = ''; /* Charset */ $meta_elements .= sprintf( '' . "\n", get_bloginfo( 'charset' ) ); /* Viewport */ $meta_elements .= '' . "\n"; /* Theme name and current version */ $theme = wp_get_theme( get_template() ); $template = sprintf( '' . "\n", esc_attr( $theme->get( 'Name' ) ), esc_attr( $theme->get( 'Version' ) ) ); $meta_elements .= $template; echo $meta_elements; } add_action( 'wp_head', 'ct_tracks_add_meta_elements', 1 ); /* Move the WordPress generator to a better priority. */ remove_action( 'wp_head', 'wp_generator' ); add_action( 'wp_head', 'wp_generator', 1 );