| Server IP : 68.183.124.220 / Your IP : 216.73.217.137 Web Server : Apache/2.4.18 (Ubuntu) System : Linux Sandbox-A 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 User : gavin ( 1000) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/wp-content/plugins/google-site-kit/includes/Core/Assets/ |
Upload File : |
<?php
/**
* Class Google\Site_Kit\Core\Assets\Asset
*
* @package Google\Site_Kit
* @copyright 2021 Google LLC
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @link https://sitekit.withgoogle.com
*/
namespace Google\Site_Kit\Core\Assets;
use Google\Site_Kit\Context;
/**
* Class representing a single asset.
*
* @since 1.0.0
* @access private
* @ignore
*/
abstract class Asset {
/**
* Unique asset handle.
*
* @since 1.0.0
* @var string
*/
protected $handle;
/**
* Asset arguments.
*
* @since 1.0.0
* @var array
*/
protected $args = array();
/**
* Constructor.
*
* @since 1.0.0
*
* @param string $handle Unique asset handle.
* @param array $args {
* Associative array of asset arguments.
*
* @type string $src Required asset source URL.
* @type array $dependencies List of asset dependencies. Default empty array.
* @type string $version Asset version. Default is the version of Site Kit.
* @type bool $fallback Whether to only register as a fallback. Default false.
* @type callable $before_print Optional callback to execute before printing. Default none.
* }
*/
public function __construct( $handle, array $args ) {
$this->handle = $handle;
$this->args = wp_parse_args(
$args,
array(
'src' => '',
'dependencies' => array(),
'version' => GOOGLESITEKIT_VERSION,
'fallback' => false,
'before_print' => null,
)
);
}
/**
* Gets the notice handle.
*
* @since 1.0.0
*
* @return string Unique notice handle.
*/
public function get_handle() {
return $this->handle;
}
/**
* Registers the asset.
*
* @since 1.0.0
* @since 1.15.0 Adds $context parameter.
*
* @param Context $context Plugin context.
*/
abstract public function register( Context $context );
/**
* Enqueues the asset.
*
* @since 1.0.0
*/
abstract public function enqueue();
/**
* Executes the extra callback if defined before printing the asset.
*
* @since 1.2.0
*/
final public function before_print() {
if ( ! is_callable( $this->args['before_print'] ) ) {
return;
}
call_user_func( $this->args['before_print'], $this->handle );
}
}