1. Go to this page and download the library: Download cba85/wp-icarus-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/ */
cba85 / wp-icarus-framework example snippets
use Icarus\Plugin;
use Icarus\Assets\Script;
$script = new Script(__DIR__ . '/js');
$script->add('style1-name', 'style.css', [], false, 'all')
->add('style2-name', 'style2.css', [], false, 'all')
->save();
Hook::register('activation', __FILE__, function () {
return new HookController;
});
use Icarus\Config\Config;
$config = new Config;
// Bind a configuration file
$config->bind(['test' =>
use Icarus\View\View;
$view = new View;
$view->setPath(__DIR__ . '/views/');
$view->render('filename');
$view->render('filename', ['key' => 'value']); // With data
use Icarus\Assets\Style;
(new Style)->setPath(Config::get('plugin')['styles'])
->add('style1-name', 'style.css', [], false, 'all')
->add('style2-name', 'style2.css', [], false, 'all')
->save('wp_enqueue_style');
use Icarus\Assets\Script;
(new Script)->setPath(Config::get('plugin')['scripts'])
->add('scripts', 'scripts.js', [], false, true)
->add('admin', 'admin.js', [], false, true)
->save('wp_enqueue_script');
Menu::create(function () {
Menu::addPage('page', 'menu', 'capability', 'slug', function () {
return (new \Icarus\Tests\Mocks\AdminController)->index();
});
Menu::addSubPage('parent', 'page', 'menu', 'capability', 'slug', function () {
return (new \Icarus\Tests\Mocks\AdminController)->index();
});
});
// Create a notice message
Notice::setKey("icarus-framework")->create('success', "Success test");
// Display a notice message
Notice::display();
Hook::register('activation', __FILE__, function () {
new ActivationHook;
})->register('deactivation', __FILE__, function () {
new DeactivationHook;
});
Admin::action('process_test', function () {
return $this->save();
});
namespace Icarus\Plugin\Models;
use Icarus\Models\Tables\Table;
class Post extends Table
{
public function table()
{
global $wpdb;
return $wpdb->prefix . 'posts';
}
public function key()
{
return 'ID';
}
public function fields()
{
return [];
}
}
namespace Icarus\Plugin\Models;
use Icarus\Models\Tables\Option;
class WoocommerceOption extends Option
{
public function prefix()
{
return 'woocommerce_';
}
public function fields()
{
return [
'status',
];
}
}
namespace Icarus\Plugin\Models;
use Icarus\Models\Tables\Meta;
class ShippingMeta extends Meta
{
public function prefix()
{
return '_shipping_';
}
public function fields()
{
return [
'first_name',
'last_name',
'company',
'address_1',
'address_2',
'city',
'postcode',
'country',
];
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.