Create an Application

We'll call our App "LawPress":

  1. Create a subfolder in your Must-Use Plugins directory:

    • For example: ~/Sites/LawPress/www/wp-content/mu-plugins/lawpress-app/
  2. Create a Main file for your Application in lawpress-app.php and add the following code:

    class LawPress extends WPLib_App_Base {
        static function on_load() {
            WPLib::register_helper( __CLASS__, 'WPLib' );
  3. Add the following line to the end of your plugin-loader.php:

    require __DIR__ . '/lawpress-app/lawpress-app.php';
  4. You now have a WPLib Application as a starting point for your application.

    • You should test your site to make sure it loads without breaking, though you will not see any changes yet.

What Did We Just Do?

We created an Application class that will be where we will add global methods needed for our LawPress applications such as LawPress::get_practice_areas( $args ) and also where we can store our general purpose hooks for our application.

Comparison to a Plugin?

An Application and a Plugin are similar in many ways, but an plugin can provide functionality of practically any type, and for any given website there is only one (1) Application specifically provides functionality that defines the nature of a website.

Comparison to a Theme?

WordPress themes were intended to provide only the look and feel for a WordPress site but many have grown to be full applications themselves.

For example, AppThemes has the theme HireBee which implements a freelance marketplace. If HireBee were refactored for WPLib then HireBee would become an Application and its look and feel would be implemented as a Theme separated from the Application's functionality.

Thus the benefit of an Application is that complementary themes can be very small and a new look and feel can easily be added.

NEXT: Create a Theme Class

BACK: Install WPLib

UP: QuickStart