Home - WebDevStudios/oops-wp GitHub Wiki

Thank you for checking out OOPS-WP! If you're reading this Wiki, you're probably wondering what this library does and how you can use it.

What is OOPS-WP?

OOPS-WP is a lightly-opinionated collection of abstract classes, traits, and interfaces designed to promote object-oriented design thinking in WordPress development. Its primary goal is to give engineers the tools they need to quickly and consistently scaffold common WordPress data structures, such as custom post types, taxonomies, settings pages, REST API routes, Gutenberg blocks, widgets, shortcodes, and more, by using a composition and SOLID-based approach to plugin and theme architecture.

What is SOLID, and how does OOPS-WP follow it?

SOLID comprises the first 5 principles of object-oriented design:

  1. Single responsibility principle
  2. Open-closed principle
  3. Liskov substitution principle
  4. Interface segregation principle
  5. Dependency Inversion principle

You can read a really great article about SOLID at scotch.io. OOPS-WP promotes object-oriented programming and SOLID principles by defining a structure for how common structural elements should be initialized in WordPress plugins and themes. Specifically, OOPS-WP:

  • Promotes single-responsibility by making objects focus on a particular task: registering a post type, setting up the objects needed for a feature, registering an API route, etc.
  • Provides a set of objects which can be easily extended but not modified.
  • Allows changing of objects so long as they abide by the same contracts, meaning we can replace code more easily down the line.
  • Separates interfaces by defining contracts for particular structures (less so in 0.1.0, but moreso in future releases)
  • Leads to dependency inversion by promoting composition over inheritance.

Where can I find examples about how to use OOPS-WP in my own projects?

We're glad you asked! Some pertinent information about the structures and utilities provided by this library, as well as examples on how they are used can be found at the following links:

  • For more details about the particular structures and utilities provided by the library, see Using OOPS-WP.
  • To see an example implementation of the various structures, check out the OOPS WP Demo plugin.