PHP code example of allindata / wordpress-micro-core

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

    

allindata / wordpress-micro-core example snippets




declare(strict_types=1);

namespace FoobarWp;

use AllInData\Micro\Core\Controller\PluginControllerInterface;
use AllInData\Micro\Core\Module\PluginModuleInterface;
use AllInData\Micro\Core\ShortCode\PluginShortCodeInterface;
use bitExpert\Disco\Annotations\Configuration;
use bitExpert\Disco\Annotations\Bean;

/**
 * Class PluginConfiguration
 * @package FoobarWp
 * @Configuration
 */
class PluginConfiguration
{
    /**
     * @Bean
     */
    public function PluginApp(): Plugin
    {
        return new Plugin(
            \FoobarWp::load()->getTemplateDirectory(),
            $this->getPluginModules(),
            $this->getPluginControllers(),
            $this->getPluginShortCodes()
        );
    }

    /**
     * @return PluginModuleInterface[]
     */
    private function getPluginModules(): array
    {
        return [];
    }

    /**
     * @return PluginControllerInterface[]
     */
    private function getPluginControllers(): array
    {
        return [];
    }

    /**
     * @return PluginShortCodeInterface[]
     */
    private function getPluginShortCodes(): array
    {
        return [];
    }
}



declare(strict_types=1);

namespace FoobarWp;

use AllInData\Micro\Core\AbstractPlugin;
use AllInData\Micro\Core\PluginInterface;

class Plugin extends AbstractPlugin implements PluginInterface
{
    public function load()
    {
        // some examples
        add_action('wp_enqueue_scripts', [$this, 'addScripts'], 999);
        add_action('admin_enqueue_scripts', [$this, 'addAdminScripts'], 999);
        add_action('admin_enqueue_scripts', [$this, 'addAdminStyles'], 999);
    }

    public function addAdminStyles()
    {
        // ...
    }

    public function addScripts()
    {
        // ...
    }

    public function addAdminScripts()
    {
        // ...
    }
}