Giter Club home page Giter Club logo

Comments (4)

DeZa90 avatar DeZa90 commented on June 7, 2024 1

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.

jessuppi avatar jessuppi commented on June 7, 2024 1

I've added this now, feedback desired:

9f61304
807750d
aa383b4

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.

jessuppi avatar jessuppi commented on June 7, 2024

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:

Ref: https://wordpress.stackexchange.com/questions/71406/is-there-a-flowchart-for-wordpress-loading-sequence

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:

  1. we must keep wp-config.php hardcoded and uneditable to achieve true stability with SlickStack
  2. we can add a sort of functions file again, but what namespace/path should it use?
  3. 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.

jessuppi avatar jessuppi commented on June 7, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.