Make WordPress Core

Opened 2 years ago

Closed 20 months ago

Last modified 20 months ago

#57371 closed enhancement (fixed)

Twenty Twenty: Remove Unused function parameter and variable.

Reported by: upadalavipul's profile upadalavipul Owned by: audrasjb's profile audrasjb
Milestone: 6.3 Priority: normal
Severity: normal Version:
Component: Bundled Theme Keywords: has-patch dev-feedback
Focuses: coding-standards Cc:

Description

I have reviewed twenty-twenty theme codes and I found some of the function parameters and variables Unused. So I have to remove it from the below files.

Files:

  • twentytwenty/classes/class-twentytwenty-walker-page.php
  • twentytwenty/inc/template-tags.php

Attachments (1)

57371.patch (1.8 KB) - added by upadalavipul 2 years ago.

Download all attachments as: .zip

Change History (10)

@upadalavipul
2 years ago

#1 @sabernhardt
2 years ago

  • Component changed from General to Bundled Theme
  • Keywords has-patch added
  • Summary changed from Remove Unused function parameter and variable. to Twenty Twenty: Remove Unused function parameter and variable.

#2 follow-up: @sabernhardt
22 months ago

  • Focuses coding-standards added
  • Keywords changes-requested added
  • Milestone changed from Awaiting Review to 6.3

Not using the $n line break variable may have been a mistake, though removing the variable probably would be better than adding it to the markup now.

The global $post variable should stay. According to the setup_postdata documentation, "setup_postdata() does not assign the global $post variable so it’s important that you do this yourself."

When removing the last parameter from the twentytwenty_filter_wp_list_pages_item_classes and twentytwenty_add_sub_toggles_to_main_menu functions, also remove the parameter from those functions' documentation and decrease the count argument in the related filters. (See #57397)

Last edited 22 months ago by sabernhardt (previous) (diff)

#3 @sabernhardt
20 months ago

  • Type changed from defect (bug) to enhancement

#4 @sabernhardt
20 months ago

#58601 was marked as a duplicate.

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


20 months ago
#5

  • Removes $n variable from TwentyTwenty_Walker_Page class start_el()
  • Removes last parameter from twentytwenty_filter_wp_list_pages_item_classes() and twentytwenty_add_sub_toggles_to_main_menu()

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

#6 in reply to: ↑ 2 @mukesh27
20 months ago

Replying to sabernhardt:

The global $post variable should stay. According to the setup_postdata documentation, "setup_postdata() does not assign the global $post variable so it’s important that you do this yourself."

I argue that if we already pass the post ID to the setup_postdata function, then why do we need to use the global variable?

#7 @sabernhardt
20 months ago

  • Keywords dev-feedback added; changes-requested removed

I removed the global, and the post's tag still appeared in the meta section as expected. If that variable is necessary or if we are unsure, I can revert that last change.

#8 @audrasjb
20 months ago

  • Owner set to audrasjb
  • Resolution set to fixed
  • Status changed from new to closed

In 56045:

Twenty Twenty: Remove various unused function parameters and variables.

This removes the $n variable from TwentyTwenty_Walker_Page class start_el() function, removes an unused global and the last parameter from
twentytwenty_filter_wp_list_pages_item_classes() and twentytwenty_add_sub_toggles_to_main_menu().

Props upadalavipul, sabernhardt, mukesh27.
Fixes #57371.

Note: See TracTickets for help on using tickets.