'loop-container', 'footer' => 'overflow-container', 'render' => 'ct_tracks_infinite_scroll_render' ) ); require_once( trailingslashit( get_template_directory() ) . 'theme-options.php' ); foreach ( glob( trailingslashit( get_template_directory() ) . 'inc/*.php' ) as $filename ) { include $filename; } foreach ( glob( trailingslashit( get_template_directory() ) . 'licenses/*.php' ) as $filename ) { include $filename; } foreach ( glob( trailingslashit( get_template_directory() ) . 'licenses/functions/*.php' ) as $filename ) { include $filename; } register_nav_menus( array( 'primary' => __( 'Primary', 'tracks' ), 'secondary' => __( 'Secondary', 'tracks' ), 'footer' => __( 'Footer', 'tracks' ) ) ); load_theme_textdomain( 'tracks', get_template_directory() . '/languages' ); } } add_action( 'after_setup_theme', 'ct_tracks_theme_setup', 10 ); function ct_tracks_register_widget_areas() { // after post content 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' => '

' ) ); // after page content 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' => '

' ) ); // footer 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' ); 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' ); 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' ); if ( ! function_exists( 'ct_tracks_excerpt' ) ) { function ct_tracks_excerpt() { global $post; $setting = get_theme_mod( 'premium_layouts_full_width_full_post' ); $read_more_text = get_theme_mod( 'read_more_text' ); $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() ) { if ( $ismore ) { // Has to be written this way because i18n text CANNOT be stored in a variable if ( ! empty( $read_more_text ) ) { the_content( $read_more_text . " " . get_the_title() . "" ); } else { the_content( __( 'Read the Post', 'tracks' ) . " " . get_the_title() . "" ); } } else { the_content(); } } elseif ( $ismore ) { if ( ! empty( $read_more_text ) ) { the_content( $read_more_text . " " . get_the_title() . "" ); } else { the_content( __( 'Read the Post', 'tracks' ) . " " . get_the_title() . "" ); } } else { the_excerpt(); } } } if ( ! function_exists( 'ct_tracks_excerpt_read_more_link' ) ) { function ct_tracks_excerpt_read_more_link( $output ) { global $post; $read_more_text = get_theme_mod( 'read_more_text' ); if ( ! empty( $read_more_text ) ) { return $output . "

    " . $read_more_text . "" . get_the_title() . "

    "; } else { return $output . "

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

    "; } } } add_filter( 'the_excerpt', 'ct_tracks_excerpt_read_more_link' ); 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 ( ! empty( $new_excerpt_length ) && $new_excerpt_length != 15 ) { return $new_excerpt_length; } elseif ( $new_excerpt_length === 0 ) { return 0; } else { return 15; } } } add_filter( 'excerpt_length', 'ct_tracks_custom_excerpt_length', 999 ); if ( ! function_exists( 'ct_tracks_new_excerpt_more' ) ) { function ct_tracks_new_excerpt_more( $more ) { $new_excerpt_length = get_theme_mod( 'additional_options_excerpt_length_settings' ); $excerpt_more = ( $new_excerpt_length === 0 ) ? '' : '…'; return $excerpt_more; } } add_filter( 'excerpt_more', 'ct_tracks_new_excerpt_more' ); 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() { global $post; $has_image = false; $featured_image = ''; $image = ''; // get the current layout $premium_layout = get_theme_mod( 'premium_layouts_setting' ); 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' ); } else { $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); } $image = $image[0]; $has_image = true; } // if no featured image, try fallback if ( $has_image == false ) { if ( get_theme_mod( 'additional_options_no_featured_image' ) == 'fallback' ) { $image = get_theme_mod( 'additional_options_fallback_featured_image' ); if ( $image ) { $has_image = true; } } } 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 = ""; } else { $featured_image = ""; } } $featured_image = apply_filters( 'ct_tracks_featured_image', $featured_image, $image, $has_image ); if ( $featured_image ) { echo $featured_image; } } } 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' ) { $classes[] = 'full-width-images'; if ( ( is_home() || is_archive() || is_search() ) && 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' ) { $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' ); 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 ( ! is_singular() ) { $setting = get_theme_mod( 'additional_options_image_zoom_settings' ); $classes[] = 'excerpt'; if ( $setting != 'no-zoom' ) { $classes[] = 'zoom'; } } else { $classes[] = 'entry'; } if ( get_post_meta( $post->ID, 'ct_tracks_video_key', true ) ) { if ( is_home() || is_archive() ) { $display_setting = get_post_meta( $post->ID, 'ct_tracks_video_display_key', true ); if ( $display_setting == 'blog' || $display_setting == 'both' ) { $classes[] = 'has-video'; } } else { $classes[] = 'has-video'; } } $featured_image_fallback = get_theme_mod( 'additional_options_no_featured_image' ); // if full or not set b/c full is the default (and Customizer doesn't save by default) if ( $featured_image_fallback == 'full' || empty( $featured_image_fallback ) ) { $classes[] = 'full-without-featured'; } return $classes; } add_filter( 'post_class', 'ct_tracks_post_class_update' ); if ( function_exists( 'add_image_size' ) ) { add_image_size( 'blog', 700, 350 ); } function ct_tracks_odd_even_post_class( $classes ) { global $wp_query; // Jetpack starts new loops of 7 posts, so it always ends with odd leading to 2 // posts in a row with content on the left if ( // if jetpack infinite scroll is active class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'infinite-scroll' ) // and the current page is an even page (will be 1,3,5 b/c page starts with 0) && get_query_var( 'paged' ) % 2 != 0 ) { // flip the classes - start with even $classes[] = ( $wp_query->current_post % 2 == 0 ) ? 'even' : 'odd'; } else { // 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' ); 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', 'foursquare', 'slack', 'slideshare', 'skype', 'whatsapp', 'qq', 'wechat', 'xing', '500px', 'digg', 'github', 'hacker-news', 'steam', 'vk', 'weibo', 'tencent-weibo', 'paypal', 'email', 'email-form' ); 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 = "" . esc_attr( $category_name ) . ""; echo $html; } } function ct_tracks_custom_css_output() { $custom_css = get_theme_mod( 'ct_tracks_custom_css_setting' ); if ( $custom_css ) { $custom_css = ct_tracks_sanitize_css( $custom_css ); wp_add_inline_style( 'ct-tracks-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'); } "; $background_image_css = ct_tracks_sanitize_css( $background_image_css ); wp_add_inline_style( 'ct-tracks-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'); } "; $background_texture_css = ct_tracks_sanitize_css( $background_texture_css ); wp_add_inline_style( 'ct-tracks-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 ( $has_image && get_theme_mod( 'premium_layouts_setting' ) == 'full-width-images' ) { $pre = ''; $post = ''; if ( is_singular() ) { $pre = ""; } $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_add_meta_elements() { $meta_elements = ''; $meta_elements .= sprintf( '' . "\n", get_bloginfo( 'charset' ) ); $meta_elements .= '' . "\n"; $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 ); function ct_tracks_infinite_scroll_render() { while ( have_posts() ) { the_post(); // Two-column Images Layout if ( get_theme_mod( 'premium_layouts_setting' ) == 'two-column-images' ) { get_template_part( 'licenses/content/content-two-column-images' ); } // Full-width Images Layout elseif ( get_theme_mod( 'premium_layouts_setting' ) == 'full-width-images' ) { get_template_part( 'licenses/content/content-full-width-images' ); } // Blog - No Premium Layout else { get_template_part( 'content', 'archive' ); } } } if ( ! function_exists( 'ct_tracks_get_content_template' ) ) { function ct_tracks_get_content_template() { /* Blog */ if ( is_home() ) { /* Two-column Images Layout */ if ( get_theme_mod( 'premium_layouts_setting' ) == 'two-column-images' ) { get_template_part( 'licenses/content/content-two-column-images' ); } /* Full-width Images Layout */ elseif ( get_theme_mod( 'premium_layouts_setting' ) == 'full-width-images' ) { get_template_part( 'licenses/content/content-full-width-images' ); } /* Blog - No Premium Layout */ else { get_template_part( 'content', 'archive' ); } } /* Post */ elseif ( is_singular( 'post' ) ) { get_template_part( 'content' ); comments_template(); } /* Page */ elseif ( is_page() ) { get_template_part( 'content', 'page' ); comments_template(); } /* Attachment */ elseif ( is_attachment() ) { get_template_part( 'content', 'attachment' ); comments_template(); } /* Archive */ elseif ( is_archive() ) { /* check if bbPress is active */ if ( function_exists( 'is_bbpress' ) ) { /* if is bbPress forum list */ if ( is_bbpress() ) { get_template_part( 'content/bbpress' ); } /* normal archive */ else { get_template_part( 'content', 'archive' ); } } elseif ( get_theme_mod( 'premium_layouts_setting' ) == 'two-column-images' ) { get_template_part( 'licenses/content/content-two-column-images' ); } elseif ( get_theme_mod( 'premium_layouts_setting' ) == 'full-width-images' ) { get_template_part( 'licenses/content/content-full-width-images' ); } else { get_template_part( 'content', 'archive' ); } } /* bbPress */ elseif ( function_exists( 'is_bbpress' ) && is_bbpress() ) { get_template_part( 'content/bbpress' ); } /* Custom Post Types */ else { get_template_part( 'content' ); } } } // allow skype URIs to be used function ct_tracks_allow_skype_protocol( $protocols ){ $protocols[] = 'skype'; return $protocols; } add_filter( 'kses_allowed_protocols' , 'ct_tracks_allow_skype_protocol' );