PHP code example of jascha030 / wp-subscriptions

1. Go to this page and download the library: Download jascha030/wp-subscriptions 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/ */

    

jascha030 / wp-subscriptions example snippets


public static $actions = []; // ActionProvider interface

public static $filters = []; // FilterProvider interface

class ExampleProvider implements ActionProvider
{
    public static $actions = [
        'plugins_loaded' => 'load', // Hook => method
        'pre_get_posts' => ['doQueryStuff', 10, 1], // Example with priority and number of arguments
        'wp_loaded' => [
            ['loaded'],
            ['moreLoaded']
        ], // Example of multiple methods hooked to one action hook
    ];
    
    public function load() // Method to be hooked to the plugins_loaded hook
    {
        echo "This is a method that loads stuff...";
    }

    public function doQueryStuff()
    {
        // hmmm, doing lots of querylicious stuff
    }
    
    public function loaded()
    {
        // Much load, such wow, very plugadocious
    }
    
    public function moreLoaded()
    {
        // Will it ever stop??
    }
}


$subscriptionContainer = WordpressSubscriptionContainer::getInstance(); // Get container instance

$subscriptionContainer->register(ExampleProvider::class); // Register provider

$subscriptionContainer->run(); // Hook all providers and their methods to hooks