PHP Class WPDKWordPressPlugin

## Overview The WPDKWordPressPlugin class provides the fundamental startup of plugin. You rarely (never) instantiate WPDKWordPressPlugin object directly. Instead, you instantiate subclasses of the WPDKWordPressPlugin class. ### Subclassing This class **must** be used to extend the main class of your plugin. Its function is to initialize the environment will operate on the plugin itself and record the Plugin for updates from WPX Store. ### Benefits In addition to initializing and recording, WPDKWordPressPlugin class performs for us a whole series of standard procedures in the writing of Plugin, in addition to providing a lot of properties and methods really comfortable. * Gets directly from standard WordPress comments prior information as to the description of the Plugin: plugin name, version, the text and the text domain domain path * Prepare a set of standard properties with paths and urls most commonly used * Provides a lot of hook to wrap (filters and actions) of most used WordPress * Prepare an instance of WPDKWatchDog object for own log ### Useful properties The path propertis are the filesystem unix path. The URL properties are the HTTP protocol URI. See below for detail ### Useful methods See below for detail
Author: =undo= ([email protected])
Inheritance: extends WPDKPlugin
Show file Open project: wpxtreme/wpdk Class Usage Examples

Public Properties

Property Type Description
$assetsURL string The Plugin URL more assets/. This property is very useful for read style sheet and Javascript file in the 'assets' folder.
$classesPath string The Filesystem plugin path more classes/
$cssURL string The Plugin URL more assets/css/
$databasePath string The Filesystem plugin path more database/
$folderName string The plugin folder, Eg. wpx-smartshop/
$imagesURL string The Plugin URL more assets/css/images/
$javascriptURL string The Plugin URL more assets/js/
$path string Filesystem plugin path
$pluginBasename string The Plugin folder and main file, Eg. wpx-smartshop/main.php This is used as unique code id.
$protocol string The Protocol http:// or https://
$slug string The plugin slug build with WordPress sanitize_title()
$url string The Plugin URL
$urlAjax string The Default WordPress admin Ajax URL gateway
$url_images string The Plugin URL more assets/css/images/
$url_javascript string The Plugin URL more assets/js/

Public Methods

Method Description
__construct ( string $file = null ) : WPDKWordPressPlugin Create a WPDKWordPressPlugin instance
activation ( ) Called when a plugin is activate; register_activation_hook()
admin ( ) See _init()
admin_init ( ) Called by action hook 'admin_init'
ajax ( ) This method is to override and it is called when an Ajax request is performed.
autoloadEnvironment ( string $sClassName ) This function performs runtime autoloading of a class specifically related to this instance; this autoloading is based on previous class registering that has to be executed before.
currentURL ( ) : string Return the current complete URL with protocol (http or https), server name, port and URI
deactivation ( ) Called when a plugin is deactivate; register_deactivation_hook()
preferences ( ) Called after load_plugin_textdomain() in _init
protocol ( ) : string Return the current web site protocol. The protocol property is set too.
registerAutoloadClass ( string | array $sLoadingPath, string $mClassName = '' ) This function records a WPX plugin class into autoloading register, joined with its loading path.
reloadTextDomain ( ) Reload the text domain for multilingual. This method is useful when the loading procedure for the text domain (which occurs in plugins_loaded()) is not complete for some reason.
theme ( ) See _init()``
urlAjax ( ) : string Returns the standard URL used by WordPress Ajax request.
widgets ( ) Fires after all default WordPress widgets have been registered.

Method Details

__construct() public method

Create a WPDKWordPressPlugin instance
public __construct ( string $file = null ) : WPDKWordPressPlugin
$file string Usually you set it as `__FILE__`, which is the name of main file of plugin
return WPDKWordPressPlugin

activation() public method

Called when a plugin is activate; register_activation_hook()
public activation ( )

admin() public method

See _init()
public admin ( )

admin_init() public method

Called by action hook 'admin_init'
public admin_init ( )

ajax() public method

This method is to override and it is called when an Ajax request is performed.
public ajax ( )

autoloadEnvironment() public method

NOTE: this SPL autoloading logic is encapsulated in every single plugin instance that extends this class, because it is embedded into an instance of WPDKWordPressPlugin. So any plugin has its own SPL autoloading logic.
Since: 1.0.0.b4
public autoloadEnvironment ( string $sClassName )
$sClassName string - The class that has to be loaded right now

currentURL() public static method

Return the current complete URL with protocol (http or https), server name, port and URI
public static currentURL ( ) : string
return string The current complete URL

deactivation() public method

Called when a plugin is deactivate; register_deactivation_hook()
public deactivation ( )

preferences() public method

Called after load_plugin_textdomain() in _init
public preferences ( )

protocol() public static method

Return the current web site protocol. The protocol property is set too.
public static protocol ( ) : string
return string `http` or `https`

registerAutoloadClass() public method

The function has some facility in its first param, in order to allow both string and array loading of class names ( useful in case of a group of classes that are defined in a single file ). 1. $this->registerAutoloadClass( 'file.php', 'ClassName' ); 2. $this->registerAutoloadClass( array( 'file.php' => 'ClassName' ) ); 3. $this->registerAutoloadClass( array( 'file.php' => array( 'ClassName', 'ClassName', ... ) ) );
public registerAutoloadClass ( string | array $sLoadingPath, string $mClassName = '' )
$sLoadingPath string | array Path of class when $mClassName is a string
$mClassName string Optional. The single class name or key value pairs array with path => classes

reloadTextDomain() public method

Reload the text domain for multilingual. This method is useful when the loading procedure for the text domain (which occurs in plugins_loaded()) is not complete for some reason.
public reloadTextDomain ( )

theme() public method

See _init()``
public theme ( )

urlAjax() public static method

Returns the standard URL used by WordPress Ajax request.
public static urlAjax ( ) : string
return string Standard URL for Ajax request

widgets() public method

Fires after all default WordPress widgets have been registered.
Since: 0.7.5
public widgets ( )

Property Details

$assetsURL public property

The Plugin URL more assets/. This property is very useful for read style sheet and Javascript file in the 'assets' folder.
public string $assetsURL
return string

$classesPath public property

The Filesystem plugin path more classes/
public string $classesPath
return string

$cssURL public property

The Plugin URL more assets/css/
public string $cssURL
return string

$databasePath public property

The Filesystem plugin path more database/
public string $databasePath
return string

$folderName public property

The plugin folder, Eg. wpx-smartshop/
public string $folderName
return string

$imagesURL public property

The Plugin URL more assets/css/images/
public string $imagesURL
return string

$javascriptURL public property

The Plugin URL more assets/js/
public string $javascriptURL
return string

$path public property

Filesystem plugin path
public string $path
return string

$pluginBasename public property

The Plugin folder and main file, Eg. wpx-smartshop/main.php This is used as unique code id.
public string $pluginBasename
return string

$protocol public property

The Protocol http:// or https://
public string $protocol
return string

$slug public property

The plugin slug build with WordPress sanitize_title()
public string $slug
return string

$url public property

The Plugin URL
public string $url
return string

$urlAjax public property

The Default WordPress admin Ajax URL gateway
See also: self::urlAjax() static method
public string $urlAjax
return string

$url_images public property

The Plugin URL more assets/css/images/
Deprecation: Since 0.6.3 - Use `imagesURL` instead
public string $url_images
return string

$url_javascript public property

The Plugin URL more assets/js/
Deprecation: Since 0.6.3 - Use `javascriptURL` instead
public string $url_javascript
return string