Code Modernization: Rename parameters that use reserved keywords in wp-admin/includes/taxonomy.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 `$parent` parameter to `$category_parent` in `category_exists()` and `wp_create_category()`. This matches the category object property of the same name. * Amends similar parameters in `dropdown_categories()` and `wp_dropdown_cats()` for consistency. Follow-up to [52946], [52996], [52997], [52998], [53003], [53014], [53029], [53039], [53116], [53117], [53137], [53174], [53184], [53185], [53192], [53193], [53198], [53203], [53207], [53215]. Props jrf, aristath, poena, justinahinon, SergeyBiryukov. See #55327. Built from https://develop.svn.wordpress.org/trunk@53216 git-svn-id: http://core.svn.wordpress.org/trunk@52805 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -17,12 +17,12 @@
|
||||
*
|
||||
* @see term_exists()
|
||||
*
|
||||
* @param int|string $cat_name Category name.
|
||||
* @param int $parent Optional. ID of parent term.
|
||||
* @param int|string $cat_name Category name.
|
||||
* @param int $category_parent Optional. ID of parent category.
|
||||
* @return string|null Returns the category ID as a numeric string if the pairing exists, null if not.
|
||||
*/
|
||||
function category_exists( $cat_name, $parent = null ) {
|
||||
$id = term_exists( $cat_name, 'category', $parent );
|
||||
function category_exists( $cat_name, $category_parent = null ) {
|
||||
$id = term_exists( $cat_name, 'category', $category_parent );
|
||||
if ( is_array( $id ) ) {
|
||||
$id = $id['term_id'];
|
||||
}
|
||||
@@ -48,12 +48,12 @@ function get_category_to_edit( $id ) {
|
||||
*
|
||||
* @since 2.0.0
|
||||
*
|
||||
* @param int|string $cat_name
|
||||
* @param int $parent
|
||||
* @param int|string $cat_name Category name.
|
||||
* @param int $category_parent Optional. ID of parent category.
|
||||
* @return int|WP_Error
|
||||
*/
|
||||
function wp_create_category( $cat_name, $parent = 0 ) {
|
||||
$id = category_exists( $cat_name, $parent );
|
||||
function wp_create_category( $cat_name, $category_parent = 0 ) {
|
||||
$id = category_exists( $cat_name, $category_parent );
|
||||
if ( $id ) {
|
||||
return $id;
|
||||
}
|
||||
@@ -61,7 +61,7 @@ function wp_create_category( $cat_name, $parent = 0 ) {
|
||||
return wp_insert_category(
|
||||
array(
|
||||
'cat_name' => $cat_name,
|
||||
'category_parent' => $parent,
|
||||
'category_parent' => $category_parent,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user