-
Notifications
You must be signed in to change notification settings - Fork 0
Core creation
Jakub edited this page Oct 12, 2017
·
7 revisions
To start writing plugin the ShellPress way, you need to create new class which extends ShellPress. Remember to use PSR-4 namespacing correctly.
For this example we will use namespace Bakery\Pizza. "Bakery" stands for company name and "Pizza" stands for product name.
This guide is written for current v1_0_6 ( 08.2017 ) version. It should work with new versions aswell.
Remember to change version in your code to the most recent.
<?php
namespace Bakery\Pizza
class App extends ShellPress {
}Cool, but it will not work yet. PHP will look for class Bakery\Pizza\ShellPress but it doesn't exist.
We need to import proper class by use.
We don't have autoloading, so we should also load file with ShellPress class.
<?php
namespace Bakery\Pizza
use shellpress\v1_0_8\ShellPress;
if( ! class_exists( 'shellpress\v1_0_8\ShellPress' ) ){
require_once( __DIR__ . '/lib/ShellPress/ShellPress.php' );
}
class App extends ShellPress {
}Perfect! The last thing here is overriding abstract methods.
<?php
namespace Bakery\Pizza
use shellpress\v1_0_8\ShellPress;
if( ! class_exists( 'shellpress\v1_0_8\ShellPress' ) ){
require_once( dirname( __DIR__ ) . '/lib/ShellPress/ShellPress.php' );
}
class App extends ShellPress {
public abstract function _a_onSetUp();
public abstract function _a_onActivation();
public abstract function _a_onDeactivation();
}Next step: Calling core and using it