Comments (4)
Solution
We solved the issue by defining the global variables in a mu-plugin, so that the variables are available once the regular plugins load.
closed
from slickstack.
I've added this now, feedback desired:
It should work on all 3 environments (production, staging, dev). If you use this feature and it works well for you, please be sure to tell us because this has been a recurring discussion the past few years... thanks!
from slickstack.
Thanks for the feedback @skilver-io
Since the underlying issue here is about global PHP constants, and not really about Sentry, I changed the title. By the way, Sentry looks really cool, we definitely want to support plugins like this, although it's probably not something we would want to bundle with SlickStack by default.
This issue has been discussed several times in our Discord chat room during the past few years, and it's been difficult for me to get much feedback from developers on how to solve it.
A few years ago, SlickStack included a file at /wp-content/functions.php
that was include_once
by our wp-config.php
boilerplate so that teams could define any PHP constants they wanted in that file, and it would load early on in the WordPress loading sequence as per this chart:
However, recently we removed that file due to:
- lack of community feedback
- confusion among users
- namespace conflict with WordPress themes already having a file called
functions.php
- users can add custom functions to their theme, or with a plugin
- users can add custom functions with MU plugins
Of course, LittleBizzy has always been a fan of hardcoding with PHP constants instead of MySQL queries whenever possible, so I understand if developers don't want to use a theme or plugin for every case.
My concerns are as follows:
- we must keep
wp-config.php
hardcoded and uneditable to achieve true stability with SlickStack - we can add a sort of functions file again, but what namespace/path should it use?
- since most teams don't use it, it probably shouldn't exist by default
What I had proposed in Discord a few times (with zero feedback from users) is maybe conditionally loading a file from within the wp-config.php
using a PHP if statement like this:
is_file($file) AND include $file;
Ref: https://stackoverflow.com/questions/4604965/how-to-include-only-if-file-exists
Ref: https://stackoverflow.com/questions/792899/is-file-or-file-exists-in-php
Ref: https://stackoverflow.com/questions/4099103/is-file-file-exists-performance-and-cache
Ref: https://www.php.net/manual/en/function.is-file.php
from slickstack.
Here's what I'm thinking maybe at the bottom of wp-config.php
to conditionally load something:
$custom_functions = '/var/www/html/wp-content/custom-functions.php';
is_file($custom_functions) AND include $custom_functions;
A few years ago LittleBizzy had a free plugin called Custom Functions that could be edited inside WP Admin (kind of) but the hooks for editing PHP files are not available by default in WordPress Core so it took a lot of jiggery hackery and is not something that would be secure long-term, so we abandoned that approach.
So, this file would be something really only available to SSH or maybe SFTP users to edit, which is maybe okay since this should only be messed with by advanced users anyways.
from slickstack.
Related Issues (20)
- Consider replacing UFW firewall with basic iptables rules HOT 2
- Auto restart MySQL service if it went down HOT 2
- MySQL and/or Redis crashing sometimes on Ubuntu 20.04 HOT 4
- Consider replacing Nginx with Caddy HOT 7
- Exiting ss-update-config: There is a version mismatch between this script and public mirrors.. HOT 1
- Migration slickstack between VPS to VPS HOT 1
- change php version and Install ioncube loader HOT 4
- Install freeze on Running ss-install-redis-packages... HOT 3
- Website very slow loading inside apps ios HOT 3
- CERT_AUTHORITY_INVALID After install HOT 1
- SUDO_USER and SFTP_USER validation check to avoid conflicts? HOT 2
- Perform custom tasks during certain SlickStack scripts HOT 1
- Invalid user mysql:mysql error when using remote database
- Ensure more privacy for openssl cert generation. HOT 11
- SS_ADMINER_PUBLIC="false" does not work as intended. HOT 9
- Allow tuning of PHP8 JIT settings (opcache.jit options in php.ini) HOT 4
- Cloudflare real visitor IP support in Nginx config HOT 18
- Option to allow only Cloudflare IPs to connect to origin server HOT 2
- OpenVZ PHP-FPM "Unable to set priority for the master process: Permission denied" HOT 8
- Support for custom Permissions Policy HTTP header in Nginx HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from slickstack.