Repository navigation
Core creation
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_6\ShellPress;
if( ! class_exists( 'shellpress\v1_0_6\ShellPress' ) ){
require_once( __DIR__ . '/lib/ShellPress/ShellPress.php' );
}
class App extends ShellPress {
}Perfect! The last thing here is overriding methods and $sp property.
The $sp property is very important. You have to override it.
<?php
namespace Bakery\Pizza
use shellpress\v1_0_6\ShellPress;
if( ! class_exists( 'shellpress\v1_0_6\ShellPress' ) ){
require_once( dirname( __DIR__ ) . '/lib/ShellPress/ShellPress.php' );
}
class App extends ShellPress {
protected static $sp; // <--- REMEMBER !!!
public static function onSetUp() {}
public static function onInit() {}
public static function onActivation() {}
public static function onDeactivation() {}
}Next step: Calling core and using it