2017 © Pedro Peláez
 

library pages-for-wp

A bootstrap for developing plugins for wordpress in a structured way

image

rogierkn/pages-for-wp

A bootstrap for developing plugins for wordpress in a structured way

  • Friday, July 29, 2016
  • by Rogierkn
  • Repository
  • 1 Watchers
  • 0 Stars
  • 25 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Pages for Wordpress, (*1)

Easily bootstrap your new Wordpress plugin., (*2)

In your plugin.php, (*3)

use Rogierkn\PagesForWp\App;
use Rogierkn\PagesForWp\DatabaseConnection;

// Or any other PDO object
$databaseConnection = DatabaseConnection::getInstance('localhost', 'wordpress', 'user', 'strongPassword');

$app = new App($databaseConnection);

$app->pages->register([
    ExamplePage::class
]);

$app->setViewsFolder(__DIR__ . '/views/');
$app->run();

ExamplePage.php, (*4)

use Rogierkn\PagesForWp\Pages\Page;

class ExamplePage extends Page
{
    /**
    * The wordpress event to bind to
    */
    public function event()
    {
        return 'admin_menu';
    }

    /**
    * Called when the above event occurs
    * This example binds to the options page
    */
    public function register()
    {
        // Any related wordpress function can be used for this
        return function () {
            add_options_page('Page Title', 'Menu Title', 'capability', "slug", $this->handle());
        };
    }

    /**
    * Handle your Page's actions in here
    * You have access to the $request and $db in here
    */
    public function handle()
    {
        return $this->render('superView.html.twig', ["name" => "John Doe"]);
    }
}

The Versions

29/07 2016

dev-master

9999999-dev

A bootstrap for developing plugins for wordpress in a structured way

  Sources   Download

The Requires

 

wordpress bootstrap