Wallogit.com
2017 © Pedro Peláez
Wordpress SDK for premmerce plugins
Premmerce wordpress SDK used in plugins generated by premmerce-dev-tools plugin., (*1)
File manager is responsible for plugin resources(assets, views, paths) management. Class should be initialized with plugin main file full path as parameter., (*2)
params:
* string $mainFile - main plugin file path
* string $templatePath - theme directory to override plugin templates located in frontend directory, (*3)
$fileManager = new FileManager($mainFile);
//V2
$fileManager = new FileManager($mainFile, $templatePath);
includeTemplate(string $template, array $variables = []), (*4)
params:
* string $template - relative path to file
* array $variables - array of variables used in template file, (*5)
Includes template located in plugin views folder with passed variables in scope, (*6)
Each template located in views/forntend directory can be overridden in theme in /plugin_name/ directory, (*7)
$fileManager->includeTemplate('admin/index.php',['title' => 'My title']);
renderTemplate(string $template, array $variables = []), (*8)
params: * string $template - relative path to file * array $variables - array of variables used in template file, (*9)
Returns rendered template located in plugin views folder with passed variables in scope, (*10)
Each template located in views/forntend directory can be overridden in theme in /plugin_name/ directory, (*11)
$rendered = $fileManager->includeTemplate('admin/index.php',['title' => 'My title']);
locateAsset(string $file), (*12)
Returns asset url located in plugin assets folder, (*13)
params: * string $template - relative path to file, (*14)
$url = $fileManager->locateAsset('admin/css/style.css'); wp_enqueue_style('my_style', $fileManager->locateAsset('front/css/style.css'));
Class is responsible for displaying messages in admin area. AdminNotifier should be instantiated, before admin_notices action, (*15)
Show message on admin_notices action, (*16)
push(string $message, string $type = self::SUCCESS, bool $isDismissible = false), (*17)
params: * string $message - message text * string $type - message type, one of predefined constants: AdminNotifier::SUCCESS|AdminNotifier::ERROR|AdminNotifier::WARNING|AdminNotifier::INFO * bool $isDismissible - can user dismiss message, (*18)
$notifier->push('Message text', AdminNotifier::SUCCESS, true)
Save flash message to show during next request, (*19)
flash(string $message, string $type = self::SUCCESS, bool $isDismissible = false), (*20)
params: * string $message - message text * string $type - message type, one of predefined constants: AdminNotifier::SUCCESS|AdminNotifier::ERROR|AdminNotifier::WARNING|AdminNotifier::INFO * bool $isDismissible - can user dismiss message, (*21)
$notifier->flash('Message text', AdminNotifier::SUCCESS, true)
The Interface that should be implemented by plugin main file, (*22)
__construct()
flash method to AdminNotifier