Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

sabernhardt
Copy link

If one global variable's name is longer than the other in the group, that can help demonstrate how they are "aligned by type, variable, and description."

  • My suggestions for the names could be better.
  • The param examples might benefit from a similar revision.

If one global variable's name is longer than the other in the group, that can help demonstrate how they are "aligned by type, variable, and description."

- My suggestions for the names could be better.
- The `param` examples might benefit from a similar revision.
Copy link
Member

@jrfnl jrfnl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the same be done for the @param tags directly below ? I.e. yes, please update those too.

As for the used variable names: you could use names of real WP global vars, maybe ?

@sabernhardt
Copy link
Author

$wpdb is one of the most common global variables, and switch_to_blog() has other globals—of various types—to consider for the example:

 * @global wpdb   $wpdb         WordPress database abstraction object.
 * @global int    $blog_id
 * @global bool   $switched
 * @global string $table_prefix The database table prefix.

Then the parameters could use something like $variable_name and $another_variable:

 * @param type $variable_name    Description.
 * @param type $another_variable Optional. Description. Default.
 * @return type Description.

@jrfnl
Copy link
Member

jrfnl commented Jun 5, 2025

@sabernhardt Thank you for coming up with those examples.

Seeing the examples you posted above.... I realize my remark about using existing WP globals was wrong, as it would lead to the example having an actual description, instead of just "Description".
I believe this will distract from what the code sample is trying to demonstrate (alignment), so the @global example should probably stay as you already currently have it in this PR.

As for the variable names, I can live with the current ones. We can also change it to more typical "anonymous" examples like $foo and $barbar. What do you think ?

For the parameter example, the names could possible be changed to $required_param and $optional ? - still not pretty, but the terms "required" and "optional" are unfortunately the same length, so just $required and $optional would still not get us different sized variables.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.