Overview

Namespaces

  • None
  • WPGMZA
    • Integration
    • Selector

Classes

  • AutoLoader
  • Crud
  • DOMDocument
  • DOMElement
  • Factory
  • GDPRCompliance
  • GoogleGeocoder
  • GoogleMap
  • GoogleMapsAPILoader
  • GoogleMapsLoader
  • LatLng
  • Map
  • MapsEngineDialog
  • Marker
  • ModalDialog
  • NominatimGeocodeCache
  • OLLoader
  • Plugin
  • RestAPI
  • ScriptLoader
  • Strings

Functions

  • create_marker_instance_delegate
  • create_plugin_instance
  • query_nominatim_cache
  • store_nominatim_cache
  • Overview
  • Namespace
  • Class

Class ScriptLoader

This class takes care of all mechanisms regarding script building and loading.

When in developer mode, or when running a build script, this class will rebuilt the combined script file, in the correct order, or issue a message where dependencies are missing or circular.

When not in developer mode, this class is simply used to enqueue the minified file, or, the combined file if that is more up to date. That can happen when changes have been made and the combined file has been re-built without the minified file being rebuilt.

Namespace: WPGMZA
Located at class.script-loader.php
Methods summary
public
# __construct( boolean $proMode )

Constructor.

Constructor.

Parameters

$proMode
Whether or not to enqueue (and optionally build) the Pro scripts.
protected
# log( string $str )

Internal function used for logging, useful when debugging the build process. This function will erase the log for each PHP execution lifespan.

Internal function used for logging, useful when debugging the build process. This function will erase the log for each PHP execution lifespan.

Parameters

$str
The string to log. Will be prefixed with a timestamp.
protected string[]
# rglob( string $pattern, integer $flags = 0 )

Recursive glob. This function is used to match files given the specified pattern, recursively.

Recursive glob. This function is used to match files given the specified pattern, recursively.

Parameters

$pattern
The pattern to match
$flags
Flags to pass to glob

Returns

string[]
An array of matching files.

See

http://php.net/manual/en/function.glob.php
protected string
# getHandleFromModuleName( string $module )

Converts a JavaScript module name to a script handle, for instance WPGMZA.GoogleMarker will be converted to wpgmza-google-marker.

Converts a JavaScript module name to a script handle, for instance WPGMZA.GoogleMarker will be converted to wpgmza-google-marker.

Parameters

$module
The JavaScript module name.

Returns

string
The associated script handle.
protected array
# getLibraryScripts( )

This function returns an array of library scripts that the plugin depends on, where the array key is the script handle and the value is the script URL.

This function returns an array of library scripts that the plugin depends on, where the array key is the script handle and the value is the script URL.

This function will also enqueue all the required jQuery UI scripts required by our plugin as they are needed, for example on the admin pages.

The result is passed through the filter wpgmza-get-library-dependencies before being returned.

Returns

array
A key value array of scripts, where the key is the handle and the value is the script URL.
protected array
# getScanDirectories( )

Returns the directories to be scanned for JavaScript files.

Returns the directories to be scanned for JavaScript files.

Returns

array
An array of directories, where the keys and values match.
protected
# scanDependencies( )

This function performs the following actions:

This function performs the following actions:

  • Scans the relevant directories for all JavaScript files.
  • Reads the comment header from each JavaScript file.
  • Converts each found module name to a script handle, and records it in $this->scripts with the handle as the key, the source file and dependencies as the value.
public object[]
# getCombineOrder( )

This function performs the following actions:

This function performs the following actions:

  • Takes a snapshot of $this->scripts, we'll call this the pending queue
  • Creates an empty list, we'll call this the combine order queue
  • For each script in the pending queue, if the scripts dependencies are satisfied, the script is moved off the pending queue and onto the back of the combine order queue

This process is repeated until either the pending queue is empty, or a built in iteration limit is hit. When the iteration limit is hit, this usually indicates either missing dependencies or circular dependencies. A notice will be issued when this happens.

You must call scanDependencies before getCombineOrder.

Returns

object[]
An indexed array of script objects, in the order that they must be combined in to respect their dependencies.

Note

As the plugin becomes increasingly complex, the 100,000 iteration limit may give false positives.
public
# buildCombinedFile( )

Builds all the plugin scripts into a combined (concatenated) string. The function will then check if the md5 hash of the existing combined script file matches the hash of the string in memory. If they match, the combined file is up to date and is left untouched. If they do not match, the combined file is updated.

Builds all the plugin scripts into a combined (concatenated) string. The function will then check if the md5 hash of the existing combined script file matches the hash of the string in memory. If they match, the combined file is up to date and is left untouched. If they do not match, the combined file is updated.

public
# build( )

This function performs a full rebuild of the combined script file

This function performs a full rebuild of the combined script file

public
# enqueueStyles( )

Enqueues all required stylesheets

Enqueues all required stylesheets

public object[]
# getPluginScripts( )

Returns an array of objects representing all scripts used by the plugin. In developer mode, this will be one script for each module, when not in developer mode, this will either be the combined or minified file, dependeing on which is more up to date.

Returns an array of objects representing all scripts used by the plugin. In developer mode, this will be one script for each module, when not in developer mode, this will either be the combined or minified file, dependeing on which is more up to date.

Returns

object[]
An array of objects representing the scripts.
public
# enqueueScripts( )

Enqueues all the libraries required by the plugin scripts, then enqueues the plugin scripts and localized data (JavaScript globals).

Enqueues all the libraries required by the plugin scripts, then enqueues the plugin scripts and localized data (JavaScript globals).

public
# enqueueLocalizedData( )

Enqueues the plugins localized data, as fetched from Plugin::getLocalizedData

Enqueues the plugins localized data, as fetched from Plugin::getLocalizedData

Properties summary
public object[] $scripts

Objects describing each script file, where the array key is the script handle.

Objects describing each script file, where the array key is the script handle.

Deprecated

This is not currently for external use and may be removed.
#
API documentation generated by ApiGen