PHP code example of javanile / granular

1. Go to this page and download the library: Download javanile/granular library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

javanile / granular example snippets


namespace Acme\Plugin;

use Javanile\Granular\Bindable;

class MyFirstPluginFeature extends Bindable
{
  static $bindings = [
    'action:init',
    'filter:the_content' => 'theContent',
  ];

  public function init()
  {
    // Init code
  }
  
  public function theContent($content)
  {
    return $content;
  }
}


use Javanile\Granular\Autoload;

$app = new Autoload();

// add MyPlugin::init() method to WordPress init action  
$app->register(MyPlugin::class, 'init');