Git Product home page Git Product logo

oow's Introduction

What is Oow?

Oow is a library that contains components to ease WordPress plugin development.

Design

If you are familiar with how Doctrine2 works, there is just a little to explain. There is a PluginManager to handle your standalone plugin classes by reading annotations. Don't worry if this doesn't make any sense to you. Continue to read. :)

PluginManager

PluginManager is at the heart of the library and all classes is registered to WordPress hooks with it.

Plugins

Plugins are just standalone PHP classes. They don't have to extend any base class and don't have to follow any naming conventions. Annotations in docblocks are used to handle classes.

Requirements

Installation

Add eabay/oow as a dependency in your composer.json file.

Usage

First create a plugin class:

<?php
namespace Plugins;

/** @Plugin */
class HelloWorld
{
    /** @Hook(tag="wp_footer",priority=50) */
    public function sayHello()
    {
        echo 'Hello World';
    }
}

Go to your plugin file and register your plugin with PluginManager;

<?php
/*
Plugin Name: Hello World
*/

use Oow\Plugin\PluginManager;
use Plugins\HelloWorld;

$manager = new PluginManager;

$manager->addPlugin(new HelloWorld);

This will print Hello World in the page footer. Check https://github.com/eabay/oow-sample-plugin for sample plugin.

You are free to create your classes as you want. @Plugin class annotation makes your class a plugin and @Hook method annotation hooks your its methods to actions and filters. If you semantically distinguish you action and filter hooks you can use @Action and @Filter annotations in method docblocks. Those are just synonyms and do exactly the same.

The parameters of @Hook is the same as add_filter function except that function_to_add is the method you assign and accepted_args is the number of arguments that method has. priority is optional and its default is 10.

Please check Doctrine Annotations documentation to learn more about annotations.

Contributing

Fork the project, create a feature branch, and send me a pull request.

oow's People

Contributors

eabay avatar roomshare avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

oow's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.