Code Modernization: Rename parameters that use reserved keywords in bundled themes.
While using reserved PHP keywords as parameter name labels is allowed, in the context of function calls using named parameters in PHP 8.0+, this will easily lead to confusion. To avoid that, it is recommended not to use reserved keywords as function parameter names. This commit: * Renames the `$class` parameter to `$css_class` in: * `twentysixteen_excerpt()` * `twentynineteen_post_classes()` * Renames the `$echo` parameter to `$display` in: * `twentythirteen_entry_date()` * `twentytwenty_generate_css()` * `twentytwenty_site_logo()` * `twentytwenty_site_description()` * `twenty_twenty_one_generate_css()` Follow-up to [52946], [52996], [52997], [52998], [53003], [53014], [53029], [53039], [53116], [53117], [53137], [53174], [53184], [53185], [53192], [53193], [53198], [53203], [53207], [53215], [53216], [53220], [53230], [53232]. Props jrf, aristath, poena, justinahinon, SergeyBiryukov. See #55327. Built from https://develop.svn.wordpress.org/trunk@53236 git-svn-id: http://core.svn.wordpress.org/trunk@52825 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
6ef5625ac2
commit
89f24e9c61
|
@ -35,7 +35,7 @@ add_filter( 'body_class', 'twentynineteen_body_classes' );
|
|||
/**
|
||||
* Adds custom class to the array of posts classes.
|
||||
*/
|
||||
function twentynineteen_post_classes( $classes, $class, $post_id ) {
|
||||
function twentynineteen_post_classes( $classes, $css_class, $post_id ) {
|
||||
$classes[] = 'entry';
|
||||
|
||||
return $classes;
|
||||
|
|
|
@ -161,16 +161,16 @@ if ( ! function_exists( 'twentysixteen_excerpt' ) ) :
|
|||
*
|
||||
* @since Twenty Sixteen 1.0
|
||||
*
|
||||
* @param string $class Optional. Class string of the div element. Defaults to 'entry-summary'.
|
||||
* @param string $css_class Optional. Class string of the div element. Defaults to 'entry-summary'.
|
||||
*/
|
||||
function twentysixteen_excerpt( $class = 'entry-summary' ) {
|
||||
$class = esc_attr( $class );
|
||||
function twentysixteen_excerpt( $css_class = 'entry-summary' ) {
|
||||
$css_class = esc_attr( $css_class );
|
||||
|
||||
if ( has_excerpt() || is_search() ) :
|
||||
?>
|
||||
<div class="<?php echo $class; ?>">
|
||||
<div class="<?php echo $css_class; ?>">
|
||||
<?php the_excerpt(); ?>
|
||||
</div><!-- .<?php echo $class; ?> -->
|
||||
</div><!-- .<?php echo $css_class; ?> -->
|
||||
<?php
|
||||
endif;
|
||||
}
|
||||
|
|
|
@ -562,10 +562,10 @@ if ( ! function_exists( 'twentythirteen_entry_date' ) ) :
|
|||
*
|
||||
* @since Twenty Thirteen 1.0
|
||||
*
|
||||
* @param bool $echo (optional) Whether to echo the date. Default true.
|
||||
* @param bool $display (optional) Whether to display the date. Default true.
|
||||
* @return string The HTML-formatted post date.
|
||||
*/
|
||||
function twentythirteen_entry_date( $echo = true ) {
|
||||
function twentythirteen_entry_date( $display = true ) {
|
||||
if ( has_post_format( array( 'chat', 'status' ) ) ) {
|
||||
/* translators: 1: Post format name, 2: Date. */
|
||||
$format_prefix = _x( '%1$s on %2$s', '1: post format name. 2: date', 'twentythirteen' );
|
||||
|
@ -582,7 +582,7 @@ if ( ! function_exists( 'twentythirteen_entry_date' ) ) :
|
|||
esc_html( sprintf( $format_prefix, get_post_format_string( get_post_format() ), get_the_date() ) )
|
||||
);
|
||||
|
||||
if ( $echo ) {
|
||||
if ( $display ) {
|
||||
echo $date;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,9 +19,9 @@ if ( ! function_exists( 'twentytwenty_generate_css' ) ) {
|
|||
* @param string $value The CSS value.
|
||||
* @param string $prefix The CSS prefix.
|
||||
* @param string $suffix The CSS suffix.
|
||||
* @param bool $echo Echo the styles.
|
||||
* @param bool $display Output the styles.
|
||||
*/
|
||||
function twentytwenty_generate_css( $selector, $style, $value, $prefix = '', $suffix = '', $echo = true ) {
|
||||
function twentytwenty_generate_css( $selector, $style, $value, $prefix = '', $suffix = '', $display = true ) {
|
||||
|
||||
$return = '';
|
||||
|
||||
|
@ -35,7 +35,7 @@ if ( ! function_exists( 'twentytwenty_generate_css' ) ) {
|
|||
|
||||
$return = sprintf( '%s { %s: %s; }', $selector, $style, $prefix . $value . $suffix );
|
||||
|
||||
if ( $echo ) {
|
||||
if ( $display ) {
|
||||
|
||||
echo $return; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- We need to double check this, but for now, we want to pass PHPCS ;)
|
||||
|
||||
|
|
|
@ -28,10 +28,10 @@
|
|||
* @since Twenty Twenty 1.0
|
||||
*
|
||||
* @param array $args Arguments for displaying the site logo either as an image or text.
|
||||
* @param bool $echo Echo or return the HTML.
|
||||
* @param bool $display Display or return the HTML.
|
||||
* @return string Compiled HTML based on our arguments.
|
||||
*/
|
||||
function twentytwenty_site_logo( $args = array(), $echo = true ) {
|
||||
function twentytwenty_site_logo( $args = array(), $display = true ) {
|
||||
$logo = get_custom_logo();
|
||||
$site_title = get_bloginfo( 'name' );
|
||||
$contents = '';
|
||||
|
@ -83,7 +83,7 @@ function twentytwenty_site_logo( $args = array(), $echo = true ) {
|
|||
*/
|
||||
$html = apply_filters( 'twentytwenty_site_logo', $html, $args, $classname, $contents );
|
||||
|
||||
if ( ! $echo ) {
|
||||
if ( ! $display ) {
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
@ -96,10 +96,10 @@ function twentytwenty_site_logo( $args = array(), $echo = true ) {
|
|||
*
|
||||
* @since Twenty Twenty 1.0
|
||||
*
|
||||
* @param bool $echo Echo or return the html.
|
||||
* @param bool $display Display or return the HTML.
|
||||
* @return string The HTML to display.
|
||||
*/
|
||||
function twentytwenty_site_description( $echo = true ) {
|
||||
function twentytwenty_site_description( $display = true ) {
|
||||
$description = get_bloginfo( 'description' );
|
||||
|
||||
if ( ! $description ) {
|
||||
|
@ -121,7 +121,7 @@ function twentytwenty_site_description( $echo = true ) {
|
|||
*/
|
||||
$html = apply_filters( 'twentytwenty_site_description', $html, $description, $wrapper );
|
||||
|
||||
if ( ! $echo ) {
|
||||
if ( ! $display ) {
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,10 +17,10 @@
|
|||
* @param string $value The CSS value.
|
||||
* @param string $prefix The CSS prefix.
|
||||
* @param string $suffix The CSS suffix.
|
||||
* @param bool $echo Echo the styles.
|
||||
* @param bool $display Output the styles.
|
||||
* @return string
|
||||
*/
|
||||
function twenty_twenty_one_generate_css( $selector, $style, $value, $prefix = '', $suffix = '', $echo = true ) {
|
||||
function twenty_twenty_one_generate_css( $selector, $style, $value, $prefix = '', $suffix = '', $display = true ) {
|
||||
|
||||
// Bail early if there is no $selector elements or properties and $value.
|
||||
if ( ! $value || ! $selector ) {
|
||||
|
@ -29,7 +29,7 @@ function twenty_twenty_one_generate_css( $selector, $style, $value, $prefix = ''
|
|||
|
||||
$css = sprintf( '%s { %s: %s; }', $selector, $style, $prefix . $value . $suffix );
|
||||
|
||||
if ( $echo ) {
|
||||
if ( $display ) {
|
||||
/*
|
||||
* Note to reviewers: $css contains auto-generated CSS.
|
||||
* It is included inside <style> tags and can only be interpreted as CSS on the browser.
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.0-beta2-53235';
|
||||
$wp_version = '6.0-beta2-53236';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue