-
Notifications
You must be signed in to change notification settings - Fork 0
Newfold Features Settings API
Evan Mullins edited this page Feb 8, 2024
·
2 revisions
newfold-labs/wp-module-features
- Do NOT use the module loader
- This is a straight-up Composer package
- Expose a
register_feature
method to add features - Will give
- Feature interactions
- Some features might be more high-level (e.g. enable/disable caching)
- Some features are more fine-tuned (e.g. page vs browser caching)
- High-level features are often going to be in a "simplified" view for basic users
- Fine-grained features are going to be displayed in an "advanced" view for professionals
- When checking internally if a feature is enabled, always check the fine-grained option
- This is essentially "bundling" for features
- Fetching a registered feature will return an object with methods for authorization, validation, save, edit, delete, get, etc.
- Callback/filter for
- Authorization
- Sanitization/Validation
- Always return
WP_Error
if something goes wrong (or throw an exception)
- Always return
- Save/Fetch/Delete
-
Move into this features module?
-
We should add a filter to the capabilities for environmental toggling
- A brand plugin may need to override a capability
- Example: Plugin disables a feature based on environment (e.g., WP Cloud)
- A brand plugin may need to override a capability
-
Settings should work similarly to the same function in WP (https://developer.wordpress.org/plugins/settings/settings-api/)
- Settings should be auto-loaded in the data store (for UI purposes only)
- Register UI type
- Input field (email, number, etc)
- Select Field (single vs multi-select)
- Need a way to provide options
- Toggle
- We should always enforce boolean values
- How do we want to render the name, description/helper text, context (e.g., sub-settings), placeholder text
- How are error and success messages handled?
- REST API
- Uses registered callbacks for a feature
- WP-CLI
- Can surface commands based on registered callbacks
- Everything
- WP Core
- Plugins
- Theme
- Close comments after x days
- Caching level
- Disabled
- Assets Only
- Assets & Web pages
- Assets & Web page - extended