first
This commit is contained in:
@ -0,0 +1,163 @@
|
||||
<?php
|
||||
/**
|
||||
* WP Async Request
|
||||
*
|
||||
* @package WP-Background-Processing
|
||||
*/
|
||||
|
||||
if ( ! class_exists( 'WP_Async_Request' ) ) {
|
||||
|
||||
/**
|
||||
* Abstract WP_Async_Request class.
|
||||
*
|
||||
* @abstract
|
||||
*/
|
||||
abstract class WP_Async_Request {
|
||||
|
||||
/**
|
||||
* Prefix
|
||||
*
|
||||
* (default value: 'wp')
|
||||
*
|
||||
* @var string
|
||||
* @access protected
|
||||
*/
|
||||
protected $prefix = 'wp';
|
||||
|
||||
/**
|
||||
* Action
|
||||
*
|
||||
* (default value: 'async_request')
|
||||
*
|
||||
* @var string
|
||||
* @access protected
|
||||
*/
|
||||
protected $action = 'async_request';
|
||||
|
||||
/**
|
||||
* Identifier
|
||||
*
|
||||
* @var mixed
|
||||
* @access protected
|
||||
*/
|
||||
protected $identifier;
|
||||
|
||||
/**
|
||||
* Data
|
||||
*
|
||||
* (default value: array())
|
||||
*
|
||||
* @var array
|
||||
* @access protected
|
||||
*/
|
||||
protected $data = array();
|
||||
|
||||
/**
|
||||
* Initiate new async request
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->identifier = $this->prefix . '_' . $this->action;
|
||||
|
||||
add_action( 'wp_ajax_' . $this->identifier, array( $this, 'maybe_handle' ) );
|
||||
add_action( 'wp_ajax_nopriv_' . $this->identifier, array( $this, 'maybe_handle' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set data used during the request
|
||||
*
|
||||
* @param array $data Data.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function data( $data ) {
|
||||
$this->data = $data;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch the async request
|
||||
*
|
||||
* @return array|WP_Error
|
||||
*/
|
||||
public function dispatch() {
|
||||
$url = add_query_arg( $this->get_query_args(), $this->get_query_url() );
|
||||
$args = $this->get_post_args();
|
||||
|
||||
return wp_remote_post( esc_url_raw( $url ), $args );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get query args
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_query_args() {
|
||||
if ( property_exists( $this, 'query_args' ) ) {
|
||||
return $this->query_args;
|
||||
}
|
||||
|
||||
return array(
|
||||
'action' => $this->identifier,
|
||||
'nonce' => wp_create_nonce( $this->identifier ),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get query URL
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function get_query_url() {
|
||||
if ( property_exists( $this, 'query_url' ) ) {
|
||||
return $this->query_url;
|
||||
}
|
||||
|
||||
return admin_url( 'admin-ajax.php' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get post args
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_post_args() {
|
||||
if ( property_exists( $this, 'post_args' ) ) {
|
||||
return $this->post_args;
|
||||
}
|
||||
|
||||
return array(
|
||||
'timeout' => 0.01,
|
||||
'blocking' => false,
|
||||
'body' => $this->data,
|
||||
'cookies' => $_COOKIE,
|
||||
'sslverify' => apply_filters( 'https_local_ssl_verify', false ),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Maybe handle
|
||||
*
|
||||
* Check for correct nonce and pass to handler.
|
||||
*/
|
||||
public function maybe_handle() {
|
||||
// Don't lock up other requests while processing
|
||||
session_write_close();
|
||||
|
||||
check_ajax_referer( $this->identifier, 'nonce' );
|
||||
|
||||
$this->handle();
|
||||
|
||||
wp_die();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle
|
||||
*
|
||||
* Override this method to perform any actions required
|
||||
* during the async request.
|
||||
*/
|
||||
abstract protected function handle();
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,507 @@
|
||||
<?php
|
||||
/**
|
||||
* WP Background Process
|
||||
*
|
||||
* @package WP-Background-Processing
|
||||
*/
|
||||
|
||||
if ( ! class_exists( 'WP_Background_Process' ) ) {
|
||||
|
||||
/**
|
||||
* Abstract WP_Background_Process class.
|
||||
*
|
||||
* @abstract
|
||||
* @extends WP_Async_Request
|
||||
*/
|
||||
abstract class WP_Background_Process extends WP_Async_Request {
|
||||
|
||||
/**
|
||||
* Action
|
||||
*
|
||||
* (default value: 'background_process')
|
||||
*
|
||||
* @var string
|
||||
* @access protected
|
||||
*/
|
||||
protected $action = 'background_process';
|
||||
|
||||
/**
|
||||
* Start time of current process.
|
||||
*
|
||||
* (default value: 0)
|
||||
*
|
||||
* @var int
|
||||
* @access protected
|
||||
*/
|
||||
protected $start_time = 0;
|
||||
|
||||
/**
|
||||
* Cron_hook_identifier
|
||||
*
|
||||
* @var mixed
|
||||
* @access protected
|
||||
*/
|
||||
protected $cron_hook_identifier;
|
||||
|
||||
/**
|
||||
* Cron_interval_identifier
|
||||
*
|
||||
* @var mixed
|
||||
* @access protected
|
||||
*/
|
||||
protected $cron_interval_identifier;
|
||||
|
||||
/**
|
||||
* Initiate new background process
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
|
||||
$this->cron_hook_identifier = $this->identifier . '_cron';
|
||||
$this->cron_interval_identifier = $this->identifier . '_cron_interval';
|
||||
|
||||
add_action( $this->cron_hook_identifier, array( $this, 'handle_cron_healthcheck' ) );
|
||||
add_filter( 'cron_schedules', array( $this, 'schedule_cron_healthcheck' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function dispatch() {
|
||||
// Schedule the cron healthcheck.
|
||||
$this->schedule_event();
|
||||
|
||||
// Perform remote post.
|
||||
return parent::dispatch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Push to queue
|
||||
*
|
||||
* @param mixed $data Data.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function push_to_queue( $data ) {
|
||||
$this->data[] = $data;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save queue
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function save() {
|
||||
$key = $this->generate_key();
|
||||
|
||||
if ( ! empty( $this->data ) ) {
|
||||
update_site_option( $key, $this->data );
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update queue
|
||||
*
|
||||
* @param string $key Key.
|
||||
* @param array $data Data.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function update( $key, $data ) {
|
||||
if ( ! empty( $data ) ) {
|
||||
update_site_option( $key, $data );
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete queue
|
||||
*
|
||||
* @param string $key Key.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function delete( $key ) {
|
||||
delete_site_option( $key );
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate key
|
||||
*
|
||||
* Generates a unique key based on microtime. Queue items are
|
||||
* given a unique key so that they can be merged upon save.
|
||||
*
|
||||
* @param int $length Length.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function generate_key( $length = 64 ) {
|
||||
$unique = md5( microtime() . rand() );
|
||||
$prepend = $this->identifier . '_batch_';
|
||||
|
||||
return substr( $prepend . $unique, 0, $length );
|
||||
}
|
||||
|
||||
/**
|
||||
* Maybe process queue
|
||||
*
|
||||
* Checks whether data exists within the queue and that
|
||||
* the process is not already running.
|
||||
*/
|
||||
public function maybe_handle() {
|
||||
// Don't lock up other requests while processing
|
||||
session_write_close();
|
||||
|
||||
if ( $this->is_process_running() ) {
|
||||
// Background process already running.
|
||||
wp_die();
|
||||
}
|
||||
|
||||
if ( $this->is_queue_empty() ) {
|
||||
// No data to process.
|
||||
wp_die();
|
||||
}
|
||||
|
||||
check_ajax_referer( $this->identifier, 'nonce' );
|
||||
|
||||
$this->handle();
|
||||
|
||||
wp_die();
|
||||
}
|
||||
|
||||
/**
|
||||
* Is queue empty
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function is_queue_empty() {
|
||||
global $wpdb;
|
||||
|
||||
$table = $wpdb->options;
|
||||
$column = 'option_name';
|
||||
|
||||
if ( is_multisite() ) {
|
||||
$table = $wpdb->sitemeta;
|
||||
$column = 'meta_key';
|
||||
}
|
||||
|
||||
$key = $this->identifier . '_batch_%';
|
||||
|
||||
$count = $wpdb->get_var( $wpdb->prepare( "
|
||||
SELECT COUNT(*)
|
||||
FROM {$table}
|
||||
WHERE {$column} LIKE %s
|
||||
", $key ) );
|
||||
|
||||
return ( $count > 0 ) ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is process running
|
||||
*
|
||||
* Check whether the current process is already running
|
||||
* in a background process.
|
||||
*/
|
||||
protected function is_process_running() {
|
||||
if ( get_site_transient( $this->identifier . '_process_lock' ) ) {
|
||||
// Process already running.
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lock process
|
||||
*
|
||||
* Lock the process so that multiple instances can't run simultaneously.
|
||||
* Override if applicable, but the duration should be greater than that
|
||||
* defined in the time_exceeded() method.
|
||||
*/
|
||||
public function lock_process() {
|
||||
$this->start_time = time(); // Set start time of current process.
|
||||
|
||||
$lock_duration = ( property_exists( $this, 'queue_lock_time' ) ) ? $this->queue_lock_time : 60; // 1 minute
|
||||
$lock_duration = apply_filters( $this->identifier . '_queue_lock_time', $lock_duration );
|
||||
|
||||
set_site_transient( $this->identifier . '_process_lock', microtime(), $lock_duration );
|
||||
}
|
||||
|
||||
/**
|
||||
* Unlock process
|
||||
*
|
||||
* Unlock the process so that other instances can spawn.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
protected function unlock_process() {
|
||||
delete_site_transient( $this->identifier . '_process_lock' );
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get batch
|
||||
*
|
||||
* @return stdClass Return the first batch from the queue
|
||||
*/
|
||||
protected function get_batch() {
|
||||
global $wpdb;
|
||||
|
||||
$table = $wpdb->options;
|
||||
$column = 'option_name';
|
||||
$key_column = 'option_id';
|
||||
$value_column = 'option_value';
|
||||
|
||||
if ( is_multisite() ) {
|
||||
$table = $wpdb->sitemeta;
|
||||
$column = 'meta_key';
|
||||
$key_column = 'meta_id';
|
||||
$value_column = 'meta_value';
|
||||
}
|
||||
|
||||
$key = $this->identifier . '_batch_%';
|
||||
|
||||
$query = $wpdb->get_row( $wpdb->prepare( "
|
||||
SELECT *
|
||||
FROM {$table}
|
||||
WHERE {$column} LIKE %s
|
||||
ORDER BY {$key_column} ASC
|
||||
LIMIT 1
|
||||
", $key ) );
|
||||
|
||||
$batch = new stdClass();
|
||||
$batch->key = $query->$column;
|
||||
$batch->data = maybe_unserialize( $query->$value_column );
|
||||
|
||||
return $batch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle
|
||||
*
|
||||
* Pass each queue item to the task handler, while remaining
|
||||
* within server memory and time limit constraints.
|
||||
*/
|
||||
protected function handle() {
|
||||
$this->lock_process();
|
||||
|
||||
do {
|
||||
$batch = $this->get_batch();
|
||||
|
||||
foreach ( $batch->data as $key => $value ) {
|
||||
$task = $this->task( $value );
|
||||
|
||||
if ( false !== $task ) {
|
||||
$batch->data[ $key ] = $task;
|
||||
} else {
|
||||
unset( $batch->data[ $key ] );
|
||||
}
|
||||
|
||||
if ( $this->time_exceeded() || $this->memory_exceeded() ) {
|
||||
// Batch limits reached.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Update or delete current batch.
|
||||
if ( ! empty( $batch->data ) ) {
|
||||
$this->update( $batch->key, $batch->data );
|
||||
} else {
|
||||
$this->delete( $batch->key );
|
||||
}
|
||||
} while ( ! $this->time_exceeded() && ! $this->memory_exceeded() && ! $this->is_queue_empty() );
|
||||
|
||||
$this->unlock_process();
|
||||
|
||||
// Start next batch or complete process.
|
||||
if ( ! $this->is_queue_empty() ) {
|
||||
$this->dispatch();
|
||||
} else {
|
||||
$this->complete();
|
||||
}
|
||||
|
||||
wp_die();
|
||||
}
|
||||
|
||||
/**
|
||||
* Memory exceeded
|
||||
*
|
||||
* Ensures the batch process never exceeds 90%
|
||||
* of the maximum WordPress memory.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function memory_exceeded() {
|
||||
$memory_limit = $this->get_memory_limit() * 0.9; // 90% of max memory
|
||||
$current_memory = memory_get_usage( true );
|
||||
$return = false;
|
||||
|
||||
if ( $current_memory >= $memory_limit ) {
|
||||
$return = true;
|
||||
}
|
||||
|
||||
return apply_filters( $this->identifier . '_memory_exceeded', $return );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get memory limit
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function get_memory_limit() {
|
||||
if ( function_exists( 'ini_get' ) ) {
|
||||
$memory_limit = ini_get( 'memory_limit' );
|
||||
} else {
|
||||
// Sensible default.
|
||||
$memory_limit = '128M';
|
||||
}
|
||||
|
||||
if ( ! $memory_limit || -1 === $memory_limit ) {
|
||||
// Unlimited, set to 32GB.
|
||||
$memory_limit = '32000M';
|
||||
}
|
||||
|
||||
return intval( $memory_limit ) * 1024 * 1024;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time exceeded.
|
||||
*
|
||||
* Ensures the batch never exceeds a sensible time limit.
|
||||
* A timeout limit of 30s is common on shared hosting.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function time_exceeded() {
|
||||
$finish = $this->start_time + apply_filters( $this->identifier . '_default_time_limit', 20 ); // 20 seconds
|
||||
$return = false;
|
||||
|
||||
if ( time() >= $finish ) {
|
||||
$return = true;
|
||||
}
|
||||
|
||||
return apply_filters( $this->identifier . '_time_exceeded', $return );
|
||||
}
|
||||
|
||||
/**
|
||||
* Complete.
|
||||
*
|
||||
* Override if applicable, but ensure that the below actions are
|
||||
* performed, or, call parent::complete().
|
||||
*/
|
||||
protected function complete() {
|
||||
// Unschedule the cron healthcheck.
|
||||
$this->clear_scheduled_event();
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedule cron healthcheck
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $schedules Schedules.
|
||||
* @return mixed
|
||||
*/
|
||||
public function schedule_cron_healthcheck( $schedules ) {
|
||||
$interval = apply_filters( $this->identifier . '_cron_interval', 5 );
|
||||
|
||||
if ( property_exists( $this, 'cron_interval' ) ) {
|
||||
$interval = apply_filters( $this->identifier . '_cron_interval', $this->cron_interval_identifier );
|
||||
}
|
||||
|
||||
// Adds every 5 minutes to the existing schedules.
|
||||
$schedules[ $this->identifier . '_cron_interval' ] = array(
|
||||
'interval' => MINUTE_IN_SECONDS * $interval,
|
||||
'display' => sprintf( __( 'Every %d Minutes' ), $interval ),
|
||||
);
|
||||
|
||||
return $schedules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle cron healthcheck
|
||||
*
|
||||
* Restart the background process if not already running
|
||||
* and data exists in the queue.
|
||||
*/
|
||||
public function handle_cron_healthcheck() {
|
||||
if ( $this->is_process_running() ) {
|
||||
// Background process already running.
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( $this->is_queue_empty() ) {
|
||||
// No data to process.
|
||||
$this->clear_scheduled_event();
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->handle();
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedule event
|
||||
*/
|
||||
protected function schedule_event() {
|
||||
if ( ! wp_next_scheduled( $this->cron_hook_identifier ) ) {
|
||||
(SPCCSS_DEBUG & \ShortPixel\CriticalCSS\FileLog::DEBUG_AREA_INIT) && \ShortPixel\CriticalCSS\FileLog::instance()->log("SCHEDULING " . $this->cron_hook_identifier . " now!");
|
||||
wp_schedule_event( time(), $this->cron_interval_identifier, $this->cron_hook_identifier );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear scheduled event
|
||||
*/
|
||||
protected function clear_scheduled_event() {
|
||||
$timestamp = wp_next_scheduled( $this->cron_hook_identifier );
|
||||
|
||||
if ( $timestamp ) {
|
||||
wp_unschedule_event( $timestamp, $this->cron_hook_identifier );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel Process
|
||||
*
|
||||
* Stop processing queue items, clear cronjob and delete batch.
|
||||
*
|
||||
*/
|
||||
public function cancel_process() {
|
||||
if ( ! $this->is_queue_empty() ) {
|
||||
$batch = $this->get_batch();
|
||||
|
||||
$this->delete( $batch->key );
|
||||
|
||||
wp_clear_scheduled_hook( $this->cron_hook_identifier );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Task
|
||||
*
|
||||
* Override this method to perform any actions required on each
|
||||
* queue item. Return the modified item for further processing
|
||||
* in the next pass through. Or, return false to remove the
|
||||
* item from the queue.
|
||||
*
|
||||
* @param mixed $item Queue item to iterate over.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
abstract protected function task( $item );
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "a5hleyrich/wp-background-processing",
|
||||
"description": "WP Background Processing can be used to fire off non-blocking asynchronous requests or as a background processing tool, allowing you to queue tasks.",
|
||||
"type": "library",
|
||||
"require": {
|
||||
"php": ">=5.2"
|
||||
},
|
||||
"license": "GPLv2+",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Ashley Rich",
|
||||
"email": "hello@ashleyrich.com"
|
||||
}
|
||||
],
|
||||
"autoload": {
|
||||
"classmap": [ "classes/" ]
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
/**
|
||||
* WP-Background Processing
|
||||
*
|
||||
* @package WP-Background-Processing
|
||||
*/
|
||||
|
||||
/*
|
||||
Plugin Name: WP Background Processing
|
||||
Plugin URI: https://github.com/A5hleyRich/wp-background-processing
|
||||
Description: Asynchronous requests and background processing in WordPress.
|
||||
Author: Delicious Brains Inc.
|
||||
Version: 1.0
|
||||
Author URI: https://deliciousbrains.com/
|
||||
GitHub Plugin URI: https://github.com/A5hleyRich/wp-background-processing
|
||||
GitHub Branch: master
|
||||
*/
|
||||
|
||||
require_once plugin_dir_path( __FILE__ ) . 'classes/wp-async-request.php';
|
||||
require_once plugin_dir_path( __FILE__ ) . 'classes/wp-background-process.php';
|
7
wp-content/plugins/shortpixel-critical-css/vendor/autoload.php
vendored
Normal file
7
wp-content/plugins/shortpixel-critical-css/vendor/autoload.php
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
// autoload.php @generated by Composer
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit226e249f9bf55b3c1eadbfaa33fa611e::getLoader();
|
165
wp-content/plugins/shortpixel-critical-css/vendor/composepress/core/LICENSE
vendored
Normal file
165
wp-content/plugins/shortpixel-critical-css/vendor/composepress/core/LICENSE
vendored
Normal file
@ -0,0 +1,165 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
25
wp-content/plugins/shortpixel-critical-css/vendor/composepress/core/composer.json
vendored
Normal file
25
wp-content/plugins/shortpixel-critical-css/vendor/composepress/core/composer.json
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "composepress/core",
|
||||
"type": "library",
|
||||
"description": "A simple PSR-4 and composer ready plugin framework for the modern wordpress age",
|
||||
"license": "LGPL-3.0-or-later",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Derrick Hammer",
|
||||
"email": "derrick@derrickhammer.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"level-2/dice": "dev-v2.0-PHP5.4-5.5"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"ComposePress\\Core\\": "src/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"ComposePress\\Core\\": "tests/"
|
||||
}
|
||||
}
|
||||
}
|
24
wp-content/plugins/shortpixel-critical-css/vendor/composepress/core/src/Abstracts/BaseObject.php
vendored
Normal file
24
wp-content/plugins/shortpixel-critical-css/vendor/composepress/core/src/Abstracts/BaseObject.php
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace ComposePress\Core\Abstracts;
|
||||
|
||||
use ComposePress\Core\ComponentInterface;
|
||||
use ComposePress\Core\Exception\InexistentProperty;
|
||||
use ComposePress\Core\Exception\ReadOnlyException;
|
||||
|
||||
/**
|
||||
* Class BaseObjectAbstract
|
||||
*
|
||||
* @package ComposePress\Core\Abstracts
|
||||
* @property \wpdb $wpdb
|
||||
* @property \WP_Post $post
|
||||
* @property \WP_Rewrite $wp_rewrite
|
||||
* @property \WP $wp
|
||||
* @property \WP_Query $wp_query
|
||||
* @property \WP_Query $wp_the_query
|
||||
* @property string $pagenow
|
||||
* @property int $page
|
||||
*/
|
||||
abstract class BaseObject {
|
||||
use \ComposePress\Core\Traits\BaseObject;
|
||||
}
|
18
wp-content/plugins/shortpixel-critical-css/vendor/composepress/core/src/Abstracts/Component.php
vendored
Normal file
18
wp-content/plugins/shortpixel-critical-css/vendor/composepress/core/src/Abstracts/Component.php
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace ComposePress\Core\Abstracts;
|
||||
|
||||
use ComposePress\Core\ComponentInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Class Component
|
||||
*
|
||||
* @package ComposePress\Core\Abstracts
|
||||
* @property Plugin $plugin
|
||||
* @property Component $parent
|
||||
*/
|
||||
abstract class Component implements ComponentInterface {
|
||||
use \ComposePress\Core\Traits\Component;
|
||||
}
|
86
wp-content/plugins/shortpixel-critical-css/vendor/composepress/core/src/Abstracts/Manager.php
vendored
Normal file
86
wp-content/plugins/shortpixel-critical-css/vendor/composepress/core/src/Abstracts/Manager.php
vendored
Normal file
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace ComposePress\Core\Abstracts;
|
||||
|
||||
/**
|
||||
* Class Manager
|
||||
*
|
||||
* @package ComposePress\Core\Abstracts
|
||||
*/
|
||||
class Manager extends Component {
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $modules = [];
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
const MODULE_NAMESPACE = '';
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function init() {
|
||||
if ( 0 < count( array_filter( $this->modules, 'is_object' ) ) ) {
|
||||
return;
|
||||
}
|
||||
$modules = [];
|
||||
|
||||
$reflect = new \ReflectionClass( get_called_class() );
|
||||
$class = strtolower( $reflect->getShortName() );
|
||||
$namespace = static::MODULE_NAMESPACE;
|
||||
if ( empty( $namespace ) ) {
|
||||
$namespace = $reflect->getNamespaceName();
|
||||
}
|
||||
|
||||
$component = strtolower( basename( str_replace( '\\', '/', $namespace ) ) );
|
||||
|
||||
$slug = $this->plugin->safe_slug;
|
||||
$filter = "{$slug}_{$component}_{$class}_modules";
|
||||
$modules_list = apply_filters( $filter, $this->modules );
|
||||
|
||||
foreach ( $modules_list as $module ) {
|
||||
$class = trim( $module, '\\' );
|
||||
if ( false === strpos( $module, '\\' ) ) {
|
||||
$class = $namespace . '\\' . $module;
|
||||
}
|
||||
$modules[ $module ] = $this->plugin->container->create( $class );
|
||||
}
|
||||
foreach ( $modules_list as $module ) {
|
||||
$modules[ $module ]->parent = $this;
|
||||
$modules[ $module ]->init();
|
||||
}
|
||||
|
||||
$this->modules = $modules;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function get_modules() {
|
||||
return $this->modules;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
*
|
||||
* @return bool|mixed
|
||||
*/
|
||||
public function get_module( $name ) {
|
||||
if ( null === $name ) {
|
||||
return false;
|
||||
}
|
||||
if ( isset( $this->modules[ $name ] ) ) {
|
||||
return $this->modules[ $name ];
|
||||
}
|
||||
$name = "\\{$name}";
|
||||
if ( isset( $this->modules[ $name ] ) ) {
|
||||
return $this->modules[ $name ];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
210
wp-content/plugins/shortpixel-critical-css/vendor/composepress/core/src/Abstracts/Plugin.php
vendored
Normal file
210
wp-content/plugins/shortpixel-critical-css/vendor/composepress/core/src/Abstracts/Plugin.php
vendored
Normal file
@ -0,0 +1,210 @@
|
||||
<?php
|
||||
|
||||
namespace ComposePress\Core\Abstracts;
|
||||
|
||||
use Dice\Dice;
|
||||
use ComposePress\Core\Exception\ContainerInvalid;
|
||||
use ComposePress\Core\Exception\ContainerNotExists;
|
||||
|
||||
/**
|
||||
* Class Plugin
|
||||
*
|
||||
* @package ComposePress\Core\Abstracts
|
||||
*
|
||||
* @property \Dice\Dice $container
|
||||
* @property string $slug
|
||||
* @property string $safe_slug
|
||||
* @property array $plugin_info
|
||||
* @property string $plugin_file
|
||||
* @property \WP_Filesystem_Direct $wp_filesystem
|
||||
*/
|
||||
abstract class Plugin extends Component {
|
||||
/**
|
||||
* Default version constant
|
||||
*/
|
||||
const VERSION = '';
|
||||
/**
|
||||
* Default slug constant
|
||||
*/
|
||||
const PLUGIN_SLUG = '';
|
||||
|
||||
/**
|
||||
* Path to plugin entry file
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $plugin_file;
|
||||
/**
|
||||
* Dependency Container
|
||||
*
|
||||
* @var Dice
|
||||
*/
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* Dependency Container
|
||||
*
|
||||
* @var \WP_Filesystem_Direct
|
||||
*/
|
||||
protected $wp_filesystem;
|
||||
|
||||
/**
|
||||
* PluginAbstract constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->find_plugin_file();
|
||||
$this->set_container();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function find_plugin_file() {
|
||||
$dir = dirname( ( new \ReflectionClass( $this ) )->getFileName() );
|
||||
$file = null;
|
||||
do {
|
||||
$last_dir = $dir;
|
||||
$dir = dirname( $dir );
|
||||
$file = $dir . DIRECTORY_SEPARATOR . $this->plugin->get_slug() . '.php';
|
||||
} while ( ! $this->get_wp_filesystem()->is_file( $file ) && $dir !== $last_dir );
|
||||
$this->plugin_file = $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \WP_Filesystem_Direct
|
||||
*/
|
||||
public function get_wp_filesystem( $args = [] ) {
|
||||
/** @var \WP_Filesystem_Direct $wp_filesystem */
|
||||
global $wp_filesystem;
|
||||
$original_wp_filesystem = $wp_filesystem;
|
||||
if ( null === $this->wp_filesystem ) {
|
||||
require_once ABSPATH . '/wp-admin/includes/file.php';
|
||||
add_filter( 'filesystem_method', [ $this, 'filesystem_method_override' ] );
|
||||
WP_Filesystem( $args );
|
||||
remove_filter( 'filesystem_method', [ $this, 'filesystem_method_override' ] );
|
||||
$this->wp_filesystem = $wp_filesystem;
|
||||
$wp_filesystem = $original_wp_filesystem;
|
||||
}
|
||||
|
||||
return $this->wp_filesystem;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
abstract public function activate();
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
abstract public function deactivate();
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
abstract public function uninstall();
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function get_plugin_file() {
|
||||
return $this->plugin_file;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Dice
|
||||
*/
|
||||
public function get_container() {
|
||||
return $this->container;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @throws \ComposePress\Core\Exception\ContainerInvalid
|
||||
* @throws \ComposePress\Core\Exception\ContainerNotExists
|
||||
*/
|
||||
protected function set_container() {
|
||||
$slug = str_replace( '-', '_', static::PLUGIN_SLUG );
|
||||
$container = "{$slug}_container";
|
||||
if ( ! function_exists( $container ) ) {
|
||||
throw new ContainerNotExists( sprintf( 'Container function %s does not exist.', $container ) );
|
||||
}
|
||||
$this->container = $container();
|
||||
if ( ! ( $this->container instanceof Dice ) ) {
|
||||
throw new ContainerInvalid( sprintf( 'Container function %s does not return a Dice instance.', $container ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Plugin initialization
|
||||
*/
|
||||
public function init() {
|
||||
if ( ! static::get_dependencies_exist() ) {
|
||||
return;
|
||||
}
|
||||
$this->setup_components();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function get_dependencies_exist() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function get_version() {
|
||||
return static::VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function get_safe_slug() {
|
||||
return strtolower( str_replace( '-', '_', $this->get_slug() ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function get_slug() {
|
||||
return static::PLUGIN_SLUG;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $field
|
||||
*
|
||||
* @return string|array
|
||||
*/
|
||||
public function get_plugin_info( $field = null ) {
|
||||
$info = get_plugin_data( $this->plugin_file );
|
||||
if ( null !== $field && isset( $info[ $field ] ) ) {
|
||||
return $info[ $field ];
|
||||
}
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function filesystem_method_override() {
|
||||
return 'direct';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $file
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_asset_url( $file ) {
|
||||
if ( $this->get_wp_filesystem()->is_file( $file ) ) {
|
||||
$file = str_replace( plugin_dir_path( $this->plugin_file ), '', $file );
|
||||
}
|
||||
|
||||
return plugins_url( $file, __FILE__ );
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace ComposePress\Core;
|
||||
|
||||
|
||||
interface ComponentInterface {
|
||||
public function init();
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace ComposePress\Core\Exception;
|
||||
|
||||
|
||||
class ContainerInvalid extends \Exception {
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace ComposePress\Core\Exception;
|
||||
|
||||
|
||||
class ContainerNotExists extends \Exception {
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace ComposePress\Core\Exception;
|
||||
|
||||
|
||||
class InexistentProperty extends \Exception {
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace ComposePress\Core\Exception;
|
||||
|
||||
|
||||
class ReadOnlyException extends \Exception {
|
||||
|
||||
}
|
80
wp-content/plugins/shortpixel-critical-css/vendor/composepress/core/src/Traits/BaseObject.php
vendored
Normal file
80
wp-content/plugins/shortpixel-critical-css/vendor/composepress/core/src/Traits/BaseObject.php
vendored
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace ComposePress\Core\Traits;
|
||||
|
||||
|
||||
use ComposePress\Core\Exception\InexistentProperty;
|
||||
use ComposePress\Core\Exception\ReadOnlyException;
|
||||
|
||||
trait BaseObject {
|
||||
/**
|
||||
* @param $name
|
||||
*
|
||||
* @return bool|mixed
|
||||
*/
|
||||
public function __get( $name ) {
|
||||
$func = "get_{$name}";
|
||||
if ( method_exists( $this, $func ) ) {
|
||||
return $this->$func();
|
||||
}
|
||||
$func = "is_{$name}";
|
||||
if ( method_exists( $this, $func ) ) {
|
||||
return $this->$func();
|
||||
}
|
||||
|
||||
if ( isset( $GLOBALS[ $name ] ) ) {
|
||||
return $GLOBALS[ $name ];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param $value
|
||||
*
|
||||
* @throws \ComposePress\Core\Exception\InexistentProperty
|
||||
* @throws \ComposePress\Core\Exception\ReadOnlyException
|
||||
*/
|
||||
public function __set( $name, $value ) {
|
||||
$func = "set_{$name}";
|
||||
if ( method_exists( $this, $func ) ) {
|
||||
$this->$func( $value );
|
||||
|
||||
return;
|
||||
}
|
||||
$func = "get_{$name}";
|
||||
if ( method_exists( $this, $func ) ) {
|
||||
throw new ReadOnlyException( sprintf( 'Property %s is read-only', $name ) );
|
||||
}
|
||||
$func = "is_{$name}";
|
||||
if ( method_exists( $this, $func ) ) {
|
||||
throw new ReadOnlyException( sprintf( 'Property %s is read-only', $name ) );
|
||||
}
|
||||
if ( isset( $GLOBALS[ $name ] ) ) {
|
||||
$GLOBALS[ $name ] = $value;
|
||||
|
||||
return;
|
||||
}
|
||||
throw new InexistentProperty( sprintf( 'Inexistent property: %s', $name ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function __isset( $name ) {
|
||||
$func = "get_{$name}";
|
||||
if ( method_exists( $this, $func ) ) {
|
||||
return true;
|
||||
}
|
||||
$func = "is_{$name}";
|
||||
if ( method_exists( $this, $func ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return isset( $GLOBALS[ $name ] );
|
||||
}
|
||||
}
|
149
wp-content/plugins/shortpixel-critical-css/vendor/composepress/core/src/Traits/Component.php
vendored
Normal file
149
wp-content/plugins/shortpixel-critical-css/vendor/composepress/core/src/Traits/Component.php
vendored
Normal file
@ -0,0 +1,149 @@
|
||||
<?php
|
||||
|
||||
namespace ComposePress\Core\Traits;
|
||||
|
||||
use ComposePress\Core\Abstracts\Plugin;
|
||||
use WP\CriticalCSS\FileLog;
|
||||
|
||||
trait Component {
|
||||
use BaseObject;
|
||||
/**
|
||||
* @var Plugin
|
||||
*/
|
||||
private $plugin;
|
||||
|
||||
/**
|
||||
* @var Component
|
||||
*/
|
||||
private $parent;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function __destruct() {
|
||||
$this->plugin = null;
|
||||
$this->parent = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Component
|
||||
*/
|
||||
public function get_parent() {
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Component $parent
|
||||
*/
|
||||
public function set_parent( $parent ) {
|
||||
$this->parent = $parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Plugin
|
||||
*/
|
||||
public function get_plugin() {
|
||||
if ( null === $this->plugin ) {
|
||||
$parent = $this;
|
||||
while ( $parent->has_parent() ) {
|
||||
$parent = $parent->parent;
|
||||
}
|
||||
$this->plugin = $parent;
|
||||
}
|
||||
|
||||
if ( $this->plugin === $this && ! ( $this instanceof Plugin ) ) {
|
||||
throw new \Exception( 'Plugin property is equal to self. Did you forget to set the parent or create a getter?' );
|
||||
}
|
||||
|
||||
return $this->plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function has_parent() {
|
||||
return null !== $this->parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup components and run init
|
||||
*/
|
||||
protected function setup_components() {
|
||||
$components = $this->get_components();
|
||||
$this->set_component_parents( $components );
|
||||
/** @var \ComposePress\Core\Abstracts\Component[] $components */
|
||||
foreach ( $components as $component ) {
|
||||
if ( method_exists( $component, 'init' ) ) {
|
||||
$component->init();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|\ReflectionProperty[]
|
||||
*/
|
||||
protected function get_components() {
|
||||
$components = ( new \ReflectionClass( $this ) )->getProperties();
|
||||
$components = array_filter(
|
||||
$components,
|
||||
/**
|
||||
* @param \ReflectionProperty $component
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function ( $component ) {
|
||||
$getter = 'get_' . $component->name;
|
||||
|
||||
if ( ! ( method_exists( $this, $getter ) && ( new \ReflectionMethod( $this, $getter ) )->isPublic() ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$property = $this->$getter();
|
||||
|
||||
if ( ! is_object( $property ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$trait = __TRAIT__;
|
||||
$used = class_uses( $property );
|
||||
if ( ! isset( $used[ $trait ] ) ) {
|
||||
$parents = class_parents( $property );
|
||||
while ( ! isset( $used[ $trait ] ) && $parents ) {
|
||||
//get trait used by parents
|
||||
$used = class_uses( array_pop( $parents ) );
|
||||
}
|
||||
}
|
||||
|
||||
return isset( array_flip( $used )[ $trait ] );
|
||||
} );
|
||||
$components = array_map(
|
||||
/**
|
||||
* @param \ReflectionProperty $component
|
||||
*
|
||||
* @return Component
|
||||
*/
|
||||
function ( $component ) {
|
||||
$getter = 'get_' . $component->name;
|
||||
|
||||
return $this->$getter();
|
||||
}, $components );
|
||||
|
||||
return $components;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $components
|
||||
*/
|
||||
protected function set_component_parents( $components ) {
|
||||
/** @var Component $component */
|
||||
foreach ( $components as $component ) {
|
||||
$component->parent = $this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
abstract public function init();
|
||||
|
||||
}
|
445
wp-content/plugins/shortpixel-critical-css/vendor/composer/ClassLoader.php
vendored
Normal file
445
wp-content/plugins/shortpixel-critical-css/vendor/composer/ClassLoader.php
vendored
Normal file
@ -0,0 +1,445 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Composer.
|
||||
*
|
||||
* (c) Nils Adermann <naderman@naderman.de>
|
||||
* Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
/**
|
||||
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
|
||||
*
|
||||
* $loader = new \Composer\Autoload\ClassLoader();
|
||||
*
|
||||
* // register classes with namespaces
|
||||
* $loader->add('Symfony\Component', __DIR__.'/component');
|
||||
* $loader->add('Symfony', __DIR__.'/framework');
|
||||
*
|
||||
* // activate the autoloader
|
||||
* $loader->register();
|
||||
*
|
||||
* // to enable searching the include path (eg. for PEAR packages)
|
||||
* $loader->setUseIncludePath(true);
|
||||
*
|
||||
* In this example, if you try to use a class in the Symfony\Component
|
||||
* namespace or one of its children (Symfony\Component\Console for instance),
|
||||
* the autoloader will first look for the class under the component/
|
||||
* directory, and it will then fallback to the framework/ directory if not
|
||||
* found before giving up.
|
||||
*
|
||||
* This class is loosely based on the Symfony UniversalClassLoader.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @see http://www.php-fig.org/psr/psr-0/
|
||||
* @see http://www.php-fig.org/psr/psr-4/
|
||||
*/
|
||||
class ClassLoader
|
||||
{
|
||||
// PSR-4
|
||||
private $prefixLengthsPsr4 = array();
|
||||
private $prefixDirsPsr4 = array();
|
||||
private $fallbackDirsPsr4 = array();
|
||||
|
||||
// PSR-0
|
||||
private $prefixesPsr0 = array();
|
||||
private $fallbackDirsPsr0 = array();
|
||||
|
||||
private $useIncludePath = false;
|
||||
private $classMap = array();
|
||||
private $classMapAuthoritative = false;
|
||||
private $missingClasses = array();
|
||||
private $apcuPrefix;
|
||||
|
||||
public function getPrefixes()
|
||||
{
|
||||
if (!empty($this->prefixesPsr0)) {
|
||||
return call_user_func_array('array_merge', $this->prefixesPsr0);
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
public function getPrefixesPsr4()
|
||||
{
|
||||
return $this->prefixDirsPsr4;
|
||||
}
|
||||
|
||||
public function getFallbackDirs()
|
||||
{
|
||||
return $this->fallbackDirsPsr0;
|
||||
}
|
||||
|
||||
public function getFallbackDirsPsr4()
|
||||
{
|
||||
return $this->fallbackDirsPsr4;
|
||||
}
|
||||
|
||||
public function getClassMap()
|
||||
{
|
||||
return $this->classMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $classMap Class to filename map
|
||||
*/
|
||||
public function addClassMap(array $classMap)
|
||||
{
|
||||
if ($this->classMap) {
|
||||
$this->classMap = array_merge($this->classMap, $classMap);
|
||||
} else {
|
||||
$this->classMap = $classMap;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-0 directories for a given prefix, either
|
||||
* appending or prepending to the ones previously set for this prefix.
|
||||
*
|
||||
* @param string $prefix The prefix
|
||||
* @param array|string $paths The PSR-0 root directories
|
||||
* @param bool $prepend Whether to prepend the directories
|
||||
*/
|
||||
public function add($prefix, $paths, $prepend = false)
|
||||
{
|
||||
if (!$prefix) {
|
||||
if ($prepend) {
|
||||
$this->fallbackDirsPsr0 = array_merge(
|
||||
(array) $paths,
|
||||
$this->fallbackDirsPsr0
|
||||
);
|
||||
} else {
|
||||
$this->fallbackDirsPsr0 = array_merge(
|
||||
$this->fallbackDirsPsr0,
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$first = $prefix[0];
|
||||
if (!isset($this->prefixesPsr0[$first][$prefix])) {
|
||||
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
|
||||
|
||||
return;
|
||||
}
|
||||
if ($prepend) {
|
||||
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
||||
(array) $paths,
|
||||
$this->prefixesPsr0[$first][$prefix]
|
||||
);
|
||||
} else {
|
||||
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
||||
$this->prefixesPsr0[$first][$prefix],
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-4 directories for a given namespace, either
|
||||
* appending or prepending to the ones previously set for this namespace.
|
||||
*
|
||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||
* @param array|string $paths The PSR-4 base directories
|
||||
* @param bool $prepend Whether to prepend the directories
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function addPsr4($prefix, $paths, $prepend = false)
|
||||
{
|
||||
if (!$prefix) {
|
||||
// Register directories for the root namespace.
|
||||
if ($prepend) {
|
||||
$this->fallbackDirsPsr4 = array_merge(
|
||||
(array) $paths,
|
||||
$this->fallbackDirsPsr4
|
||||
);
|
||||
} else {
|
||||
$this->fallbackDirsPsr4 = array_merge(
|
||||
$this->fallbackDirsPsr4,
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
|
||||
// Register directories for a new namespace.
|
||||
$length = strlen($prefix);
|
||||
if ('\\' !== $prefix[$length - 1]) {
|
||||
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
||||
}
|
||||
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
||||
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
||||
} elseif ($prepend) {
|
||||
// Prepend directories for an already registered namespace.
|
||||
$this->prefixDirsPsr4[$prefix] = array_merge(
|
||||
(array) $paths,
|
||||
$this->prefixDirsPsr4[$prefix]
|
||||
);
|
||||
} else {
|
||||
// Append directories for an already registered namespace.
|
||||
$this->prefixDirsPsr4[$prefix] = array_merge(
|
||||
$this->prefixDirsPsr4[$prefix],
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-0 directories for a given prefix,
|
||||
* replacing any others previously set for this prefix.
|
||||
*
|
||||
* @param string $prefix The prefix
|
||||
* @param array|string $paths The PSR-0 base directories
|
||||
*/
|
||||
public function set($prefix, $paths)
|
||||
{
|
||||
if (!$prefix) {
|
||||
$this->fallbackDirsPsr0 = (array) $paths;
|
||||
} else {
|
||||
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-4 directories for a given namespace,
|
||||
* replacing any others previously set for this namespace.
|
||||
*
|
||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||
* @param array|string $paths The PSR-4 base directories
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function setPsr4($prefix, $paths)
|
||||
{
|
||||
if (!$prefix) {
|
||||
$this->fallbackDirsPsr4 = (array) $paths;
|
||||
} else {
|
||||
$length = strlen($prefix);
|
||||
if ('\\' !== $prefix[$length - 1]) {
|
||||
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
||||
}
|
||||
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
||||
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns on searching the include path for class files.
|
||||
*
|
||||
* @param bool $useIncludePath
|
||||
*/
|
||||
public function setUseIncludePath($useIncludePath)
|
||||
{
|
||||
$this->useIncludePath = $useIncludePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can be used to check if the autoloader uses the include path to check
|
||||
* for classes.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getUseIncludePath()
|
||||
{
|
||||
return $this->useIncludePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns off searching the prefix and fallback directories for classes
|
||||
* that have not been registered with the class map.
|
||||
*
|
||||
* @param bool $classMapAuthoritative
|
||||
*/
|
||||
public function setClassMapAuthoritative($classMapAuthoritative)
|
||||
{
|
||||
$this->classMapAuthoritative = $classMapAuthoritative;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should class lookup fail if not found in the current class map?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isClassMapAuthoritative()
|
||||
{
|
||||
return $this->classMapAuthoritative;
|
||||
}
|
||||
|
||||
/**
|
||||
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
|
||||
*
|
||||
* @param string|null $apcuPrefix
|
||||
*/
|
||||
public function setApcuPrefix($apcuPrefix)
|
||||
{
|
||||
$this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The APCu prefix in use, or null if APCu caching is not enabled.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getApcuPrefix()
|
||||
{
|
||||
return $this->apcuPrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers this instance as an autoloader.
|
||||
*
|
||||
* @param bool $prepend Whether to prepend the autoloader or not
|
||||
*/
|
||||
public function register($prepend = false)
|
||||
{
|
||||
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters this instance as an autoloader.
|
||||
*/
|
||||
public function unregister()
|
||||
{
|
||||
spl_autoload_unregister(array($this, 'loadClass'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the given class or interface.
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
* @return bool|null True if loaded, null otherwise
|
||||
*/
|
||||
public function loadClass($class)
|
||||
{
|
||||
if ($file = $this->findFile($class)) {
|
||||
includeFile($file);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the path to the file where the class is defined.
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
*
|
||||
* @return string|false The path if found, false otherwise
|
||||
*/
|
||||
public function findFile($class)
|
||||
{
|
||||
// class map lookup
|
||||
if (isset($this->classMap[$class])) {
|
||||
return $this->classMap[$class];
|
||||
}
|
||||
if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
|
||||
return false;
|
||||
}
|
||||
if (null !== $this->apcuPrefix) {
|
||||
$file = apcu_fetch($this->apcuPrefix.$class, $hit);
|
||||
if ($hit) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
||||
$file = $this->findFileWithExtension($class, '.php');
|
||||
|
||||
// Search for Hack files if we are running on HHVM
|
||||
if (false === $file && defined('HHVM_VERSION')) {
|
||||
$file = $this->findFileWithExtension($class, '.hh');
|
||||
}
|
||||
|
||||
if (null !== $this->apcuPrefix) {
|
||||
apcu_add($this->apcuPrefix.$class, $file);
|
||||
}
|
||||
|
||||
if (false === $file) {
|
||||
// Remember that this class does not exist.
|
||||
$this->missingClasses[$class] = true;
|
||||
}
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
private function findFileWithExtension($class, $ext)
|
||||
{
|
||||
// PSR-4 lookup
|
||||
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
|
||||
|
||||
$first = $class[0];
|
||||
if (isset($this->prefixLengthsPsr4[$first])) {
|
||||
$subPath = $class;
|
||||
while (false !== $lastPos = strrpos($subPath, '\\')) {
|
||||
$subPath = substr($subPath, 0, $lastPos);
|
||||
$search = $subPath.'\\';
|
||||
if (isset($this->prefixDirsPsr4[$search])) {
|
||||
foreach ($this->prefixDirsPsr4[$search] as $dir) {
|
||||
$length = $this->prefixLengthsPsr4[$first][$search];
|
||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-4 fallback dirs
|
||||
foreach ($this->fallbackDirsPsr4 as $dir) {
|
||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-0 lookup
|
||||
if (false !== $pos = strrpos($class, '\\')) {
|
||||
// namespaced class name
|
||||
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
|
||||
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
|
||||
} else {
|
||||
// PEAR-like class name
|
||||
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
|
||||
}
|
||||
|
||||
if (isset($this->prefixesPsr0[$first])) {
|
||||
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
|
||||
if (0 === strpos($class, $prefix)) {
|
||||
foreach ($dirs as $dir) {
|
||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-0 fallback dirs
|
||||
foreach ($this->fallbackDirsPsr0 as $dir) {
|
||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-0 include paths.
|
||||
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
|
||||
return $file;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope isolated include.
|
||||
*
|
||||
* Prevents access to $this/self from included files.
|
||||
*/
|
||||
function includeFile($file)
|
||||
{
|
||||
include $file;
|
||||
}
|
21
wp-content/plugins/shortpixel-critical-css/vendor/composer/LICENSE
vendored
Normal file
21
wp-content/plugins/shortpixel-critical-css/vendor/composer/LICENSE
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
|
||||
Copyright (c) Nils Adermann, Jordi Boggiano
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
11
wp-content/plugins/shortpixel-critical-css/vendor/composer/autoload_classmap.php
vendored
Normal file
11
wp-content/plugins/shortpixel-critical-css/vendor/composer/autoload_classmap.php
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
// autoload_classmap.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'WP_Async_Request' => $vendorDir . '/a5hleyrich/wp-background-processing/classes/wp-async-request.php',
|
||||
'WP_Background_Process' => $vendorDir . '/a5hleyrich/wp-background-processing/classes/wp-background-process.php',
|
||||
);
|
10
wp-content/plugins/shortpixel-critical-css/vendor/composer/autoload_files.php
vendored
Normal file
10
wp-content/plugins/shortpixel-critical-css/vendor/composer/autoload_files.php
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
// autoload_files.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'b45b351e6b6f7487d819961fef2fda77' => $vendorDir . '/jakeasmith/http_build_url/src/http_build_url.php',
|
||||
);
|
9
wp-content/plugins/shortpixel-critical-css/vendor/composer/autoload_namespaces.php
vendored
Normal file
9
wp-content/plugins/shortpixel-critical-css/vendor/composer/autoload_namespaces.php
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
// autoload_namespaces.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
);
|
13
wp-content/plugins/shortpixel-critical-css/vendor/composer/autoload_psr4.php
vendored
Normal file
13
wp-content/plugins/shortpixel-critical-css/vendor/composer/autoload_psr4.php
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
// autoload_psr4.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'pcfreak30\\' => array($vendorDir . '/pcfreak30/wordpress-cache-store/src'),
|
||||
'Dice\\' => array($vendorDir . '/level-2/dice'),
|
||||
'ComposePress\\Core\\' => array($vendorDir . '/composepress/core/src'),
|
||||
'' => array($baseDir . '/lib'),
|
||||
);
|
70
wp-content/plugins/shortpixel-critical-css/vendor/composer/autoload_real.php
vendored
Normal file
70
wp-content/plugins/shortpixel-critical-css/vendor/composer/autoload_real.php
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit226e249f9bf55b3c1eadbfaa33fa611e
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
public static function loadClassLoader($class)
|
||||
{
|
||||
if ('Composer\Autoload\ClassLoader' === $class) {
|
||||
require __DIR__ . '/ClassLoader.php';
|
||||
}
|
||||
}
|
||||
|
||||
public static function getLoader()
|
||||
{
|
||||
if (null !== self::$loader) {
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit226e249f9bf55b3c1eadbfaa33fa611e', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit226e249f9bf55b3c1eadbfaa33fa611e', 'loadClassLoader'));
|
||||
|
||||
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
||||
if ($useStaticLoader) {
|
||||
require_once __DIR__ . '/autoload_static.php';
|
||||
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit226e249f9bf55b3c1eadbfaa33fa611e::getInitializer($loader));
|
||||
} else {
|
||||
$map = require __DIR__ . '/autoload_namespaces.php';
|
||||
foreach ($map as $namespace => $path) {
|
||||
$loader->set($namespace, $path);
|
||||
}
|
||||
|
||||
$map = require __DIR__ . '/autoload_psr4.php';
|
||||
foreach ($map as $namespace => $path) {
|
||||
$loader->setPsr4($namespace, $path);
|
||||
}
|
||||
|
||||
$classMap = require __DIR__ . '/autoload_classmap.php';
|
||||
if ($classMap) {
|
||||
$loader->addClassMap($classMap);
|
||||
}
|
||||
}
|
||||
|
||||
$loader->register(true);
|
||||
|
||||
if ($useStaticLoader) {
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit226e249f9bf55b3c1eadbfaa33fa611e::$files;
|
||||
} else {
|
||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||
}
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequire226e249f9bf55b3c1eadbfaa33fa611e($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
||||
|
||||
function composerRequire226e249f9bf55b3c1eadbfaa33fa611e($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
require $file;
|
||||
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
}
|
||||
}
|
62
wp-content/plugins/shortpixel-critical-css/vendor/composer/autoload_static.php
vendored
Normal file
62
wp-content/plugins/shortpixel-critical-css/vendor/composer/autoload_static.php
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
// autoload_static.php @generated by Composer
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit226e249f9bf55b3c1eadbfaa33fa611e
|
||||
{
|
||||
public static $files = array (
|
||||
'b45b351e6b6f7487d819961fef2fda77' => __DIR__ . '/..' . '/jakeasmith/http_build_url/src/http_build_url.php',
|
||||
);
|
||||
|
||||
public static $prefixLengthsPsr4 = array (
|
||||
'p' =>
|
||||
array (
|
||||
'pcfreak30\\' => 10,
|
||||
),
|
||||
'D' =>
|
||||
array (
|
||||
'Dice\\' => 5,
|
||||
),
|
||||
'C' =>
|
||||
array (
|
||||
'ComposePress\\Core\\' => 18,
|
||||
),
|
||||
);
|
||||
|
||||
public static $prefixDirsPsr4 = array (
|
||||
'pcfreak30\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/pcfreak30/wordpress-cache-store/src',
|
||||
),
|
||||
'Dice\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/level-2/dice',
|
||||
),
|
||||
'ComposePress\\Core\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/composepress/core/src',
|
||||
),
|
||||
);
|
||||
|
||||
public static $fallbackDirsPsr4 = array (
|
||||
0 => __DIR__ . '/../..' . '/lib',
|
||||
);
|
||||
|
||||
public static $classMap = array (
|
||||
'WP_Async_Request' => __DIR__ . '/..' . '/a5hleyrich/wp-background-processing/classes/wp-async-request.php',
|
||||
'WP_Background_Process' => __DIR__ . '/..' . '/a5hleyrich/wp-background-processing/classes/wp-background-process.php',
|
||||
);
|
||||
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit226e249f9bf55b3c1eadbfaa33fa611e::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit226e249f9bf55b3c1eadbfaa33fa611e::$prefixDirsPsr4;
|
||||
$loader->fallbackDirsPsr4 = ComposerStaticInit226e249f9bf55b3c1eadbfaa33fa611e::$fallbackDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit226e249f9bf55b3c1eadbfaa33fa611e::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
}
|
193
wp-content/plugins/shortpixel-critical-css/vendor/composer/installed.json
vendored
Normal file
193
wp-content/plugins/shortpixel-critical-css/vendor/composer/installed.json
vendored
Normal file
@ -0,0 +1,193 @@
|
||||
[
|
||||
{
|
||||
"name": "pcfreak30/wordpress-cache-store",
|
||||
"version": "0.1.1",
|
||||
"version_normalized": "0.1.1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/pcfreak30/wordpress-cache-store.git",
|
||||
"reference": "dd8eede8cf150476551166c3032273d3a417d0fe"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/pcfreak30/wordpress-cache-store/zipball/dd8eede8cf150476551166c3032273d3a417d0fe",
|
||||
"reference": "dd8eede8cf150476551166c3032273d3a417d0fe",
|
||||
"shasum": ""
|
||||
},
|
||||
"time": "2017-07-22T21:43:49+00:00",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"pcfreak30\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"GPL-3.0"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Derrick Hammer",
|
||||
"email": "derrick@derrickhammer.com"
|
||||
}
|
||||
],
|
||||
"description": "WordPress cache library to enable a data tree inspired storage structure to offset the limitation of the WordPress cache API for querying available keys"
|
||||
},
|
||||
{
|
||||
"name": "jakeasmith/http_build_url",
|
||||
"version": "1.0.1",
|
||||
"version_normalized": "1.0.1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/jakeasmith/http_build_url.git",
|
||||
"reference": "93c273e77cb1edead0cf8bcf8cd2003428e74e37"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/jakeasmith/http_build_url/zipball/93c273e77cb1edead0cf8bcf8cd2003428e74e37",
|
||||
"reference": "93c273e77cb1edead0cf8bcf8cd2003428e74e37",
|
||||
"shasum": ""
|
||||
},
|
||||
"time": "2017-05-01T15:36:40+00:00",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"files": [
|
||||
"src/http_build_url.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Jake A. Smith",
|
||||
"email": "theman@jakeasmith.com"
|
||||
}
|
||||
],
|
||||
"description": "Provides functionality for http_build_url() to environments without pecl_http."
|
||||
},
|
||||
{
|
||||
"name": "level-2/dice",
|
||||
"version": "dev-v2.0-PHP5.4-5.5",
|
||||
"version_normalized": "dev-v2.0-PHP5.4-5.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Level-2/Dice.git",
|
||||
"reference": "33e5401c4a577b7d8dc7dc04db295fe5084343c4"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Level-2/Dice/zipball/33e5401c4a577b7d8dc7dc04db295fe5084343c4",
|
||||
"reference": "33e5401c4a577b7d8dc7dc04db295fe5084343c4",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.4.0"
|
||||
},
|
||||
"time": "2015-11-30T17:19:11+00:00",
|
||||
"type": "library",
|
||||
"installation-source": "source",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Dice\\": "./"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-2-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Tom Butler",
|
||||
"email": "tom@r.je"
|
||||
}
|
||||
],
|
||||
"description": "A minimalist Dependency injection container (DIC) for PHP. Please note: This branch is only compatible with PHP5.6. 5.5, 5.4 and 5.3 compatible version is available as a separate branch on github. ",
|
||||
"homepage": "http://r.je/dice.html",
|
||||
"keywords": [
|
||||
"dependency injection",
|
||||
"dependency injection container",
|
||||
"di",
|
||||
"ioc"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "composepress/core",
|
||||
"version": "0.3.2",
|
||||
"version_normalized": "0.3.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/ComposePress/core.git",
|
||||
"reference": "080287b81fd811edfe13afe7831c8115e0fce281"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/ComposePress/core/zipball/080287b81fd811edfe13afe7831c8115e0fce281",
|
||||
"reference": "080287b81fd811edfe13afe7831c8115e0fce281",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"level-2/dice": "dev-v2.0-PHP5.4-5.5"
|
||||
},
|
||||
"time": "2018-01-29T06:17:21+00:00",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"ComposePress\\Core\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"LGPL-3.0-or-later"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Derrick Hammer",
|
||||
"email": "derrick@derrickhammer.com"
|
||||
}
|
||||
],
|
||||
"description": "A simple PSR-4 and composer ready plugin framework for the modern wordpress age"
|
||||
},
|
||||
{
|
||||
"name": "a5hleyrich/wp-background-processing",
|
||||
"version": "dev-master",
|
||||
"version_normalized": "9999999-dev",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/A5hleyRich/wp-background-processing.git",
|
||||
"reference": "a3f3a1f66a1dfa529f5712d410d09317cc86a2de"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/A5hleyRich/wp-background-processing/zipball/a3f3a1f66a1dfa529f5712d410d09317cc86a2de",
|
||||
"reference": "a3f3a1f66a1dfa529f5712d410d09317cc86a2de",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.2"
|
||||
},
|
||||
"time": "2017-10-03T14:33:09+00:00",
|
||||
"type": "library",
|
||||
"installation-source": "source",
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"classes/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"GPLv2+"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Ashley Rich",
|
||||
"email": "hello@ashleyrich.com"
|
||||
}
|
||||
],
|
||||
"description": "WP Background Processing can be used to fire off non-blocking asynchronous requests or as a background processing tool, allowing you to queue tasks."
|
||||
}
|
||||
]
|
21
wp-content/plugins/shortpixel-critical-css/vendor/jakeasmith/http_build_url/LICENSE
vendored
Normal file
21
wp-content/plugins/shortpixel-critical-css/vendor/jakeasmith/http_build_url/LICENSE
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Jake A. Smith
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
18
wp-content/plugins/shortpixel-critical-css/vendor/jakeasmith/http_build_url/composer.json
vendored
Normal file
18
wp-content/plugins/shortpixel-critical-css/vendor/jakeasmith/http_build_url/composer.json
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "jakeasmith/http_build_url",
|
||||
"description": "Provides functionality for http_build_url() to environments without pecl_http.",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Jake A. Smith",
|
||||
"email": "theman@jakeasmith.com"
|
||||
}
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/jakeasmith/http_build_url/issues",
|
||||
"source": "https://github.com/jakeasmith/http_build_url"
|
||||
},
|
||||
"autoload": {
|
||||
"files": ["src/http_build_url.php"]
|
||||
}
|
||||
}
|
174
wp-content/plugins/shortpixel-critical-css/vendor/jakeasmith/http_build_url/src/http_build_url.php
vendored
Normal file
174
wp-content/plugins/shortpixel-critical-css/vendor/jakeasmith/http_build_url/src/http_build_url.php
vendored
Normal file
@ -0,0 +1,174 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* URL constants as defined in the PHP Manual under "Constants usable with
|
||||
* http_build_url()".
|
||||
*
|
||||
* @see http://us2.php.net/manual/en/http.constants.php#http.constants.url
|
||||
*/
|
||||
if (!defined('HTTP_URL_REPLACE')) {
|
||||
define('HTTP_URL_REPLACE', 1);
|
||||
}
|
||||
if (!defined('HTTP_URL_JOIN_PATH')) {
|
||||
define('HTTP_URL_JOIN_PATH', 2);
|
||||
}
|
||||
if (!defined('HTTP_URL_JOIN_QUERY')) {
|
||||
define('HTTP_URL_JOIN_QUERY', 4);
|
||||
}
|
||||
if (!defined('HTTP_URL_STRIP_USER')) {
|
||||
define('HTTP_URL_STRIP_USER', 8);
|
||||
}
|
||||
if (!defined('HTTP_URL_STRIP_PASS')) {
|
||||
define('HTTP_URL_STRIP_PASS', 16);
|
||||
}
|
||||
if (!defined('HTTP_URL_STRIP_AUTH')) {
|
||||
define('HTTP_URL_STRIP_AUTH', 32);
|
||||
}
|
||||
if (!defined('HTTP_URL_STRIP_PORT')) {
|
||||
define('HTTP_URL_STRIP_PORT', 64);
|
||||
}
|
||||
if (!defined('HTTP_URL_STRIP_PATH')) {
|
||||
define('HTTP_URL_STRIP_PATH', 128);
|
||||
}
|
||||
if (!defined('HTTP_URL_STRIP_QUERY')) {
|
||||
define('HTTP_URL_STRIP_QUERY', 256);
|
||||
}
|
||||
if (!defined('HTTP_URL_STRIP_FRAGMENT')) {
|
||||
define('HTTP_URL_STRIP_FRAGMENT', 512);
|
||||
}
|
||||
if (!defined('HTTP_URL_STRIP_ALL')) {
|
||||
define('HTTP_URL_STRIP_ALL', 1024);
|
||||
}
|
||||
|
||||
if (!function_exists('http_build_url')) {
|
||||
|
||||
/**
|
||||
* Build a URL.
|
||||
*
|
||||
* The parts of the second URL will be merged into the first according to
|
||||
* the flags argument.
|
||||
*
|
||||
* @param mixed $url (part(s) of) an URL in form of a string or
|
||||
* associative array like parse_url() returns
|
||||
* @param mixed $parts same as the first argument
|
||||
* @param int $flags a bitmask of binary or'ed HTTP_URL constants;
|
||||
* HTTP_URL_REPLACE is the default
|
||||
* @param array $new_url if set, it will be filled with the parts of the
|
||||
* composed url like parse_url() would return
|
||||
* @return string
|
||||
*/
|
||||
function http_build_url($url, $parts = array(), $flags = HTTP_URL_REPLACE, &$new_url = array())
|
||||
{
|
||||
is_array($url) || $url = parse_url($url);
|
||||
is_array($parts) || $parts = parse_url($parts);
|
||||
|
||||
isset($url['query']) && is_string($url['query']) || $url['query'] = null;
|
||||
isset($parts['query']) && is_string($parts['query']) || $parts['query'] = null;
|
||||
|
||||
$keys = array('user', 'pass', 'port', 'path', 'query', 'fragment');
|
||||
|
||||
// HTTP_URL_STRIP_ALL and HTTP_URL_STRIP_AUTH cover several other flags.
|
||||
if ($flags & HTTP_URL_STRIP_ALL) {
|
||||
$flags |= HTTP_URL_STRIP_USER | HTTP_URL_STRIP_PASS
|
||||
| HTTP_URL_STRIP_PORT | HTTP_URL_STRIP_PATH
|
||||
| HTTP_URL_STRIP_QUERY | HTTP_URL_STRIP_FRAGMENT;
|
||||
} elseif ($flags & HTTP_URL_STRIP_AUTH) {
|
||||
$flags |= HTTP_URL_STRIP_USER | HTTP_URL_STRIP_PASS;
|
||||
}
|
||||
|
||||
// Schema and host are alwasy replaced
|
||||
foreach (array('scheme', 'host') as $part) {
|
||||
if (isset($parts[$part])) {
|
||||
$url[$part] = $parts[$part];
|
||||
}
|
||||
}
|
||||
|
||||
if ($flags & HTTP_URL_REPLACE) {
|
||||
foreach ($keys as $key) {
|
||||
if (isset($parts[$key])) {
|
||||
$url[$key] = $parts[$key];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (isset($parts['path']) && ($flags & HTTP_URL_JOIN_PATH)) {
|
||||
if (isset($url['path']) && substr($parts['path'], 0, 1) !== '/') {
|
||||
// Workaround for trailing slashes
|
||||
$url['path'] .= 'a';
|
||||
$url['path'] = rtrim(
|
||||
str_replace(basename($url['path']), '', $url['path']),
|
||||
'/'
|
||||
) . '/' . ltrim($parts['path'], '/');
|
||||
} else {
|
||||
$url['path'] = $parts['path'];
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($parts['query']) && ($flags & HTTP_URL_JOIN_QUERY)) {
|
||||
if (isset($url['query'])) {
|
||||
parse_str($url['query'], $url_query);
|
||||
parse_str($parts['query'], $parts_query);
|
||||
|
||||
$url['query'] = http_build_query(
|
||||
array_replace_recursive(
|
||||
$url_query,
|
||||
$parts_query
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$url['query'] = $parts['query'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($url['path']) && $url['path'] !== '' && substr($url['path'], 0, 1) !== '/') {
|
||||
$url['path'] = '/' . $url['path'];
|
||||
}
|
||||
|
||||
foreach ($keys as $key) {
|
||||
$strip = 'HTTP_URL_STRIP_' . strtoupper($key);
|
||||
if ($flags & constant($strip)) {
|
||||
unset($url[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
$parsed_string = '';
|
||||
|
||||
if (!empty($url['scheme'])) {
|
||||
$parsed_string .= $url['scheme'] . '://';
|
||||
}
|
||||
|
||||
if (!empty($url['user'])) {
|
||||
$parsed_string .= $url['user'];
|
||||
|
||||
if (isset($url['pass'])) {
|
||||
$parsed_string .= ':' . $url['pass'];
|
||||
}
|
||||
|
||||
$parsed_string .= '@';
|
||||
}
|
||||
|
||||
if (!empty($url['host'])) {
|
||||
$parsed_string .= $url['host'];
|
||||
}
|
||||
|
||||
if (!empty($url['port'])) {
|
||||
$parsed_string .= ':' . $url['port'];
|
||||
}
|
||||
|
||||
if (!empty($url['path'])) {
|
||||
$parsed_string .= $url['path'];
|
||||
}
|
||||
|
||||
if (!empty($url['query'])) {
|
||||
$parsed_string .= '?' . $url['query'];
|
||||
}
|
||||
|
||||
if (!empty($url['fragment'])) {
|
||||
$parsed_string .= '#' . $url['fragment'];
|
||||
}
|
||||
|
||||
$new_url = $url;
|
||||
|
||||
return $parsed_string;
|
||||
}
|
||||
}
|
102
wp-content/plugins/shortpixel-critical-css/vendor/level-2/dice/Dice.php
vendored
Normal file
102
wp-content/plugins/shortpixel-critical-css/vendor/level-2/dice/Dice.php
vendored
Normal file
@ -0,0 +1,102 @@
|
||||
<?php
|
||||
/* @description Dice - A minimal Dependency Injection Container for PHP *
|
||||
* @author Tom Butler tom@r.je *
|
||||
* @copyright 2012-2015 Tom Butler <tom@r.je> | http://r.je/dice.html *
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License *
|
||||
* @version 2.0 */
|
||||
namespace Dice;
|
||||
class Dice {
|
||||
private $rules = [];
|
||||
private $cache = [];
|
||||
private $instances = [];
|
||||
|
||||
public function addRule($name, array $rule) {
|
||||
$this->rules[ltrim(strtolower($name), '\\')] = array_merge($this->getRule($name), $rule);
|
||||
}
|
||||
|
||||
public function getRule($name) {
|
||||
$lcName = strtolower(ltrim($name, '\\'));
|
||||
if (isset($this->rules[$lcName])) return $this->rules[$lcName];
|
||||
|
||||
foreach ($this->rules as $key => $rule) {
|
||||
if (empty($rule['instanceOf']) && $key !== '*' && is_subclass_of($name, $key) && (!array_key_exists('inherit', $rule) || $rule['inherit'] === true )) return $rule;
|
||||
}
|
||||
return isset($this->rules['*']) ? $this->rules['*'] : [];
|
||||
}
|
||||
|
||||
public function create($name, array $args = [], array $share = []) {
|
||||
if (!empty($this->instances[$name])) return $this->instances[$name];
|
||||
if (empty($this->cache[$name])) $this->cache[$name] = $this->getClosure($name, $this->getRule($name));
|
||||
return $this->cache[$name]($args, $share);
|
||||
}
|
||||
|
||||
private function getClosure($name, array $rule) {
|
||||
$class = new \ReflectionClass(isset($rule['instanceOf']) ? $rule['instanceOf'] : $name);
|
||||
$constructor = $class->getConstructor();
|
||||
$params = $constructor ? $this->getParams($constructor, $rule) : null;
|
||||
|
||||
if (isset($rule['shared']) && $rule['shared'] === true ) $closure = function (array $args, array $share) use ($class, $name, $constructor, $params) {
|
||||
try {
|
||||
$this->instances[$name] = $this->instances[ltrim($name, '\\')] = $class->newInstanceWithoutConstructor();
|
||||
}
|
||||
catch (\ReflectionException $e) {
|
||||
$this->instances[$name] = $this->instances[ltrim($name, '\\')] = $class->newInstanceArgs($params($args, $share));
|
||||
}
|
||||
|
||||
if ($constructor) $constructor->invokeArgs($this->instances[$name], $params($args, $share));
|
||||
return $this->instances[$name];
|
||||
};
|
||||
else if ($params) $closure = function (array $args, array $share) use ($class, $params) { return $class->newInstanceArgs($params($args, $share)); };
|
||||
|
||||
else $closure = function () use ($class) { return new $class->name; };
|
||||
|
||||
return isset($rule['call']) ? function (array $args, array $share) use ($closure, $class, $rule) {
|
||||
$object = $closure($args, $share);
|
||||
foreach ($rule['call'] as $call) call_user_func_array([$object, $call[0]] , $this->getParams($class->getMethod($call[0]), $rule)->__invoke($this->expand($call[1])));
|
||||
return $object;
|
||||
} : $closure;
|
||||
}
|
||||
|
||||
/** looks for 'instance' array keys in $param and when found returns an object based on the value see https://r.je/dice.html#example3-1 */
|
||||
private function expand($param, array $share = [], $createFromString = false) {
|
||||
if (is_array($param) && isset($param['instance'])) {
|
||||
if (is_callable($param['instance'])) return call_user_func_array($param['instance'], (isset($param['params']) ? $this->expand($param['params']) : []));
|
||||
else return $this->create($param['instance'], $share);
|
||||
}
|
||||
else if (is_array($param)) foreach ($param as &$value) $value = $this->expand($value, $share);
|
||||
return is_string($param) && $createFromString ? $this->create($param) : $param;
|
||||
}
|
||||
|
||||
private function getParams(\ReflectionMethod $method, array $rule) {
|
||||
$paramInfo = [];
|
||||
foreach ($method->getParameters() as $param) {
|
||||
if(method_exists($param, 'getType')) {
|
||||
//php 8 onwards
|
||||
$type = $param->getType();
|
||||
$class = $type instanceof \ReflectionNamedType && !$type->isBuiltIn() ? $type->getName() : null;
|
||||
} else {
|
||||
$class = $param->getClass() ? $param->getClass()->name : null;
|
||||
}
|
||||
$paramInfo[] = [$class, $param, isset($rule['substitutions']) && array_key_exists($class, $rule['substitutions'])];
|
||||
}
|
||||
return function (array $args, array $share = []) use ($paramInfo, $rule) {
|
||||
if (isset($rule['shareInstances'])) $share = array_merge($share, array_map([$this, 'create'], $rule['shareInstances']));
|
||||
if ($share || isset($rule['constructParams'])) $args = array_merge($args, isset($rule['constructParams']) ? $this->expand($rule['constructParams'], $share) : [], $share);
|
||||
$parameters = [];
|
||||
|
||||
foreach ($paramInfo as $p) {
|
||||
list($class, $param, $sub) = $p;
|
||||
if ($args) foreach ($args as $i => $arg) {
|
||||
if ($class && ($arg instanceof $class || ($arg === null && $param->allowsNull()))) {
|
||||
$parameters[] = array_splice($args, $i, 1)[0];
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
if ($class) $parameters[] = $sub ? $this->expand($rule['substitutions'][$class], $share, true) : $this->create($class, [], $share);
|
||||
else if ($args) $parameters[] = $this->expand(array_shift($args));
|
||||
else $parameters[] = $param->isDefaultValueAvailable() ? $param->getDefaultValue() : null;
|
||||
}
|
||||
return $parameters;
|
||||
};
|
||||
}
|
||||
}
|
21
wp-content/plugins/shortpixel-critical-css/vendor/level-2/dice/Loader/Json.php
vendored
Normal file
21
wp-content/plugins/shortpixel-critical-css/vendor/level-2/dice/Loader/Json.php
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/* @description Dice - A minimal Dependency Injection Container for PHP *
|
||||
* @author Tom Butler tom@r.je *
|
||||
* @copyright 2012-2015 Tom Butler <tom@r.je> | http://r.je/dice.html *
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License *
|
||||
* @version 1.3.2 */
|
||||
namespace Dice\Loader;
|
||||
class Json {
|
||||
public function load($json, \Dice\Dice $dice = null) {
|
||||
if ($dice === null) $dice = new \Dice\Dice;
|
||||
$map = json_decode($json, true);
|
||||
if (!is_array($map)) throw new \Exception('Could not decode json: ' . json_last_error_msg());
|
||||
|
||||
foreach ($map['rules'] as $rule) {
|
||||
$name = $rule['name'];
|
||||
unset($rule['name']);
|
||||
$dice->addRule($name, $rule);
|
||||
}
|
||||
return $dice;
|
||||
}
|
||||
}
|
72
wp-content/plugins/shortpixel-critical-css/vendor/level-2/dice/Loader/Xml.php
vendored
Normal file
72
wp-content/plugins/shortpixel-critical-css/vendor/level-2/dice/Loader/Xml.php
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
/* @description Dice - A minimal Dependency Injection Container for PHP
|
||||
* @author Tom Butler tom@r.je
|
||||
* @copyright 2012-2014 Tom Butler <tom@r.je>
|
||||
* @link http://r.je/dice.html
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version 2.0
|
||||
*/
|
||||
namespace Dice\Loader;
|
||||
class Xml {
|
||||
private function getComponent(\SimpleXmlElement $element, $forceInstance = false) {
|
||||
if ($forceInstance) return ['instance' => (string) $element];
|
||||
else if ($element->instance) return ['instance' => (string) $element->instance];
|
||||
else return (string) $element;
|
||||
}
|
||||
|
||||
private function loadV1(\SimpleXmlElement $xml, \Dice\Dice $dice) {
|
||||
foreach ($xml as $key => $value) {
|
||||
$rule = $dice->getRule((string) $value->name);
|
||||
|
||||
if (isset($value->shared)) $rule['shared'] = ((string) $value->shared === 'true');
|
||||
|
||||
if (isset($value->inherit)) $rule['inherit'] = ($value->inherit == 'false') ? false : true;
|
||||
if ($value->call) {
|
||||
foreach ($value->call as $name => $call) {
|
||||
$callArgs = [];
|
||||
if ($call->params) foreach ($call->params->children() as $key => $param) $callArgs[] = $this->getComponent($param);
|
||||
$rule['call'][] = [(string) $call->method, $callArgs];
|
||||
}
|
||||
}
|
||||
if ($value->instanceOf) $rule['instanceOf'] = (string) $value->instanceOf;
|
||||
if ($value->newInstances) foreach ($value->newInstances as $ni) $rule['newInstances'][] = (string) $ni;
|
||||
if ($value->substitutions) foreach ($value->substitutions as $use) $rule['substitutions'][(string) $use->as] = $this->getComponent($use->use, true);
|
||||
if ($value->constructParams) foreach ($value->constructParams->children() as $child) $rule['constructParams'][] = $this->getComponent($child);
|
||||
if ($value->shareInstances) foreach ($value->shareInstances as $share) $rule['shareInstances'][] = $this->getComponent($share);
|
||||
$dice->addRule((string) $value->name, $rule);
|
||||
}
|
||||
}
|
||||
|
||||
private function loadV2(\SimpleXmlElement $xml, \Dice\Dice $dice) {
|
||||
foreach ($xml as $key => $value) {
|
||||
$rule = $dice->getRule((string) $value->name);
|
||||
|
||||
if ($value->call) {
|
||||
foreach ($value->call as $name => $call) {
|
||||
$callArgs = [];
|
||||
foreach ($call->children() as $key => $param) $callArgs[] = $this->getComponent($param);
|
||||
$rule['call'][] = [(string) $call['method'], $callArgs];
|
||||
}
|
||||
}
|
||||
if (isset($value['inherit'])) $rule['inherit'] = ($value['inherit'] == 'false') ? false : true;
|
||||
if ($value['instanceOf']) $rule['instanceOf'] = (string) $value['instanceOf'];
|
||||
if (isset($value['shared'])) $rule['shared'] = ((string) $value['shared'] === 'true');
|
||||
if ($value->constructParams) foreach ($value->constructParams->children() as $child) $rule['constructParams'][] = $this->getComponent($child);
|
||||
if ($value->substitute) foreach ($value->substitute as $use) $rule['substitutions'][(string) $use['as']] = $this->getComponent($use['use'], true);
|
||||
if ($value->shareInstances) foreach ($value->shareInstances->children() as $share) $rule['shareInstances'][] = $this->getComponent($share);
|
||||
$dice->addRule((string) $value['name'], $rule);
|
||||
}
|
||||
}
|
||||
|
||||
public function load($xml, \Dice\Dice $dice = null) {
|
||||
if ($dice === null) $dice = new \Dice\Dice;
|
||||
if (!($xml instanceof \SimpleXmlElement)) $xml = simplexml_load_file($xml);
|
||||
$ns = $xml->getNamespaces();
|
||||
$nsName = (isset($ns[''])) ? $ns[''] : '';
|
||||
|
||||
if ($nsName == 'https://r.je/dice/2.0') $this->loadV2($xml, $dice);
|
||||
else $this->loadV1($xml, $dice);
|
||||
|
||||
|
||||
}
|
||||
}
|
21
wp-content/plugins/shortpixel-critical-css/vendor/level-2/dice/composer.json
vendored
Normal file
21
wp-content/plugins/shortpixel-critical-css/vendor/level-2/dice/composer.json
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "level-2/dice",
|
||||
"description": "A minimalist Dependency injection container (DIC) for PHP. Please note: This branch is only compatible with PHP5.6. 5.5, 5.4 and 5.3 compatible version is available as a separate branch on github. ",
|
||||
"license": "BSD-2-Clause",
|
||||
"homepage": "http://r.je/dice.html",
|
||||
"keywords": ["Dependency injection", "ioc", "Dependency injection container", "DI"],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Tom Butler",
|
||||
"email": "tom@r.je"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.4.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Dice\\": "./"
|
||||
}
|
||||
}
|
||||
}
|
674
wp-content/plugins/shortpixel-critical-css/vendor/pcfreak30/wordpress-cache-store/LICENSE
vendored
Normal file
674
wp-content/plugins/shortpixel-critical-css/vendor/pcfreak30/wordpress-cache-store/LICENSE
vendored
Normal file
@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
{one line to give the program's name and a brief idea of what it does.}
|
||||
Copyright (C) {year} {name of author}
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
{project} Copyright (C) {year} {fullname}
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
17
wp-content/plugins/shortpixel-critical-css/vendor/pcfreak30/wordpress-cache-store/composer.json
vendored
Normal file
17
wp-content/plugins/shortpixel-critical-css/vendor/pcfreak30/wordpress-cache-store/composer.json
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "pcfreak30/wordpress-cache-store",
|
||||
"description": "WordPress cache library to enable a data tree inspired storage structure to offset the limitation of the WordPress cache API for querying available keys",
|
||||
"license": "GPL-3.0",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Derrick Hammer",
|
||||
"email": "derrick@derrickhammer.com"
|
||||
}
|
||||
],
|
||||
"require": {},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"pcfreak30\\": "src/"
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,263 @@
|
||||
<?php
|
||||
|
||||
namespace pcfreak30\WordPress\Cache;
|
||||
|
||||
use WP\CriticalCSS\FileLog;
|
||||
|
||||
/**
|
||||
* Class Store
|
||||
*
|
||||
* @package pcfreak30\WordPress\Cache
|
||||
*/
|
||||
class Store {
|
||||
private $prefix = '';
|
||||
private $expire = 3600;
|
||||
private $max_branch_length = 50;
|
||||
|
||||
/**
|
||||
* @param array $path
|
||||
*
|
||||
* @return bool|mixed
|
||||
*/
|
||||
public function delete_cache_branch( $path = [] ) {
|
||||
$result = false;
|
||||
if ( is_array( $path ) ) {
|
||||
if ( ! empty( $path ) ) {
|
||||
$path = $this->set_path_defaults( $path );
|
||||
$path = $this->prefix . implode( '_', $path ) . '_';
|
||||
} else {
|
||||
$path = $this->prefix;
|
||||
}
|
||||
}
|
||||
$counter_transient = "{$path}cache_count";
|
||||
$counter = $this->get_transient( $counter_transient );
|
||||
|
||||
if ( is_null( $counter ) || false === $counter ) {
|
||||
return $this->delete_cache_leaf( rtrim( $path, '_' ) );
|
||||
}
|
||||
for ( $i = 1; $i <= $counter; $i ++ ) {
|
||||
$transient_name = "{$path}cache_{$i}";
|
||||
$cache = $this->get_transient( "{$path}cache_{$i}" );
|
||||
if ( ! empty( $cache ) ) {
|
||||
$branch_result = false;
|
||||
foreach ( $cache as $sub_branch ) {
|
||||
$branch_result = $this->delete_cache_branch( "{$sub_branch}_" );
|
||||
}
|
||||
$result = $branch_result && $this->delete_cache_leaf( $transient_name );
|
||||
}
|
||||
}
|
||||
$this->delete_transient( $counter_transient );
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function get_prefix() {
|
||||
return $this->prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $prefix
|
||||
*/
|
||||
public function set_prefix( $prefix ) {
|
||||
$this->prefix = $prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function get_expire() {
|
||||
return $this->expire;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $expire
|
||||
*/
|
||||
public function set_expire( $expire ) {
|
||||
$this->expire = $expire;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function get_max_branch_length() {
|
||||
return $this->max_branch_length;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $max_branch_length
|
||||
*/
|
||||
public function set_max_branch_length( $max_branch_length ) {
|
||||
$this->max_branch_length = $max_branch_length;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $path
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function set_path_defaults( $path ) {
|
||||
$defaults = [ 'cache' ];
|
||||
if ( is_multisite() ) {
|
||||
$defaults[] = 'blog-' . get_current_blog_id();
|
||||
}
|
||||
$path = array_merge( $defaults, $path );
|
||||
$path = array_unique( $path );
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_transient() {
|
||||
if ( is_multisite() ) {
|
||||
return call_user_func_array( 'get_site_transient', func_get_args() );
|
||||
}
|
||||
|
||||
return call_user_func_array( 'get_transient', func_get_args() );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $path
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function delete_cache_leaf( $path = [] ) {
|
||||
if ( is_array( $path ) ) {
|
||||
if ( ! empty( $path ) ) {
|
||||
$path = $this->set_path_defaults( $path );
|
||||
$path = $this->prefix . implode( '_', $path );
|
||||
|
||||
return $this->delete_transient( $path );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->delete_transient( $path );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function delete_transient() {
|
||||
if ( is_multisite() ) {
|
||||
return call_user_func_array( 'delete_site_transient', func_get_args() );
|
||||
}
|
||||
|
||||
return call_user_func_array( 'delete_transient', func_get_args() );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $path
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_cache_fragment( $path ) {
|
||||
$path = $this->set_path_defaults( $path );
|
||||
return $this->get_transient( $this->prefix . implode( '_', $path ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $path
|
||||
* @param $value
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function update_cache_fragment( $path, $value ) {
|
||||
$path = $this->set_path_defaults( $path );
|
||||
$this->build_cache_tree( array_slice( $path, 0, - 1 ) );
|
||||
|
||||
return $this->update_tree_leaf( $path, $value );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $path
|
||||
*/
|
||||
protected function build_cache_tree( $path ) {
|
||||
$levels = count( $path );
|
||||
$expire = $this->expire;
|
||||
for ( $i = 0; $i < $levels; $i ++ ) {
|
||||
$transient_id = $this->prefix . implode( '_', array_slice( $path, 0, $i + 1 ) );
|
||||
$transient_cache_id = $transient_id;
|
||||
if ( 'cache' !== $path[ $i ] ) {
|
||||
$transient_cache_id .= '_cache';
|
||||
}
|
||||
$transient_cache_id .= '_1';
|
||||
$cache = $this->get_transient( $transient_cache_id );
|
||||
$transient_value = [];
|
||||
if ( $i + 1 < $levels ) {
|
||||
$transient_value[] = $this->prefix . implode( '_', array_slice( $path, 0, $i + 2 ) );
|
||||
}
|
||||
if ( ! is_null( $cache ) && false !== $cache ) {
|
||||
$transient_value = array_unique( array_merge( $cache, $transient_value ) );
|
||||
}
|
||||
$this->set_transient( $transient_cache_id, $transient_value, $expire );
|
||||
$transient_counter_id = $transient_id;
|
||||
if ( 'cache' !== $path[ $i ] ) {
|
||||
$transient_counter_id .= '_cache';
|
||||
}
|
||||
$transient_counter_id .= '_count';
|
||||
$transient_counter = $this->get_transient( $transient_counter_id );
|
||||
if ( is_null( $transient_counter ) || false === $transient_counter ) {
|
||||
$this->set_transient( $transient_counter_id, 1, $expire );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function set_transient() {
|
||||
if ( is_multisite() ) {
|
||||
return call_user_func_array( 'set_site_transient', func_get_args() );
|
||||
}
|
||||
|
||||
return call_user_func_array( 'set_transient', func_get_args() );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $path
|
||||
* @param $value
|
||||
*/
|
||||
protected function update_tree_leaf( $path, $value ) {
|
||||
$leaf = $this->prefix . implode( '_', $path );
|
||||
$parent_path = array_slice( $path, 0, is_multisite() ? - 2 : - 1 );
|
||||
$parent = $this->prefix . implode( '_', $parent_path );
|
||||
$counter_transient = $parent;
|
||||
$cache_transient = $parent;
|
||||
if ( 'cache' !== end( $parent_path ) ) {
|
||||
$counter_transient .= '_cache';
|
||||
$cache_transient .= '_cache';
|
||||
}
|
||||
$counter_transient .= '_count';
|
||||
$counter = (int) $this->get_transient( $counter_transient );
|
||||
$cache_transient .= "_{$counter}";
|
||||
$cache = $this->get_transient( $cache_transient );
|
||||
$count = count( $cache );
|
||||
$cache_keys = array_flip( $cache );
|
||||
$expire = $this->expire;
|
||||
if ( ! isset( $cache_keys[ $leaf ] ) ) {
|
||||
if ( $count >= $this->max_branch_length ) {
|
||||
$counter ++;
|
||||
$this->set_transient( $counter_transient, $counter, $expire );
|
||||
$cache_transient = $parent;
|
||||
if ( 'cache' !== end( $parent_path ) ) {
|
||||
$cache_transient .= '_cache';
|
||||
}
|
||||
$cache_transient .= "_{$counter}";
|
||||
$cache = [];
|
||||
}
|
||||
$cache[] = $leaf;
|
||||
$this->set_transient( $cache_transient, $cache, $expire );
|
||||
}
|
||||
|
||||
return $this->set_transient( $leaf, $value, $expire );
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use pcfreak30\WordPress\Cache\Store;
|
||||
|
||||
class StoreTest extends PHPUnit_Framework_TestCase {
|
||||
public function test_update_cache_fragment() {
|
||||
|
||||
$store = new Store( 'test_prefix', 60, 50 );
|
||||
|
||||
$this->assertTrue( $store->update_cache_fragment( [ 'test' ], true ) );
|
||||
$this->assertTrue( $store->get_cache_fragment( [ 'test' ] ) );
|
||||
}
|
||||
|
||||
public function test_delete_cache_branch() {
|
||||
$store = new Store( 'test_prefix', 60, 50 );
|
||||
|
||||
$store->update_cache_fragment( [ 'test' ], true );
|
||||
$this->assertTrue( $store->delete_cache_branch() );
|
||||
$this->assertFalse( $store->get_cache_fragment( [] ) );
|
||||
}
|
||||
|
||||
public function test_delete_cache_leaf() {
|
||||
$store = new Store( 'test_prefix', 60, 50 );
|
||||
|
||||
$store->update_cache_fragment( [ 'test' ], true );
|
||||
$this->assertTrue( $store->delete_cache_leaf( [ 'test' ] ) );
|
||||
$this->assertFalse( $store->get_cache_fragment( [ 'test' ] ) );
|
||||
}
|
||||
|
||||
public function test_get_cache_fragment() {
|
||||
$store = new Store( 'test_prefix', 60, 50 );
|
||||
|
||||
$store->update_cache_fragment( [ 'test' ], true );
|
||||
$this->assertTrue( $store->get_cache_fragment( [ 'test' ] ) );
|
||||
}
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPUnit bootstrap file
|
||||
*
|
||||
* @package Wp_Criticalcss
|
||||
*/
|
||||
|
||||
$_tests_dir = getenv( 'WP_TESTS_DIR' );
|
||||
if ( ! $_tests_dir ) {
|
||||
$_tests_dir = '/tmp/wordpress-tests-lib';
|
||||
}
|
||||
// Initialize composer
|
||||
require_once dirname( __DIR__ ) . '/vendor/autoload.php';
|
||||
|
||||
// Give access to tests_add_filter() function.
|
||||
require_once $_tests_dir . '/includes/functions.php';
|
||||
|
||||
// Start up the WP testing environment.
|
||||
require $_tests_dir . '/includes/bootstrap.php';
|
165
wp-content/plugins/shortpixel-critical-css/vendor/pcfreak30/wordpress-plugin-framework/LICENSE
vendored
Normal file
165
wp-content/plugins/shortpixel-critical-css/vendor/pcfreak30/wordpress-plugin-framework/LICENSE
vendored
Normal file
@ -0,0 +1,165 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "pcfreak30/wordpress-plugin-framework",
|
||||
"type": "library",
|
||||
"description": "A simple PSR-4 and composer ready plugin framework for the modern wordpress age",
|
||||
"license": "LGPL3",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Derrick Hammer",
|
||||
"email": "derrick@derrickhammer.com"
|
||||
}
|
||||
],
|
||||
"require": {},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"pcfreak30\\WordPress\\Plugin\\Framework\\": "src/"
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace pcfreak30\WordPress\Plugin\Framework;
|
||||
|
||||
use pcfreak30\WordPress\Plugin\Framework\Exception\InexistentProperty;
|
||||
use pcfreak30\WordPress\Plugin\Framework\Exception\ReadOnlyException;
|
||||
|
||||
/**
|
||||
* Class BaseObjectAbstract
|
||||
*
|
||||
* @package pcfreak30\WordPress\Plugin\Framework
|
||||
* @property \wpdb $wpdb
|
||||
* @property \WP_Post $post
|
||||
* @property \WP_Rewrite $wp_rewrite
|
||||
* @property \WP $wp
|
||||
* @property \WP_Query $wp_query
|
||||
* @property \WP_Query $wp_the_query
|
||||
* @property string $pagenow
|
||||
* @property int $page
|
||||
*/
|
||||
abstract class BaseObjectAbstract implements ComponentInterface {
|
||||
public function __get( $name ) {
|
||||
$func = "get_{$name}";
|
||||
if ( method_exists( $this, $func ) ) {
|
||||
return $this->$func();
|
||||
}
|
||||
|
||||
if ( isset( $GLOBALS[ $name ] ) ) {
|
||||
return $GLOBALS[ $name ];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function __set( $name, $value ) {
|
||||
$func = "set_{$name}";
|
||||
if ( method_exists( $this, $func ) ) {
|
||||
$this->$func( $value );
|
||||
|
||||
return;
|
||||
}
|
||||
$func = "get_{$name}";
|
||||
if ( method_exists( $this, $func ) ) {
|
||||
throw new ReadOnlyException( sprintf( 'Property %s is read-only', $name ) );
|
||||
}
|
||||
if ( isset( $GLOBALS[ $name ] ) ) {
|
||||
$GLOBALS[ $name ] = $value;
|
||||
|
||||
return;
|
||||
}
|
||||
throw new InexistentProperty( sprintf( 'Inexistent property: %s', $name ) );
|
||||
}
|
||||
|
||||
public function __isset( $name ) {
|
||||
$func = "get_{$name}";
|
||||
if ( method_exists( $this, $func ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return isset( $GLOBALS[ $name ] );
|
||||
}
|
||||
}
|
@ -0,0 +1,128 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace pcfreak30\WordPress\Plugin\Framework;
|
||||
|
||||
|
||||
/**
|
||||
* Class ComponentAbstract
|
||||
*
|
||||
* @package pcfreak30\WordPress\Plugin\Framework/*
|
||||
* @property PluginAbstract $plugin
|
||||
* @property ComponentAbstract $parent
|
||||
*/
|
||||
abstract class ComponentAbstract extends BaseObjectAbstract {
|
||||
/**
|
||||
* @var PluginAbstract
|
||||
*/
|
||||
private $plugin;
|
||||
|
||||
/**
|
||||
* @var ComponentAbstract
|
||||
*/
|
||||
private $parent;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
abstract public function init();
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function __destruct() {
|
||||
$this->plugin = null;
|
||||
$this->parent = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ComponentAbstract
|
||||
*/
|
||||
public function get_parent() {
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ComponentAbstract $parent
|
||||
*/
|
||||
public function set_parent( $parent ) {
|
||||
$this->parent = $parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PluginAbstract
|
||||
*/
|
||||
public function get_plugin() {
|
||||
if ( null === $this->plugin ) {
|
||||
$parent = $this;
|
||||
while ( $parent->has_parent() ) {
|
||||
$parent = $parent->parent;
|
||||
}
|
||||
$this->plugin = $parent;
|
||||
}
|
||||
|
||||
return $this->plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function has_parent() {
|
||||
return null !== $this->parent;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $components
|
||||
*/
|
||||
protected function set_component_parents( $components ) {
|
||||
/** @var ComponentAbstract $component */
|
||||
foreach ( $components as $component ) {
|
||||
$component->parent = $this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|\ReflectionProperty[]
|
||||
*/
|
||||
protected function get_components() {
|
||||
$components = ( new \ReflectionClass( $this ) )->getProperties();
|
||||
$components = array_filter(
|
||||
$components,
|
||||
/**
|
||||
* @param \ReflectionProperty $component
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function ( $component ) {
|
||||
$getter = 'get_' . $component->name;
|
||||
|
||||
return method_exists( $this, $getter ) && ( new \ReflectionMethod( $this, $getter ) )->isPublic() && $this->$getter() instanceof ComponentAbstract;
|
||||
} );
|
||||
$components = array_map(
|
||||
/**
|
||||
* @param \ReflectionProperty $component
|
||||
*
|
||||
* @return ComponentAbstract
|
||||
*/
|
||||
function ( $component ) {
|
||||
$getter = 'get_' . $component->name;
|
||||
|
||||
return $this->$getter();
|
||||
}, $components );
|
||||
|
||||
return $components;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup components and run init
|
||||
*/
|
||||
protected function setup_components() {
|
||||
$components = $this->get_components();
|
||||
$this->set_component_parents( $components );
|
||||
foreach ( $components as $component ) {
|
||||
$component->init();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace pcfreak30\WordPress\Plugin\Framework;
|
||||
|
||||
|
||||
interface ComponentInterface {
|
||||
public function init();
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace pcfreak30\WordPress\Plugin\Framework\Exception;
|
||||
|
||||
|
||||
class ContainerInvalid extends \Exception {
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace pcfreak30\WordPress\Plugin\Framework\Exception;
|
||||
|
||||
|
||||
class ContainerNotExists extends \Exception {
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace pcfreak30\WordPress\Plugin\Framework\Exception;
|
||||
|
||||
|
||||
class InexistentProperty extends \Exception {
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace pcfreak30\WordPress\Plugin\Framework\Exception;
|
||||
|
||||
|
||||
class ReadOnlyException extends \Exception {
|
||||
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace pcfreak30\WordPress\Plugin\Framework;
|
||||
|
||||
class ManagerAbstract extends ComponentAbstract {
|
||||
protected $modules = [
|
||||
|
||||
];
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function init() {
|
||||
if ( 0 < count( array_filter( $this->modules, 'is_object' ) ) ) {
|
||||
return;
|
||||
}
|
||||
$modules = [];
|
||||
|
||||
$reflect = new \ReflectionClass( get_called_class() );
|
||||
$class = strtolower( $reflect->getShortName() );
|
||||
$namespace = $reflect->getNamespaceName();
|
||||
$component = strtolower( basename( $namespace ) );
|
||||
|
||||
$slug = $this->plugin->get_safe_slug();
|
||||
$filter = "{$slug}_{$component}_{$class}_modules";
|
||||
$modules_list = apply_filters( $filter, $this->modules );
|
||||
|
||||
foreach ( $modules_list as $module ) {
|
||||
$class = trim( $module, '\\' );
|
||||
if ( false === strpos( $module, '\\' ) ) {
|
||||
$class = $namespace . '\\' . $module;
|
||||
}
|
||||
$modules[ $module ] = $this->plugin->container->create( $class );
|
||||
}
|
||||
foreach ( $modules_list as $module ) {
|
||||
$modules[ $module ]->parent = $this;
|
||||
$modules[ $module ]->init();
|
||||
}
|
||||
|
||||
$this->modules = $modules;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function get_modules() {
|
||||
return $this->modules;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
*
|
||||
* @return bool|mixed
|
||||
*/
|
||||
public function get_module( $name ) {
|
||||
if ( null === $name ) {
|
||||
return false;
|
||||
}
|
||||
if ( isset( $this->modules[ $name ] ) ) {
|
||||
return $this->modules[ $name ];
|
||||
}
|
||||
$name = "\\{$name}";
|
||||
if ( isset( $this->modules[ $name ] ) ) {
|
||||
return $this->modules[ $name ];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,176 @@
|
||||
<?php
|
||||
|
||||
namespace pcfreak30\WordPress\Plugin\Framework;
|
||||
|
||||
use Dice\Dice;
|
||||
use pcfreak30\WordPress\Plugin\Framework\Exception\ComposerMissing;
|
||||
use pcfreak30\WordPress\Plugin\Framework\Exception\ContainerInvalid;
|
||||
use pcfreak30\WordPress\Plugin\Framework\Exception\ContainerNotExists;
|
||||
|
||||
/**
|
||||
* Class PluginAbstract
|
||||
*
|
||||
* @package pcfreak30\WordPress\Plugin\Framework
|
||||
*
|
||||
* @property Dice\Dice $container
|
||||
*/
|
||||
abstract class PluginAbstract extends ComponentAbstract {
|
||||
/**
|
||||
* Default version constant
|
||||
*/
|
||||
const VERSION = '';
|
||||
/**
|
||||
* Default slug constant
|
||||
*/
|
||||
const PLUGIN_SLUG = '';
|
||||
|
||||
/**
|
||||
* Path to plugin entry file
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $plugin_file;
|
||||
/**
|
||||
* Dependency Container
|
||||
*
|
||||
* @var Dice
|
||||
*/
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* PluginAbstract constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->find_plugin_file();
|
||||
$this->set_container();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function find_plugin_file() {
|
||||
$dir = dirname( ( new \ReflectionClass( $this ) )->getFileName() );
|
||||
$file = null;
|
||||
do {
|
||||
$last_dir = $dir;
|
||||
$dir = dirname( $dir );
|
||||
$file = $dir . DIRECTORY_SEPARATOR . static::PLUGIN_SLUG . '.php';
|
||||
} while ( ! $this->get_wp_filesystem()->is_file( $file ) && $dir !== $last_dir );
|
||||
$this->plugin_file = $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \WP_Filesystem_Direct
|
||||
*/
|
||||
protected function get_wp_filesystem() {
|
||||
/** @var \WP_Filesystem_Direct $wp_filesystem */
|
||||
global $wp_filesystem;
|
||||
if ( is_null( $wp_filesystem ) ) {
|
||||
require_once ABSPATH . '/wp-admin/includes/file.php';
|
||||
WP_Filesystem();
|
||||
}
|
||||
|
||||
return $wp_filesystem;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
abstract public function activate();
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
abstract public function deactivate();
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
abstract public function uninstall();
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function get_plugin_file() {
|
||||
return $this->plugin_file;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Dice
|
||||
*/
|
||||
public function get_container() {
|
||||
return $this->container;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \pcfreak30\WordPress\Plugin\Framework\Exception\ContainerInvalid
|
||||
* @throws \pcfreak30\WordPress\Plugin\Framework\Exception\ContainerNotExists
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function set_container() {
|
||||
$slug = str_replace( '-', '_', static::PLUGIN_SLUG );
|
||||
$container = "{$slug}_container";
|
||||
if ( ! function_exists( $container ) ) {
|
||||
throw new ContainerNotExists( sprintf( 'Container function %s does not exist.', $container ) );
|
||||
}
|
||||
$this->container = $container();
|
||||
if ( ! ( $this->container instanceof Dice ) ) {
|
||||
throw new ContainerInvalid( sprintf( 'Container function %s does not return a Dice instance.', $container ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Plugin initialization
|
||||
*/
|
||||
public function init() {
|
||||
if ( ! $this->get_dependancies_exist() ) {
|
||||
return;
|
||||
}
|
||||
$this->setup_components();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function get_dependancies_exist() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function get_slug() {
|
||||
return static::PLUGIN_SLUG;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function get_version() {
|
||||
return static::VERSION;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function get_safe_slug() {
|
||||
return strtolower( str_replace( '-', '_', $this->get_slug() ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $field
|
||||
*
|
||||
* @return string|array
|
||||
*/
|
||||
public function get_plugin_info( $field = null ) {
|
||||
$info = get_plugin_data( $this->plugin_file );
|
||||
if ( null !== $field && isset( $info[ $field ] ) ) {
|
||||
return $info[ $field ];
|
||||
}
|
||||
|
||||
return $info;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user