diff options
Diffstat (limited to 'themes/twentyfifteen/inc')
-rw-r--r-- | themes/twentyfifteen/inc/back-compat.php | 24 | ||||
-rw-r--r-- | themes/twentyfifteen/inc/block-patterns.php | 68 | ||||
-rw-r--r-- | themes/twentyfifteen/inc/custom-header.php | 32 | ||||
-rw-r--r-- | themes/twentyfifteen/inc/customizer.php | 10 | ||||
-rw-r--r-- | themes/twentyfifteen/inc/template-tags.php | 29 |
5 files changed, 126 insertions, 37 deletions
diff --git a/themes/twentyfifteen/inc/back-compat.php b/themes/twentyfifteen/inc/back-compat.php index a4f03e3a..6b871f5e 100644 --- a/themes/twentyfifteen/inc/back-compat.php +++ b/themes/twentyfifteen/inc/back-compat.php @@ -34,8 +34,14 @@ add_action( 'after_switch_theme', 'twentyfifteen_switch_theme' ); * @since Twenty Fifteen 1.0 */ function twentyfifteen_upgrade_notice() { - $message = sprintf( __( 'Twenty Fifteen requires at least WordPress version 4.1. You are running version %s. Please upgrade and try again.', 'twentyfifteen' ), $GLOBALS['wp_version'] ); - printf( '<div class="error"><p>%s</p></div>', $message ); + printf( + '<div class="error"><p>%s</p></div>', + sprintf( + /* translators: %s: WordPress version. */ + __( 'Twenty Fifteen requires at least WordPress version 4.1. You are running version %s. Please upgrade and try again.', 'twentyfifteen' ), + $GLOBALS['wp_version'] + ) + ); } /** @@ -45,7 +51,11 @@ function twentyfifteen_upgrade_notice() { */ function twentyfifteen_customize() { wp_die( - sprintf( __( 'Twenty Fifteen requires at least WordPress version 4.1. You are running version %s. Please upgrade and try again.', 'twentyfifteen' ), $GLOBALS['wp_version'] ), + sprintf( + /* translators: %s: WordPress version. */ + __( 'Twenty Fifteen requires at least WordPress version 4.1. You are running version %s. Please upgrade and try again.', 'twentyfifteen' ), + $GLOBALS['wp_version'] + ), '', array( 'back_link' => true, @@ -61,7 +71,13 @@ add_action( 'load-customize.php', 'twentyfifteen_customize' ); */ function twentyfifteen_preview() { if ( isset( $_GET['preview'] ) ) { - wp_die( sprintf( __( 'Twenty Fifteen requires at least WordPress version 4.1. You are running version %s. Please upgrade and try again.', 'twentyfifteen' ), $GLOBALS['wp_version'] ) ); + wp_die( + sprintf( + /* translators: %s: WordPress version. */ + __( 'Twenty Fifteen requires at least WordPress version 4.1. You are running version %s. Please upgrade and try again.', 'twentyfifteen' ), + $GLOBALS['wp_version'] + ) + ); } } add_action( 'template_redirect', 'twentyfifteen_preview' ); diff --git a/themes/twentyfifteen/inc/block-patterns.php b/themes/twentyfifteen/inc/block-patterns.php new file mode 100644 index 00000000..0e220d3e --- /dev/null +++ b/themes/twentyfifteen/inc/block-patterns.php @@ -0,0 +1,68 @@ +<?php +/** + * Block Patterns + * + * @link https://developer.wordpress.org/reference/functions/register_block_pattern/ + * @link https://developer.wordpress.org/reference/functions/register_block_pattern_category/ + * + * @package WordPress + * @subpackage Twenty_Fifteen + * @since Twenty Fifteen 3.0 + */ + +/** + * Register Block Pattern Category. + */ +if ( function_exists( 'register_block_pattern_category' ) ) { + + register_block_pattern_category( + 'twentyfifteen', + array( 'label' => esc_html__( 'Twenty Fifteen', 'twentyfifteen' ) ) + ); +} + +/** + * Register Block Patterns. + */ +if ( function_exists( 'register_block_pattern' ) ) { + + // Gallery and Description. + register_block_pattern( + 'twentyfifteen/gallery-description', + array( + 'title' => esc_html__( 'Gallery and Description', 'twentyfifteen' ), + 'categories' => array( 'twentyfifteen' ), + 'content' => '<!-- wp:columns {"verticalAlignment":"top"} --><div class="wp-block-columns are-vertically-aligned-top"><!-- wp:column {"verticalAlignment":"top","width":"70%"} --><div class="wp-block-column is-vertically-aligned-top" style="flex-basis:70%"><!-- wp:gallery {"ids":[null,null,null],"columns":2,"linkTo":"none"} --><figure class="wp-block-gallery columns-2 is-cropped"><ul class="blocks-gallery-grid"><li class="blocks-gallery-item"><figure><img src="' . esc_url( get_template_directory_uri() ) . '/assets/pier-seagull.jpg" alt="' . esc_attr__( 'A pier with a seagull.', 'twentyfifteen' ) . '" data-full-url="' . esc_url( get_template_directory_uri() ) . '/assets/pier-seagull.jpg" data-link="#"/></figure></li><li class="blocks-gallery-item"><figure><img src="' . esc_url( get_template_directory_uri() ) . '/assets/pier-seagulls.jpg" alt="' . esc_attr__( 'A pier with seagulls.', 'twentyfifteen' ) . '" data-full-url="' . esc_url( get_template_directory_uri() ) . '/assets/pier-seagulls.jpg" data-link="#"/></figure></li><li class="blocks-gallery-item"><figure><img src="' . esc_url( get_template_directory_uri() ) . '/assets/pier-sunset.jpg" alt="' . esc_attr__( 'A pier at sunset', 'twentyfifteen' ) . '" data-full-url="' . esc_url( get_template_directory_uri() ) . '/assets/pier-sunset.jpg" data-link="#"/></figure></li></ul></figure><!-- /wp:gallery --></div><!-- /wp:column --><!-- wp:column {"verticalAlignment":"top"} --><div class="wp-block-column is-vertically-aligned-top"><!-- wp:paragraph {"fontSize":"small"} --><p class="has-small-font-size"><em>' . esc_html__( 'Our default 2015 theme is clean, blog-focused, and designed for clarity. Twenty Fifteen’s simple, straightforward typography is readable on a wide variety of screen sizes, and suitable for multiple languages.', 'twentyfifteen' ) . '</em></p><!-- /wp:paragraph --><!-- wp:separator {"color":"dark-gray","className":"is-style-wide"} --><hr class="wp-block-separator has-text-color has-background has-dark-gray-background-color has-dark-gray-color is-style-wide"/><!-- /wp:separator --></div><!-- /wp:column --></div><!-- /wp:columns -->', + ) + ); + + // Contact Area. + register_block_pattern( + 'twentyfifteen/contact-area', + array( + 'title' => esc_html__( 'Contact area', 'twentyfifteen' ), + 'categories' => array( 'twentyfifteen' ), + 'content' => '<!-- wp:group {"backgroundColor":"light-gray","textColor":"dark-gray"} --><div class="wp-block-group has-dark-gray-color has-light-gray-background-color has-text-color has-background"><div class="wp-block-group__inner-container"><!-- wp:columns --><div class="wp-block-columns"><!-- wp:column --><div class="wp-block-column"><!-- wp:paragraph --><p><strong>' . esc_html__( 'Email', 'twentyfifteen' ) . '</strong><br><a href="mailto:#">' . esc_html__( 'example@example.com', 'twentyfifteen' ) . '</a></p><!-- /wp:paragraph --><!-- wp:paragraph --><p><strong>' . esc_html__( 'Follow us', 'twentyfifteen' ) . '</strong></p><!-- /wp:paragraph --><!-- wp:social-links --><ul class="wp-block-social-links"><!-- wp:social-link {"url":"https://facebook.com","service":"facebook"} /--><!-- wp:social-link {"url":"https://twitter.com","service":"twitter"} /--><!-- wp:social-link {"url":"https://instagram.com","service":"instagram"} /--><!-- wp:social-link {"url":"https://youtube.com","service":"youtube"} /--></ul><!-- /wp:social-links --></div><!-- /wp:column --><!-- wp:column --><div class="wp-block-column"><!-- wp:paragraph --><p><strong>' . esc_html__( 'Phone', 'twentyfifteen' ) . '</strong><br>' . esc_html__( '(123) 555-5555', 'twentyfifteen' ) . '</p><!-- /wp:paragraph --><!-- wp:paragraph --><p><strong>' . esc_html__( 'Address', 'twentyfifteen' ) . '</strong><br>' . esc_html__( '123 Main Street', 'twentyfifteen' ) . '<br>' . esc_html__( 'City, State, 00000', 'twentyfifteen' ) . '</p><!-- /wp:paragraph --></div><!-- /wp:column --></div><!-- /wp:columns --></div></div><!-- /wp:group -->', + ) + ); + + // Two Columns with Images. + register_block_pattern( + 'twentyfifteen/two-columns-with-images', + array( + 'title' => esc_html__( 'Two Columns with Images', 'twentyfifteen' ), + 'categories' => array( 'twentyfifteen' ), + 'content' => '<!-- wp:columns --><div class="wp-block-columns"><!-- wp:column --><div class="wp-block-column"><!-- wp:image {"id":null,"sizeSlug":"large","linkDestination":"none"} --><figure class="wp-block-image size-large"><img src="' . esc_url( get_template_directory_uri() ) . '/assets/pier-seagull.jpg" alt="' . esc_attr__( 'A pier with a seagull.', 'twentyfifteen' ) . '"/></figure><!-- /wp:image --><!-- wp:heading --><h2>' . esc_html__( 'Adventure', 'twentyfifteen' ) . '</h2><!-- /wp:heading --><!-- wp:paragraph --><p>' . esc_html__( 'I faced about again, and rushed towards the approaching Martian, rushed right down the gravelly beach and headlong into the water. Others did the same.', 'twentyfifteen' ) . '</p><!-- /wp:paragraph --></div><!-- /wp:column --><!-- wp:column --><div class="wp-block-column"><!-- wp:image {"id":null,"sizeSlug":"large","linkDestination":"none"} --><figure class="wp-block-image size-large"><img src="' . esc_url( get_template_directory_uri() ) . '/assets/pier-seagulls.jpg" alt="' . esc_attr__( 'A pier with seagulls.', 'twentyfifteen' ) . '"/></figure><!-- /wp:image --><!-- wp:heading --><h2>' . esc_html__( 'Travels', 'twentyfifteen' ) . '</h2><!-- /wp:heading --><!-- wp:paragraph --><p>' . esc_html__( 'A boatload of people putting back came leaping out as I rushed past. The stones under my feet were muddy and slippery, and the river was so low.', 'twentyfifteen' ) . '</p><!-- /wp:paragraph --></div><!-- /wp:column --></div><!-- /wp:columns -->', + ) + ); + + // Columns with a list. + register_block_pattern( + 'twentyfifteen/columns-with-list', + array( + 'title' => esc_html__( 'Columns with a List', 'twentyfifteen' ), + 'categories' => array( 'twentyfifteen' ), + 'content' => '<!-- wp:heading --><h2>' . esc_html__( 'What to pack for the beach', 'twentyfifteen' ) . '</h2><!-- /wp:heading --><!-- wp:paragraph {"style":{"color":{"text":"#707070"}}} --><p class="has-text-color" style="color:#707070"><em>' . esc_html__( 'You don’t need a lot, trust us!', 'twentyfifteen' ) . '</em></p><!-- /wp:paragraph --><!-- wp:columns --><div class="wp-block-columns"><!-- wp:column {"width":"65%"} --><div class="wp-block-column" style="flex-basis:65%"><!-- wp:paragraph --><p>' . esc_html__( 'As I watched, the planet seemed to grow larger and smaller and to advance and recede, but that was simply that my eye was tired. Forty millions of miles it was from us — more than forty millions of miles of void. Few people realize the immensity of vacancy in which the dust of the material universe swims.', 'twentyfifteen' ) . '</p><!-- /wp:paragraph --></div><!-- /wp:column --><!-- wp:column {"width":"5%"} --><div class="wp-block-column" style="flex-basis:5%"></div><!-- /wp:column --><!-- wp:column {"width":"30%"} --><div class="wp-block-column" style="flex-basis:30%"><!-- wp:list --><ul><li>' . esc_html__( 'Towels', 'twentyfifteen' ) . '</li><li>' . esc_html__( 'Camera', 'twentyfifteen' ) . '</li><li>' . esc_html__( 'Water Bottle', 'twentyfifteen' ) . '</li><li>' . esc_html__( 'Swimsuit', 'twentyfifteen' ) . '</li><li>' . esc_html__( 'Snacks', 'twentyfifteen' ) . '</li></ul><!-- /wp:list --></div><!-- /wp:column --></div><!-- /wp:columns -->', + ) + ); +} diff --git a/themes/twentyfifteen/inc/custom-header.php b/themes/twentyfifteen/inc/custom-header.php index 763ef00d..bf8655a7 100644 --- a/themes/twentyfifteen/inc/custom-header.php +++ b/themes/twentyfifteen/inc/custom-header.php @@ -16,23 +16,23 @@ function twentyfifteen_custom_header_setup() { $color_scheme = twentyfifteen_get_color_scheme(); $default_text_color = trim( $color_scheme[4], '#' ); - /** - * Filter Twenty Fifteen custom-header support arguments. - * - * @since Twenty Fifteen 1.0 - * - * @param array $args { - * An array of custom-header support arguments. - * - * @type string $default_text_color Default color of the header text. - * @type int $width Width in pixels of the custom header image. Default 954. - * @type int $height Height in pixels of the custom header image. Default 1300. - * @type string $wp-head-callback Callback function used to styles the header image and text - * displayed on the blog. - * } - */ add_theme_support( 'custom-header', + /** + * Filters Twenty Fifteen custom-header support arguments. + * + * @since Twenty Fifteen 1.0 + * + * @param array $args { + * An array of custom-header support arguments. + * + * @type string $default_text_color Default color of the header text. + * @type int $width Width in pixels of the custom header image. Default 954. + * @type int $height Height in pixels of the custom header image. Default 1300. + * @type string $wp-head-callback Callback function used to styles the header image and text + * displayed on the blog. + * } + */ apply_filters( 'twentyfifteen_custom_header_args', array( @@ -193,7 +193,7 @@ if ( ! function_exists( 'twentyfifteen_header_style' ) ) : </style> <?php } -endif; // twentyfifteen_header_style +endif; // twentyfifteen_header_style() /** * Enqueues front-end CSS for the header background color. diff --git a/themes/twentyfifteen/inc/customizer.php b/themes/twentyfifteen/inc/customizer.php index 3b74f243..b4c33bce 100644 --- a/themes/twentyfifteen/inc/customizer.php +++ b/themes/twentyfifteen/inc/customizer.php @@ -116,6 +116,7 @@ add_action( 'customize_register', 'twentyfifteen_customize_register', 11 ); * Render the site title for the selective refresh partial. * * @since Twenty Fifteen 1.5 + * * @see twentyfifteen_customize_register() * * @return void @@ -128,6 +129,7 @@ function twentyfifteen_customize_partial_blogname() { * Render the site tagline for the selective refresh partial. * * @since Twenty Fifteen 1.5 + * * @see twentyfifteen_customize_register() * * @return void @@ -155,7 +157,7 @@ function twentyfifteen_customize_partial_blogdescription() { */ function twentyfifteen_get_color_schemes() { /** - * Filter the color schemes registered for use with Twenty Fifteen. + * Filters the color schemes registered for use with Twenty Fifteen. * * The default schemes include 'default', 'dark', 'yellow', 'pink', 'purple', and 'blue'. * @@ -266,7 +268,7 @@ if ( ! function_exists( 'twentyfifteen_get_color_scheme' ) ) : return $color_schemes['default']['colors']; } -endif; // twentyfifteen_get_color_scheme +endif; // twentyfifteen_get_color_scheme() if ( ! function_exists( 'twentyfifteen_get_color_scheme_choices' ) ) : /** @@ -286,7 +288,7 @@ if ( ! function_exists( 'twentyfifteen_get_color_scheme_choices' ) ) : return $color_scheme_control_options; } -endif; // twentyfifteen_get_color_scheme_choices +endif; // twentyfifteen_get_color_scheme_choices() if ( ! function_exists( 'twentyfifteen_sanitize_color_scheme' ) ) : /** @@ -306,7 +308,7 @@ if ( ! function_exists( 'twentyfifteen_sanitize_color_scheme' ) ) : return $value; } -endif; // twentyfifteen_sanitize_color_scheme +endif; // twentyfifteen_sanitize_color_scheme() /** * Enqueues front-end CSS for color scheme. diff --git a/themes/twentyfifteen/inc/template-tags.php b/themes/twentyfifteen/inc/template-tags.php index 6af6e750..b2b515f4 100644 --- a/themes/twentyfifteen/inc/template-tags.php +++ b/themes/twentyfifteen/inc/template-tags.php @@ -23,13 +23,15 @@ if ( ! function_exists( 'twentyfifteen_comment_nav' ) ) : <h2 class="screen-reader-text"><?php _e( 'Comment navigation', 'twentyfifteen' ); ?></h2> <div class="nav-links"> <?php - if ( $prev_link = get_previous_comments_link( __( 'Older Comments', 'twentyfifteen' ) ) ) : + $prev_link = get_previous_comments_link( __( 'Older Comments', 'twentyfifteen' ) ); + if ( $prev_link ) { printf( '<div class="nav-previous">%s</div>', $prev_link ); - endif; + } - if ( $next_link = get_next_comments_link( __( 'Newer Comments', 'twentyfifteen' ) ) ) : + $next_link = get_next_comments_link( __( 'Newer Comments', 'twentyfifteen' ) ); + if ( $next_link ) { printf( '<div class="nav-next">%s</div>', $next_link ); - endif; + } ?> </div><!-- .nav-links --> </nav><!-- .comment-navigation --> @@ -59,7 +61,7 @@ if ( ! function_exists( 'twentyfifteen_entry_meta' ) ) : ); } - if ( in_array( get_post_type(), array( 'post', 'attachment' ) ) ) { + if ( in_array( get_post_type(), array( 'post', 'attachment' ), true ) ) { $time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>'; if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) { @@ -82,7 +84,7 @@ if ( ! function_exists( 'twentyfifteen_entry_meta' ) ) : ); } - if ( 'post' == get_post_type() ) { + if ( 'post' === get_post_type() ) { if ( is_singular() || is_multi_author() ) { printf( '<span class="byline"><span class="author vcard"><span class="screen-reader-text">%1$s </span><a class="url fn n" href="%2$s">%3$s</a></span></span>', @@ -126,7 +128,7 @@ if ( ! function_exists( 'twentyfifteen_entry_meta' ) ) : if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) { echo '<span class="comments-link">'; - /* translators: %s: post title */ + /* translators: %s: Post title. */ comments_popup_link( sprintf( __( 'Leave a comment<span class="screen-reader-text"> on %s</span>', 'twentyfifteen' ), get_the_title() ) ); echo '</span>'; } @@ -141,7 +143,8 @@ endif; * @return bool True of there is more than one category, false otherwise. */ function twentyfifteen_categorized_blog() { - if ( false === ( $all_the_cool_cats = get_transient( 'twentyfifteen_categories' ) ) ) { + $all_the_cool_cats = get_transient( 'twentyfifteen_categories' ); + if ( false === $all_the_cool_cats ) { // Create an array of all the categories that are attached to posts. $all_the_cool_cats = get_categories( array( @@ -160,10 +163,10 @@ function twentyfifteen_categorized_blog() { } if ( $all_the_cool_cats > 1 || is_preview() ) { - // This blog has more than 1 category so twentyfifteen_categorized_blog should return true. + // This blog has more than 1 category so twentyfifteen_categorized_blog() should return true. return true; } else { - // This blog has only 1 category so twentyfifteen_categorized_blog should return false. + // This blog has only 1 category so twentyfifteen_categorized_blog() should return false. return false; } } @@ -210,7 +213,7 @@ if ( ! function_exists( 'twentyfifteen_post_thumbnail' ) ) : </a> <?php - endif; // End is_singular() + endif; // End is_singular(). } endif; @@ -245,7 +248,7 @@ if ( ! function_exists( 'twentyfifteen_excerpt_more' ) && ! is_admin() ) : $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 */ + /* translators: %s: Post title. */ sprintf( __( 'Continue reading %s', 'twentyfifteen' ), '<span class="screen-reader-text">' . get_the_title( get_the_ID() ) . '</span>' ) ); return ' … ' . $link; @@ -272,7 +275,7 @@ if ( ! function_exists( 'wp_body_open' ) ) : /** * Fire the wp_body_open action. * - * Added for backwards compatibility to support pre 5.2.0 WordPress versions. + * Added for backward compatibility to support pre-5.2.0 WordPress versions. * * @since Twenty Fifteen 2.5 */ |