berlindb / core

All of the required core code
MIT License
253 stars 27 forks source link

Abstract and encapsulate WordPress specific function calls #39

Open JJJ opened 4 years ago

JJJ commented 4 years ago

As WordPress continues to be the primary focus of this project, many of the classes currently use WordPress specific function calls.

One of the longterm goals of this project, is for it to be platform and environment agnostic. For this to happen, anything specific to WordPress needs to be abstracted into some type of middleware.

Without looking, wp_parse_args and sanitize_key() come to mind. There are probably at least a dozen functions being used.

alexstandiford commented 4 years ago

I have a plugin boilerplate that abstracts most functionality across key forms plugins. I created an abstract class, Form that is extended by each of the major forms plugins. Gravity_Forms Ninja_Forms, etc.

Each of these extensions implement key abstract methods that are used to handle the fundamental functions that any forms plugin can do. Create forms, delete forms, etc.

The Forms class is accessed using a function that automatically detects which forms plugin should be used, and returns the correct instance.

I wonder if this would be a good strategy to implement for these WordPress specific functions within Berlin, as well? This would provide a clear set of methods that would need to be created in-order for Berlin to support other platforms.