From bad03f0c8c0f6af0ddf3aea8805559e094ab21df Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 17 Apr 2022 15:35:34 +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. git-svn-id: https://develop.svn.wordpress.org/trunk@53198 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/meta-boxes.php | 35 +++++++++++++++++++++------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/src/wp-admin/includes/meta-boxes.php b/src/wp-admin/includes/meta-boxes.php index 5ba3a937c5..09a60229bd 100644 --- a/src/wp-admin/includes/meta-boxes.php +++ b/src/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"'; } }