Code Modernization: Rename parameters that use reserved keywords in wp-admin/includes/meta-boxes.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 `$class` parameter to `$xfn_relationship` in `xfn_check()`.
* Renames the `$value` parameter to `$xfn_value` for clarity.
* Includes minor code layout changes for better readability.

Reference: [http://gmpg.org/xfn/join XFN: Getting Started].

Follow-up to [52946], [52996], [52997], [52998], [53003], [53014], [53029], [53039], [53116], [53117], [53137], [53174], [53184], [53185], [53192], [53193].

Props jrf, aristath, poena, justinahinon, SergeyBiryukov.
See #55327.
Built from https://develop.svn.wordpress.org/trunk@53198


git-svn-id: http://core.svn.wordpress.org/trunk@52787 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2022-04-17 15:37:09 +00:00
parent e0d13f8b59
commit 447bd92f5d
2 changed files with 27 additions and 10 deletions

View File

@ -1186,11 +1186,11 @@ function link_target_meta_box( $link ) {
*
* @global object $link
*
* @param string $class
* @param string $value
* @param string $xfn_relationship
* @param string $xfn_value
* @param mixed $deprecated Never used.
*/
function xfn_check( $class, $value = '', $deprecated = '' ) {
function xfn_check( $xfn_relationship, $xfn_value = '', $deprecated = '' ) {
global $link;
if ( ! empty( $deprecated ) ) {
@ -1200,21 +1200,38 @@ function xfn_check( $class, $value = '', $deprecated = '' ) {
$link_rel = isset( $link->link_rel ) ? $link->link_rel : ''; // In PHP 5.3: $link_rel = $link->link_rel ?: '';
$rels = preg_split( '/\s+/', $link_rel );
if ( '' !== $value && in_array( $value, $rels, true ) ) {
if ( '' !== $xfn_value && in_array( $xfn_value, $rels, true ) ) {
echo ' checked="checked"';
}
if ( '' === $value ) {
if ( 'family' === $class && strpos( $link_rel, 'child' ) === false && strpos( $link_rel, 'parent' ) === false && strpos( $link_rel, 'sibling' ) === false && strpos( $link_rel, 'spouse' ) === false && strpos( $link_rel, 'kin' ) === false ) {
if ( '' === $xfn_value ) {
if ( 'family' === $xfn_relationship
&& strpos( $link_rel, 'child' ) === false
&& strpos( $link_rel, 'parent' ) === false
&& strpos( $link_rel, 'sibling' ) === false
&& strpos( $link_rel, 'spouse' ) === false
&& strpos( $link_rel, 'kin' ) === false
) {
echo ' checked="checked"';
}
if ( 'friendship' === $class && strpos( $link_rel, 'friend' ) === false && strpos( $link_rel, 'acquaintance' ) === false && strpos( $link_rel, 'contact' ) === false ) {
if ( 'friendship' === $xfn_relationship
&& strpos( $link_rel, 'friend' ) === false
&& strpos( $link_rel, 'acquaintance' ) === false
&& strpos( $link_rel, 'contact' ) === false ) {
echo ' checked="checked"';
}
if ( 'geographical' === $class && strpos( $link_rel, 'co-resident' ) === false && strpos( $link_rel, 'neighbor' ) === false ) {
if ( 'geographical' === $xfn_relationship
&& strpos( $link_rel, 'co-resident' ) === false
&& strpos( $link_rel, 'neighbor' ) === false
) {
echo ' checked="checked"';
}
if ( 'identity' === $class && in_array( 'me', $rels, true ) ) {
if ( 'identity' === $xfn_relationship
&& in_array( 'me', $rels, true )
) {
echo ' checked="checked"';
}
}

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.0-beta1-53197';
$wp_version = '6.0-beta1-53198';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.