PHP code example of realtyna / wp-plugin-framework

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

    

realtyna / wp-plugin-framework example snippets


return [
    'name' => 'Realtyna Base Plugin',
    'slug' => 'realtyna-base-plugin',
    'text-domain' => 'realtyna-base-plugin',
    'log' => [
        'active' => true,
        'level' => 'error',
        'path' => REALTYNA_BASE_PLUGIN_DIR . '/logs'
    ],
];

  protected function components(): void
  {
      $this->addComponent(YourComponent::class);
  }
  

  protected function adminPages(): void
  {
      $this->addAdminPage(YourAdminPage::class);
  }
  

  protected function boot(): void
  {
      // Set the container in the App class for global access.
      App::setContainer($this->container);
      if($this->config->get('log.active')){
          Log::init($this->config->get('log.path'), $this->config->get('log.level'));
      }
  }
  

  protected function migrations(): void
  {
      $this->addMigration(CreateYourTableMigration::class);
  }
  

namespace MyCompany\MyPlugin\Components;

use Realtyna\MvcCore\Abstracts\ComponentAbstract;

class MyComponent extends ComponentAbstract
{
    public function register()
    {
        // Register your component actions and filters here
    }

    public function postTypes()
    {
        $this->addPostType(MyCustomPostType::class);
    }

    public function subComponents()
    {
        $this->addSubComponent(MySubComponent::class);
    }

    public function adminPages()
    {
        $this->addAdminPage(MyAdminPage::class);
    }

    public function ajaxHandlers()
    {
        $this->addAjaxHandler(MyAjaxHandler::class);
    }

    public function shortcodes()
    {
        $this->addShortcode(MyShortcode::class);
    }

    public function restApiEndpoints()
    {
        $this->addRestApiEndpoint(MyRestApiEndpoint::class);
    }

    public function widgets()
    {
        $this->addWidget(MyWidget::class);
    }

    public function customTaxonomies()
    {
        $this->addCustomTaxonomy(MyCustomTaxonomy::class);
    }
}