PHP Class WPDKScripts

Very useful for view controller.
Since: 1.4.13
Author: =undo= ([email protected])
显示文件 Open project: wpxtreme/wpdk

Protected Properties

Property Type Description
$scripts

Public Methods

Method Description
__construct ( ) : WPDKScripts Create an instance of WPDKScripts class
enqueue_script_page_templates ( array $page_templates, string | array $handle, boolean $src = false, array $deps = [], boolean $ver = false, boolean $in_footer = false ) : boolean Enqueue script for list of page template. Return FALSE if $page_templates is empty
enqueue_script_pages ( array $pages, string | array $handle, boolean $src = false, array $deps = [], boolean $ver = false, boolean $in_footer = false ) : boolean Enqueue script for list of page. Return FALSE if $pages is empty
enqueue_style_page_templates ( array $page_templates, string | array $handle, boolean $src = false, array $deps = [], boolean $ver = false ) : boolean Enqueue script for list of page template. Return FALSE if $page_templates is empty
enqueue_style_pages ( array $pages, string | array $handle, boolean $src = false, array $deps = [], boolean $ver = false ) : boolean Enqueue style for list of page. Return FALSE if $pages is empty
hasScripts ( string | array $handle, string $comp = '&' ) : boolean Return TRUE if a handle is registered
registerScripts ( array $scripts, string $path = '', string | array $deps = [], boolean | string $version = false, boolean $in_footer = true ) : boolean Register one or more script following the view controller standard

Method Details

__construct() public method

Create an instance of WPDKScripts class
public __construct ( ) : WPDKScripts
return WPDKScripts

enqueue_script_page_templates() public static method

Enqueue script for list of page template. Return FALSE if $page_templates is empty
public static enqueue_script_page_templates ( array $page_templates, string | array $handle, boolean $src = false, array $deps = [], boolean $ver = false, boolean $in_footer = false ) : boolean
$page_templates array Array of page slug template
$handle string | array The script handle or an array of handles
$src boolean Optional. Source URI
$deps array Optional. Array of other handle
$ver boolean Optional. Version to avoid cache
$in_footer boolean Optional. Load in footer
return boolean

enqueue_script_pages() public static method

Enqueue script for list of page. Return FALSE if $pages is empty
public static enqueue_script_pages ( array $pages, string | array $handle, boolean $src = false, array $deps = [], boolean $ver = false, boolean $in_footer = false ) : boolean
$pages array Array of page slug
$handle string | array The script handle or an array of handles
$src boolean Optional. Source URI
$deps array Optional. Array of other handle
$ver boolean Optional. Version to avoid cache
$in_footer boolean Optional. Load in footer
return boolean

enqueue_style_page_templates() public static method

Enqueue script for list of page template. Return FALSE if $page_templates is empty
public static enqueue_style_page_templates ( array $page_templates, string | array $handle, boolean $src = false, array $deps = [], boolean $ver = false ) : boolean
$page_templates array Array of page slug template
$handle string | array The script handle or andarray of handles
$src boolean Optional. Source URI
$deps array Optional. Array of other handle
$ver boolean Optional. Version to avoid cache
return boolean

enqueue_style_pages() public static method

Enqueue style for list of page. Return FALSE if $pages is empty
public static enqueue_style_pages ( array $pages, string | array $handle, boolean $src = false, array $deps = [], boolean $ver = false ) : boolean
$pages array Array of page slug
$handle string | array The script handle or an array of handles
$src boolean Optional. Source URI
$deps array Optional. Array of other handle
$ver boolean Optional. Version to avoid cache
return boolean

hasScripts() public method

Return TRUE if a handle is registered
public hasScripts ( string | array $handle, string $comp = '&' ) : boolean
$handle string | array Handle or list of handles.
$comp string If $handle is an array or list of handles, use 'AND' or '&' to return TRUE wheter all handle exists use 'OR' or '|' to return TRUE if almost one handle exists
return boolean

registerScripts() public method

Register one or more script following the view controller standard
public registerScripts ( array $scripts, string $path = '', string | array $deps = [], boolean | string $version = false, boolean $in_footer = true ) : boolean
$scripts array List of scripts $scripts = array( 'wpxbz-preferences.js' => array( 'handle' => 'my-handle', // Optional -sanitize_titile( $key ) + remove '.js' 'path' => WPXBANNERIZE_URL_JAVASCRIPT, // Optional if set $path params 'deps' => array( 'jquery' ), // Optional if set $deps params 'version' => '1.2.3', // Optional if set $version 'footer' => false, // Optional override the $in_footer params, ) ); WPDKScripts::registerScripts( $scripts ); OR $scripts = array( 'wpxbz-preferences.js', 'wpxbz-admin.js', ); WPDKScripts::registerScripts( $scripts, $path, $version ); OR $scripts = array( 'wpxbz-preferences.js' => array( 'handle' => 'my-handle', // Optional -sanitize_titile( $key ) + remove '.js' 'path' => WPXBANNERIZE_URL_JAVASCRIPT, // Optional if set $path params 'version' => '1.2.3', // Optional if set $version 'footer' => false, // Optional override the $in_footer params ), 'wpxbz-admin.js', ); // $path and version will be used for 2th iten WPDKScripts::registerScripts( $scripts, $path, $version );
$path string Optional. If set all scripts will be loaded fron this url
$deps string | array Optional. One or more handle dependiences
$version boolean | string Optional. If set will apply to all script
$in_footer boolean Optional. Default all scripts are loaded in footer
return boolean

Property Details

$scripts protected_oe property

protected $scripts