2017 © Pedro Peláez
 

library wordpress-sdk

Wordpress SDK for premmerce plugins

image

premmerce/wordpress-sdk

Wordpress SDK for premmerce plugins

  • Friday, June 1, 2018
  • by premmerce
  • Repository
  • 1 Watchers
  • 0 Stars
  • 87 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 78 % Grown

The README.md

Premmerce Wordpress SDK

Premmerce wordpress SDK used in plugins generated by premmerce-dev-tools plugin., (*1)

FileManager

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

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

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

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'));

AdminNotifier

Class is responsible for displaying messages in admin area. AdminNotifier should be instantiated, before admin_notices action, (*15)

push

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)

flash

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)

PluginInterface

The Interface that should be implemented by plugin main file, (*22)

Changelog

V2

  • Added second parameter to FileManager __construct()
  • Added flash method to AdminNotifier

The Versions

01/06 2018

dev-master

9999999-dev

Wordpress SDK for premmerce plugins

  Sources   Download

GPL-2.0+

by Avatar premmerce

01/06 2018

v2.0

2.0.0.0

Wordpress SDK for premmerce plugins

  Sources   Download

GPL-2.0+

by Avatar premmerce

16/03 2018

dev-sdk

dev-sdk

Wordpress SDK for premmerce plugins

  Sources   Download

GPL-2.0+

by Avatar premmerce

16/03 2018

v1.1

1.1.0.0

Wordpress SDK for premmerce plugins

  Sources   Download

GPL-2.0+

by Avatar premmerce

30/10 2017

v1.0

1.0.0.0

Wordpress SDK for premmerce plugins

  Sources   Download

GPL-2.0+

by Avatar premmerce