esc_html__( 'Main Menu', 'short-news' ), 'social_menu' => esc_html__( 'Social Menu', 'short-news' ), ) ); /* * Switch default core markup for search form, comment form, and comments * to output valid HTML5. */ add_theme_support( 'html5', array( 'comment-form', 'comment-list', 'gallery', 'caption' ) ); // Enable support for Post Formats add_theme_support('post-formats', array( 'image', 'video', 'audio', 'gallery', 'quote' ) ); // Set up the WordPress Custom Background Feature. add_theme_support( 'custom-background', apply_filters( 'short_news_custom_background_args', array( 'default-color' => 'eeeeee', 'default-image' => '', ) ) ); // Set up the WordPress Custom Header Feature. add_theme_support( 'custom-header', apply_filters( 'short_news_custom_header_args', array( 'height' => 900, 'width' => 1600, 'flex-width' => true, 'flex-height' => true, 'default-text-color' => '111111', 'default-image' => '', 'wp-head-callback' => 'short_news_header_style', ) ) ); // Set up the WordPress Custom Logo Feature. add_theme_support( 'custom-logo', array( 'height' => 400, 'width' => 400, 'flex-width' => true, 'flex-height' => true, ) ); // Add theme support for selective refresh for widgets. add_theme_support( 'customize-selective-refresh-widgets' ); // This theme styles the visual editor to resemble the theme style, add_editor_style( array( 'assets/css/editor-style.css', short_news_fonts_url() ) ); // Custom template tags for this theme require get_template_directory() . '/inc/template-tags.php'; // Theme Customizer require get_template_directory() . '/inc/customizer.php'; // Custom styles handled by the Theme customizer require get_template_directory() . '/inc/custom-styles.php'; // Load Jetpack compatibility file require get_template_directory() . '/inc/jetpack.php'; } endif; add_action( 'after_setup_theme', 'short_news_setup' ); if ( ! function_exists( 'short_news_fonts_url' ) ) : /** * Register Google fonts. * * @return string Google fonts URL for the theme. */ function short_news_fonts_url() { $fonts_url = ''; $fonts = array(); $subsets = 'latin,latin-ext'; /* translators: If there are characters in your language that are not supported by Work Sans, translate this to 'off'. Do not translate into your own language. */ if ( 'off' !== _x( 'on', 'Work Sans: on or off', 'short-news' ) ) { $fonts[] = 'Work Sans:400,700,900,400italic'; } /* translators: If there are characters in your language that are not supported by Rubik, translate this to 'off'. Do not translate into your own language. */ if ( 'off' !== _x( 'on', 'Rubik: on or off', 'short-news' ) ) { $fonts[] = 'Rubik:400,700,400italic,700italic'; } /* translators: To add an additional character subset specific to your language, translate this to 'greek', 'cyrillic', 'devanagari' or 'vietnamese'. Do not translate into your own language. */ $subset = _x( 'no-subset', 'Add new subset (greek, cyrillic, devanagari, vietnamese)', 'short-news' ); if ( 'cyrillic' == $subset ) { $subsets .= ',cyrillic,cyrillic-ext'; } elseif ( 'greek' == $subset ) { $subsets .= ',greek,greek-ext'; } elseif ( 'devanagari' == $subset ) { $subsets .= ',devanagari'; } elseif ( 'vietnamese' == $subset ) { $subsets .= ',vietnamese'; } if ( $fonts ) { $fonts_url = add_query_arg( array( 'family' => urlencode( implode( '|', $fonts ) ), 'subset' => urlencode( $subsets ), ), '//fonts.googleapis.com/css' ); } return $fonts_url; } endif; /** * Enqueue scripts and styles. */ function short_news_scripts() { // Add Google Fonts, used in the main stylesheet. wp_enqueue_style( 'short-news-fonts', short_news_fonts_url(), array(), null ); // Add Social Icons. wp_enqueue_style( 'short-news-social-icons', get_template_directory_uri() . '/assets/css/socicon.css', array(), '3.6.2' ); // Theme stylesheet. wp_enqueue_style( 'short-news-style', get_stylesheet_uri(), array(), '1.0.4' ); wp_enqueue_script( 'short-news-skip-link-focus-fix', get_template_directory_uri() . '/assets/js/skip-link-focus-fix.js', array(), '20180901', true ); wp_enqueue_script( 'short-news-script', get_template_directory_uri() . '/assets/js/main.js', array( 'jquery' ), '20180928', true ); // Add Reading Time. if ( is_single() ) { wp_enqueue_script( 'short-news-reading-time', get_template_directory_uri() . '/assets/js/readingtime.js', array( 'jquery' ), '20180901', true ); wp_add_inline_script( 'short-news-reading-time', 'jQuery(document).ready(function($) { $(".entry-content").readingTime( { readingTimeTarget: ".reading-eta", wordCountTarget: ".word-count", wordsPerMinute: 180, round: true }); });' ); } // Add Breaking News. if ( get_theme_mod( 'show_header_top_bar', 1) && get_theme_mod('show_breaking_news', 1) ) { wp_enqueue_script( 'short-news-ticker', get_template_directory_uri() . '/assets/js/jquery.newsTicker.js', array( 'jquery' ), '1.0.11', true ); wp_add_inline_script( 'short-news-ticker', 'jQuery(document).ready(function(){ jQuery(".newsticker").newsTicker({ row_height: 30, max_rows: 1, speed: 600, direction: "down", duration: 2500, autostart: 1, pauseOnHover: 1 }); });' ); } if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } } add_action( 'wp_enqueue_scripts', 'short_news_scripts' ); /** * Register widget area. * * @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar */ function short_news_widgets_init() { register_sidebar( array( 'name' => __( 'Sidebar', 'short-news' ), 'id' => 'sidebar-1', 'description' => __( 'Add widgets here to appear in your sidebar.', 'short-news' ), 'before_widget' => '
', 'before_title' => ''; the_custom_logo(); echo '
'; } else { echo '' . get_bloginfo( 'name' ) . '
'; } } $description = get_bloginfo( 'description', 'display' ); if ( $description || is_customize_preview() ) : echo '' . $description . '
'; endif; } /** * Filter the except length. * */ function short_news_excerpt_length( $excerpt_length ) { if ( is_admin() ) { return $excerpt_length; } if ( is_home() ) { $excerpt_length = get_theme_mod( 'home_excerpt_length', 25 ); } elseif ( is_archive() || is_search() ) { $excerpt_length = get_theme_mod( 'archive_excerpt_length', 25 ); } else { $excerpt_length = 25; } return intval($excerpt_length); } add_filter( 'excerpt_length', 'short_news_excerpt_length', 999 ); /** * Filter the "read more" excerpt string link to the post. * * @param string $more "Read more" excerpt string. */ function short_news_excerpt_more( $more ) { if ( is_admin() ) { return $more; } $home_layout = get_theme_mod('home_layout', 'standard-grid'); $archive_layout = get_theme_mod( 'archive_layout', 'grid' ); if ( ( is_home() && 'standard' == $home_layout ) || ( ( is_archive() || is_search() ) && 'standard' == $archive_layout ) ) { $more = sprintf( '', esc_url( get_permalink( get_the_ID() ) ), esc_html__( 'Continue reading', 'short-news' ) ); } else { $more = ' … '; } return $more; } add_filter( 'excerpt_more', 'short_news_excerpt_more' ); /** * Home: Post Style * */ function short_news_home_post() { $home_layout = get_theme_mod('home_layout', 'standard-grid'); if ('grid' == $home_layout) { return sanitize_file_name('grid'); } elseif ('standard-grid' == $home_layout) { return sanitize_file_name('standard-grid'); } else { return; } } /** * Archive: Post Style * */ function short_news_archive_post() { $archive_layout = get_theme_mod('archive_layout', 'grid'); if ('grid' == $archive_layout) { return sanitize_file_name('grid'); } elseif ('standard-grid' == $archive_layout) { return sanitize_file_name('standard-grid'); } else { return; } } /** * Display Header Template * */ function short_news_header() { $header_template = sanitize_file_name( get_theme_mod('header_layout', 'style-1') ); get_template_part( 'template-parts/header/header', $header_template ); } /** * Display the Header Top Bar * */ function short_news_header_top() { if ( get_theme_mod( 'show_header_top_bar' ) ) : echo '