__( 'Primary Menu', 'automobile' ), 'header-top' => __( 'Header Top Menu', 'automobile' ), 'header-right' => __( 'Header Right Menu', 'automobile' ), ) ); /** * Enable support for Post Formats */ add_theme_support( 'post-formats', array( 'aside', 'image', 'video', 'quote', 'link' ) ); /** * Setup the WordPress core custom background feature. */ $default_options = automobile_get_default_theme_options(); //Get Default Theme Options Values $default_bg_color = $default_options['background_color']; add_theme_support( 'custom-background', apply_filters( 'automobile_custom_background_args', array( 'default-color' => $default_bg_color ) ) ); /** * Setup Editor style */ add_editor_style( 'css/editor-style.css' ); /** * Setup title support for theme * Supported from WordPress version 4.1 onwards * More Info: https://make.wordpress.org/core/2014/10/29/title-tags-in-4-1/ */ add_theme_support( 'title-tag' ); /** * Setup Custom Logo Support for theme * Supported from WordPress version 4.5 onwards * More Info: https://make.wordpress.org/core/2016/03/10/custom-logo/ */ add_theme_support( 'custom-logo' ); /** * Setup Infinite Scroll using JetPack if navigation type is set */ $pagination_type = isset( $options['pagination_type'] ) ? $options['pagination_type'] : ''; if( 'infinite-scroll-click' == $pagination_type ) { add_theme_support( 'infinite-scroll', array( 'type' => 'click', 'container' => 'main', 'footer' => 'page' ) ); } else if ( 'infinite-scroll-scroll' == $pagination_type ) { //Override infinite scroll disable scroll option update_option('infinite_scroll', true); add_theme_support( 'infinite-scroll', array( 'type' => 'scroll', 'container' => 'main', 'footer' => 'page' ) ); } } endif; // automobile_setup add_action( 'after_setup_theme', 'automobile_setup' ); /** * Enqueue scripts and styles * * @uses wp_register_script, wp_enqueue_script, wp_register_style, wp_enqueue_style, wp_localize_script * @action wp_enqueue_scripts * * @since Automobile 0.1 */ function automobile_scripts() { $options = automobile_get_theme_options(); //Used default Google fonts $automobile_fonts = array( 'Oswald', 'Quattrocento' ); $web_fonts_stylesheet = '//fonts.googleapis.com/css?family='; $i = 0; foreach( $automobile_fonts as $automobile_font ) { if( $i )// only set | to $web_fonts_stylesheet from second loop onwards $web_fonts_stylesheet .='%7c'; $web_fonts_stylesheet .= $automobile_font . ':300,300italic,regular,italic,600,600italic'; $i = 1; } $web_fonts_stylesheet .= '&subset=latin'; wp_register_style( 'automobile-web-font', $web_fonts_stylesheet, false, null ); wp_enqueue_style( 'automobile-style', get_stylesheet_uri(), array( 'automobile-web-font' ), CLEAN_MAGAZINE_THEME_VERSION ); wp_enqueue_script( 'automobile-navigation', get_template_directory_uri() . '/js/navigation.min.js', array(), '20120206', true ); wp_enqueue_script( 'automobile-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.min.js', array(), '20130115', true ); /** * Adds JavaScript to pages with the comment form to support * sites with threaded comments (when in use). */ if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } //For genericons wp_enqueue_style( 'genericons', get_template_directory_uri() . '/css/genericons/genericons.css', false, '3.4.1' ); /** * Loads up Responsive Menu JS and fit vids */ wp_enqueue_script('sidr', get_template_directory_uri() . '/js/jquery.sidr.min.js', array('jquery'), '2.2.1.1', false ); /** * Loads up fit vids */ wp_enqueue_script( 'fitvids', get_template_directory_uri() . '/js/fitvids.min.js', array( 'jquery' ), '1.1', true ); /** * Loads up Cycle JS */ if( $options['featured_slider_option'] != 'disabled' || $options['news_ticker_option'] != 'disabled' ) { wp_register_script( 'jquery.cycle2', get_template_directory_uri() . '/js/jquery.cycle/jquery.cycle2.min.js', array( 'jquery' ), '2.1.5', true ); $transition_effects = array( $options['featured_slide_transition_effect'], $options['news_ticker_transition_effect'] ); /** * Condition checks for additional slider transition plugins */ // Scroll Vertical transition plugin addition if ( in_array( 'scrollVert', $transition_effects ) ){ wp_enqueue_script( 'jquery.cycle2.scrollVert', get_template_directory_uri() . '/js/jquery.cycle/jquery.cycle2.scrollVert.min.js', array( 'jquery.cycle2' ), '20140128', true ); } // Flip transition plugin addition if ( in_array( 'flipHorz', $transition_effects ) || in_array( 'flipVert', $transition_effects ) ){ wp_enqueue_script( 'jquery.cycle2.flip', get_template_directory_uri() . '/js/jquery.cycle/jquery.cycle2.flip.min.js', array( 'jquery.cycle2' ), '20140128', true ); } // Suffle transition plugin addition if ( in_array( 'tileSlide', $transition_effects ) || in_array( 'tileBlind', $transition_effects ) ){ wp_enqueue_script( 'jquery.cycle2.tile', get_template_directory_uri() . '/js/jquery.cycle/jquery.cycle2.tile.min.js', array( 'jquery.cycle2' ), '20140128', true ); } // Suffle transition plugin addition if ( in_array( 'shuffle', $transition_effects ) ){ wp_enqueue_script( 'jquery.cycle2.shuffle', get_template_directory_uri() . '/js/jquery.cycle/jquery.cycle2.shuffle.min.js', array( 'jquery.cycle2' ), '20140128 ', true ); } //Load jquery cycle alone if no plugin is required if ( !( in_array( 'scrollVert', $transition_effects ) || in_array( 'flipHorz', $transition_effects ) || in_array( 'flipVert', $transition_effects ) || in_array( 'tileSlide', $transition_effects ) || in_array( 'tileBlind', $transition_effects ) || in_array( 'shuffle', $transition_effects ) ) ){ wp_enqueue_script( 'jquery.cycle2' ); } } /** * Loads up Scroll Up script */ if ( ! $options['disable_scrollup'] ) { wp_enqueue_script( 'automobile-scrollup', get_template_directory_uri() . '/js/scrollup.min.js', array( 'jquery' ), '20072014', true ); } /** * Enqueue custom script for Automobile. */ wp_enqueue_script( 'automobile-custom-scripts', get_template_directory_uri() . '/js/custom-scripts.min.js', array( 'jquery' ), null ); } add_action( 'wp_enqueue_scripts', 'automobile_scripts' ); /** * Enqueue scripts and styles for Metaboxes * @uses wp_register_script, wp_enqueue_script, and wp_enqueue_style * * @action admin_print_scripts-post-new, admin_print_scripts-post, admin_print_scripts-page-new, admin_print_scripts-page * * @since Automobile 0.1 */ function automobile_enqueue_metabox_scripts() { //Scripts wp_enqueue_script( 'automobile-metabox', get_template_directory_uri() . '/js/automobilemetabox.min.js', array( 'jquery', 'jquery-ui-tabs' ), '2013-10-05' ); //CSS Styles wp_enqueue_style( 'automobile-metabox-tabs', get_template_directory_uri() . '/css/metabox-tabs.css' ); } add_action( 'admin_print_scripts-post-new.php', 'automobile_enqueue_metabox_scripts', 11 ); add_action( 'admin_print_scripts-post.php', 'automobile_enqueue_metabox_scripts', 11 ); add_action( 'admin_print_scripts-page-new.php', 'automobile_enqueue_metabox_scripts', 11 ); add_action( 'admin_print_scripts-page.php', 'automobile_enqueue_metabox_scripts', 11 ); /** * Default Options. */ require get_template_directory() . '/inc/default-options.php'; /** * Custom Header. */ require get_template_directory() . '/inc/custom-header.php'; /** * Structure for Automobile */ require get_template_directory() . '/inc/structure.php'; /** * Customizer additions. */ require get_template_directory() . '/inc/customizer-includes/customizer.php'; /** * Custom Menus */ require get_template_directory() . '/inc/menus.php'; /** * Load Header Highlight Content file. */ require get_template_directory() . '/inc/header-highlight-content.php'; /** * Load Slider file. */ require get_template_directory() . '/inc/featured-slider.php'; /** * Load Featured Content. */ require get_template_directory() . '/inc/featured-content.php'; /** * News Ticker */ require get_template_directory() . '/inc/news-ticker.php'; /** * Load Breadcrumb file. */ require get_template_directory() . '/inc/breadcrumb.php'; /** * Load Widgets and Sidebars */ require get_template_directory() . '/inc/widgets/widgets.php'; /** * Load Social Icons */ require get_template_directory() . '/inc/social-icons.php'; /** * Load Metaboxes */ require get_template_directory() . '/inc/metabox.php'; /** * Returns the options array for Automobile. * @uses get_theme_mod * * @since Automobile 0.1 */ function automobile_get_theme_options() { $automobile_default_options = automobile_get_default_theme_options(); return array_merge( $automobile_default_options , get_theme_mod( 'automobile_theme_options', $automobile_default_options ) ) ; } /** * Flush out all transients * * @uses delete_transient * * @action customize_save, automobile_customize_preview (see automobile_customizer function: automobile_customize_preview) * * @since Automobile 0.1 */ function automobile_flush_transients(){ delete_transient( 'automobile_header_highlight_content' ); delete_transient( 'automobile_featured_content' ); delete_transient( 'automobile_news_ticker' ); delete_transient( 'automobile_featured_slider' ); delete_transient( 'automobile_custom_css' ); delete_transient( 'automobile_footer_content' ); delete_transient( 'automobile_featured_image' ); delete_transient( 'automobile_social_icons' ); delete_transient( 'automobile_scrollup' ); delete_transient( 'all_the_cool_cats' ); //Add Automobile default themes if there is no values if ( !get_theme_mod('automobile_theme_options') ) { set_theme_mod( 'automobile_theme_options', automobile_get_default_theme_options() ); } } add_action( 'customize_save', 'automobile_flush_transients' ); /** * Flush out category transients * * @uses delete_transient * * @action edit_category * * @since Automobile 0.1 */ function automobile_flush_category_transients(){ delete_transient( 'all_the_cool_cats' ); } add_action( 'edit_category', 'automobile_flush_category_transients' ); /** * Flush out post related transients * * @uses delete_transient * * @action save_post * * @since Automobile 0.1 */ function automobile_flush_post_transients(){ delete_transient( 'automobile_featured_content' ); delete_transient( 'automobile_news_ticker' ); delete_transient( 'automobile_featured_slider' ); delete_transient( 'automobile_featured_image' ); delete_transient( 'all_the_cool_cats' ); } add_action( 'save_post', 'automobile_flush_post_transients' ); if ( ! function_exists( 'automobile_custom_css' ) ) : /** * Enqueue Custon CSS * * @uses set_transient, wp_head, wp_enqueue_style * * @action wp_enqueue_scripts * * @since Automobile 0.1 */ function automobile_custom_css() { //automobile_flush_transients(); $options = automobile_get_theme_options(); $defaults = automobile_get_default_theme_options(); if ( ( !$automobile_custom_css = get_transient( 'automobile_custom_css' ) ) ) { $automobile_custom_css =''; $text_color = get_header_textcolor(); if ( 'blank' == $text_color ){ $automobile_custom_css .= ".site-title a, .site-description { position: absolute !important; clip: rect(1px 1px 1px 1px); clip: rect(1px, 1px, 1px, 1px); }". "\n"; } elseif ( HEADER_TEXTCOLOR != $text_color ) { $automobile_custom_css .= ".site-title a, .site-description { color: #". $text_color ."; }". "\n"; } //Custom CSS Option if( !empty( $options[ 'custom_css' ] ) ) { $automobile_custom_css .= $options[ 'custom_css'] . "\n"; } if ( '' != $automobile_custom_css ){ echo '' . "\n"; $automobile_custom_css = '' . "\n" . '' . "\n"; } set_transient( 'automobile_custom_css', htmlspecialchars_decode( $automobile_custom_css ), 86940 ); } echo $automobile_custom_css; } endif; //automobile_custom_css add_action( 'wp_head', 'automobile_custom_css', 101 ); /** * Alter the query for the main loop in homepage * * @action pre_get_posts * * @since Automobile 0.1 */ function automobile_alter_home( $query ){ $options = automobile_get_theme_options(); $cats = $options[ 'front_page_category' ]; if ( is_array( $cats ) && !in_array( '0', $cats ) ) { if( $query->is_main_query() && $query->is_home() ) { $query->query_vars['category__in'] = $cats; } } } add_action( 'pre_get_posts','automobile_alter_home' ); if ( ! function_exists( 'automobile_content_nav' ) ) : /** * Display navigation to next/previous pages when applicable * * @since Automobile 0.1 */ function automobile_content_nav( $nav_id ) { global $wp_query, $post; // Don't print empty markup on single pages if there's nowhere to navigate. if ( is_single() ) { $previous = ( is_attachment() ) ? get_post( $post->post_parent ) : get_adjacent_post( false, '', true ); $next = get_adjacent_post( false, '', false ); if ( ! $next && ! $previous ) return; } // Don't print empty markup in archives if there's only one page. if ( $wp_query->max_num_pages < 2 && ( is_home() || is_archive() || is_search() ) ) { return; } $options = automobile_get_theme_options(); $pagination_type = $options['pagination_type']; $nav_class = ( is_single() ) ? 'site-navigation post-navigation' : 'site-navigation paging-navigation'; /** * Check if navigation type is Jetpack Infinite Scroll and if it is enabled, else goto default pagination * if it's active then disable pagination */ if ( ( 'infinite-scroll-click' == $pagination_type || 'infinite-scroll-scroll' == $pagination_type ) && class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'infinite-scroll' ) ) { return false; } ?> comment_type || 'trackback' == $comment->comment_type ) : ?>
  • >
    ', '' ); ?>
  • >
    says:', 'automobile' ), sprintf( '%s', get_comment_author_link() ) ); ?>
    comment_approved ) : ?>

    'div-comment', 'depth' => $depth, 'max_depth' => $args['max_depth'], 'before' => '
    ', 'after' => '
    ', ) ) ); ?>
    $post->post_parent, 'fields' => 'ids', 'numberposts' => 1, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID' ) ); // If there is more than 1 attachment in a gallery... if ( count( $attachment_ids ) > 1 ) { foreach ( $attachment_ids as $attachment_id ) { if ( $attachment_id == $post->ID ) { $next_id = current( $attachment_ids ); break; } } // get the URL of the next image attachment... if ( $next_id ) $next_attachment_url = get_attachment_link( $next_id ); // or get the URL of the first image attachment. else $next_attachment_url = get_attachment_link( array_shift( $attachment_ids ) ); } printf( '%3$s', esc_url( $next_attachment_url ), the_title_attribute( array( 'echo' => false ) ), wp_get_attachment_image( $post->ID, $attachment_size ) ); } endif; //automobile_the_attached_image if ( ! function_exists( 'automobile_entry_meta' ) ) : /** * Prints HTML with meta information for the current post-date/time and author. * * @since Automobile 0.1 */ function automobile_entry_meta() { echo '

    '; $time_string = ''; if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) { $time_string = ''; } $time_string = sprintf( $time_string, esc_attr( get_the_date( 'c' ) ), esc_html( get_the_date() ), esc_attr( get_the_modified_date( 'c' ) ), esc_html( get_the_modified_date() ) ); printf( '%1$s%3$s', sprintf( _x( 'Posted on', 'Used before publish date.', 'automobile' ) ), esc_url( get_permalink() ), $time_string ); if ( is_singular() || is_multi_author() ) { printf( '', sprintf( _x( 'Author', 'Used before post author name.', 'automobile' ) ), esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), esc_html( get_the_author() ) ); } if ( ! post_password_required() && ( comments_open() || '0' != get_comments_number() ) ) { echo ''; comments_popup_link( esc_html__( 'Leave a comment', 'automobile' ), esc_html__( '1 Comment', 'automobile' ), esc_html__( '% Comments', 'automobile' ) ); echo ''; } edit_post_link( esc_html__( 'Edit', 'automobile' ), '', '' ); echo '

    '; } endif; //automobile_entry_meta if ( ! function_exists( 'automobile_tag_category' ) ) : /** * Prints HTML with meta information for the categories, tags. * * @since Automobile 0.1 */ function automobile_tag_category() { echo '

    '; if ( 'post' == get_post_type() ) { $categories_list = get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'automobile' ) ); if ( $categories_list && automobile_categorized_blog() ) { printf( '%1$s%2$s', sprintf( _x( 'Categories', 'Used before category names.', 'automobile' ) ), $categories_list ); } $tags_list = get_the_tag_list( '', _x( ', ', 'Used between list items, there is a space after the comma.', 'automobile' ) ); if ( $tags_list ) { printf( '%1$s%2$s', sprintf( _x( 'Tags', 'Used before tag names.', 'automobile' ) ), $tags_list ); } } echo '

    '; } endif; //automobile_tag_category if ( ! function_exists( 'automobile_get_highlight_meta' ) ) : /** * Returns HTML with meta information for the categories, tags, date and author. * * @param [boolean] $hide_category Adds screen-reader-text class to category meta if true * @param [boolean] $hide_tags Adds screen-reader-text class to tag meta if true * @param [boolean] $hide_posted_by Adds screen-reader-text class to date meta if true * @param [boolean] $hide_author Adds screen-reader-text class to author meta if true * * @since Automobile 0.1 */ function automobile_get_highlight_meta( $hide_category = false, $hide_tags = false, $hide_posted_by = false, $hide_author = false ) { $output = '

    '; if ( 'post' == get_post_type() ) { $class = $hide_category ? 'screen-reader-text' : ''; $categories_list = get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'automobile' ) ); if ( $categories_list && automobile_categorized_blog() ) { $output .= sprintf( '%1$s%2$s', sprintf( _x( 'Categories', 'Used before category names.', 'automobile' ) ), $categories_list ); } $class = $hide_tags ? 'screen-reader-text' : ''; $tags_list = get_the_tag_list( '', _x( ', ', 'Used between list items, there is a space after the comma.', 'automobile' ) ); if ( $tags_list ) { $output .= sprintf( '%1$s%2$s', sprintf( _x( 'Tags', 'Used before tag names.', 'automobile' ) ), $tags_list ); } $time_string = ''; if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) { $time_string = ''; } $time_string = sprintf( $time_string, esc_attr( get_the_date( 'c' ) ), esc_html( get_the_date() ), esc_attr( get_the_modified_date( 'c' ) ), esc_html( get_the_modified_date() ) ); $class = $hide_posted_by ? 'screen-reader-text' : ''; $output .= sprintf( '%1$s%3$s', sprintf( _x( 'Posted on', 'Used before publish date.', 'automobile' ) ), esc_url( get_permalink() ), $time_string ); if ( is_singular() || is_multi_author() ) { $class = $hide_author ? 'screen-reader-text' : ''; $output .= sprintf( '', sprintf( _x( 'Author', 'Used before post author name.', 'automobile' ) ), esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), esc_html( get_the_author() ) ); } } $output .= '

    '; return $output; } endif; //automobile_get_highlight_meta /** * Returns true if a blog has more than 1 category * * @since Automobile 0.1 */ function automobile_categorized_blog() { if ( false === ( $all_the_cool_cats = get_transient( 'all_the_cool_cats' ) ) ) { // Create an array of all the categories that are attached to posts $all_the_cool_cats = get_categories( array( 'hide_empty' => 1, ) ); // Count the number of categories that are attached to the posts $all_the_cool_cats = count( $all_the_cool_cats ); set_transient( 'all_the_cool_cats', $all_the_cool_cats ); } if ( '1' != $all_the_cool_cats ) { // This blog has more than 1 category so automobile_categorized_blog should return true return true; } else { // This blog has only 1 category so automobile_categorized_blog should return false return false; } } /** * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link. * * @since Automobile 0.1 */ function automobile_page_menu_args( $args ) { $args['show_home'] = true; return $args; } add_filter( 'wp_page_menu_args', 'automobile_page_menu_args' ); /** * Filter in a link to a content ID attribute for the next/previous image links on image attachment pages * * @since Automobile 0.1 */ function automobile_enhanced_image_navigation( $url, $id ) { if ( ! is_attachment() && ! wp_attachment_is_image( $id ) ) return $url; $image = get_post( $id ); if ( ! empty( $image->post_parent ) && $image->post_parent != $id ) $url .= '#main'; return $url; } add_filter( 'attachment_link', 'automobile_enhanced_image_navigation', 10, 2 ); /** * Count the number of footer sidebars to enable dynamic classes for the footer * * @since Automobile 0.1 */ function automobile_footer_sidebar_class() { $count = 0; if ( is_active_sidebar( 'footer-1' ) ) $count++; if ( is_active_sidebar( 'footer-2' ) ) $count++; if ( is_active_sidebar( 'footer-3' ) ) $count++; if ( is_active_sidebar( 'footer-4' ) ) $count++; $class = ''; switch ( $count ) { case '1': $class = 'one'; break; case '2': $class = 'two'; break; case '3': $class = 'three'; break; case '4': $class = 'four'; break; } if ( $class ) echo 'class="' . $class . '"'; } if ( ! function_exists( 'automobile_excerpt_length' ) ) : /** * Sets the post excerpt length to n words. * * function tied to the excerpt_length filter hook. * @uses filter excerpt_length * * @since Automobile 0.1 */ function automobile_excerpt_length( $length ) { // Getting data from Customizer Options $options = automobile_get_theme_options(); $length = $options['excerpt_length']; return $length; } endif; //automobile_excerpt_length add_filter( 'excerpt_length', 'automobile_excerpt_length' ); /** * Change the defult excerpt length of 30 to whatever passed as value * * @use excerpt(10) or excerpt (..) if excerpt length needs only 10 or whatevere * @uses get_permalink, get_the_excerpt */ function automobile_excerpt_desired( $num ) { $limit = $num+1; $excerpt = explode( ' ', get_the_excerpt(), $limit ); array_pop( $excerpt ); $excerpt = implode( " ",$excerpt ).""; return $excerpt; } if ( ! function_exists( 'automobile_continue_reading' ) ) : /** * Returns a "Custom Continue Reading" link for excerpts * * @since Automobile 0.1 */ function automobile_continue_reading() { // Getting data from Customizer Options $options = automobile_get_theme_options(); $more_tag_text = $options['excerpt_more_text']; return ' ' . sprintf( __( '%s', 'automobile' ) , $more_tag_text ) . ''; } endif; //automobile_continue_reading add_filter( 'excerpt_more', 'automobile_continue_reading' ); if ( ! function_exists( 'automobile_excerpt_more' ) ) : /** * Replaces "[...]" (appended to automatically generated excerpts) with automobile_continue_reading(). * * @since Automobile 0.1 */ function automobile_excerpt_more( $more ) { return automobile_continue_reading(); } endif; //automobile_excerpt_more add_filter( 'excerpt_more', 'automobile_excerpt_more' ); if ( ! function_exists( 'automobile_custom_excerpt' ) ) : /** * Adds Continue Reading link to more tag excerpts. * * function tied to the get_the_excerpt filter hook. * * @since Automobile 0.1 */ function automobile_custom_excerpt( $output ) { if ( has_excerpt() && ! is_attachment() ) { $output .= automobile_continue_reading(); } return $output; } endif; //automobile_custom_excerpt add_filter( 'get_the_excerpt', 'automobile_custom_excerpt' ); if ( ! function_exists( 'automobile_more_link' ) ) : /** * Replacing Continue Reading link to the_content more. * * function tied to the the_content_more_link filter hook. * * @since Automobile 0.1 */ function automobile_more_link( $more_link, $more_link_text ) { $options = automobile_get_theme_options(); $more_tag_text = $options['excerpt_more_text']; return str_replace( $more_link_text, $more_tag_text, $more_link ); } endif; //automobile_more_link add_filter( 'the_content_more_link', 'automobile_more_link', 10, 2 ); if ( ! function_exists( 'automobile_body_classes' ) ) : /** * Adds Automobile layout classes to the array of body classes. * * @since Automobile 0.1 */ function automobile_body_classes( $classes ) { $options = automobile_get_theme_options(); // Adds a class of group-blog to blogs with more than 1 published author if ( is_multi_author() ) { $classes[] = 'group-blog'; } $layout = automobile_get_theme_layout(); switch ( $layout ) { case 'left-sidebar': $classes[] = 'two-columns content-right'; break; case 'right-sidebar': $classes[] = 'two-columns content-left'; break; case 'no-sidebar': $classes[] = 'no-sidebar content-width'; break; } $current_content_layout = $options['content_layout']; if( "" != $current_content_layout ) { $classes[] = $current_content_layout; } //Count number of menus avaliable and set class accordingly $mobile_menu_count = 1; if ( has_nav_menu( 'header-right' ) ) { $mobile_menu_count++; } switch ( $mobile_menu_count ) { case 1: $classes[] = 'mobile-menu-one'; break; case 2: $classes[] = 'mobile-menu-two'; break; } if( is_active_sidebar( 'header-top-left' ) && is_active_sidebar( 'header-top-right' ) ) { $classes[] = 'header-top-two-columns'; } else if ( ( !is_active_sidebar( 'header-top-left' ) && !is_active_sidebar( 'header-top-right' ) ) && ( '' != ( $automobile_social_icons = automobile_get_social_icons() ) && has_nav_menu( 'header-top' ) ) ) { $classes[] = 'header-top-two-columns'; } $classes = apply_filters( 'automobile_body_classes', $classes ); return $classes; } endif; //automobile_body_classes add_filter( 'body_class', 'automobile_body_classes' ); if ( ! function_exists( 'automobile_post_classes' ) ) : /** * Adds Automobile post classes to the array of post classes. * used for supporting different content layouts * * @since Automobile 0.1 */ function automobile_post_classes( $classes ) { //Getting Ready to load data from Theme Options Panel $options = automobile_get_theme_options(); $contentlayout = $options['content_layout']; if ( is_archive() || is_home() ) { $classes[] = $contentlayout; } return $classes; } endif; //automobile_post_classes add_filter( 'post_class', 'automobile_post_classes' ); if ( ! function_exists( 'automobile_get_theme_layout' ) ) : /** * Returns Theme Layout prioritizing the meta box layouts * * @uses get_theme_mod * * @action wp_head * * @since Automobile 0.1 */ function automobile_get_theme_layout() { $id = ''; global $post, $wp_query; // Front page displays in Reading Settings $page_on_front = get_option('page_on_front') ; $page_for_posts = get_option('page_for_posts'); // Get Page ID outside Loop $page_id = $wp_query->get_queried_object_id(); // Blog Page or Front Page setting in Reading Settings if ( $page_id == $page_for_posts || $page_id == $page_on_front ) { $id = $page_id; } else if ( is_singular() ) { if ( is_attachment() ) { $id = $post->post_parent; } else { $id = $post->ID; } } //Get appropriate metabox value of layout if ( '' != $id ) { $layout = get_post_meta( $id, 'automobilelayout-option', true ); } else { $layout = 'default'; } //Load options data $options = automobile_get_theme_options(); //check empty and load default if ( empty( $layout ) || 'default' == $layout ) { $layout = $options['theme_layout']; } return $layout; } endif; //automobile_get_theme_layout if ( ! function_exists( 'automobile_archive_content_image' ) ) : /** * Template for Featured Image in Archive Content * * To override this in a child theme * simply create your own automobile_archive_content_image(), and that function will be used instead. * * @since Automobile 0.1 */ function automobile_archive_content_image() { $options = automobile_get_theme_options(); $featured_image = $options['content_layout']; if ( has_post_thumbnail() && 'full-content' != $featured_image ) { ?> get_queried_object_id(); if( $post) { if ( is_attachment() ) { $parent = $post->post_parent; $individual_featured_image = get_post_meta( $parent,'automobilefeatured-image', true ); } else { $individual_featured_image = get_post_meta( $page_id,'automobilefeatured-image', true ); } } if( empty( $individual_featured_image ) || ( !is_page() && !is_single() ) ) { $individual_featured_image = 'default'; } // Getting data from Theme Options $options = automobile_get_theme_options(); $featured_image = $options['single_post_image_layout']; if ( ( $individual_featured_image == 'disable' || '' == get_the_post_thumbnail() || ( $individual_featured_image=='default' && $featured_image == 'disabled') ) ) { echo ''; return false; } else { $class = ''; if ( 'default' == $individual_featured_image ) { $class = $featured_image; } else { $class = 'from-metabox ' . $individual_featured_image; } ?> get_queried_object_id(); if ( 'entire-site' == $enable_promotion || ( ( is_front_page() || ( is_home() && $page_for_posts != $page_id ) ) && 'homepage' == $enable_promotion ) ) { echo ' '; } } endif; // automobile_promotion_featured_content add_action( 'automobile_header', 'automobile_promotion_headline', 25 ); /** * Footer Text * * @get footer text from theme options and display them accordingly * @display footer_text * @action automobile_footer * * @since Automobile 0.1 */ function automobile_footer_content() { //automobile_flush_transients(); if ( ( !$automobile_footer_content = get_transient( 'automobile_footer_content' ) ) ) { echo ''; $automobile_content = automobile_get_content(); $automobile_footer_content = '
    '; set_transient( 'automobile_footer_content', $automobile_footer_content, 86940 ); } echo $automobile_footer_content; } add_action( 'automobile_footer', 'automobile_footer_content', 100 ); /** * Return the first image in a post. Works inside a loop. * @param [integer] $post_id [Post or page id] * @param [string/array] $size Image size. Either a string keyword (thumbnail, medium, large or full) or a 2-item array representing width and height in pixels, e.g. array(32,32). * @param [string/array] $attr Query string or array of attributes. * @return [string] image html * * @since Automobile 0.1 */ function automobile_get_first_image( $postID, $size, $attr ) { ob_start(); ob_end_clean(); $image = ''; $output = preg_match_all('//i', get_post_field('post_content', $postID ) , $matches); if( isset( $matches [1] [0] ) ) { //Get first image $first_img = $matches [1] [0]; return ''; } return false; } if ( ! function_exists( 'automobile_scrollup' ) ) { /** * This function loads Scroll Up Navigation * * @action automobile_footer action * @uses set_transient and delete_transient */ function automobile_scrollup() { //automobile_flush_transients(); if ( !$automobile_scrollup = get_transient( 'automobile_scrollup' ) ) { // get the data value from theme options $options = automobile_get_theme_options(); echo ''; //site stats, analytics header code if ( ! $options['disable_scrollup'] ) { $automobile_scrollup = '' ; } set_transient( 'automobile_scrollup', $automobile_scrollup, 86940 ); } echo $automobile_scrollup; } } add_action( 'automobile_after', 'automobile_scrollup', 10 ); if ( ! function_exists( 'automobile_page_post_meta' ) ) : /** * Post/Page Meta for Google Structure Data */ function automobile_page_post_meta() { $automobile_author_url = esc_url( get_author_posts_url( get_the_author_meta( "ID" ) ) ); $automobile_page_post_meta = '' . __( 'Posted on', 'automobile' ) . ' '; $automobile_page_post_meta .= '