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

Add variables for default configuration #250

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

guilhem
Copy link

@guilhem guilhem commented Jan 11, 2021

Adding ability to set default configuration in wp-config.php.

@vishalkakadiya
Copy link
Contributor

Hi @guilhem 👋

Thank you for taking the time to open this PR. 🙇

Could you share more details about the use case behind defining all the options as constants?

@yashhhYB
Copy link

Hello @guilhem,

Thank you for your contribution to enhancing the configuration flexibility in wp-config.php. I’ve reviewed the proposed changes, and they look like a great addition for customizing default configurations. Here are some suggestions and feedback to refine this further:

Key Suggestions:
Validation for Default Configuration Variables:

To prevent issues with missing or incorrect configurations, you could add validation logic to ensure that only valid values are assigned to these new default configuration variables.
Example:
php
Copy
Edit
if ( ! defined( 'DEFAULT_CONFIG_VAR' ) || empty( DEFAULT_CONFIG_VAR ) ) {
define( 'DEFAULT_CONFIG_VAR', 'default_value' );
}
Backward Compatibility:

Ensure the newly added variables do not override existing settings in wp-config.php. If a variable is already defined, skip redefining it to avoid unexpected behavior.
Documentation for Developers:

Including comments or documentation in the code to explain how these default configurations can be set and overridden by developers would be highly beneficial.
Testing:

Have you tested this change across various environments to ensure compatibility and seamless operation? If not, I can assist with writing test cases to cover edge cases for these default configurations.
Suggested Implementation of Default Configuration Variables:
Here’s an example of how default variables can be conditionally set:

phpCode

// Define default database table prefix if not already set.
if ( ! defined( 'DB_PREFIX' ) ) {
define( 'DB_PREFIX', 'wp_' );
}

// Define default memory limit.
if ( ! defined( 'WP_MEMORY_LIMIT' ) ) {
define( 'WP_MEMORY_LIMIT', '128M' );
}
Follow-Up:
Let me know if you’d like assistance with writing additional tests, improving documentation, or handling edge cases. I’m happy to collaborate on refining this feature further.

Looking forward to your feedback!

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