Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefix Your Globals #1726

Merged
merged 8 commits into from
Jun 2, 2022
Merged

Prefix Your Globals #1726

merged 8 commits into from
Jun 2, 2022

Conversation

Ipstenu
Copy link
Contributor

@Ipstenu Ipstenu commented Jun 20, 2019

Globals need to be uniquely and distinctly named in order to prevent conflicts with other plugins and themes.

Prefixes may not use terms designated for WordPress.

Two Letter Prefixes are also bad (80+ THOUSAND PLUGINS, wanna know how many have the same two-letter initials? Ouch)

Related #1722

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.

Hi Mika, I've had a look and left some comments.

Also: should it be mentioned that there is an error for prefixes which use characters outside of the characters which PHP allows for constructs ?

</code_comparison>
<standard>
<![CDATA[
Using any prefixes designated for WordPress are not permitted, even if WordPress has not used the define. This includes all defines such as _() (underscores), __() double underscores, wp_, and wordpress_
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Using any prefixes designated for WordPress are not permitted, even if WordPress has not used the define. This includes all defines such as _() (underscores), __() double underscores, wp_, and wordpress_
Using any prefixes reserved for WordPress are not permitted, even if WordPress has not started using the prefix (yet). This includes all defines such as _() (underscores), () double underscores, wp, and wordpress

Copy link
Member

Choose a reason for hiding this comment

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

This includes all defines such as _() (underscores), () double underscores, wp, and wordpress

What do you mean to say by this ? () are not characters allowed in prefixes as they are not allowed in PHP namespace/class/function/constant names etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It ate __() for some reason...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added in second example.

</code_comparison>
<standard>
<![CDATA[
Using any prefixes reserved for WordPress are not permitted, even if WordPress has not used the define. This includes all defines such as _() (underscores), __() double underscores, wp_, and wordpress_
Copy link
Member

Choose a reason for hiding this comment

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

Possible to add a link here to where the full list of WordPress-reserved prefixes are documented?

Copy link
Member

Choose a reason for hiding this comment

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

Good question. Got a link ?

Ipstenu and others added 8 commits May 17, 2022 14:20
* Use consistent indentation in the file.
* Expand the base explanation.
* Improve the valid/invalid descriptions.
* Use `<em>` tags to mark valid/invalid code.
* Expand the code samples.
* Add a code comparison demonstrating how namespaces affect the prefixes.
* Remove the unclear sentence regarding reserved prefixes.
* Clarify the three character minimum length rule.
@jrfnl
Copy link
Member

jrfnl commented May 31, 2022

I've rebased the PR and added one commit to make the fixes needed and other improvements. Let's get this merged!

For whomever will merge this: probably squash/merge would be a good idea.

@jrfnl jrfnl added this to the 3.0.0 milestone May 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants