1. Home
  2. Docs
  3. Application Framework
  4. Plugin Guide
  5. Functionality

Functionality

Give your plugin functionality by adding methods to your main plugin class and attaching them as callbacks to WordPress hooks.

plugin-dir/classes/Plugin.php

In addition to the traditional add_action() and add_filter() methods of assigning your functionality to WordPress, you can also just use an annotation in the doc-block of your class method to do the same job.

class Plugin
{
    /**
     * @MWP\WordPress\Action( for="init" )
     */
    public function bootMeUp() {

    }
}

It’s much clearer as to what the method is a callback for, and there is no need for decoupled add_action() or add_filter() declarations in a class constructor.

When you’re ready, there are many more annotations you can use to quickly tie in your functionality to WordPress automatically.

Was this article helpful to you? Yes No

How can we help?