From 466ec7483a5b7ecfab62ecd04b9353b59412bc40 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Fri, 14 Dec 2018 03:24:35 +0000 Subject: [PATCH] General: Fix some code formatting issues. A handful of code formatting issues were introduced in recent commits, runs the auto-fixer on them. git-svn-id: https://develop.svn.wordpress.org/trunk@44155 602fd350-edb4-49c9-b593-d223f7449a82 --- .../class-twentynineteen-svg-icons.php | 36 ++--- .../class-twentynineteen-walker-comment.php | 28 ++-- .../themes/twentynineteen/comments.php | 50 +++---- .../themes/twentynineteen/image.php | 98 ++++++------- .../twentynineteen/inc/color-patterns.php | 20 +-- .../themes/twentynineteen/inc/customizer.php | 4 +- .../twentynineteen/inc/template-functions.php | 14 +- .../twentynineteen/inc/template-tags.php | 4 +- .../template-parts/content/content-single.php | 2 +- .../template-parts/footer/footer-widgets.php | 8 +- src/wp-includes/embed.php | 133 ++++++++++-------- tests/phpunit/tests/oembed/controller.php | 48 ++++--- 12 files changed, 233 insertions(+), 212 deletions(-) diff --git a/src/wp-content/themes/twentynineteen/classes/class-twentynineteen-svg-icons.php b/src/wp-content/themes/twentynineteen/classes/class-twentynineteen-svg-icons.php index 0d839a3722..16efb0aa50 100644 --- a/src/wp-content/themes/twentynineteen/classes/class-twentynineteen-svg-icons.php +++ b/src/wp-content/themes/twentynineteen/classes/class-twentynineteen-svg-icons.php @@ -71,13 +71,13 @@ class TwentyNineteen_SVG_Icons { * @var array */ static $ui_icons = array( - 'link' => /* material-design – link */ ' + 'link' => /* material-design – link */ ' ', - 'watch' => /* material-design – watch-later */ ' + 'watch' => /* material-design – watch-later */ ' @@ -88,73 +88,73 @@ class TwentyNineteen_SVG_Icons { ', - 'archive' => /* material-design – folder */ ' + 'archive' => /* material-design – folder */ ' ', - 'tag' => /* material-design – local_offer */ ' + 'tag' => /* material-design – local_offer */ ' ', - 'comment' => /* material-design – comment */ ' + 'comment' => /* material-design – comment */ ' ', - 'person' => /* material-design – person */ ' + 'person' => /* material-design – person */ ' ', - 'edit' => /* material-design – edit */ ' + 'edit' => /* material-design – edit */ ' ', - 'chevron_left' => /* material-design – chevron_left */ ' + 'chevron_left' => /* material-design – chevron_left */ ' ', - 'chevron_right' => /* material-design – chevron_right */ ' + 'chevron_right' => /* material-design – chevron_right */ ' ', - 'check' => /* material-design – check */ ' + 'check' => /* material-design – check */ ' ', - 'arrow_drop_down_circle' => /* material-design – arrow_drop_down_circle */ ' + 'arrow_drop_down_circle' => /* material-design – arrow_drop_down_circle */ ' ', - 'keyboard_arrow_down' => /* material-design – keyboard_arrow_down */ ' + 'keyboard_arrow_down' => /* material-design – keyboard_arrow_down */ ' ', - 'keyboard_arrow_right' => /* material-design – keyboard_arrow_right */ ' + 'keyboard_arrow_right' => /* material-design – keyboard_arrow_right */ ' ', - 'keyboard_arrow_left' => /* material-design – keyboard_arrow_left */ ' + 'keyboard_arrow_left' => /* material-design – keyboard_arrow_left */ ' @@ -205,16 +205,16 @@ class TwentyNineteen_SVG_Icons { 'facebook.com', 'fb.me', ), - 'feed' => array( + 'feed' => array( 'feed', ), 'google-plus' => array( 'plus.google.com', ), - 'lastfm' => array( + 'lastfm' => array( 'last.fm', ), - 'mail' => array( + 'mail' => array( 'mailto:', ), 'slideshare' => array( @@ -343,7 +343,7 @@ class TwentyNineteen_SVG_Icons { ', - 'lastfm' => ' + 'lastfm' => ' ', diff --git a/src/wp-content/themes/twentynineteen/classes/class-twentynineteen-walker-comment.php b/src/wp-content/themes/twentynineteen/classes/class-twentynineteen-walker-comment.php index b39185e45e..27236e07db 100644 --- a/src/wp-content/themes/twentynineteen/classes/class-twentynineteen-walker-comment.php +++ b/src/wp-content/themes/twentynineteen/classes/class-twentynineteen-walker-comment.php @@ -37,23 +37,23 @@ class TwentyNineteen_Walker_Comment extends Walker_Comment { $comment_author_url = get_comment_author_url( $comment ); $comment_author = get_comment_author( $comment ); $avatar = get_avatar( $comment, $args['avatar_size'] ); - if ( 0 != $args['avatar_size'] ) { - if ( empty( $comment_author_url ) ) { - echo $avatar; - } else { - printf( '', $comment_author_url ); - echo $avatar; - } + if ( 0 != $args['avatar_size'] ) { + if ( empty( $comment_author_url ) ) { + echo $avatar; + } else { + printf( '', $comment_author_url ); + echo $avatar; } + } /* * Using the `check` icon instead of `check_circle`, since we can't add a * fill color to the inner check shape when in circle form. */ - if ( twentynineteen_is_comment_by_post_author( $comment ) ) { - /* translators: %s: SVG Icon */ - printf( '', twentynineteen_get_icon_svg( 'check', 24 ) ); - } + if ( twentynineteen_is_comment_by_post_author( $comment ) ) { + /* translators: %s: SVG Icon */ + printf( '', twentynineteen_get_icon_svg( 'check', 24 ) ); + } printf( /* translators: %s: comment author link */ @@ -61,9 +61,9 @@ class TwentyNineteen_Walker_Comment extends Walker_Comment { sprintf( '%s', $comment_author ) ); - if ( ! empty( $comment_author_url ) ) { - echo ''; - } + if ( ! empty( $comment_author_url ) ) { + echo ''; + } ?> diff --git a/src/wp-content/themes/twentynineteen/comments.php b/src/wp-content/themes/twentynineteen/comments.php index 7b21dca0c6..d74c1cff66 100644 --- a/src/wp-content/themes/twentynineteen/comments.php +++ b/src/wp-content/themes/twentynineteen/comments.php @@ -28,38 +28,38 @@ $discussion = twentynineteen_get_discussion_data();

responses ) { - /* translators: %s: post title */ - printf( _x( 'One reply on “%s”', 'comments title', 'twentynineteen' ), get_the_title() ); - } else { - printf( - /* translators: 1: number of comments, 2: post title */ - _nx( - '%1$s reply on “%2$s”', - '%1$s replies on “%2$s”', - $discussion->responses, - 'comments title', - 'twentynineteen' - ), - number_format_i18n( $discussion->responses ), - get_the_title() - ); - } + _e( 'Leave a comment', 'twentynineteen' ); } + } else { + if ( '1' == $discussion->responses ) { + /* translators: %s: post title */ + printf( _x( 'One reply on “%s”', 'comments title', 'twentynineteen' ), get_the_title() ); + } else { + printf( + /* translators: 1: number of comments, 2: post title */ + _nx( + '%1$s reply on “%2$s”', + '%1$s replies on “%2$s”', + $discussion->responses, + 'comments title', + 'twentynineteen' + ), + number_format_i18n( $discussion->responses ), + get_the_title() + ); + } + } ?>

+ while ( have_posts() ) : + the_post(); + ?>
>
- ', '' ); ?> + ', '' ); ?>
- + echo wp_get_attachment_image( get_the_ID(), $image_size ); + ?>
'', - 'link_before' => '', - 'link_after' => '', - 'pagelink' => '' . __( 'Page', 'twentynineteen' ) . ' %', - 'separator' => ', ', - ) - ); + the_content(); + wp_link_pages( + array( + 'before' => '', + 'link_before' => '', + 'link_after' => '', + 'pagelink' => '' . __( 'Page', 'twentynineteen' ) . ' %', + 'separator' => ', ', + ) + ); ?>
- %1$s%3$s × %4$s', - _x( 'Full size', 'Used before full size attachment link.', 'twentynineteen' ), - esc_url( wp_get_attachment_url() ), - absint( $metadata['width'] ), - absint( $metadata['height'] ) - ); - } - ?> + %1$s%3$s × %4$s', + _x( 'Full size', 'Used before full size attachment link.', 'twentynineteen' ), + esc_url( wp_get_attachment_url() ), + absint( $metadata['width'] ), + absint( $metadata['height'] ) + ); + } + ?> @@ -81,17 +81,17 @@ get_header();
_x( 'Published in
%title', 'Parent post link', 'twentynineteen' ), - ) - ); + // Parent post navigation. + the_post_navigation( + array( + 'prev_text' => _x( 'Published in
%title', 'Parent post link', 'twentynineteen' ), + ) + ); - // If comments are open or we have at least one comment, load up the comment template. - if ( comments_open() || get_comments_number() ) { - comments_template(); - } + // If comments are open or we have at least one comment, load up the comment template. + if ( comments_open() || get_comments_number() ) { + comments_template(); + } // End the loop. endwhile; diff --git a/src/wp-content/themes/twentynineteen/inc/color-patterns.php b/src/wp-content/themes/twentynineteen/inc/color-patterns.php index 9579d4209f..f2eff854f5 100644 --- a/src/wp-content/themes/twentynineteen/inc/color-patterns.php +++ b/src/wp-content/themes/twentynineteen/inc/color-patterns.php @@ -26,20 +26,20 @@ function twentynineteen_custom_colors_css() { * @param int $saturation Color saturation level. */ - $saturation = absint( apply_filters( 'twentynineteen_custom_colors_saturation', 100 ) ); - $saturation = $saturation . '%'; + $saturation = absint( apply_filters( 'twentynineteen_custom_colors_saturation', 100 ) ); + $saturation = $saturation . '%'; $saturation_selection = absint( apply_filters( 'twentynineteen_custom_colors_saturation_selection', 50 ) ); $saturation_selection = $saturation_selection . '%'; - $lightness = absint( apply_filters( 'twentynineteen_custom_colors_lightness', 33 ) ); - $lightness = $lightness . '%'; + $lightness = absint( apply_filters( 'twentynineteen_custom_colors_lightness', 33 ) ); + $lightness = $lightness . '%'; - $lightness_hover = absint( apply_filters( 'twentynineteen_custom_colors_lightness_hover', 23 ) ); - $lightness_hover = $lightness_hover . '%'; + $lightness_hover = absint( apply_filters( 'twentynineteen_custom_colors_lightness_hover', 23 ) ); + $lightness_hover = $lightness_hover . '%'; - $lightness_selection = absint( apply_filters( 'twentynineteen_custom_colors_lightness_selection', 90 ) ); - $lightness_selection = $lightness_selection . '%'; + $lightness_selection = absint( apply_filters( 'twentynineteen_custom_colors_lightness_selection', 90 ) ); + $lightness_selection = $lightness_selection . '%'; $theme_css = ' /* @@ -233,10 +233,10 @@ function twentynineteen_custom_colors_css() { color: inherit; } '; - $css = ''; + $css = ''; if ( function_exists( 'register_block_type' ) && is_admin() ) { $css .= $editor_css; - } else if ( ! is_admin() ) { + } elseif ( ! is_admin() ) { $css = $theme_css; } diff --git a/src/wp-content/themes/twentynineteen/inc/customizer.php b/src/wp-content/themes/twentynineteen/inc/customizer.php index 197d33c267..2ce309c91a 100644 --- a/src/wp-content/themes/twentynineteen/inc/customizer.php +++ b/src/wp-content/themes/twentynineteen/inc/customizer.php @@ -52,8 +52,8 @@ function twentynineteen_customize_register( $wp_customize ) { 'type' => 'radio', 'label' => __( 'Primary Color', 'twentynineteen' ), 'choices' => array( - 'default' => _x( 'Default', 'primary color', 'twentynineteen' ), - 'custom' => _x( 'Custom', 'primary color', 'twentynineteen' ), + 'default' => _x( 'Default', 'primary color', 'twentynineteen' ), + 'custom' => _x( 'Custom', 'primary color', 'twentynineteen' ), ), 'section' => 'colors', 'priority' => 5, diff --git a/src/wp-content/themes/twentynineteen/inc/template-functions.php b/src/wp-content/themes/twentynineteen/inc/template-functions.php index 6d21f06ee5..947b3d77d5 100644 --- a/src/wp-content/themes/twentynineteen/inc/template-functions.php +++ b/src/wp-content/themes/twentynineteen/inc/template-functions.php @@ -364,14 +364,14 @@ function twentynineteen_hsl_hex( $h, $s, $l, $to_hex = true ) { $mid1; $mid2; - $m = $l + $l - $v; - $sv = ( $v - $m ) / $v; - $h *= 6.0; + $m = $l + $l - $v; + $sv = ( $v - $m ) / $v; + $h *= 6.0; $sextant = floor( $h ); - $fract = $h - $sextant; - $vsf = $v * $sv * $fract; - $mid1 = $m + $vsf; - $mid2 = $v - $vsf; + $fract = $h - $sextant; + $vsf = $v * $sv * $fract; + $mid1 = $m + $vsf; + $mid2 = $v - $vsf; switch ( $sextant ) { case 0: diff --git a/src/wp-content/themes/twentynineteen/inc/template-tags.php b/src/wp-content/themes/twentynineteen/inc/template-tags.php index 2740efeeac..b435a35027 100644 --- a/src/wp-content/themes/twentynineteen/inc/template-tags.php +++ b/src/wp-content/themes/twentynineteen/inc/template-tags.php @@ -210,8 +210,8 @@ if ( ! function_exists( 'twentynineteen_comment_form' ) ) : comment_form( array( - 'logged_in_as' => null, - 'title_reply' => null, + 'logged_in_as' => null, + 'title_reply' => null, ) ); } diff --git a/src/wp-content/themes/twentynineteen/template-parts/content/content-single.php b/src/wp-content/themes/twentynineteen/template-parts/content/content-single.php index b98854e44d..720a253539 100644 --- a/src/wp-content/themes/twentynineteen/template-parts/content/content-single.php +++ b/src/wp-content/themes/twentynineteen/template-parts/content/content-single.php @@ -49,7 +49,7 @@ - + diff --git a/src/wp-content/themes/twentynineteen/template-parts/footer/footer-widgets.php b/src/wp-content/themes/twentynineteen/template-parts/footer/footer-widgets.php index 550e2afc20..163cbd89df 100644 --- a/src/wp-content/themes/twentynineteen/template-parts/footer/footer-widgets.php +++ b/src/wp-content/themes/twentynineteen/template-parts/footer/footer-widgets.php @@ -11,13 +11,13 @@ if ( is_active_sidebar( 'sidebar-1' ) ) : ?> diff --git a/src/wp-includes/embed.php b/src/wp-includes/embed.php index efd991104a..7cce664548 100644 --- a/src/wp-includes/embed.php +++ b/src/wp-includes/embed.php @@ -61,11 +61,13 @@ function wp_embed_unregister_handler( $id, $priority = 10 ) { * @return array Default embed parameters. */ function wp_embed_defaults( $url = '' ) { - if ( ! empty( $GLOBALS['content_width'] ) ) + if ( ! empty( $GLOBALS['content_width'] ) ) { $width = (int) $GLOBALS['content_width']; + } - if ( empty( $width ) ) + if ( empty( $width ) ) { $width = 500; + } $height = min( ceil( $width * 1.5 ), 1000 ); @@ -131,8 +133,8 @@ function _wp_oembed_get_object() { */ function wp_oembed_add_provider( $format, $provider, $regex = false ) { if ( did_action( 'plugins_loaded' ) ) { - $oembed = _wp_oembed_get_object(); - $oembed->providers[$format] = array( $provider, $regex ); + $oembed = _wp_oembed_get_object(); + $oembed->providers[ $format ] = array( $provider, $regex ); } else { WP_oEmbed::_add_provider_early( $format, $provider, $regex ); } @@ -226,7 +228,7 @@ function wp_maybe_load_embeds() { */ function wp_embed_handler_youtube( $matches, $attr, $url, $rawattr ) { global $wp_embed; - $embed = $wp_embed->autoembed( sprintf( "https://youtube.com/watch?v=%s", urlencode( $matches[2] ) ) ); + $embed = $wp_embed->autoembed( sprintf( 'https://youtube.com/watch?v=%s', urlencode( $matches[2] ) ) ); /** * Filters the YoutTube embed output. @@ -395,10 +397,13 @@ function get_oembed_endpoint_url( $permalink = '', $format = 'json' ) { $url = rest_url( 'oembed/1.0/embed' ); if ( '' !== $permalink ) { - $url = add_query_arg( array( - 'url' => urlencode( $permalink ), - 'format' => ( 'json' !== $format ) ? $format : false, - ), $url ); + $url = add_query_arg( + array( + 'url' => urlencode( $permalink ), + 'format' => ( 'json' !== $format ) ? $format : false, + ), + $url + ); } /** @@ -449,7 +454,7 @@ function get_post_embed_html( $width, $height, $post = null ) { * minified JavaScript. If you need to debug it, please turn on SCRIPT_DEBUG * and edit wp-embed.js directly. */ - $output .=<< 200, - 'max' => 600 - ) ); + $min_max_width = apply_filters( + 'oembed_min_max_width', + array( + 'min' => 200, + 'max' => 600, + ) + ); $width = min( max( $min_max_width['min'], $width ), $min_max_width['max'] ); $height = max( ceil( $width / 16 * 9 ), 200 ); @@ -569,12 +577,18 @@ function get_oembed_response_data_for_url( $url, $args ) { $switched_blog = false; if ( is_multisite() ) { - $url_parts = wp_parse_args( wp_parse_url( $url ), array( - 'host' => '', - 'path' => '/', - ) ); + $url_parts = wp_parse_args( + wp_parse_url( $url ), + array( + 'host' => '', + 'path' => '/', + ) + ); - $qv = array( 'domain' => $url_parts['host'], 'path' => '/' ); + $qv = array( + 'domain' => $url_parts['host'], + 'path' => '/', + ); // In case of subdirectory configs, set the path. if ( ! is_subdomain_install() ) { @@ -647,7 +661,7 @@ function get_oembed_response_data_rich( $data, $post, $width, $height ) { if ( 'attachment' === get_post_type( $post ) ) { if ( wp_attachment_is_image( $post ) ) { $thumbnail_id = $post->ID; - } else if ( wp_attachment_is( 'video', $post ) ) { + } elseif ( wp_attachment_is( 'video', $post ) ) { $thumbnail_id = get_post_thumbnail_id( $post ); $data['type'] = 'video'; } @@ -655,9 +669,9 @@ function get_oembed_response_data_rich( $data, $post, $width, $height ) { if ( $thumbnail_id ) { list( $thumbnail_url, $thumbnail_width, $thumbnail_height ) = wp_get_attachment_image_src( $thumbnail_id, array( $width, 99999 ) ); - $data['thumbnail_url'] = $thumbnail_url; - $data['thumbnail_width'] = $thumbnail_width; - $data['thumbnail_height'] = $thumbnail_height; + $data['thumbnail_url'] = $thumbnail_url; + $data['thumbnail_width'] = $thumbnail_width; + $data['thumbnail_height'] = $thumbnail_height; } return $data; @@ -794,7 +808,7 @@ function wp_filter_oembed_result( $result, $data, $url ) { $allowed_html = array( 'a' => array( - 'href' => true, + 'href' => true, ), 'blockquote' => array(), 'iframe' => array( @@ -824,14 +838,14 @@ function wp_filter_oembed_result( $result, $data, $url ) { $secret = wp_generate_password( 10, false ); $url = esc_url( "{$results[2]}#?secret=$secret" ); - $q = $results[1]; + $q = $results[1]; $html = str_replace( $results[0], ' src=' . $q . $url . $q . ' data-secret=' . $q . $secret . $q, $html ); $html = str_replace( '%2$s', + $link = sprintf( + '%2$s', esc_url( get_permalink() ), /* translators: %s: Name of current post */ sprintf( __( 'Continue reading %s' ), '' . get_the_title() . '' ) @@ -938,23 +953,23 @@ function print_embed_styles() { ?> wp_json_encode( array( - 'version' => '1.0', - 'type' => 'rich', - 'provider_name' => 'Untrusted', - 'provider_url' => self::UNTRUSTED_PROVIDER_URL, - 'html' => 'FilteredUnfiltered', - 'author_name' => 'Untrusted Embed Author', - 'title' => 'Untrusted Embed', + 'version' => '1.0', + 'type' => 'rich', + 'provider_name' => 'Untrusted', + 'provider_url' => self::UNTRUSTED_PROVIDER_URL, + 'html' => 'FilteredUnfiltered', + 'author_name' => 'Untrusted Embed Author', + 'title' => 'Untrusted Embed', ) ), ); @@ -651,13 +651,17 @@ class Test_oEmbed_Controller extends WP_UnitTestCase { function test_proxy_with_internal_url() { wp_set_current_user( self::$editor ); - $user = self::factory()->user->create_and_get( array( - 'display_name' => 'John Doe', - ) ); - $post = self::factory()->post->create_and_get( array( - 'post_author' => $user->ID, - 'post_title' => 'Hello World', - ) ); + $user = self::factory()->user->create_and_get( + array( + 'display_name' => 'John Doe', + ) + ); + $post = self::factory()->post->create_and_get( + array( + 'post_author' => $user->ID, + 'post_title' => 'Hello World', + ) + ); $request = new WP_REST_Request( 'GET', '/oembed/1.0/proxy' ); $request->set_param( 'url', get_permalink( $post->ID ) ); @@ -695,11 +699,13 @@ class Test_oEmbed_Controller extends WP_UnitTestCase { function test_proxy_with_static_front_page_url() { wp_set_current_user( self::$editor ); - $post = self::factory()->post->create_and_get( array( - 'post_title' => 'Front page', - 'post_type' => 'page', - 'post_author' => 0, - ) ); + $post = self::factory()->post->create_and_get( + array( + 'post_title' => 'Front page', + 'post_type' => 'page', + 'post_author' => 0, + ) + ); update_option( 'show_on_front', 'page' ); update_option( 'page_on_front', $post->ID );