grit/plugin

"basic plugin class for wordpress to build upon"

1.3.0 2023-03-03 19:50 UTC

This package is not auto-updated.

Last update: 2024-04-27 01:05:57 UTC


README

This composer installable library adds basic boilerplate for WordPress plugins.

Installation

From within your plugin composer require the library

composer require grit/plugin

Usage

Extend the library with your own class. Use the Grit\Container class as injection container. Your main plugin file could look like this

//File: example-plugin.php
/**
 * Plugin Name:     Example plugin
 * Plugin URI:      PLUGIN SITE HERE
 * Description:     example
 * Author:          AUTHOR HERE
 * Author URI:      YOUR SITE HERE
 * Text Domain:     example
 * Domain Path:     /languages
 * Version:         0.1.0
 *
 * @package         Example
 */

require_once("vendor/autoload.php");

$container = Grit\Container::getInstance();

$container['example'] = new MyNamespace\Example(__FILE__);

The main class would look like this

//File: src/Example.php

namespace MyNamespace;

use Grit\Plugin;

class Example extends Plugin
{
    // your overrides and own functions here
}

Reference

Please refer to the docs folder.