PHP code example of amostajo / wordpress-plugin-core

1. Go to this page and download the library: Download amostajo/wordpress-plugin-core 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/ */

    

amostajo / wordpress-plugin-core example snippets


namespace MyNamespace;

use Amostajo\WPPluginCore\Classes\Addon;

class PostPicker extends Addon
{
    /**
     * Function called when plugin or theme starts.
     * Add wordpress hooks (actions, filters) here.
     */
    public function init()
    {
        // YOUR CUSTOM CODE HERE.
    }

    /**
     * Function called when user is on admin dashboard.
     * Add wordpress hooks (actions, filters) here.
     */
    public function on_admin()
    {
        // YOUR CUSTOM CODE HERE.
    }
}

namespace MyNamespace;

use Amostajo\WPPluginCore\Classes\Addon;

class PostPicker extends Addon
{
    /**
     * Function called when plugin or theme starts.
     * Add wordpress hooks (actions, filters) here.
     */
    public function init()
    {
        add_filter( 'post_content', [ &$this, 'picker_filter' ] )
    }

    /**
     * Called by wordpress.
     */
    public function picker_filter()
    {
        // YOUR CUSTOM CODE HERE.
    }
}

/**
 * Custom method.
 */
public function picker_filter()
{
    // Getting a config settings.
    $this->main->config->get( 'setting' );
}

/**
 * Custom method.
 */
public function picker_filter()
{
    // Calling MVC.
    $this->mvc->call( 'Controller@method' );
}

    'addons' => [
        'MyNamespace\PostPicker',
    ],