mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 09:37:42 +01:00
Code Modernization: Rename parameters that use reserved keywords in wp-includes/general-template.php
.
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 `$echo` parameter to `$display` in: * `wp_loginout()` * `wp_register()` * `get_calendar()` * `the_date()` * `the_modified_date()` * `checked()` * `selected()` * `disabled()` * `wp_readonly()` * `__checked_selected_helper()` * Renames the `$readonly` parameter to `$readonly_value` in `wp_readonly()`. 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], [53236], [53239], [53240], [53242], [53243], [53245], [53246], [53257], [53269], [53270], [53271], [53272], [53273], [53274], [53275], [53276], [53277], [53281], [53283], [53284], [53285], [53287], [53364], [53365], [54927], [54929], [54930], [54931]. Props jrf, aristath, poena, justinahinon, SergeyBiryukov. See #56788. Built from https://develop.svn.wordpress.org/trunk@54932 git-svn-id: http://core.svn.wordpress.org/trunk@54484 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
25c78a1b2a
commit
19382aa5e4
@ -370,17 +370,17 @@ function get_search_form( $args = array() ) {
|
|||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*
|
*
|
||||||
* @param string $redirect Optional path to redirect to on login/logout.
|
* @param string $redirect Optional path to redirect to on login/logout.
|
||||||
* @param bool $echo Default to echo and not return the link.
|
* @param bool $display Default to echo and not return the link.
|
||||||
* @return void|string Void if `$echo` argument is true, log in/out link if `$echo` is false.
|
* @return void|string Void if `$display` argument is true, log in/out link if `$display` is false.
|
||||||
*/
|
*/
|
||||||
function wp_loginout( $redirect = '', $echo = true ) {
|
function wp_loginout( $redirect = '', $display = true ) {
|
||||||
if ( ! is_user_logged_in() ) {
|
if ( ! is_user_logged_in() ) {
|
||||||
$link = '<a href="' . esc_url( wp_login_url( $redirect ) ) . '">' . __( 'Log in' ) . '</a>';
|
$link = '<a href="' . esc_url( wp_login_url( $redirect ) ) . '">' . __( 'Log in' ) . '</a>';
|
||||||
} else {
|
} else {
|
||||||
$link = '<a href="' . esc_url( wp_logout_url( $redirect ) ) . '">' . __( 'Log out' ) . '</a>';
|
$link = '<a href="' . esc_url( wp_logout_url( $redirect ) ) . '">' . __( 'Log out' ) . '</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $echo ) {
|
if ( $display ) {
|
||||||
/**
|
/**
|
||||||
* Filters the HTML output for the Log In/Log Out link.
|
* Filters the HTML output for the Log In/Log Out link.
|
||||||
*
|
*
|
||||||
@ -675,11 +675,11 @@ function wp_lostpassword_url( $redirect = '' ) {
|
|||||||
*
|
*
|
||||||
* @param string $before Text to output before the link. Default `<li>`.
|
* @param string $before Text to output before the link. Default `<li>`.
|
||||||
* @param string $after Text to output after the link. Default `</li>`.
|
* @param string $after Text to output after the link. Default `</li>`.
|
||||||
* @param bool $echo Default to echo and not return the link.
|
* @param bool $display Default to echo and not return the link.
|
||||||
* @return void|string Void if `$echo` argument is true, registration or admin link
|
* @return void|string Void if `$display` argument is true, registration or admin link
|
||||||
* if `$echo` is false.
|
* if `$display` is false.
|
||||||
*/
|
*/
|
||||||
function wp_register( $before = '<li>', $after = '</li>', $echo = true ) {
|
function wp_register( $before = '<li>', $after = '</li>', $display = true ) {
|
||||||
if ( ! is_user_logged_in() ) {
|
if ( ! is_user_logged_in() ) {
|
||||||
if ( get_option( 'users_can_register' ) ) {
|
if ( get_option( 'users_can_register' ) ) {
|
||||||
$link = $before . '<a href="' . esc_url( wp_registration_url() ) . '">' . __( 'Register' ) . '</a>' . $after;
|
$link = $before . '<a href="' . esc_url( wp_registration_url() ) . '">' . __( 'Register' ) . '</a>' . $after;
|
||||||
@ -704,7 +704,7 @@ function wp_register( $before = '<li>', $after = '</li>', $echo = true ) {
|
|||||||
*/
|
*/
|
||||||
$link = apply_filters( 'register', $link );
|
$link = apply_filters( 'register', $link );
|
||||||
|
|
||||||
if ( $echo ) {
|
if ( $display ) {
|
||||||
echo $link;
|
echo $link;
|
||||||
} else {
|
} else {
|
||||||
return $link;
|
return $link;
|
||||||
@ -2220,10 +2220,10 @@ function calendar_week_mod( $num ) {
|
|||||||
* @global array $posts
|
* @global array $posts
|
||||||
*
|
*
|
||||||
* @param bool $initial Optional. Whether to use initial calendar names. Default true.
|
* @param bool $initial Optional. Whether to use initial calendar names. Default true.
|
||||||
* @param bool $echo Optional. Whether to display the calendar output. Default true.
|
* @param bool $display Optional. Whether to display the calendar output. Default true.
|
||||||
* @return void|string Void if `$echo` argument is true, calendar HTML if `$echo` is false.
|
* @return void|string Void if `$display` argument is true, calendar HTML if `$display` is false.
|
||||||
*/
|
*/
|
||||||
function get_calendar( $initial = true, $echo = true ) {
|
function get_calendar( $initial = true, $display = true ) {
|
||||||
global $wpdb, $m, $monthnum, $year, $wp_locale, $posts;
|
global $wpdb, $m, $monthnum, $year, $wp_locale, $posts;
|
||||||
|
|
||||||
$key = md5( $m . $monthnum . $year );
|
$key = md5( $m . $monthnum . $year );
|
||||||
@ -2233,7 +2233,7 @@ function get_calendar( $initial = true, $echo = true ) {
|
|||||||
/** This filter is documented in wp-includes/general-template.php */
|
/** This filter is documented in wp-includes/general-template.php */
|
||||||
$output = apply_filters( 'get_calendar', $cache[ $key ] );
|
$output = apply_filters( 'get_calendar', $cache[ $key ] );
|
||||||
|
|
||||||
if ( $echo ) {
|
if ( $display ) {
|
||||||
echo $output;
|
echo $output;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2430,7 +2430,7 @@ function get_calendar( $initial = true, $echo = true ) {
|
|||||||
$cache[ $key ] = $calendar_output;
|
$cache[ $key ] = $calendar_output;
|
||||||
wp_cache_set( 'get_calendar', $cache, 'calendar' );
|
wp_cache_set( 'get_calendar', $cache, 'calendar' );
|
||||||
|
|
||||||
if ( $echo ) {
|
if ( $display ) {
|
||||||
/**
|
/**
|
||||||
* Filters the HTML calendar output.
|
* Filters the HTML calendar output.
|
||||||
*
|
*
|
||||||
@ -2514,10 +2514,10 @@ function the_date_xml() {
|
|||||||
* @param string $format Optional. PHP date format. Defaults to the 'date_format' option.
|
* @param string $format Optional. PHP date format. Defaults to the 'date_format' option.
|
||||||
* @param string $before Optional. Output before the date. Default empty.
|
* @param string $before Optional. Output before the date. Default empty.
|
||||||
* @param string $after Optional. Output after the date. Default empty.
|
* @param string $after Optional. Output after the date. Default empty.
|
||||||
* @param bool $echo Optional. Whether to echo the date or return it. Default true.
|
* @param bool $display Optional. Whether to echo the date or return it. Default true.
|
||||||
* @return string|void String if retrieving.
|
* @return string|void String if retrieving.
|
||||||
*/
|
*/
|
||||||
function the_date( $format = '', $before = '', $after = '', $echo = true ) {
|
function the_date( $format = '', $before = '', $after = '', $display = true ) {
|
||||||
global $currentday, $previousday;
|
global $currentday, $previousday;
|
||||||
|
|
||||||
$the_date = '';
|
$the_date = '';
|
||||||
@ -2539,7 +2539,7 @@ function the_date( $format = '', $before = '', $after = '', $echo = true ) {
|
|||||||
*/
|
*/
|
||||||
$the_date = apply_filters( 'the_date', $the_date, $format, $before, $after );
|
$the_date = apply_filters( 'the_date', $the_date, $format, $before, $after );
|
||||||
|
|
||||||
if ( $echo ) {
|
if ( $display ) {
|
||||||
echo $the_date;
|
echo $the_date;
|
||||||
} else {
|
} else {
|
||||||
return $the_date;
|
return $the_date;
|
||||||
@ -2589,10 +2589,10 @@ function get_the_date( $format = '', $post = null ) {
|
|||||||
* @param string $format Optional. PHP date format. Defaults to the 'date_format' option.
|
* @param string $format Optional. PHP date format. Defaults to the 'date_format' option.
|
||||||
* @param string $before Optional. Output before the date. Default empty.
|
* @param string $before Optional. Output before the date. Default empty.
|
||||||
* @param string $after Optional. Output after the date. Default empty.
|
* @param string $after Optional. Output after the date. Default empty.
|
||||||
* @param bool $echo Optional. Whether to echo the date or return it. Default true.
|
* @param bool $display Optional. Whether to echo the date or return it. Default true.
|
||||||
* @return string|void String if retrieving.
|
* @return string|void String if retrieving.
|
||||||
*/
|
*/
|
||||||
function the_modified_date( $format = '', $before = '', $after = '', $echo = true ) {
|
function the_modified_date( $format = '', $before = '', $after = '', $display = true ) {
|
||||||
$the_modified_date = $before . get_the_modified_date( $format ) . $after;
|
$the_modified_date = $before . get_the_modified_date( $format ) . $after;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2607,7 +2607,7 @@ function the_modified_date( $format = '', $before = '', $after = '', $echo = tru
|
|||||||
*/
|
*/
|
||||||
$the_modified_date = apply_filters( 'the_modified_date', $the_modified_date, $format, $before, $after );
|
$the_modified_date = apply_filters( 'the_modified_date', $the_modified_date, $format, $before, $after );
|
||||||
|
|
||||||
if ( $echo ) {
|
if ( $display ) {
|
||||||
echo $the_modified_date;
|
echo $the_modified_date;
|
||||||
} else {
|
} else {
|
||||||
return $the_modified_date;
|
return $the_modified_date;
|
||||||
@ -5066,12 +5066,12 @@ function get_the_generator( $type = '' ) {
|
|||||||
* @param mixed $checked One of the values to compare.
|
* @param mixed $checked One of the values to compare.
|
||||||
* @param mixed $current Optional. The other value to compare if not just true.
|
* @param mixed $current Optional. The other value to compare if not just true.
|
||||||
* Default true.
|
* Default true.
|
||||||
* @param bool $echo Optional. Whether to echo or just return the string.
|
* @param bool $display Optional. Whether to echo or just return the string.
|
||||||
* Default true.
|
* Default true.
|
||||||
* @return string HTML attribute or empty string.
|
* @return string HTML attribute or empty string.
|
||||||
*/
|
*/
|
||||||
function checked( $checked, $current = true, $echo = true ) {
|
function checked( $checked, $current = true, $display = true ) {
|
||||||
return __checked_selected_helper( $checked, $current, $echo, 'checked' );
|
return __checked_selected_helper( $checked, $current, $display, 'checked' );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -5084,12 +5084,12 @@ function checked( $checked, $current = true, $echo = true ) {
|
|||||||
* @param mixed $selected One of the values to compare.
|
* @param mixed $selected One of the values to compare.
|
||||||
* @param mixed $current Optional. The other value to compare if not just true.
|
* @param mixed $current Optional. The other value to compare if not just true.
|
||||||
* Default true.
|
* Default true.
|
||||||
* @param bool $echo Optional. Whether to echo or just return the string.
|
* @param bool $display Optional. Whether to echo or just return the string.
|
||||||
* Default true.
|
* Default true.
|
||||||
* @return string HTML attribute or empty string.
|
* @return string HTML attribute or empty string.
|
||||||
*/
|
*/
|
||||||
function selected( $selected, $current = true, $echo = true ) {
|
function selected( $selected, $current = true, $display = true ) {
|
||||||
return __checked_selected_helper( $selected, $current, $echo, 'selected' );
|
return __checked_selected_helper( $selected, $current, $display, 'selected' );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -5102,12 +5102,12 @@ function selected( $selected, $current = true, $echo = true ) {
|
|||||||
* @param mixed $disabled One of the values to compare.
|
* @param mixed $disabled One of the values to compare.
|
||||||
* @param mixed $current Optional. The other value to compare if not just true.
|
* @param mixed $current Optional. The other value to compare if not just true.
|
||||||
* Default true.
|
* Default true.
|
||||||
* @param bool $echo Optional. Whether to echo or just return the string.
|
* @param bool $display Optional. Whether to echo or just return the string.
|
||||||
* Default true.
|
* Default true.
|
||||||
* @return string HTML attribute or empty string.
|
* @return string HTML attribute or empty string.
|
||||||
*/
|
*/
|
||||||
function disabled( $disabled, $current = true, $echo = true ) {
|
function disabled( $disabled, $current = true, $display = true ) {
|
||||||
return __checked_selected_helper( $disabled, $current, $echo, 'disabled' );
|
return __checked_selected_helper( $disabled, $current, $display, 'disabled' );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -5117,15 +5117,15 @@ function disabled( $disabled, $current = true, $echo = true ) {
|
|||||||
*
|
*
|
||||||
* @since 5.9.0
|
* @since 5.9.0
|
||||||
*
|
*
|
||||||
* @param mixed $readonly One of the values to compare.
|
* @param mixed $readonly_value One of the values to compare.
|
||||||
* @param mixed $current Optional. The other value to compare if not just true.
|
* @param mixed $current Optional. The other value to compare if not just true.
|
||||||
* Default true.
|
* Default true.
|
||||||
* @param bool $echo Optional. Whether to echo or just return the string.
|
* @param bool $display Optional. Whether to echo or just return the string.
|
||||||
* Default true.
|
* Default true.
|
||||||
* @return string HTML attribute or empty string.
|
* @return string HTML attribute or empty string.
|
||||||
*/
|
*/
|
||||||
function wp_readonly( $readonly, $current = true, $echo = true ) {
|
function wp_readonly( $readonly_value, $current = true, $display = true ) {
|
||||||
return __checked_selected_helper( $readonly, $current, $echo, 'readonly' );
|
return __checked_selected_helper( $readonly_value, $current, $display, 'readonly' );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -5148,18 +5148,18 @@ if ( PHP_VERSION_ID < 80100 ) {
|
|||||||
*
|
*
|
||||||
* @param mixed $helper One of the values to compare.
|
* @param mixed $helper One of the values to compare.
|
||||||
* @param mixed $current The other value to compare if not just true.
|
* @param mixed $current The other value to compare if not just true.
|
||||||
* @param bool $echo Whether to echo or just return the string.
|
* @param bool $display Whether to echo or just return the string.
|
||||||
* @param string $type The type of checked|selected|disabled|readonly we are doing.
|
* @param string $type The type of checked|selected|disabled|readonly we are doing.
|
||||||
* @return string HTML attribute or empty string.
|
* @return string HTML attribute or empty string.
|
||||||
*/
|
*/
|
||||||
function __checked_selected_helper( $helper, $current, $echo, $type ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore,PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore
|
function __checked_selected_helper( $helper, $current, $display, $type ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore,PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore
|
||||||
if ( (string) $helper === (string) $current ) {
|
if ( (string) $helper === (string) $current ) {
|
||||||
$result = " $type='$type'";
|
$result = " $type='$type'";
|
||||||
} else {
|
} else {
|
||||||
$result = '';
|
$result = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $echo ) {
|
if ( $display ) {
|
||||||
echo $result;
|
echo $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '6.2-alpha-54931';
|
$wp_version = '6.2-alpha-54932';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user