14, 'type' => 'theme', 'slug' => 'mission-news', 'message' => __( 'Hey! Sorry to interrupt, but you\'ve been using Mission News for a little while now. If you\'re happy with this theme, could you take a minute to leave a review? You won\'t see this notice again after closing it.', 'mission-news' ) ) ); //---------------------------------------------------------------------------------- // Set content width variable //---------------------------------------------------------------------------------- if ( ! function_exists( ( 'ct_mission_news_set_content_width' ) ) ) { function ct_mission_news_set_content_width() { if ( ! isset( $content_width ) ) { $content_width = 569; } } } add_action( 'after_setup_theme', 'ct_mission_news_set_content_width', 0 ); //---------------------------------------------------------------------------------- // Add theme support for various features, register menus, load text domain //---------------------------------------------------------------------------------- if ( ! function_exists( ( 'ct_mission_news_theme_setup' ) ) ) { function ct_mission_news_theme_setup() { add_theme_support( 'post-thumbnails' ); add_theme_support( 'automatic-feed-links' ); add_theme_support( 'title-tag' ); add_theme_support( 'html5', array( 'comment-form', 'comment-list', 'gallery', 'caption' ) ); add_theme_support( 'infinite-scroll', array( 'container' => 'loop-container', 'footer' => 'overflow-container', 'render' => 'ct_mission_news_infinite_scroll_render' ) ); add_theme_support( 'custom-logo', array( 'height' => 120, 'width' => 480, 'flex-height' => true, 'flex-width' => true ) ); register_nav_menus( array( 'primary' => esc_html__( 'Primary', 'mission-news' ), 'secondary' => esc_html__( 'Secondary', 'mission-news' ) ) ); load_theme_textdomain( 'mission-news', get_template_directory() . '/languages' ); } } add_action( 'after_setup_theme', 'ct_mission_news_theme_setup' ); //---------------------------------------------------------------------------------- // Register widget areas //---------------------------------------------------------------------------------- if ( ! function_exists( ( 'ct_mission_news_register_widget_areas' ) ) ) { function ct_mission_news_register_widget_areas() { register_sidebar( array( 'name' => esc_html__( 'Left Sidebar', 'mission-news' ), 'id' => 'left', 'description' => esc_html__( 'Widgets in this area will be shown left of the main post content.', 'mission-news' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

' ) ); register_sidebar( array( 'name' => esc_html__( 'Right Sidebar', 'mission-news' ), 'id' => 'right', 'description' => esc_html__( 'Widgets in this area will be shown right of the main post content.', 'mission-news' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

' ) ); register_sidebar( array( 'name' => esc_html__( 'Ad Spot - Below Header', 'mission-news' ), 'id' => 'below-header', 'description' => esc_html__( 'Widgets in this area will be shown below the header and above the posts and sidebars.', 'mission-news' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

' ) ); register_sidebar( array( 'name' => esc_html__( 'Ad Spot - Above Posts', 'mission-news' ), 'id' => 'above-main', 'description' => esc_html__( 'Widgets in this area will be shown in the center column above the posts.', 'mission-news' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

' ) ); register_sidebar( array( 'name' => esc_html__( 'Ad Spot - After Post Content', 'mission-news' ), 'id' => 'after-post', 'description' => esc_html__( 'Widgets in this area will be shown on post pages after the content.', 'mission-news' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

' ) ); register_sidebar( array( 'name' => esc_html__( 'Ad Spot - After Page Content', 'mission-news' ), 'id' => 'after-page', 'description' => esc_html__( 'Widgets in this area will be shown on pages after the content.', 'mission-news' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

' ) ); register_sidebar( array( 'name' => esc_html__( 'Ad Spot - After First Post', 'mission-news' ), 'id' => 'after-first-post', 'description' => esc_html__( 'Widgets in this area will be shown on the blog after the first post.', 'mission-news' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

' ) ); register_sidebar( array( 'name' => esc_html__( 'Footer', 'mission-news' ), 'id' => 'site-footer', 'description' => esc_html__( 'Widgets in this area will be shown in the footer.', 'mission-news' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

' ) ); } } add_action( 'widgets_init', 'ct_mission_news_register_widget_areas' ); //---------------------------------------------------------------------------------- // Output excerpt/content // Can't return the_content() so need to use get_the_content() // Apply same filter and str_replace() as the_content(): https://developer.wordpress.org/reference/functions/the_content/ //---------------------------------------------------------------------------------- if ( ! function_exists( 'ct_mission_news_excerpt' ) ) { function ct_mission_news_excerpt() { if ( get_theme_mod( 'full_post' ) == 'yes' ) { $content = get_the_content(); $content = apply_filters( 'the_content', $content ); $content = str_replace( ']]>', ']]>', $content ); return $content; } else { return wpautop( wp_kses_post( get_the_excerpt() ) ); } } } //---------------------------------------------------------------------------------- // Update excerpt length. Allow user input from Customizer. //---------------------------------------------------------------------------------- if ( ! function_exists( 'ct_mission_news_custom_excerpt_length' ) ) { function ct_mission_news_custom_excerpt_length( $length ) { if ( is_admin() ) { return $length; } $new_excerpt_length = get_theme_mod( 'excerpt_length' ); if ( ! empty( $new_excerpt_length ) && $new_excerpt_length != 25 ) { return $new_excerpt_length; } elseif ( $new_excerpt_length === 0 ) { return 0; } else { return 25; } } } add_filter( 'excerpt_length', 'ct_mission_news_custom_excerpt_length', 99 ); //---------------------------------------------------------------------------------- // Add plain ellipsis for automatic excerpts ("[...]" => "...") //---------------------------------------------------------------------------------- if ( ! function_exists( 'ct_mission_news_excerpt_ellipsis' ) ) { function ct_mission_news_excerpt_ellipsis() { return '…'; } } add_filter( 'excerpt_more', 'ct_mission_news_excerpt_ellipsis', 10 ); //---------------------------------------------------------------------------------- // Don't scroll to text after clicking a "more tag" link //---------------------------------------------------------------------------------- if ( ! function_exists( 'ct_mission_news_remove_more_link_scroll' ) ) { function ct_mission_news_remove_more_link_scroll( $link ) { if ( is_admin() ) { return $link; } $link = preg_replace( '|#more-[0-9]+|', '', $link ); return $link; } } add_filter( 'the_content_more_link', 'ct_mission_news_remove_more_link_scroll' ); //---------------------------------------------------------------------------------- // Output the Featured Image //---------------------------------------------------------------------------------- if ( ! function_exists( 'ct_mission_news_featured_image' ) ) { function ct_mission_news_featured_image() { $blog_display = apply_filters( 'ct_mission_news_featured_image_display_filter', get_theme_mod( 'featured_image_blog_archives' ) ); $post_display = apply_filters( 'ct_mission_news_featured_image_display_filter', get_theme_mod( 'featured_image_posts' ) ); // don't output on archives or post pages when turned off via Customizer setting if ( ( ( is_home() || is_archive() || is_search() ) && ($blog_display == 'post' || $blog_display == 'no') ) || ( is_singular( 'post' ) && ($post_display == 'blog' || $post_display == 'no' ) ) ) { return; } global $post; $featured_image = ''; if ( has_post_thumbnail( $post->ID ) ) { if ( is_singular() ) { $featured_image = ''; } else { $featured_image = ''; } } $featured_image = apply_filters( 'ct_mission_news_featured_image', $featured_image ); if ( $featured_image ) { echo $featured_image; } } } /* * WP will apply the ".menu-primary-items" class & id to the containing
instead of