Make WordPress Core

Opened 3 years ago

Closed 2 years ago

#55098 closed enhancement (fixed)

Use meaningful variable name for "$s" and "$tax" in wp_ajax_ajax_tag_search()

Reported by: azouamauriac's profile azouamauriac Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 6.1 Priority: normal
Severity: normal Version:
Component: Taxonomy Keywords: has-patch
Focuses: administration, coding-standards Cc:

Description

Change name of followings variables to give them more meaning: $tax, $s.

update documentation too https://developer.wordpress.org/reference/hooks/term_search_min_chars/

Attachments (1)

55098.diff (2.3 KB) - added by azouamauriac 3 years ago.

Download all attachments as: .zip

Change History (5)

#1 @SergeyBiryukov
3 years ago

  • Component changed from General to Taxonomy
  • Focuses administration added

Hi there, welcome back to WordPress Trac! Thanks for the ticket.

My initial thought here was that these particular variables seem fine as is:

  • $tax is used in many more core files as a shorthand for "taxonomy", so renaming it here does not seem to have a significant benefit in terms of consistency.
  • $s is also used in many core files as a reference to a search keyword. This matches the WP_Query parameter and a public query variable of the same name.

On second thought, we do have some instances in core where similar variables are called $taxonomy and $search, respectively, so I guess we can rename these two as well for clarity. Would you like to work on a patch?

@azouamauriac
3 years ago

#2 @azouamauriac
3 years ago

  • Keywords has-patch added

@SergeyBiryukov i renamed "$tax" to "$taxonomy_object" since there is already another variable named "$taxonomy" in the same function...

#3 @SergeyBiryukov
2 years ago

  • Milestone changed from Awaiting Review to 6.1

#4 @SergeyBiryukov
2 years ago

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

In 53801:

Coding Standards: Use more meaningful variables names in some Ajax functions.

This renames $tax to $taxonomy_object and $s to $search for clarity. The latter is only renamed when used as an internal variable and not referring to the $s global.

The list of affected functions:

  • wp_ajax_ajax_tag_search()
  • wp_ajax_add_link_category
  • wp_ajax_add_tag()
  • wp_ajax_get_tagcloud()
  • wp_ajax_inline_save_tax()
  • wp_ajax_find_posts()

Follow-up to [6542], [8901], [10222], [12833], [16771], [16992], [22723], [38698].

Props azouamauriac.
Fixes #55098.

Note: See TracTickets for help on using tickets.