From 447bd92f5d32b1e153a7d800fbba7392128fa9f1 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 17 Apr 2022 15:37:09 +0000 Subject: [PATCH] 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 --- wp-admin/includes/meta-boxes.php | 35 ++++++++++++++++++++++++-------- wp-includes/version.php | 2 +- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/wp-admin/includes/meta-boxes.php b/wp-admin/includes/meta-boxes.php index 5ba3a937c5..09a60229bd 100644 --- a/wp-admin/includes/meta-boxes.php +++ b/wp-admin/includes/meta-boxes.php @@ -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"'; } } diff --git a/wp-includes/version.php b/wp-includes/version.php index f6b591cb04..8d3fdc7cc8 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.