-
Notifications
You must be signed in to change notification settings - Fork 117
Remove global from litespeed-cache.php #837
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
Conversation
This branch has conflicts that must be resolved |
Resolved 🍏 |
litespeed-cache.php
Outdated
@@ -46,11 +45,10 @@ | |||
* @since 5.2 Auto correct protocol for CONTENT URL | |||
*/ | |||
$WP_CONTENT_URL = WP_CONTENT_URL; | |||
$site_url = site_url('/'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling function twice costs more than a var. Why drop this assignment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All is in the title.
Because this adds a new global variable to WordPress.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't L48 $WP_CONTENT_URL
similar?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yes, it is! $WP_CONTENT_URL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it to unset. How do you think this way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you.
Actually I am paralyzed when meeting PHP 4 technology. PHP 5 introduced namespaces: 1 July 2004
Here is my What to avoid list.
- ❌ Global constants
- ❌ Global functions
- ❌ Classes without namespace
- ❌ Loading PHP files with
require
- ❌ Code with side-effects outside the main file
- ❌ Immediate execution without
add_action
in the main file - ❌ Conditional function or class definitions
Avoiding adding a new global at all cost.