Make WordPress Core

Opened 4 months ago

Last modified 2 days ago

#64226 new task (blessed)

Coding Standards fixes for WP 7.0

Reported by: desrosj's profile desrosj Owned by:
Milestone: 7.0 Priority: normal
Severity: normal Version:
Component: General Keywords: has-patch
Focuses: coding-standards Cc:

Description

Previously:

Change History (20)

This ticket was mentioned in PR #3198 on WordPress/wordpress-develop by @costdev.


4 months ago
#1

  • Keywords has-patch added

Per naming conventions, don’t abbreviate variable names unnecessarily; let the code be unambiguous and self-documenting.

See PHP Coding Standards - Naming Conventions.

This PR includes renaming of the following variables:

  • $post_ID to $post_id. - "Use lowercase letters in variable, action/filter, and function names"
  • $ext_type to $extension_type.
  • $ext to $extension.
  • $id3data to $id3_data. - "Separate words via underscores."
  • $msg to $message.
  • $sb to $sidebar.
  • $alt to $alternate.
  • $pid to $post_id.
  • $menu_obj to $menu_object.
  • $noparents to $no_parents. - "Separate words via underscores."
  • $sup to $supplemental.
  • $cat_id to $category_id.
  • $cat_name to $category_name.
  • $out to $output.
  • $r to $edit_result.
  • $t to $taxonomy.
  • $u to $update_result.
  • $r to $result.
  • $response to $response_data.
  • $x to $response.

Trac ticket:
https://core.trac.wordpress.org/ticket/64226
https://core.trac.wordpress.org/ticket/63168
https://core.trac.wordpress.org/ticket/55647

#3 @SergeyBiryukov
4 months ago

In 61224:

Coding Standards: Use more meaningful variable names in Admin Ajax actions.

Per the Naming Conventions:

Don’t abbreviate variable names unnecessarily; let the code be unambiguous and self-documenting.

This commit includes renaming of the following variables:

  • $post_ID to $post_id — “Use lowercase letters in variable, action/filter, and function names”.
  • $ext_type to $extension_type.
  • $ext to $extension.
  • $id3data to $id3_data — “Separate words via underscores”.
  • $msg to $message.
  • $sb to $sidebar.
  • $alt to $alternate.
  • $pid to $post_id.
  • $mid to $meta_id.
  • $menu_obj to $menu_object.
  • $noparents to $no_parents — “Separate words via underscores”.
  • $sup to $supplemental.
  • $cat_id to $category_id.
  • $cat_name to $category_name.
  • $out to $output.
  • $r to $edit_result.
  • $t to $taxonomy.
  • $u to $update_result.
  • $r to $result.
  • $response to $response_data.
  • $x to $response.

Follow-up to [53723], [55365].

Props costdev, mukesh27, SergeyBiryukov.
See #64226.

@SergeyBiryukov commented on PR #3198:


4 months ago
#4

Thanks for the PR! Merged in r61224.

#5 @westonruter
4 months ago

In 61272:

Twenty Twenty-Five: Remove redundant comments for conditionally-defined functions.

This also improves consistency with other themes.

Follow-up to [59146].

Fixes #64265.
See #64226.
Props hbhalodia, huzaifaalmesbah.

#6 @westonruter
3 months ago

In 61298:

Docs: Update typing for wp_create_category().

  • Ensure that wp_create_category() returns int as opposed to numeric-string.
  • Rename $cat_name to $category_name to avoid abbreviating variables.
  • Update docblock to remove erroneous int for $category_name param when only string is intended.
  • Add missing tests for wp_create_category().

Developed in https://github.com/WordPress/wordpress-develop/pull/8861

Props justlevine, westonruter.
See #64238, #64226.

#7 @westonruter
3 months ago

In 61389:

Coding Standards: Improve formatting/readability of if statement in WP_Styles constructor.

Follow-up to [46287].

See #64226, #42804.

This ticket was mentioned in PR #10650 on WordPress/wordpress-develop by @peterwilsoncc.


2 months ago
#8

Renames the get_bloginfo(_rss?) $show parameter to $site_info as the functions don't show (ie, echo) the argument but return it.

Trac ticket: https://core.trac.wordpress.org/ticket/64226

#9 follow-up: @peterwilsoncc
2 months ago

I'm in two minds about PR#10650.

It renames the $show parameter in the get_bloginfo(_rss)? functions to $site_info as the functions return the values rather than output them. To me, $show suggests the result is echoed.

@SergeyBiryukov Do you have thoughts on this?

#10 in reply to: ↑ 9 @SergeyBiryukov
2 months ago

Replying to peterwilsoncc:

Do you have thoughts on this?

Looks good to me at a glance, approved 👍

This ticket was mentioned in PR #10780 on WordPress/wordpress-develop by @huzaifaalmesbah.


6 weeks ago
#11

This PR updates variable names in wp-admin includes to strictly adhere to WordPress Coding Standards (lowercase with underscores, no unnecessary abbreviations). These changes focus on local variables to avoid backward compatibility issues.

Trac ticket: https://core.trac.wordpress.org/ticket/64226

### Changes

  • src/wp-admin/includes/post.php: Renamed $id3data to $id3_data in edit_post().
  • src/wp-admin/includes/media.php: Renamed $ext to $extension and $ext_type to $extension_type in media_handle_upload() and media_send_to_editor().
  • src/wp-admin/includes/image-edit.php: Renamed $ext to $extension in wp_image_editor().

### Testing Instructions

  1. Media Upload: Upload image, audio, and video files. Ensure uploads complete successfully and correct icons/metadata are displayed.
  2. Image Editing: Go to Media Library, select an image, click "Edit Image", perform a crop or rotation, and save. Confirm the edit is applied successfully.
  3. General Admin: Edit a post and verify the page loads and saves correctly without any PHP notices or errors.

This ticket was mentioned in PR #10786 on WordPress/wordpress-develop by @huzaifaalmesbah.


6 weeks ago
#12

Removes three instances of comments in src/wp-content/themes/twentytwentyfour/functions.php
that duplicate the function summaries in the DocBlocks immediately following them.

## Rationale
The comments “Register block styles.”, “Enqueue block stylesheets.”, and “Register pattern categories.” are unnecessary because the DocBlocks for the following functions already clearly describe their purposes:

  • twentytwentyfour_block_styles
  • twentytwentyfour_block_stylesheets
  • twentytwentyfour_pattern_categories

Removing these duplicate comments improves code cleanliness and avoids redundant documentation.

#13 @SergeyBiryukov
5 weeks ago

In 61552:

Twenty Twenty-Four: Remove redundant comments for conditionally-defined functions.

This also improves consistency with other themes.

Follow-up to [56716], [61272].

Props huzaifaalmesbah, mukesh27, sabernhardt.
See #64226.

@SergeyBiryukov commented on PR #10786:


5 weeks ago
#14

Thanks for the PR! Merged in r61552.

This ticket was mentioned in PR #10899 on WordPress/wordpress-develop by @sabernhardt.


3 weeks ago
#15

Removes the redundant docblock-style comment before function_exists(), and pluralizes "Patterns" in the function summary for twenty_twenty_one_register_block_pattern().

Props: huzaifaalmesbah

Trac 64226

#16 @SergeyBiryukov
3 weeks ago

In 61608:

Twenty Twenty-One: Remove redundant comment for conditionally-defined function.

This also improves consistency with other themes.

Follow-up to [49216], [53121], [61552], [61272].

Props huzaifaalmesbah, sabernhardt.
See #64226.

@SergeyBiryukov commented on PR #10899:


3 weeks ago
#17

Thanks for the PR! Merged in r61608.

#19 @westonruter
2 days ago

In 61790:

Coding Standards: Apply changes from running composer format.

Developed in https://github.com/WordPress/wordpress-develop/pull/11111

Follow-up to r61745, r61703, r33268.

Props soean.
See #64226.

@westonruter commented on PR #11111:


2 days ago
#20

Committed in r61790 (976ca47)

Note: See TracTickets for help on using tickets.