diff options
Diffstat (limited to 'themes/twentyfourteen/inc')
-rw-r--r-- | themes/twentyfourteen/inc/back-compat.php | 8 | ||||
-rw-r--r-- | themes/twentyfourteen/inc/custom-header.php | 96 | ||||
-rw-r--r-- | themes/twentyfourteen/inc/customizer.php | 105 | ||||
-rw-r--r-- | themes/twentyfourteen/inc/featured-content.php | 161 | ||||
-rw-r--r-- | themes/twentyfourteen/inc/template-tags.php | 269 | ||||
-rw-r--r-- | themes/twentyfourteen/inc/widgets.php | 151 |
6 files changed, 388 insertions, 402 deletions
diff --git a/themes/twentyfourteen/inc/back-compat.php b/themes/twentyfourteen/inc/back-compat.php index 3943aeef..c184d912 100644 --- a/themes/twentyfourteen/inc/back-compat.php +++ b/themes/twentyfourteen/inc/back-compat.php @@ -44,11 +44,9 @@ function twentyfourteen_upgrade_notice() { * @since Twenty Fourteen 1.0 */ function twentyfourteen_customize() { - wp_die( - sprintf( __( 'Twenty Fourteen requires at least WordPress version 3.6. You are running version %s. Please upgrade and try again.', 'twentyfourteen' ), $GLOBALS['wp_version'] ), '', array( - 'back_link' => true, - ) - ); + wp_die( sprintf( __( 'Twenty Fourteen requires at least WordPress version 3.6. You are running version %s. Please upgrade and try again.', 'twentyfourteen' ), $GLOBALS['wp_version'] ), '', array( + 'back_link' => true, + ) ); } add_action( 'load-customize.php', 'twentyfourteen_customize' ); diff --git a/themes/twentyfourteen/inc/custom-header.php b/themes/twentyfourteen/inc/custom-header.php index bfea8976..287b1068 100644 --- a/themes/twentyfourteen/inc/custom-header.php +++ b/themes/twentyfourteen/inc/custom-header.php @@ -35,40 +35,36 @@ function twentyfourteen_custom_header_setup() { * the Appearance > Header screen. * } */ - add_theme_support( - 'custom-header', apply_filters( - 'twentyfourteen_custom_header_args', array( - 'default-text-color' => 'fff', - 'width' => 1260, - 'height' => 240, - 'flex-height' => true, - 'wp-head-callback' => 'twentyfourteen_header_style', - 'admin-head-callback' => 'twentyfourteen_admin_header_style', - 'admin-preview-callback' => 'twentyfourteen_admin_header_image', - ) - ) - ); + add_theme_support( 'custom-header', apply_filters( 'twentyfourteen_custom_header_args', array( + 'default-text-color' => 'fff', + 'width' => 1260, + 'height' => 240, + 'flex-height' => true, + 'wp-head-callback' => 'twentyfourteen_header_style', + 'admin-head-callback' => 'twentyfourteen_admin_header_style', + 'admin-preview-callback' => 'twentyfourteen_admin_header_image', + ) ) ); } add_action( 'after_setup_theme', 'twentyfourteen_custom_header_setup' ); if ( ! function_exists( 'twentyfourteen_header_style' ) ) : - /** - * Styles the header image and text displayed on the blog - * - * @see twentyfourteen_custom_header_setup(). - */ - function twentyfourteen_header_style() { - $text_color = get_header_textcolor(); +/** + * Styles the header image and text displayed on the blog + * + * @see twentyfourteen_custom_header_setup(). + * + */ +function twentyfourteen_header_style() { + $text_color = get_header_textcolor(); - // If no custom color for text is set, let's bail. - if ( display_header_text() && $text_color === get_theme_support( 'custom-header', 'default-text-color' ) ) { - return; - } + // If no custom color for text is set, let's bail. + if ( display_header_text() && $text_color === get_theme_support( 'custom-header', 'default-text-color' ) ) + return; - // If we get this far, we have custom styles. - ?> - <style type="text/css" id="twentyfourteen-header-css"> - <?php + // If we get this far, we have custom styles. + ?> + <style type="text/css" id="twentyfourteen-header-css"> + <?php // Has the text been hidden? if ( ! display_header_text() ) : ?> @@ -88,20 +84,20 @@ if ( ! function_exists( 'twentyfourteen_header_style' ) ) : <?php endif; ?> </style> <?php - } +} endif; // twentyfourteen_header_style if ( ! function_exists( 'twentyfourteen_admin_header_style' ) ) : - /** - * Style the header image displayed on the Appearance > Header screen. - * - * @see twentyfourteen_custom_header_setup() - * - * @since Twenty Fourteen 1.0 - */ - function twentyfourteen_admin_header_style() { - ?> +/** + * Style the header image displayed on the Appearance > Header screen. + * + * @see twentyfourteen_custom_header_setup() + * + * @since Twenty Fourteen 1.0 + */ +function twentyfourteen_admin_header_style() { +?> <style type="text/css" id="twentyfourteen-admin-header-css"> .appearance_page_custom-header #headimg { background-color: #000; @@ -126,20 +122,20 @@ if ( ! function_exists( 'twentyfourteen_admin_header_style' ) ) : vertical-align: middle; } </style> - <?php - } +<?php +} endif; // twentyfourteen_admin_header_style if ( ! function_exists( 'twentyfourteen_admin_header_image' ) ) : - /** - * Create the custom header image markup displayed on the Appearance > Header screen. - * - * @see twentyfourteen_custom_header_setup() - * - * @since Twenty Fourteen 1.0 - */ - function twentyfourteen_admin_header_image() { - ?> +/** + * Create the custom header image markup displayed on the Appearance > Header screen. + * + * @see twentyfourteen_custom_header_setup() + * + * @since Twenty Fourteen 1.0 + */ +function twentyfourteen_admin_header_image() { +?> <div id="headimg"> <?php if ( get_header_image() ) : ?> <img src="<?php header_image(); ?>" alt=""> @@ -147,5 +143,5 @@ if ( ! function_exists( 'twentyfourteen_admin_header_image' ) ) : <h1 class="displaying-header-text"><a id="name" style="<?php echo esc_attr( sprintf( 'color: #%s;', get_header_textcolor() ) ); ?>" onclick="return false;" href="<?php echo esc_url( home_url( '/' ) ); ?>" tabindex="-1"><?php bloginfo( 'name' ); ?></a></h1> </div> <?php - } +} endif; // twentyfourteen_admin_header_image diff --git a/themes/twentyfourteen/inc/customizer.php b/themes/twentyfourteen/inc/customizer.php index 5a41f188..39289159 100644 --- a/themes/twentyfourteen/inc/customizer.php +++ b/themes/twentyfourteen/inc/customizer.php @@ -16,25 +16,21 @@ */ function twentyfourteen_customize_register( $wp_customize ) { // Add postMessage support for site title and description. - $wp_customize->get_setting( 'blogname' )->transport = 'postMessage'; - $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; - $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage'; + $wp_customize->get_setting( 'blogname' )->transport = 'postMessage'; + $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; + $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage'; if ( isset( $wp_customize->selective_refresh ) ) { - $wp_customize->selective_refresh->add_partial( - 'blogname', array( - 'selector' => '.site-title a', - 'container_inclusive' => false, - 'render_callback' => 'twentyfourteen_customize_partial_blogname', - ) - ); - $wp_customize->selective_refresh->add_partial( - 'blogdescription', array( - 'selector' => '.site-description', - 'container_inclusive' => false, - 'render_callback' => 'twentyfourteen_customize_partial_blogdescription', - ) - ); + $wp_customize->selective_refresh->add_partial( 'blogname', array( + 'selector' => '.site-title a', + 'container_inclusive' => false, + 'render_callback' => 'twentyfourteen_customize_partial_blogname', + ) ); + $wp_customize->selective_refresh->add_partial( 'blogdescription', array( + 'selector' => '.site-description', + 'container_inclusive' => false, + 'render_callback' => 'twentyfourteen_customize_partial_blogdescription', + ) ); } // Rename the label to "Site Title Color" because this only affects the site title in this theme. @@ -53,38 +49,31 @@ function twentyfourteen_customize_register( $wp_customize ) { } // Add the featured content section in case it's not already there. - $wp_customize->add_section( - 'featured_content', array( - 'title' => __( 'Featured Content', 'twentyfourteen' ), - 'description' => sprintf( - __( 'Use a <a href="%1$s">tag</a> to feature your posts. If no posts match the tag, <a href="%2$s">sticky posts</a> will be displayed instead.', 'twentyfourteen' ), - esc_url( add_query_arg( 'tag', _x( 'featured', 'featured content default tag slug', 'twentyfourteen' ), admin_url( 'edit.php' ) ) ), - admin_url( 'edit.php?show_sticky=1' ) - ), - 'priority' => 130, - 'active_callback' => 'is_front_page', - ) - ); + $wp_customize->add_section( 'featured_content', array( + 'title' => __( 'Featured Content', 'twentyfourteen' ), + 'description' => sprintf( __( 'Use a <a href="%1$s">tag</a> to feature your posts. If no posts match the tag, <a href="%2$s">sticky posts</a> will be displayed instead.', 'twentyfourteen' ), + esc_url( add_query_arg( 'tag', _x( 'featured', 'featured content default tag slug', 'twentyfourteen' ), admin_url( 'edit.php' ) ) ), + admin_url( 'edit.php?show_sticky=1' ) + ), + 'priority' => 130, + 'active_callback' => 'is_front_page', + ) ); // Add the featured content layout setting and control. - $wp_customize->add_setting( - 'featured_content_layout', array( - 'default' => 'grid', - 'sanitize_callback' => 'twentyfourteen_sanitize_layout', - ) - ); + $wp_customize->add_setting( 'featured_content_layout', array( + 'default' => 'grid', + 'sanitize_callback' => 'twentyfourteen_sanitize_layout', + ) ); - $wp_customize->add_control( - 'featured_content_layout', array( - 'label' => __( 'Layout', 'twentyfourteen' ), - 'section' => 'featured_content', - 'type' => 'select', - 'choices' => array( - 'grid' => __( 'Grid', 'twentyfourteen' ), - 'slider' => __( 'Slider', 'twentyfourteen' ), - ), - ) - ); + $wp_customize->add_control( 'featured_content_layout', array( + 'label' => __( 'Layout', 'twentyfourteen' ), + 'section' => 'featured_content', + 'type' => 'select', + 'choices' => array( + 'grid' => __( 'Grid', 'twentyfourteen' ), + 'slider' => __( 'Slider', 'twentyfourteen' ), + ), + ) ); } add_action( 'customize_register', 'twentyfourteen_customize_register' ); @@ -148,18 +137,16 @@ function twentyfourteen_contextual_help() { return; } - get_current_screen()->add_help_tab( - array( - 'id' => 'twentyfourteen', - 'title' => __( 'Twenty Fourteen', 'twentyfourteen' ), - 'content' => - '<ul>' . - '<li>' . sprintf( __( 'The home page features your choice of up to 6 posts prominently displayed in a grid or slider, controlled by a <a href="%1$s">tag</a>; you can change the tag and layout in <a href="%2$s">Appearance → Customize</a>. If no posts match the tag, <a href="%3$s">sticky posts</a> will be displayed instead.', 'twentyfourteen' ), esc_url( add_query_arg( 'tag', _x( 'featured', 'featured content default tag slug', 'twentyfourteen' ), admin_url( 'edit.php' ) ) ), admin_url( 'customize.php' ), admin_url( 'edit.php?show_sticky=1' ) ) . '</li>' . - '<li>' . sprintf( __( 'Enhance your site design by using <a href="%s">Featured Images</a> for posts you’d like to stand out (also known as post thumbnails). This allows you to associate an image with your post without inserting it. Twenty Fourteen uses featured images for posts and pages—above the title—and in the Featured Content area on the home page.', 'twentyfourteen' ), 'https://codex.wordpress.org/Post_Thumbnails#Setting_a_Post_Thumbnail' ) . '</li>' . - '<li>' . sprintf( __( 'For an in-depth tutorial, and more tips and tricks, visit the <a href="%s">Twenty Fourteen documentation</a>.', 'twentyfourteen' ), 'https://codex.wordpress.org/Twenty_Fourteen' ) . '</li>' . - '</ul>', - ) - ); + get_current_screen()->add_help_tab( array( + 'id' => 'twentyfourteen', + 'title' => __( 'Twenty Fourteen', 'twentyfourteen' ), + 'content' => + '<ul>' . + '<li>' . sprintf( __( 'The home page features your choice of up to 6 posts prominently displayed in a grid or slider, controlled by a <a href="%1$s">tag</a>; you can change the tag and layout in <a href="%2$s">Appearance → Customize</a>. If no posts match the tag, <a href="%3$s">sticky posts</a> will be displayed instead.', 'twentyfourteen' ), esc_url( add_query_arg( 'tag', _x( 'featured', 'featured content default tag slug', 'twentyfourteen' ), admin_url( 'edit.php' ) ) ), admin_url( 'customize.php' ), admin_url( 'edit.php?show_sticky=1' ) ) . '</li>' . + '<li>' . sprintf( __( 'Enhance your site design by using <a href="%s">Featured Images</a> for posts you’d like to stand out (also known as post thumbnails). This allows you to associate an image with your post without inserting it. Twenty Fourteen uses featured images for posts and pages—above the title—and in the Featured Content area on the home page.', 'twentyfourteen' ), 'https://codex.wordpress.org/Post_Thumbnails#Setting_a_Post_Thumbnail' ) . '</li>' . + '<li>' . sprintf( __( 'For an in-depth tutorial, and more tips and tricks, visit the <a href="%s">Twenty Fourteen documentation</a>.', 'twentyfourteen' ), 'https://codex.wordpress.org/Twenty_Fourteen' ) . '</li>' . + '</ul>', + ) ); } add_action( 'admin_head-themes.php', 'twentyfourteen_contextual_help' ); -add_action( 'admin_head-edit.php', 'twentyfourteen_contextual_help' ); +add_action( 'admin_head-edit.php', 'twentyfourteen_contextual_help' ); diff --git a/themes/twentyfourteen/inc/featured-content.php b/themes/twentyfourteen/inc/featured-content.php index 808a8a74..ffeb993d 100644 --- a/themes/twentyfourteen/inc/featured-content.php +++ b/themes/twentyfourteen/inc/featured-content.php @@ -23,6 +23,8 @@ class Featured_Content { * * @since Twenty Fourteen 1.0 * + * @static + * @access public * @var int */ public static $max_posts = 15; @@ -32,6 +34,8 @@ class Featured_Content { * * All custom functionality will be hooked into the "init" action. * + * @static + * @access public * @since Twenty Fourteen 1.0 */ public static function setup() { @@ -47,6 +51,8 @@ class Featured_Content { * If no theme support is found there is no need to hook into WordPress. * We'll just return early instead. * + * @static + * @access public * @since Twenty Fourteen 1.0 */ public static function init() { @@ -77,15 +83,15 @@ class Featured_Content { self::$max_posts = absint( $theme_support[0]['max_posts'] ); } - add_filter( $filter, array( __CLASS__, 'get_featured_posts' ) ); - add_action( 'customize_register', array( __CLASS__, 'customize_register' ), 9 ); - add_action( 'admin_init', array( __CLASS__, 'register_setting' ) ); - add_action( 'switch_theme', array( __CLASS__, 'delete_transient' ) ); - add_action( 'save_post', array( __CLASS__, 'delete_transient' ) ); - add_action( 'delete_post_tag', array( __CLASS__, 'delete_post_tag' ) ); - add_action( 'customize_controls_enqueue_scripts', array( __CLASS__, 'enqueue_scripts' ) ); - add_action( 'pre_get_posts', array( __CLASS__, 'pre_get_posts' ) ); - add_action( 'wp_loaded', array( __CLASS__, 'wp_loaded' ) ); + add_filter( $filter, array( __CLASS__, 'get_featured_posts' ) ); + add_action( 'customize_register', array( __CLASS__, 'customize_register' ), 9 ); + add_action( 'admin_init', array( __CLASS__, 'register_setting' ) ); + add_action( 'switch_theme', array( __CLASS__, 'delete_transient' ) ); + add_action( 'save_post', array( __CLASS__, 'delete_transient' ) ); + add_action( 'delete_post_tag', array( __CLASS__, 'delete_post_tag' ) ); + add_action( 'customize_controls_enqueue_scripts', array( __CLASS__, 'enqueue_scripts' ) ); + add_action( 'pre_get_posts', array( __CLASS__, 'pre_get_posts' ) ); + add_action( 'wp_loaded', array( __CLASS__, 'wp_loaded' ) ); } /** @@ -94,11 +100,13 @@ class Featured_Content { * Has to run on wp_loaded so that the preview filters of the Customizer * have a chance to alter the value. * + * @static + * @access public * @since Twenty Fourteen 1.0 */ public static function wp_loaded() { if ( self::get_setting( 'hide-tag' ) ) { - add_filter( 'get_terms', array( __CLASS__, 'hide_featured_term' ), 10, 3 ); + add_filter( 'get_terms', array( __CLASS__, 'hide_featured_term' ), 10, 3 ); add_filter( 'get_the_terms', array( __CLASS__, 'hide_the_featured_term' ), 10, 3 ); } } @@ -106,6 +114,8 @@ class Featured_Content { /** * Get featured posts. * + * @static + * @access public * @since Twenty Fourteen 1.0 * * @return array Array of featured posts. @@ -118,12 +128,10 @@ class Featured_Content { return array(); } - $featured_posts = get_posts( - array( - 'include' => $post_ids, - 'posts_per_page' => count( $post_ids ), - ) - ); + $featured_posts = get_posts( array( + 'include' => $post_ids, + 'posts_per_page' => count( $post_ids ), + ) ); return $featured_posts; } @@ -136,6 +144,8 @@ class Featured_Content { * * Sets the "featured_content_ids" transient. * + * @static + * @access public * @since Twenty Fourteen 1.0 * * @return array Array of post IDs. @@ -150,20 +160,18 @@ class Featured_Content { if ( $term ) { // Query for featured posts. - $featured_ids = get_posts( - array( - 'fields' => 'ids', - 'numberposts' => self::$max_posts, - 'suppress_filters' => false, - 'tax_query' => array( - array( - 'field' => 'term_id', - 'taxonomy' => 'post_tag', - 'terms' => $term->term_id, - ), + $featured_ids = get_posts( array( + 'fields' => 'ids', + 'numberposts' => self::$max_posts, + 'suppress_filters' => false, + 'tax_query' => array( + array( + 'field' => 'term_id', + 'taxonomy' => 'post_tag', + 'terms' => $term->term_id, ), - ) - ); + ), + ) ); } // Get sticky posts if no Featured Content exists. @@ -181,6 +189,8 @@ class Featured_Content { /** * Return an array with IDs of posts maked as sticky. * + * @static + * @access public * @since Twenty Fourteen 1.0 * * @return array Array of sticky posts. @@ -196,6 +206,8 @@ class Featured_Content { * * @see Featured_Content::validate_settings(). * + * @static + * @access public * @since Twenty Fourteen 1.0 */ public static function delete_transient() { @@ -209,6 +221,8 @@ class Featured_Content { * Hooked onto the 'pre_get_posts' action, this changes the parameters of * the query before it gets any posts. * + * @static + * @access public * @since Twenty Fourteen 1.0 * * @param WP_Query $query WP_Query object. @@ -255,6 +269,8 @@ class Featured_Content { * * @see Featured_Content::validate_settings(). * + * @static + * @access public * @since Twenty Fourteen 1.0 * * @param int $tag_id The term_id of the tag that has been deleted. @@ -267,7 +283,7 @@ class Featured_Content { } $settings['tag-id'] = 0; - $settings = self::validate_settings( $settings ); + $settings = self::validate_settings( $settings ); update_option( 'featured-content', $settings ); } @@ -276,6 +292,8 @@ class Featured_Content { * * Hooks into the "get_terms" filter. * + * @static + * @access public * @since Twenty Fourteen 1.0 * * @param array $terms List of term objects. This is the return value of get_terms(). @@ -322,6 +340,8 @@ class Featured_Content { * * Hooks into the "get_the_terms" filter. * + * @static + * @access public * @since Twenty Fourteen 1.0 * * @param array $terms A list of term objects. This is the return value of get_the_terms(). @@ -361,6 +381,8 @@ class Featured_Content { /** * Register custom setting on the Settings -> Reading screen. * + * @static + * @access public * @since Twenty Fourteen 1.0 */ public static function register_setting() { @@ -370,61 +392,54 @@ class Featured_Content { /** * Add settings to the Customizer. * + * @static + * @access public * @since Twenty Fourteen 1.0 * * @param WP_Customize_Manager $wp_customize Customizer object. */ public static function customize_register( $wp_customize ) { - $wp_customize->add_section( - 'featured_content', array( - 'title' => __( 'Featured Content', 'twentyfourteen' ), - 'description' => sprintf( - __( 'Use a <a href="%1$s">tag</a> to feature your posts. If no posts match the tag, <a href="%2$s">sticky posts</a> will be displayed instead.', 'twentyfourteen' ), - esc_url( add_query_arg( 'tag', _x( 'featured', 'featured content default tag slug', 'twentyfourteen' ), admin_url( 'edit.php' ) ) ), - admin_url( 'edit.php?show_sticky=1' ) - ), - 'priority' => 130, - 'theme_supports' => 'featured-content', - ) - ); + $wp_customize->add_section( 'featured_content', array( + 'title' => __( 'Featured Content', 'twentyfourteen' ), + 'description' => sprintf( __( 'Use a <a href="%1$s">tag</a> to feature your posts. If no posts match the tag, <a href="%2$s">sticky posts</a> will be displayed instead.', 'twentyfourteen' ), + esc_url( add_query_arg( 'tag', _x( 'featured', 'featured content default tag slug', 'twentyfourteen' ), admin_url( 'edit.php' ) ) ), + admin_url( 'edit.php?show_sticky=1' ) + ), + 'priority' => 130, + 'theme_supports' => 'featured-content', + ) ); // Add Featured Content settings. - $wp_customize->add_setting( - 'featured-content[tag-name]', array( - 'default' => _x( 'featured', 'featured content default tag slug', 'twentyfourteen' ), - 'type' => 'option', - 'sanitize_js_callback' => array( __CLASS__, 'delete_transient' ), - ) - ); - $wp_customize->add_setting( - 'featured-content[hide-tag]', array( - 'default' => true, - 'type' => 'option', - 'sanitize_js_callback' => array( __CLASS__, 'delete_transient' ), - ) - ); + $wp_customize->add_setting( 'featured-content[tag-name]', array( + 'default' => _x( 'featured', 'featured content default tag slug', 'twentyfourteen' ), + 'type' => 'option', + 'sanitize_js_callback' => array( __CLASS__, 'delete_transient' ), + ) ); + $wp_customize->add_setting( 'featured-content[hide-tag]', array( + 'default' => true, + 'type' => 'option', + 'sanitize_js_callback' => array( __CLASS__, 'delete_transient' ), + ) ); // Add Featured Content controls. - $wp_customize->add_control( - 'featured-content[tag-name]', array( - 'label' => __( 'Tag Name', 'twentyfourteen' ), - 'section' => 'featured_content', - 'priority' => 20, - ) - ); - $wp_customize->add_control( - 'featured-content[hide-tag]', array( - 'label' => __( 'Don’t display tag on front end.', 'twentyfourteen' ), - 'section' => 'featured_content', - 'type' => 'checkbox', - 'priority' => 30, - ) - ); + $wp_customize->add_control( 'featured-content[tag-name]', array( + 'label' => __( 'Tag Name', 'twentyfourteen' ), + 'section' => 'featured_content', + 'priority' => 20, + ) ); + $wp_customize->add_control( 'featured-content[hide-tag]', array( + 'label' => __( 'Don’t display tag on front end.', 'twentyfourteen' ), + 'section' => 'featured_content', + 'type' => 'checkbox', + 'priority' => 30, + ) ); } /** * Enqueue the tag suggestion script. * + * @static + * @access public * @since Twenty Fourteen 1.0 */ public static function enqueue_scripts() { @@ -443,6 +458,8 @@ class Featured_Content { * its name as the first parameter to the function and only that * value will be returned. * + * @static + * @access public * @since Twenty Fourteen 1.0 * * @param string $key The key of a recognized setting. @@ -474,6 +491,8 @@ class Featured_Content { * format before saving to the database. This function will also * delete the transient set in Featured_Content::get_featured_content(). * + * @static + * @access public * @since Twenty Fourteen 1.0 * * @param array $input Array of settings input. diff --git a/themes/twentyfourteen/inc/template-tags.php b/themes/twentyfourteen/inc/template-tags.php index 89393316..1d35d0d5 100644 --- a/themes/twentyfourteen/inc/template-tags.php +++ b/themes/twentyfourteen/inc/template-tags.php @@ -8,55 +8,53 @@ */ if ( ! function_exists( 'twentyfourteen_paging_nav' ) ) : - /** - * Display navigation to next/previous set of posts when applicable. - * - * @since Twenty Fourteen 1.0 - * - * @global WP_Query $wp_query WordPress Query object. - * @global WP_Rewrite $wp_rewrite WordPress Rewrite object. - */ - function twentyfourteen_paging_nav() { - global $wp_query, $wp_rewrite; - - // Don't print empty markup if there's only one page. - if ( $wp_query->max_num_pages < 2 ) { - return; - } +/** + * Display navigation to next/previous set of posts when applicable. + * + * @since Twenty Fourteen 1.0 + * + * @global WP_Query $wp_query WordPress Query object. + * @global WP_Rewrite $wp_rewrite WordPress Rewrite object. + */ +function twentyfourteen_paging_nav() { + global $wp_query, $wp_rewrite; - $paged = get_query_var( 'paged' ) ? intval( get_query_var( 'paged' ) ) : 1; - $pagenum_link = html_entity_decode( get_pagenum_link() ); - $query_args = array(); - $url_parts = explode( '?', $pagenum_link ); + // Don't print empty markup if there's only one page. + if ( $wp_query->max_num_pages < 2 ) { + return; + } - if ( isset( $url_parts[1] ) ) { - wp_parse_str( $url_parts[1], $query_args ); - } + $paged = get_query_var( 'paged' ) ? intval( get_query_var( 'paged' ) ) : 1; + $pagenum_link = html_entity_decode( get_pagenum_link() ); + $query_args = array(); + $url_parts = explode( '?', $pagenum_link ); - $pagenum_link = remove_query_arg( array_keys( $query_args ), $pagenum_link ); - $pagenum_link = trailingslashit( $pagenum_link ) . '%_%'; - - $format = $wp_rewrite->using_index_permalinks() && ! strpos( $pagenum_link, 'index.php' ) ? 'index.php/' : ''; - $format .= $wp_rewrite->using_permalinks() ? user_trailingslashit( $wp_rewrite->pagination_base . '/%#%', 'paged' ) : '?paged=%#%'; - - // Set up paginated links. - $links = paginate_links( - array( - 'base' => $pagenum_link, - 'format' => $format, - 'total' => $wp_query->max_num_pages, - 'current' => $paged, - 'mid_size' => 1, - 'add_args' => array_map( 'urlencode', $query_args ), - 'prev_text' => __( '← Previous', 'twentyfourteen' ), - 'next_text' => __( 'Next →', 'twentyfourteen' ), - ) - ); + if ( isset( $url_parts[1] ) ) { + wp_parse_str( $url_parts[1], $query_args ); + } + + $pagenum_link = remove_query_arg( array_keys( $query_args ), $pagenum_link ); + $pagenum_link = trailingslashit( $pagenum_link ) . '%_%'; + + $format = $wp_rewrite->using_index_permalinks() && ! strpos( $pagenum_link, 'index.php' ) ? 'index.php/' : ''; + $format .= $wp_rewrite->using_permalinks() ? user_trailingslashit( $wp_rewrite->pagination_base . '/%#%', 'paged' ) : '?paged=%#%'; - if ( $links ) : + // Set up paginated links. + $links = paginate_links( array( + 'base' => $pagenum_link, + 'format' => $format, + 'total' => $wp_query->max_num_pages, + 'current' => $paged, + 'mid_size' => 1, + 'add_args' => array_map( 'urlencode', $query_args ), + 'prev_text' => __( '← Previous', 'twentyfourteen' ), + 'next_text' => __( 'Next →', 'twentyfourteen' ), + ) ); - ?> - <nav class="navigation paging-navigation" role="navigation"> + if ( $links ) : + + ?> + <nav class="navigation paging-navigation" role="navigation"> <h1 class="screen-reader-text"><?php _e( 'Posts navigation', 'twentyfourteen' ); ?></h1> <div class="pagination loop-pagination"> <?php echo $links; ?> @@ -64,63 +62,62 @@ if ( ! function_exists( 'twentyfourteen_paging_nav' ) ) : </nav><!-- .navigation --> <?php endif; - } +} endif; if ( ! function_exists( 'twentyfourteen_post_nav' ) ) : - /** - * Display navigation to next/previous post when applicable. - * - * @since Twenty Fourteen 1.0 - */ - function twentyfourteen_post_nav() { - // Don't print empty markup if there's nowhere to navigate. - $previous = ( is_attachment() ) ? get_post( get_post()->post_parent ) : get_adjacent_post( false, '', true ); - $next = get_adjacent_post( false, '', false ); - - if ( ! $next && ! $previous ) { - return; - } +/** + * Display navigation to next/previous post when applicable. + * + * @since Twenty Fourteen 1.0 + */ +function twentyfourteen_post_nav() { + // Don't print empty markup if there's nowhere to navigate. + $previous = ( is_attachment() ) ? get_post( get_post()->post_parent ) : get_adjacent_post( false, '', true ); + $next = get_adjacent_post( false, '', false ); + + if ( ! $next && ! $previous ) { + return; + } - ?> - <nav class="navigation post-navigation" role="navigation"> + ?> + <nav class="navigation post-navigation" role="navigation"> <h1 class="screen-reader-text"><?php _e( 'Post navigation', 'twentyfourteen' ); ?></h1> <div class="nav-links"> <?php if ( is_attachment() ) : previous_post_link( '%link', __( '<span class="meta-nav">Published In</span>%title', 'twentyfourteen' ) ); - else : - previous_post_link( '%link', __( '<span class="meta-nav">Previous Post</span>%title', 'twentyfourteen' ) ); - next_post_link( '%link', __( '<span class="meta-nav">Next Post</span>%title', 'twentyfourteen' ) ); - endif; - ?> - </div><!-- .nav-links --> - </nav><!-- .navigation --> - <?php - } + else : + previous_post_link( '%link', __( '<span class="meta-nav">Previous Post</span>%title', 'twentyfourteen' ) ); + next_post_link( '%link', __( '<span class="meta-nav">Next Post</span>%title', 'twentyfourteen' ) ); + endif; + ?> + </div><!-- .nav-links --> + </nav><!-- .navigation --> + <?php +} endif; if ( ! function_exists( 'twentyfourteen_posted_on' ) ) : - /** - * Print HTML with meta information for the current post-date/time and author. - * - * @since Twenty Fourteen 1.0 - */ - function twentyfourteen_posted_on() { - if ( is_sticky() && is_home() && ! is_paged() ) { - echo '<span class="featured-post">' . __( 'Sticky', 'twentyfourteen' ) . '</span>'; - } - - // Set up and print post meta information. - printf( - '<span class="entry-date"><a href="%1$s" rel="bookmark"><time class="entry-date" datetime="%2$s">%3$s</time></a></span> <span class="byline"><span class="author vcard"><a class="url fn n" href="%4$s" rel="author">%5$s</a></span></span>', - esc_url( get_permalink() ), - esc_attr( get_the_date( 'c' ) ), - esc_html( get_the_date() ), - esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), - get_the_author() - ); +/** + * Print HTML with meta information for the current post-date/time and author. + * + * @since Twenty Fourteen 1.0 + */ +function twentyfourteen_posted_on() { + if ( is_sticky() && is_home() && ! is_paged() ) { + echo '<span class="featured-post">' . __( 'Sticky', 'twentyfourteen' ) . '</span>'; } + + // Set up and print post meta information. + printf( '<span class="entry-date"><a href="%1$s" rel="bookmark"><time class="entry-date" datetime="%2$s">%3$s</time></a></span> <span class="byline"><span class="author vcard"><a class="url fn n" href="%4$s" rel="author">%5$s</a></span></span>', + esc_url( get_permalink() ), + esc_attr( get_the_date( 'c' ) ), + esc_html( get_the_date() ), + esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), + get_the_author() + ); +} endif; /** @@ -133,11 +130,9 @@ endif; function twentyfourteen_categorized_blog() { if ( false === ( $all_the_cool_cats = get_transient( 'twentyfourteen_category_count' ) ) ) { // Create an array of all the categories that are attached to posts - $all_the_cool_cats = get_categories( - array( - 'hide_empty' => 1, - ) - ); + $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 ); @@ -164,71 +159,69 @@ function twentyfourteen_category_transient_flusher() { delete_transient( 'twentyfourteen_category_count' ); } add_action( 'edit_category', 'twentyfourteen_category_transient_flusher' ); -add_action( 'save_post', 'twentyfourteen_category_transient_flusher' ); +add_action( 'save_post', 'twentyfourteen_category_transient_flusher' ); if ( ! function_exists( 'twentyfourteen_post_thumbnail' ) ) : - /** - * Display an optional post thumbnail. - * - * Wraps the post thumbnail in an anchor element on index - * views, or a div element when on single views. - * - * @since Twenty Fourteen 1.0 - * @since Twenty Fourteen 1.4 Was made 'pluggable', or overridable. - */ - function twentyfourteen_post_thumbnail() { - if ( post_password_required() || is_attachment() || ! has_post_thumbnail() ) { - return; - } +/** + * Display an optional post thumbnail. + * + * Wraps the post thumbnail in an anchor element on index + * views, or a div element when on single views. + * + * @since Twenty Fourteen 1.0 + * @since Twenty Fourteen 1.4 Was made 'pluggable', or overridable. + */ +function twentyfourteen_post_thumbnail() { + if ( post_password_required() || is_attachment() || ! has_post_thumbnail() ) { + return; + } - if ( is_singular() ) : - ?> + if ( is_singular() ) : + ?> - <div class="post-thumbnail"> - <?php + <div class="post-thumbnail"> + <?php if ( ( ! is_active_sidebar( 'sidebar-2' ) || is_page_template( 'page-templates/full-width.php' ) ) ) { the_post_thumbnail( 'twentyfourteen-full-width' ); } else { the_post_thumbnail(); } - ?> - </div> + ?> + </div> - <?php else : ?> + <?php else : ?> <a class="post-thumbnail" href="<?php the_permalink(); ?>" aria-hidden="true"> <?php - if ( ( ! is_active_sidebar( 'sidebar-2' ) || is_page_template( 'page-templates/full-width.php' ) ) ) { - the_post_thumbnail( 'twentyfourteen-full-width' ); - } else { - the_post_thumbnail( 'post-thumbnail', array( 'alt' => get_the_title() ) ); - } + if ( ( ! is_active_sidebar( 'sidebar-2' ) || is_page_template( 'page-templates/full-width.php' ) ) ) { + the_post_thumbnail( 'twentyfourteen-full-width' ); + } else { + the_post_thumbnail( 'post-thumbnail', array( 'alt' => get_the_title() ) ); + } ?> </a> - <?php - endif; // End is_singular() - } + <?php endif; // End is_singular() +} endif; if ( ! function_exists( 'twentyfourteen_excerpt_more' ) && ! is_admin() ) : - /** - * Replaces "[...]" (appended to automatically generated excerpts) with ... - * and a Continue reading link. - * - * @since Twenty Fourteen 1.3 - * - * @param string $more Default Read More excerpt link. - * @return string Filtered Read More excerpt link. - */ - function twentyfourteen_excerpt_more( $more ) { - $link = sprintf( - '<a href="%1$s" class="more-link">%2$s</a>', - esc_url( get_permalink( get_the_ID() ) ), +/** + * Replaces "[...]" (appended to automatically generated excerpts) with ... + * and a Continue reading link. + * + * @since Twenty Fourteen 1.3 + * + * @param string $more Default Read More excerpt link. + * @return string Filtered Read More excerpt link. + */ +function twentyfourteen_excerpt_more( $more ) { + $link = sprintf( '<a href="%1$s" class="more-link">%2$s</a>', + esc_url( get_permalink( get_the_ID() ) ), /* translators: %s: Name of current post */ sprintf( __( 'Continue reading %s <span class="meta-nav">→</span>', 'twentyfourteen' ), '<span class="screen-reader-text">' . get_the_title( get_the_ID() ) . '</span>' ) ); - return ' … ' . $link; - } - add_filter( 'excerpt_more', 'twentyfourteen_excerpt_more' ); + return ' … ' . $link; +} +add_filter( 'excerpt_more', 'twentyfourteen_excerpt_more' ); endif; diff --git a/themes/twentyfourteen/inc/widgets.php b/themes/twentyfourteen/inc/widgets.php index 64118b5e..533f34a5 100644 --- a/themes/twentyfourteen/inc/widgets.php +++ b/themes/twentyfourteen/inc/widgets.php @@ -16,6 +16,7 @@ class Twenty_Fourteen_Ephemera_Widget extends WP_Widget { /** * The supported post formats. * + * @access private * @since Twenty Fourteen 1.0 * * @var array @@ -30,13 +31,11 @@ class Twenty_Fourteen_Ephemera_Widget extends WP_Widget { * @return Twenty_Fourteen_Ephemera_Widget */ public function __construct() { - parent::__construct( - 'widget_twentyfourteen_ephemera', __( 'Twenty Fourteen Ephemera', 'twentyfourteen' ), array( - 'classname' => 'widget_twentyfourteen_ephemera', - 'description' => __( 'Use this widget to list your recent Aside, Quote, Video, Audio, Image, Gallery, and Link posts.', 'twentyfourteen' ), - 'customize_selective_refresh' => true, - ) - ); + parent::__construct( 'widget_twentyfourteen_ephemera', __( 'Twenty Fourteen Ephemera', 'twentyfourteen' ), array( + 'classname' => 'widget_twentyfourteen_ephemera', + 'description' => __( 'Use this widget to list your recent Aside, Quote, Video, Audio, Image, Gallery, and Link posts.', 'twentyfourteen' ), + 'customize_selective_refresh' => true, + ) ); if ( is_active_widget( false, false, $this->id_base ) || is_customize_preview() ) { add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); @@ -63,6 +62,7 @@ class Twenty_Fourteen_Ephemera_Widget extends WP_Widget { /** * Output the HTML for this widget. * + * @access public * @since Twenty Fourteen 1.0 * * @param array $args An array of standard parameters for widgets in this theme. @@ -106,26 +106,24 @@ class Twenty_Fourteen_Ephemera_Widget extends WP_Widget { $number = empty( $instance['number'] ) ? 2 : absint( $instance['number'] ); $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? $format_string : $instance['title'], $instance, $this->id_base ); - $ephemera = new WP_Query( - array( - 'order' => 'DESC', - 'posts_per_page' => $number, - 'no_found_rows' => true, - 'post_status' => 'publish', - 'post__not_in' => get_option( 'sticky_posts' ), - 'tax_query' => array( - array( - 'taxonomy' => 'post_format', - 'terms' => array( "post-format-$format" ), - 'field' => 'slug', - 'operator' => 'IN', - ), + $ephemera = new WP_Query( array( + 'order' => 'DESC', + 'posts_per_page' => $number, + 'no_found_rows' => true, + 'post_status' => 'publish', + 'post__not_in' => get_option( 'sticky_posts' ), + 'tax_query' => array( + array( + 'taxonomy' => 'post_format', + 'terms' => array( "post-format-$format" ), + 'field' => 'slug', + 'operator' => 'IN', ), - ) - ); + ), + ) ); if ( $ephemera->have_posts() ) : - $tmp_content_width = $GLOBALS['content_width']; + $tmp_content_width = $GLOBALS['content_width']; $GLOBALS['content_width'] = 306; echo $args['before_widget']; @@ -136,65 +134,61 @@ class Twenty_Fourteen_Ephemera_Widget extends WP_Widget { <ol> <?php - while ( $ephemera->have_posts() ) : - $ephemera->the_post(); - $tmp_more = $GLOBALS['more']; - $GLOBALS['more'] = 0; + while ( $ephemera->have_posts() ) : + $ephemera->the_post(); + $tmp_more = $GLOBALS['more']; + $GLOBALS['more'] = 0; ?> <li> <article <?php post_class(); ?>> - <div class="entry-content"> - <?php - if ( has_post_format( 'gallery' ) ) : - - if ( post_password_required() ) : - the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentyfourteen' ) ); - else : - $images = array(); - - $galleries = get_post_galleries( get_the_ID(), false ); - if ( isset( $galleries[0]['ids'] ) ) { - $images = explode( ',', $galleries[0]['ids'] ); - } - - if ( ! $images ) : - $images = get_posts( - array( - 'fields' => 'ids', - 'numberposts' => -1, - 'order' => 'ASC', - 'orderby' => 'menu_order', + <div class="entry-content"> + <?php + if ( has_post_format( 'gallery' ) ) : + + if ( post_password_required() ) : + the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentyfourteen' ) ); + else : + $images = array(); + + $galleries = get_post_galleries( get_the_ID(), false ); + if ( isset( $galleries[0]['ids'] ) ) + $images = explode( ',', $galleries[0]['ids'] ); + + if ( ! $images ) : + $images = get_posts( array( + 'fields' => 'ids', + 'numberposts' => -1, + 'order' => 'ASC', + 'orderby' => 'menu_order', 'post_mime_type' => 'image', - 'post_parent' => get_the_ID(), - 'post_type' => 'attachment', - ) - ); - endif; + 'post_parent' => get_the_ID(), + 'post_type' => 'attachment', + ) ); + endif; - $total_images = count( $images ); + $total_images = count( $images ); - if ( has_post_thumbnail() ) : - $post_thumbnail = get_the_post_thumbnail(); + if ( has_post_thumbnail() ) : + $post_thumbnail = get_the_post_thumbnail(); elseif ( $total_images > 0 ) : $image = reset( $images ); $post_thumbnail = wp_get_attachment_image( $image, 'post-thumbnail' ); endif; - if ( ! empty( $post_thumbnail ) ) : + if ( ! empty ( $post_thumbnail ) ) : ?> <a href="<?php the_permalink(); ?>"><?php echo $post_thumbnail; ?></a> <?php endif; ?> <p class="wp-caption-text"> - <?php - printf( - _n( 'This gallery contains <a href="%1$s" rel="bookmark">%2$s photo</a>.', 'This gallery contains <a href="%1$s" rel="bookmark">%2$s photos</a>.', $total_images, 'twentyfourteen' ), - esc_url( get_permalink() ), - number_format_i18n( $total_images ) - ); - ?> + <?php + printf( _n( 'This gallery contains <a href="%1$s" rel="bookmark">%2$s photo</a>.', 'This gallery contains <a href="%1$s" rel="bookmark">%2$s photos</a>.', $total_images, 'twentyfourteen' ), + esc_url( get_permalink() ), + number_format_i18n( $total_images ) + ); + ?> </p> <?php - endif; + endif; else : the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentyfourteen' ) ); @@ -204,21 +198,20 @@ class Twenty_Fourteen_Ephemera_Widget extends WP_Widget { <header class="entry-header"> <div class="entry-meta"> - <?php - if ( ! has_post_format( 'link' ) ) : - the_title( '<h1 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h1>' ); - endif; + <?php + if ( ! has_post_format( 'link' ) ) : + the_title( '<h1 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h1>' ); + endif; - printf( - '<span class="entry-date"><a href="%1$s" rel="bookmark"><time class="entry-date" datetime="%2$s">%3$s</time></a></span> <span class="byline"><span class="author vcard"><a class="url fn n" href="%4$s" rel="author">%5$s</a></span></span>', - esc_url( get_permalink() ), - esc_attr( get_the_date( 'c' ) ), - esc_html( get_the_date() ), - esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), - get_the_author() - ); + printf( '<span class="entry-date"><a href="%1$s" rel="bookmark"><time class="entry-date" datetime="%2$s">%3$s</time></a></span> <span class="byline"><span class="author vcard"><a class="url fn n" href="%4$s" rel="author">%5$s</a></span></span>', + esc_url( get_permalink() ), + esc_attr( get_the_date( 'c' ) ), + esc_html( get_the_date() ), + esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), + get_the_author() + ); - if ( ! post_password_required() && ( comments_open() || get_comments_number() ) ) : + if ( ! post_password_required() && ( comments_open() || get_comments_number() ) ) : ?> <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyfourteen' ), __( '1 Comment', 'twentyfourteen' ), __( '% Comments', 'twentyfourteen' ) ); ?></span> <?php endif; ?> |