diff --git a/.github/workflows/lint_phpcs.yml b/.github/workflows/lint_phpcs.yml
index 74b327c01..a500e54dc 100644
--- a/.github/workflows/lint_phpcs.yml
+++ b/.github/workflows/lint_phpcs.yml
@@ -31,8 +31,11 @@ jobs:
coverage: none # XDebug can be enabled here 'coverage: xdebug'
tools: composer:v2
+ - name: Install Strauss
+ run: sh -c 'test -f ./bin/strauss.phar || curl -o bin/strauss.phar -L -C - https://github.com/BrianHenryIE/strauss/releases/latest/download/strauss.phar'
+
- name: Install dependencies
- run: composer install --prefer-dist --no-interaction --no-scripts
+ run: composer install --no-interaction
- name: Lint with phpcs
run: composer phpcs
diff --git a/.github/workflows/lint_phpstan.yml b/.github/workflows/lint_phpstan.yml
index f9dd138bb..d6e829f36 100644
--- a/.github/workflows/lint_phpstan.yml
+++ b/.github/workflows/lint_phpstan.yml
@@ -32,8 +32,11 @@ jobs:
coverage: none # XDebug can be enabled here 'coverage: xdebug'
tools: composer:v2
+ - name: Install Strauss
+ run: sh -c 'test -f ./bin/strauss.phar || curl -o bin/strauss.phar -L -C - https://github.com/BrianHenryIE/strauss/releases/latest/download/strauss.phar'
+
- name: Install dependencies
- run: composer install --prefer-dist --no-interaction --no-scripts
+ run: composer install --no-interaction
- name: Lint with PHP Stan
run: composer run-stan -- --error-format=github
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 3e19cc259..4c9d8f968 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -18,7 +18,7 @@ jobs:
fail-fast: false
matrix:
operating-system: [ubuntu-latest]
- php-versions: ['8.0', '8.1', '8.2']
+ php-versions: ['8.0', '8.1', '8.2', '8.3', '8.4']
wp-versions: ['latest']
name: WP ${{ matrix.wp-versions }} with PHP ${{ matrix.php-versions }} on ${{ matrix.operating-system }}.
@@ -62,8 +62,11 @@ jobs:
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-
+ - name: Install Strauss
+ run: sh -c 'test -f ./bin/strauss.phar || curl -o bin/strauss.phar -L -C - https://github.com/BrianHenryIE/strauss/releases/latest/download/strauss.phar'
+
- name: Install dependencies
- run: composer install --prefer-dist --no-interaction --no-scripts --ignore-platform-reqs
+ run: composer install --no-interaction
- name: Install tests
run: bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1:3306 ${{ matrix.wp-versions }}
diff --git a/.github/workflows/test_legacy.yml b/.github/workflows/test_legacy.yml
index ae03ef972..0452ba2be 100644
--- a/.github/workflows/test_legacy.yml
+++ b/.github/workflows/test_legacy.yml
@@ -75,8 +75,11 @@ jobs:
- name: Require PHPUnit 7.5 for WP compatibility
run: composer require --dev --no-scripts phpunit/phpunit "^7.5" -W
+ - name: Install Strauss
+ run: sh -c 'test -f ./bin/strauss.phar || curl -o bin/strauss.phar -L -C - https://github.com/BrianHenryIE/strauss/releases/latest/download/strauss.phar'
+
- name: Install dependencies
- run: composer install --prefer-dist --no-interaction --no-scripts
+ run: composer install --no-interaction
- name: Install tests
run: bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1:3306 ${{ matrix.wp-versions }}
diff --git a/.gitignore b/.gitignore
index 14c615832..910bdf8e9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,3 +9,4 @@ composer.lock
package-lock.json
/_dev/node_modules
.phpunit.result.cache
+bin/strauss.phar
diff --git a/bin/.gitkeep b/bin/.gitkeep
new file mode 100644
index 000000000..e69de29bb
diff --git a/classes/Admin/PluginFamilySubscriber.php b/classes/Admin/PluginFamilySubscriber.php
index c501c2b66..477e05541 100644
--- a/classes/Admin/PluginFamilySubscriber.php
+++ b/classes/Admin/PluginFamilySubscriber.php
@@ -55,4 +55,50 @@ public function install_activate() {
public function display_error_notice() {
$this->plugin_family->display_error_notice();
}
+
+ /**
+ * Enqueue block editor assets.
+ *
+ * @return void
+ */
+ public function enqueue_assets(): void {
+ $this->plugin_family->enqueue_assets();
+ }
+
+ /**
+ * Install Imagify using the ajax request.
+ *
+ * @return void
+ */
+ public function install_imagify(): void {
+ $this->plugin_family->install_imagify();
+ }
+
+ /**
+ * Enqueue Admin assets.
+ *
+ * @param string $page Page ID.
+ * @return void
+ */
+ public function enqueue_admin_assets( $page ): void {
+ $this->plugin_family->enqueue_admin_assets( $page );
+ }
+
+ /**
+ * Insert admin footer JS templates.
+ *
+ * @return void
+ */
+ public function insert_footer_templates(): void {
+ $this->plugin_family->insert_footer_templates();
+ }
+
+ /**
+ * Dismiss promote Imagify using the ajax request.
+ *
+ * @return void
+ */
+ public function dismiss_promote_imagify(): void {
+ $this->plugin_family->dismiss_promote_imagify();
+ }
}
diff --git a/classes/Dependencies/WPMedia/PluginFamily/Controller/PluginFamily.php b/classes/Dependencies/WPMedia/PluginFamily/Controller/PluginFamily.php
deleted file mode 100644
index 54e7e7140..000000000
--- a/classes/Dependencies/WPMedia/PluginFamily/Controller/PluginFamily.php
+++ /dev/null
@@ -1,295 +0,0 @@
- 'install_activate',
- ];
- }
-
- /**
- * Process to install and activate plugin.
- *
- * @return void
- */
- public function install_activate() {
- if ( ! $this->is_allowed() ) {
- wp_die(
- 'Plugin Installation is not allowed.',
- '',
- [ 'back_link' => true ]
- );
- }
-
- // Install plugin.
- $this->install();
-
- // Activate plugin.
- $result = activate_plugin( $this->get_plugin(), '', is_multisite() );
-
- if ( is_wp_error( $result ) ) {
- $this->set_error( $result );
- }
-
- wp_safe_redirect( wp_get_referer() );
- exit;
- }
-
- /**
- * Install plugin.
- *
- * @return void
- */
- private function install() {
- if ( $this->is_installed() ) {
- return;
- }
-
- $upgrader_class = ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
-
- if ( ! defined( 'ABSPATH' ) || ! file_exists( $upgrader_class ) ) {
- wp_die(
- 'Plugin Installation failed. class-wp-upgrader.php not found',
- '',
- [ 'back_link' => true ]
- );
- }
-
- require_once $upgrader_class; // @phpstan-ignore-line
-
- $upgrader = new \Plugin_Upgrader( new \Automatic_Upgrader_Skin() );
- $result = $upgrader->install( $this->get_download_url() );
-
- if ( is_wp_error( $result ) ) {
- $this->set_error( $result );
- }
-
- clearstatcache();
- }
-
- /**
- * Check if plugin is installed.
- *
- * @return boolean
- */
- private function is_installed(): bool {
- return file_exists( WP_PLUGIN_DIR . '/' . $this->get_plugin() );
- }
-
- /**
- * Check if installation is allowed.
- *
- * @return boolean
- */
- private function is_allowed(): bool {
- if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET['_wpnonce'] ) ), 'plugin_family_install_' . $this->get_slug() ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated
- return false;
- }
-
- if ( ! current_user_can( is_multisite() ? 'manage_network_plugins' : 'install_plugins' ) ) {
- return false;
- }
-
- return true;
- }
-
- /**
- * Get plugin slug.
- *
- * @return string
- */
- private function get_slug(): string {
- return dirname( rawurldecode( sanitize_text_field( wp_unslash( $_GET['plugin_to_install'] ) ) ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotValidated
- }
-
- /**
- * Get plugin identifier.
- *
- * @return string
- */
- private function get_plugin(): string {
- return rawurldecode( sanitize_text_field( wp_unslash( $_GET['plugin_to_install'] ) ) ) . '.php'; // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotValidated
- }
-
- /**
- * Get plugin download url.
- *
- * @return string
- */
- private function get_download_url(): string {
-
- $slug = $this->get_slug();
-
- $custom_download_url = $this->maybe_get_custom_download_url( $slug );
-
- if ( false !== $custom_download_url ) {
- return $custom_download_url;
- }
-
- $plugin_install = ABSPATH . 'wp-admin/includes/plugin-install.php';
-
- if ( ! defined( 'ABSPATH' ) || ! file_exists( $plugin_install ) ) {
- wp_die(
- 'Plugin Installation failed. plugin-install.php not found',
- '',
- [ 'back_link' => true ]
- );
- }
-
- require_once $plugin_install; // @phpstan-ignore-line
-
- $data = [
- 'slug' => $slug,
- 'fields' => [
- 'download_link' => true,
- 'short_description' => false,
- 'sections' => false,
- 'rating' => false,
- 'ratings' => false,
- 'downloaded' => false,
- 'last_updated' => false,
- 'added' => false,
- 'tags' => false,
- 'homepage' => false,
- 'donate_link' => false,
- ],
- ];
-
- // Get Plugin Infos.
- $plugin_info = plugins_api( 'plugin_information', $data );
-
- if ( is_wp_error( $plugin_info ) ) {
- $this->set_error( $plugin_info );
- }
-
- // Ensure that $plugin_info is an object before accessing the property.
- if ( ! is_object( $plugin_info ) || ! isset( $plugin_info->download_link ) ) {
- return '';
- }
-
- return $plugin_info->download_link;
- }
-
- /**
- * Maybe display error notice.
- *
- * @return void
- */
- public function display_error_notice() {
- $errors = get_transient( $this->error_transient );
-
- if ( ! $errors ) {
- return;
- }
-
- if ( ! is_wp_error( $errors ) ) {
- delete_transient( $this->error_transient );
- return;
- }
-
- $errors = $errors->get_error_messages();
-
- if ( ! $errors ) {
- $errors[] = 'Installation process failed';
- }
-
- $notice = '
' . implode( '
', $errors ) . '
';
- echo wp_kses_post( $notice );
-
- // Remove transient after displaying notice.
- delete_transient( $this->error_transient );
- }
-
- /**
- * Store an error message in a transient then redirect.
- *
- * @param object $error A WP_Error object.
- * @return void
- */
- private function set_error( $error ) {
- set_transient( $this->error_transient, $error, 30 );
-
- wp_safe_redirect( wp_get_referer() );
- exit;
- }
-
- /**
- * Returns a custom download url for plugin if exists.
- *
- * @param string $plugin_slug plugin slug.
- * @return string|bool
- */
- private function maybe_get_custom_download_url( string $plugin_slug ) {
- $parent_plugin_slug = $this->get_parent_plugin_slug();
-
- $urls = [
- 'seo-by-rank-math' => 'https://rankmath.com/downloads/plugin-family/' . $parent_plugin_slug,
- ];
-
- if ( ! isset( $urls[ $plugin_slug ] ) ) {
- return false;
- }
-
- return $urls[ $plugin_slug ];
- }
-
- /**
- * Get parent plugin slug.
- *
- * @return string
- */
- private function get_parent_plugin_slug(): string {
- $plugin_path = plugin_basename( __FILE__ );
- $chunks = explode( '/', $plugin_path );
-
- return $chunks[0];
- }
-}
diff --git a/classes/Dependencies/autoload.php b/classes/Dependencies/autoload.php
new file mode 100644
index 000000000..99b958020
--- /dev/null
+++ b/classes/Dependencies/autoload.php
@@ -0,0 +1,22 @@
+
+ * Jordi Boggiano
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Imagify\Dependencies\Composer\Autoload;
+
+/**
+ * ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
+ *
+ * $loader = new \Imagify\Dependencies\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
+ * @author Jordi Boggiano
+ * @see https://www.php-fig.org/psr/psr-0/
+ * @see https://www.php-fig.org/psr/psr-4/
+ */
+class ClassLoader
+{
+ /** @var \Closure(string):void */
+ private static $includeFile;
+
+ /** @var string|null */
+ private $vendorDir;
+
+ // PSR-4
+ /**
+ * @var array>
+ */
+ private $prefixLengthsPsr4 = array();
+ /**
+ * @var array>
+ */
+ private $prefixDirsPsr4 = array();
+ /**
+ * @var list
+ */
+ private $fallbackDirsPsr4 = array();
+
+ // PSR-0
+ /**
+ * List of PSR-0 prefixes
+ *
+ * Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2')))
+ *
+ * @var array>>
+ */
+ private $prefixesPsr0 = array();
+ /**
+ * @var list
+ */
+ private $fallbackDirsPsr0 = array();
+
+ /** @var bool */
+ private $useIncludePath = false;
+
+ /**
+ * @var array
+ */
+ private $classMap = array();
+
+ /** @var bool */
+ private $classMapAuthoritative = false;
+
+ /**
+ * @var array
+ */
+ private $missingClasses = array();
+
+ /** @var string|null */
+ private $apcuPrefix;
+
+ /**
+ * @var array
+ */
+ private static $registeredLoaders = array();
+
+ /**
+ * @param string|null $vendorDir
+ */
+ public function __construct($vendorDir = null)
+ {
+ $this->vendorDir = $vendorDir;
+ self::initializeIncludeClosure();
+ }
+
+ /**
+ * @return array>
+ */
+ public function getPrefixes()
+ {
+ if (!empty($this->prefixesPsr0)) {
+ return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
+ }
+
+ return array();
+ }
+
+ /**
+ * @return array>
+ */
+ public function getPrefixesPsr4()
+ {
+ return $this->prefixDirsPsr4;
+ }
+
+ /**
+ * @return list
+ */
+ public function getFallbackDirs()
+ {
+ return $this->fallbackDirsPsr0;
+ }
+
+ /**
+ * @return list
+ */
+ public function getFallbackDirsPsr4()
+ {
+ return $this->fallbackDirsPsr4;
+ }
+
+ /**
+ * @return array Array of classname => path
+ */
+ public function getClassMap()
+ {
+ return $this->classMap;
+ }
+
+ /**
+ * @param array $classMap Class to filename map
+ *
+ * @return void
+ */
+ 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 list|string $paths The PSR-0 root directories
+ * @param bool $prepend Whether to prepend the directories
+ *
+ * @return void
+ */
+ public function add($prefix, $paths, $prepend = false)
+ {
+ $paths = (array) $paths;
+ if (!$prefix) {
+ if ($prepend) {
+ $this->fallbackDirsPsr0 = array_merge(
+ $paths,
+ $this->fallbackDirsPsr0
+ );
+ } else {
+ $this->fallbackDirsPsr0 = array_merge(
+ $this->fallbackDirsPsr0,
+ $paths
+ );
+ }
+
+ return;
+ }
+
+ $first = $prefix[0];
+ if (!isset($this->prefixesPsr0[$first][$prefix])) {
+ $this->prefixesPsr0[$first][$prefix] = $paths;
+
+ return;
+ }
+ if ($prepend) {
+ $this->prefixesPsr0[$first][$prefix] = array_merge(
+ $paths,
+ $this->prefixesPsr0[$first][$prefix]
+ );
+ } else {
+ $this->prefixesPsr0[$first][$prefix] = array_merge(
+ $this->prefixesPsr0[$first][$prefix],
+ $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 list|string $paths The PSR-4 base directories
+ * @param bool $prepend Whether to prepend the directories
+ *
+ * @throws \InvalidArgumentException
+ *
+ * @return void
+ */
+ public function addPsr4($prefix, $paths, $prepend = false)
+ {
+ $paths = (array) $paths;
+ if (!$prefix) {
+ // Register directories for the root namespace.
+ if ($prepend) {
+ $this->fallbackDirsPsr4 = array_merge(
+ $paths,
+ $this->fallbackDirsPsr4
+ );
+ } else {
+ $this->fallbackDirsPsr4 = array_merge(
+ $this->fallbackDirsPsr4,
+ $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] = $paths;
+ } elseif ($prepend) {
+ // Prepend directories for an already registered namespace.
+ $this->prefixDirsPsr4[$prefix] = array_merge(
+ $paths,
+ $this->prefixDirsPsr4[$prefix]
+ );
+ } else {
+ // Append directories for an already registered namespace.
+ $this->prefixDirsPsr4[$prefix] = array_merge(
+ $this->prefixDirsPsr4[$prefix],
+ $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 list|string $paths The PSR-0 base directories
+ *
+ * @return void
+ */
+ 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 list|string $paths The PSR-4 base directories
+ *
+ * @throws \InvalidArgumentException
+ *
+ * @return void
+ */
+ 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
+ *
+ * @return void
+ */
+ 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
+ *
+ * @return void
+ */
+ 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
+ *
+ * @return void
+ */
+ public function setApcuPrefix($apcuPrefix)
+ {
+ $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $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
+ *
+ * @return void
+ */
+ public function register($prepend = false)
+ {
+ spl_autoload_register(array($this, 'loadClass'), true, $prepend);
+
+ if (null === $this->vendorDir) {
+ return;
+ }
+
+ if ($prepend) {
+ self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
+ } else {
+ unset(self::$registeredLoaders[$this->vendorDir]);
+ self::$registeredLoaders[$this->vendorDir] = $this;
+ }
+ }
+
+ /**
+ * Unregisters this instance as an autoloader.
+ *
+ * @return void
+ */
+ public function unregister()
+ {
+ spl_autoload_unregister(array($this, 'loadClass'));
+
+ if (null !== $this->vendorDir) {
+ unset(self::$registeredLoaders[$this->vendorDir]);
+ }
+ }
+
+ /**
+ * Loads the given class or interface.
+ *
+ * @param string $class The name of the class
+ * @return true|null True if loaded, null otherwise
+ */
+ public function loadClass($class)
+ {
+ if ($file = $this->findFile($class)) {
+ $includeFile = self::$includeFile;
+ $includeFile($file);
+
+ return true;
+ }
+
+ return null;
+ }
+
+ /**
+ * 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;
+ }
+
+ /**
+ * Returns the currently registered loaders keyed by their corresponding vendor directories.
+ *
+ * @return array
+ */
+ public static function getRegisteredLoaders()
+ {
+ return self::$registeredLoaders;
+ }
+
+ /**
+ * @param string $class
+ * @param string $ext
+ * @return string|false
+ */
+ 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])) {
+ $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
+ foreach ($this->prefixDirsPsr4[$search] as $dir) {
+ if (file_exists($file = $dir . $pathEnd)) {
+ 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;
+ }
+
+ /**
+ * @return void
+ */
+ private static function initializeIncludeClosure()
+ {
+ if (self::$includeFile !== null) {
+ return;
+ }
+
+ /**
+ * Scope isolated include.
+ *
+ * Prevents access to $this/self from included files.
+ *
+ * @param string $file
+ * @return void
+ */
+ self::$includeFile = \Closure::bind(static function($file) {
+ include $file;
+ }, null, null);
+ }
+}
diff --git a/classes/Dependencies/composer/InstalledVersions.php b/classes/Dependencies/composer/InstalledVersions.php
new file mode 100644
index 000000000..da10c4726
--- /dev/null
+++ b/classes/Dependencies/composer/InstalledVersions.php
@@ -0,0 +1,359 @@
+
+ * Jordi Boggiano
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Imagify\Dependencies\Composer;
+
+use Imagify\Dependencies\Composer\Autoload\ClassLoader;
+use Imagify\Dependencies\Composer\Semver\VersionParser;
+
+/**
+ * This class is copied in every Composer installed project and available to all
+ *
+ * See also https://getcomposer.org/doc/07-runtime.md#installed-versions
+ *
+ * To require its presence, you can require `composer-runtime-api ^2.0`
+ *
+ * @final
+ */
+class InstalledVersions
+{
+ /**
+ * @var mixed[]|null
+ * @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array}|array{}|null
+ */
+ private static $installed;
+
+ /**
+ * @var bool|null
+ */
+ private static $canGetVendors;
+
+ /**
+ * @var array[]
+ * @psalm-var array}>
+ */
+ private static $installedByVendor = array();
+
+ /**
+ * Returns a list of all package names which are present, either by being installed, replaced or provided
+ *
+ * @return string[]
+ * @psalm-return list
+ */
+ public static function getInstalledPackages()
+ {
+ $packages = array();
+ foreach (self::getInstalled() as $installed) {
+ $packages[] = array_keys($installed['versions']);
+ }
+
+ if (1 === \count($packages)) {
+ return $packages[0];
+ }
+
+ return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
+ }
+
+ /**
+ * Returns a list of all package names with a specific type e.g. 'library'
+ *
+ * @param string $type
+ * @return string[]
+ * @psalm-return list
+ */
+ public static function getInstalledPackagesByType($type)
+ {
+ $packagesByType = array();
+
+ foreach (self::getInstalled() as $installed) {
+ foreach ($installed['versions'] as $name => $package) {
+ if (isset($package['type']) && $package['type'] === $type) {
+ $packagesByType[] = $name;
+ }
+ }
+ }
+
+ return $packagesByType;
+ }
+
+ /**
+ * Checks whether the given package is installed
+ *
+ * This also returns true if the package name is provided or replaced by another package
+ *
+ * @param string $packageName
+ * @param bool $includeDevRequirements
+ * @return bool
+ */
+ public static function isInstalled($packageName, $includeDevRequirements = true)
+ {
+ foreach (self::getInstalled() as $installed) {
+ if (isset($installed['versions'][$packageName])) {
+ return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Checks whether the given package satisfies a version constraint
+ *
+ * e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call:
+ *
+ * Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3')
+ *
+ * @param VersionParser $parser Install composer/semver to have access to this class and functionality
+ * @param string $packageName
+ * @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package
+ * @return bool
+ */
+ public static function satisfies(VersionParser $parser, $packageName, $constraint)
+ {
+ $constraint = $parser->parseConstraints((string) $constraint);
+ $provided = $parser->parseConstraints(self::getVersionRanges($packageName));
+
+ return $provided->matches($constraint);
+ }
+
+ /**
+ * Returns a version constraint representing all the range(s) which are installed for a given package
+ *
+ * It is easier to use this via isInstalled() with the $constraint argument if you need to check
+ * whether a given version of a package is installed, and not just whether it exists
+ *
+ * @param string $packageName
+ * @return string Version constraint usable with composer/semver
+ */
+ public static function getVersionRanges($packageName)
+ {
+ foreach (self::getInstalled() as $installed) {
+ if (!isset($installed['versions'][$packageName])) {
+ continue;
+ }
+
+ $ranges = array();
+ if (isset($installed['versions'][$packageName]['pretty_version'])) {
+ $ranges[] = $installed['versions'][$packageName]['pretty_version'];
+ }
+ if (array_key_exists('aliases', $installed['versions'][$packageName])) {
+ $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
+ }
+ if (array_key_exists('replaced', $installed['versions'][$packageName])) {
+ $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
+ }
+ if (array_key_exists('provided', $installed['versions'][$packageName])) {
+ $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
+ }
+
+ return implode(' || ', $ranges);
+ }
+
+ throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
+ }
+
+ /**
+ * @param string $packageName
+ * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
+ */
+ public static function getVersion($packageName)
+ {
+ foreach (self::getInstalled() as $installed) {
+ if (!isset($installed['versions'][$packageName])) {
+ continue;
+ }
+
+ if (!isset($installed['versions'][$packageName]['version'])) {
+ return null;
+ }
+
+ return $installed['versions'][$packageName]['version'];
+ }
+
+ throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
+ }
+
+ /**
+ * @param string $packageName
+ * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
+ */
+ public static function getPrettyVersion($packageName)
+ {
+ foreach (self::getInstalled() as $installed) {
+ if (!isset($installed['versions'][$packageName])) {
+ continue;
+ }
+
+ if (!isset($installed['versions'][$packageName]['pretty_version'])) {
+ return null;
+ }
+
+ return $installed['versions'][$packageName]['pretty_version'];
+ }
+
+ throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
+ }
+
+ /**
+ * @param string $packageName
+ * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference
+ */
+ public static function getReference($packageName)
+ {
+ foreach (self::getInstalled() as $installed) {
+ if (!isset($installed['versions'][$packageName])) {
+ continue;
+ }
+
+ if (!isset($installed['versions'][$packageName]['reference'])) {
+ return null;
+ }
+
+ return $installed['versions'][$packageName]['reference'];
+ }
+
+ throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
+ }
+
+ /**
+ * @param string $packageName
+ * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path.
+ */
+ public static function getInstallPath($packageName)
+ {
+ foreach (self::getInstalled() as $installed) {
+ if (!isset($installed['versions'][$packageName])) {
+ continue;
+ }
+
+ return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null;
+ }
+
+ throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
+ }
+
+ /**
+ * @return array
+ * @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}
+ */
+ public static function getRootPackage()
+ {
+ $installed = self::getInstalled();
+
+ return $installed[0]['root'];
+ }
+
+ /**
+ * Returns the raw installed.php data for custom implementations
+ *
+ * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
+ * @return array[]
+ * @psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array}
+ */
+ public static function getRawData()
+ {
+ @trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED);
+
+ if (null === self::$installed) {
+ // only require the installed.php file if this file is loaded from its dumped location,
+ // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
+ if (substr(__DIR__, -8, 1) !== 'C') {
+ self::$installed = include __DIR__ . '/installed.php';
+ } else {
+ self::$installed = array();
+ }
+ }
+
+ return self::$installed;
+ }
+
+ /**
+ * Returns the raw data of all installed.php which are currently loaded for custom implementations
+ *
+ * @return array[]
+ * @psalm-return list}>
+ */
+ public static function getAllRawData()
+ {
+ return self::getInstalled();
+ }
+
+ /**
+ * Lets you reload the static array from another file
+ *
+ * This is only useful for complex integrations in which a project needs to use
+ * this class but then also needs to execute another project's autoloader in process,
+ * and wants to ensure both projects have access to their version of installed.php.
+ *
+ * A typical case would be PHPUnit, where it would need to make sure it reads all
+ * the data it needs from this class, then call reload() with
+ * `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure
+ * the project in which it runs can then also use this class safely, without
+ * interference between PHPUnit's dependencies and the project's dependencies.
+ *
+ * @param array[] $data A vendor/composer/installed.php data set
+ * @return void
+ *
+ * @psalm-param array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $data
+ */
+ public static function reload($data)
+ {
+ self::$installed = $data;
+ self::$installedByVendor = array();
+ }
+
+ /**
+ * @return array[]
+ * @psalm-return list}>
+ */
+ private static function getInstalled()
+ {
+ if (null === self::$canGetVendors) {
+ self::$canGetVendors = method_exists('Imagify\Dependencies\Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
+ }
+
+ $installed = array();
+
+ if (self::$canGetVendors) {
+ foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
+ if (isset(self::$installedByVendor[$vendorDir])) {
+ $installed[] = self::$installedByVendor[$vendorDir];
+ } elseif (is_file($vendorDir.'/composer/installed.php')) {
+ /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $required */
+ $required = require $vendorDir.'/composer/installed.php';
+ $installed[] = self::$installedByVendor[$vendorDir] = $required;
+ if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
+ self::$installed = $installed[count($installed) - 1];
+ }
+ }
+ }
+ }
+
+ if (null === self::$installed) {
+ // only require the installed.php file if this file is loaded from its dumped location,
+ // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
+ if (substr(__DIR__, -8, 1) !== 'C') {
+ /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $required */
+ $required = require __DIR__ . '/installed.php';
+ self::$installed = $required;
+ } else {
+ self::$installed = array();
+ }
+ }
+
+ if (self::$installed !== array()) {
+ $installed[] = self::$installed;
+ }
+
+ return $installed;
+ }
+}
diff --git a/classes/Dependencies/composer/LICENSE b/classes/Dependencies/composer/LICENSE
new file mode 100644
index 000000000..62ecfd8d0
--- /dev/null
+++ b/classes/Dependencies/composer/LICENSE
@@ -0,0 +1,19 @@
+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.
diff --git a/classes/Dependencies/composer/autoload_classmap.php b/classes/Dependencies/composer/autoload_classmap.php
new file mode 100644
index 000000000..213850225
--- /dev/null
+++ b/classes/Dependencies/composer/autoload_classmap.php
@@ -0,0 +1,55 @@
+ $vendorDir . '/composer/InstalledVersions.php',
+ 'Imagify\\Dependencies\\League\\Container\\Argument\\ArgumentInterface' => $vendorDir . '/league/container/src/Argument/ArgumentInterface.php',
+ 'Imagify\\Dependencies\\League\\Container\\Argument\\ArgumentResolverInterface' => $vendorDir . '/league/container/src/Argument/ArgumentResolverInterface.php',
+ 'Imagify\\Dependencies\\League\\Container\\Argument\\ArgumentResolverTrait' => $vendorDir . '/league/container/src/Argument/ArgumentResolverTrait.php',
+ 'Imagify\\Dependencies\\League\\Container\\Argument\\DefaultValueArgument' => $vendorDir . '/league/container/src/Argument/DefaultValueArgument.php',
+ 'Imagify\\Dependencies\\League\\Container\\Argument\\DefaultValueInterface' => $vendorDir . '/league/container/src/Argument/DefaultValueInterface.php',
+ 'Imagify\\Dependencies\\League\\Container\\Argument\\LiteralArgument' => $vendorDir . '/league/container/src/Argument/LiteralArgument.php',
+ 'Imagify\\Dependencies\\League\\Container\\Argument\\LiteralArgumentInterface' => $vendorDir . '/league/container/src/Argument/LiteralArgumentInterface.php',
+ 'Imagify\\Dependencies\\League\\Container\\Argument\\Literal\\ArrayArgument' => $vendorDir . '/league/container/src/Argument/Literal/ArrayArgument.php',
+ 'Imagify\\Dependencies\\League\\Container\\Argument\\Literal\\BooleanArgument' => $vendorDir . '/league/container/src/Argument/Literal/BooleanArgument.php',
+ 'Imagify\\Dependencies\\League\\Container\\Argument\\Literal\\CallableArgument' => $vendorDir . '/league/container/src/Argument/Literal/CallableArgument.php',
+ 'Imagify\\Dependencies\\League\\Container\\Argument\\Literal\\FloatArgument' => $vendorDir . '/league/container/src/Argument/Literal/FloatArgument.php',
+ 'Imagify\\Dependencies\\League\\Container\\Argument\\Literal\\IntegerArgument' => $vendorDir . '/league/container/src/Argument/Literal/IntegerArgument.php',
+ 'Imagify\\Dependencies\\League\\Container\\Argument\\Literal\\ObjectArgument' => $vendorDir . '/league/container/src/Argument/Literal/ObjectArgument.php',
+ 'Imagify\\Dependencies\\League\\Container\\Argument\\Literal\\StringArgument' => $vendorDir . '/league/container/src/Argument/Literal/StringArgument.php',
+ 'Imagify\\Dependencies\\League\\Container\\Argument\\ResolvableArgument' => $vendorDir . '/league/container/src/Argument/ResolvableArgument.php',
+ 'Imagify\\Dependencies\\League\\Container\\Argument\\ResolvableArgumentInterface' => $vendorDir . '/league/container/src/Argument/ResolvableArgumentInterface.php',
+ 'Imagify\\Dependencies\\League\\Container\\Container' => $vendorDir . '/league/container/src/Container.php',
+ 'Imagify\\Dependencies\\League\\Container\\ContainerAwareInterface' => $vendorDir . '/league/container/src/ContainerAwareInterface.php',
+ 'Imagify\\Dependencies\\League\\Container\\ContainerAwareTrait' => $vendorDir . '/league/container/src/ContainerAwareTrait.php',
+ 'Imagify\\Dependencies\\League\\Container\\DefinitionContainerInterface' => $vendorDir . '/league/container/src/DefinitionContainerInterface.php',
+ 'Imagify\\Dependencies\\League\\Container\\Definition\\Definition' => $vendorDir . '/league/container/src/Definition/Definition.php',
+ 'Imagify\\Dependencies\\League\\Container\\Definition\\DefinitionAggregate' => $vendorDir . '/league/container/src/Definition/DefinitionAggregate.php',
+ 'Imagify\\Dependencies\\League\\Container\\Definition\\DefinitionAggregateInterface' => $vendorDir . '/league/container/src/Definition/DefinitionAggregateInterface.php',
+ 'Imagify\\Dependencies\\League\\Container\\Definition\\DefinitionInterface' => $vendorDir . '/league/container/src/Definition/DefinitionInterface.php',
+ 'Imagify\\Dependencies\\League\\Container\\Exception\\ContainerException' => $vendorDir . '/league/container/src/Exception/ContainerException.php',
+ 'Imagify\\Dependencies\\League\\Container\\Exception\\NotFoundException' => $vendorDir . '/league/container/src/Exception/NotFoundException.php',
+ 'Imagify\\Dependencies\\League\\Container\\Inflector\\Inflector' => $vendorDir . '/league/container/src/Inflector/Inflector.php',
+ 'Imagify\\Dependencies\\League\\Container\\Inflector\\InflectorAggregate' => $vendorDir . '/league/container/src/Inflector/InflectorAggregate.php',
+ 'Imagify\\Dependencies\\League\\Container\\Inflector\\InflectorAggregateInterface' => $vendorDir . '/league/container/src/Inflector/InflectorAggregateInterface.php',
+ 'Imagify\\Dependencies\\League\\Container\\Inflector\\InflectorInterface' => $vendorDir . '/league/container/src/Inflector/InflectorInterface.php',
+ 'Imagify\\Dependencies\\League\\Container\\ReflectionContainer' => $vendorDir . '/league/container/src/ReflectionContainer.php',
+ 'Imagify\\Dependencies\\League\\Container\\ServiceProvider\\AbstractServiceProvider' => $vendorDir . '/league/container/src/ServiceProvider/AbstractServiceProvider.php',
+ 'Imagify\\Dependencies\\League\\Container\\ServiceProvider\\BootableServiceProviderInterface' => $vendorDir . '/league/container/src/ServiceProvider/BootableServiceProviderInterface.php',
+ 'Imagify\\Dependencies\\League\\Container\\ServiceProvider\\ServiceProviderAggregate' => $vendorDir . '/league/container/src/ServiceProvider/ServiceProviderAggregate.php',
+ 'Imagify\\Dependencies\\League\\Container\\ServiceProvider\\ServiceProviderAggregateInterface' => $vendorDir . '/league/container/src/ServiceProvider/ServiceProviderAggregateInterface.php',
+ 'Imagify\\Dependencies\\League\\Container\\ServiceProvider\\ServiceProviderInterface' => $vendorDir . '/league/container/src/ServiceProvider/ServiceProviderInterface.php',
+ 'Imagify\\Dependencies\\Psr\\Container\\ContainerExceptionInterface' => $vendorDir . '/psr/container/src/ContainerExceptionInterface.php',
+ 'Imagify\\Dependencies\\Psr\\Container\\ContainerInterface' => $vendorDir . '/psr/container/src/ContainerInterface.php',
+ 'Imagify\\Dependencies\\Psr\\Container\\NotFoundExceptionInterface' => $vendorDir . '/psr/container/src/NotFoundExceptionInterface.php',
+ 'Imagify\\Dependencies\\WPMedia\\PluginFamily\\Controller\\PluginFamily' => $vendorDir . '/wp-media/plugin-family/src/Controller/PluginFamily.php',
+ 'Imagify\\Dependencies\\WPMedia\\PluginFamily\\Controller\\PluginFamilyInterface' => $vendorDir . '/wp-media/plugin-family/src/Controller/PluginFamilyInterface.php',
+ 'Imagify\\Dependencies\\WPMedia\\PluginFamily\\Model\\PluginFamily' => $vendorDir . '/wp-media/plugin-family/src/Model/PluginFamily.php',
+ 'Imagify\\Dependencies\\WPMedia\\PluginFamily\\PostInstall' => $vendorDir . '/wp-media/plugin-family/src/PostInstall.php',
+ 'Imagify_WP_Async_Request' => $vendorDir . '/deliciousbrains/wp-background-processing/classes/wp-async-request.php',
+ 'Imagify_WP_Background_Process' => $vendorDir . '/deliciousbrains/wp-background-processing/classes/wp-background-process.php',
+);
diff --git a/classes/Dependencies/composer/autoload_namespaces.php b/classes/Dependencies/composer/autoload_namespaces.php
new file mode 100644
index 000000000..f1ae7a0ff
--- /dev/null
+++ b/classes/Dependencies/composer/autoload_namespaces.php
@@ -0,0 +1,9 @@
+ array($vendorDir . '/wp-media/plugin-family/src'),
+ 'Imagify\\Dependencies\\Psr\\Container\\' => array($vendorDir . '/psr/container/src'),
+ 'Imagify\\Dependencies\\League\\Container\\' => array($vendorDir . '/league/container/src'),
+);
diff --git a/classes/Dependencies/composer/autoload_real.php b/classes/Dependencies/composer/autoload_real.php
new file mode 100644
index 000000000..186b00248
--- /dev/null
+++ b/classes/Dependencies/composer/autoload_real.php
@@ -0,0 +1,39 @@
+setClassMapAuthoritative(true);
+ $loader->register(true);
+
+ return $loader;
+ }
+}
diff --git a/classes/Dependencies/composer/autoload_static.php b/classes/Dependencies/composer/autoload_static.php
new file mode 100644
index 000000000..d84874cba
--- /dev/null
+++ b/classes/Dependencies/composer/autoload_static.php
@@ -0,0 +1,91 @@
+
+ array (
+ 'Imagify\\Dependencies\\WPMedia\\PluginFamily\\' => 42,
+ 'Imagify\\Dependencies\\Psr\\Container\\' => 35,
+ 'Imagify\\Dependencies\\League\\Container\\' => 38,
+ ),
+ );
+
+ public static $prefixDirsPsr4 = array (
+ 'Imagify\\Dependencies\\WPMedia\\PluginFamily\\' =>
+ array (
+ 0 => __DIR__ . '/..' . '/wp-media/plugin-family/src',
+ ),
+ 'Imagify\\Dependencies\\Psr\\Container\\' =>
+ array (
+ 0 => __DIR__ . '/..' . '/psr/container/src',
+ ),
+ 'Imagify\\Dependencies\\League\\Container\\' =>
+ array (
+ 0 => __DIR__ . '/..' . '/league/container/src',
+ ),
+ );
+
+ public static $classMap = array (
+ 'Imagify\\Dependencies\\Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
+ 'Imagify\\Dependencies\\League\\Container\\Argument\\ArgumentInterface' => __DIR__ . '/..' . '/league/container/src/Argument/ArgumentInterface.php',
+ 'Imagify\\Dependencies\\League\\Container\\Argument\\ArgumentResolverInterface' => __DIR__ . '/..' . '/league/container/src/Argument/ArgumentResolverInterface.php',
+ 'Imagify\\Dependencies\\League\\Container\\Argument\\ArgumentResolverTrait' => __DIR__ . '/..' . '/league/container/src/Argument/ArgumentResolverTrait.php',
+ 'Imagify\\Dependencies\\League\\Container\\Argument\\DefaultValueArgument' => __DIR__ . '/..' . '/league/container/src/Argument/DefaultValueArgument.php',
+ 'Imagify\\Dependencies\\League\\Container\\Argument\\DefaultValueInterface' => __DIR__ . '/..' . '/league/container/src/Argument/DefaultValueInterface.php',
+ 'Imagify\\Dependencies\\League\\Container\\Argument\\LiteralArgument' => __DIR__ . '/..' . '/league/container/src/Argument/LiteralArgument.php',
+ 'Imagify\\Dependencies\\League\\Container\\Argument\\LiteralArgumentInterface' => __DIR__ . '/..' . '/league/container/src/Argument/LiteralArgumentInterface.php',
+ 'Imagify\\Dependencies\\League\\Container\\Argument\\Literal\\ArrayArgument' => __DIR__ . '/..' . '/league/container/src/Argument/Literal/ArrayArgument.php',
+ 'Imagify\\Dependencies\\League\\Container\\Argument\\Literal\\BooleanArgument' => __DIR__ . '/..' . '/league/container/src/Argument/Literal/BooleanArgument.php',
+ 'Imagify\\Dependencies\\League\\Container\\Argument\\Literal\\CallableArgument' => __DIR__ . '/..' . '/league/container/src/Argument/Literal/CallableArgument.php',
+ 'Imagify\\Dependencies\\League\\Container\\Argument\\Literal\\FloatArgument' => __DIR__ . '/..' . '/league/container/src/Argument/Literal/FloatArgument.php',
+ 'Imagify\\Dependencies\\League\\Container\\Argument\\Literal\\IntegerArgument' => __DIR__ . '/..' . '/league/container/src/Argument/Literal/IntegerArgument.php',
+ 'Imagify\\Dependencies\\League\\Container\\Argument\\Literal\\ObjectArgument' => __DIR__ . '/..' . '/league/container/src/Argument/Literal/ObjectArgument.php',
+ 'Imagify\\Dependencies\\League\\Container\\Argument\\Literal\\StringArgument' => __DIR__ . '/..' . '/league/container/src/Argument/Literal/StringArgument.php',
+ 'Imagify\\Dependencies\\League\\Container\\Argument\\ResolvableArgument' => __DIR__ . '/..' . '/league/container/src/Argument/ResolvableArgument.php',
+ 'Imagify\\Dependencies\\League\\Container\\Argument\\ResolvableArgumentInterface' => __DIR__ . '/..' . '/league/container/src/Argument/ResolvableArgumentInterface.php',
+ 'Imagify\\Dependencies\\League\\Container\\Container' => __DIR__ . '/..' . '/league/container/src/Container.php',
+ 'Imagify\\Dependencies\\League\\Container\\ContainerAwareInterface' => __DIR__ . '/..' . '/league/container/src/ContainerAwareInterface.php',
+ 'Imagify\\Dependencies\\League\\Container\\ContainerAwareTrait' => __DIR__ . '/..' . '/league/container/src/ContainerAwareTrait.php',
+ 'Imagify\\Dependencies\\League\\Container\\DefinitionContainerInterface' => __DIR__ . '/..' . '/league/container/src/DefinitionContainerInterface.php',
+ 'Imagify\\Dependencies\\League\\Container\\Definition\\Definition' => __DIR__ . '/..' . '/league/container/src/Definition/Definition.php',
+ 'Imagify\\Dependencies\\League\\Container\\Definition\\DefinitionAggregate' => __DIR__ . '/..' . '/league/container/src/Definition/DefinitionAggregate.php',
+ 'Imagify\\Dependencies\\League\\Container\\Definition\\DefinitionAggregateInterface' => __DIR__ . '/..' . '/league/container/src/Definition/DefinitionAggregateInterface.php',
+ 'Imagify\\Dependencies\\League\\Container\\Definition\\DefinitionInterface' => __DIR__ . '/..' . '/league/container/src/Definition/DefinitionInterface.php',
+ 'Imagify\\Dependencies\\League\\Container\\Exception\\ContainerException' => __DIR__ . '/..' . '/league/container/src/Exception/ContainerException.php',
+ 'Imagify\\Dependencies\\League\\Container\\Exception\\NotFoundException' => __DIR__ . '/..' . '/league/container/src/Exception/NotFoundException.php',
+ 'Imagify\\Dependencies\\League\\Container\\Inflector\\Inflector' => __DIR__ . '/..' . '/league/container/src/Inflector/Inflector.php',
+ 'Imagify\\Dependencies\\League\\Container\\Inflector\\InflectorAggregate' => __DIR__ . '/..' . '/league/container/src/Inflector/InflectorAggregate.php',
+ 'Imagify\\Dependencies\\League\\Container\\Inflector\\InflectorAggregateInterface' => __DIR__ . '/..' . '/league/container/src/Inflector/InflectorAggregateInterface.php',
+ 'Imagify\\Dependencies\\League\\Container\\Inflector\\InflectorInterface' => __DIR__ . '/..' . '/league/container/src/Inflector/InflectorInterface.php',
+ 'Imagify\\Dependencies\\League\\Container\\ReflectionContainer' => __DIR__ . '/..' . '/league/container/src/ReflectionContainer.php',
+ 'Imagify\\Dependencies\\League\\Container\\ServiceProvider\\AbstractServiceProvider' => __DIR__ . '/..' . '/league/container/src/ServiceProvider/AbstractServiceProvider.php',
+ 'Imagify\\Dependencies\\League\\Container\\ServiceProvider\\BootableServiceProviderInterface' => __DIR__ . '/..' . '/league/container/src/ServiceProvider/BootableServiceProviderInterface.php',
+ 'Imagify\\Dependencies\\League\\Container\\ServiceProvider\\ServiceProviderAggregate' => __DIR__ . '/..' . '/league/container/src/ServiceProvider/ServiceProviderAggregate.php',
+ 'Imagify\\Dependencies\\League\\Container\\ServiceProvider\\ServiceProviderAggregateInterface' => __DIR__ . '/..' . '/league/container/src/ServiceProvider/ServiceProviderAggregateInterface.php',
+ 'Imagify\\Dependencies\\League\\Container\\ServiceProvider\\ServiceProviderInterface' => __DIR__ . '/..' . '/league/container/src/ServiceProvider/ServiceProviderInterface.php',
+ 'Imagify\\Dependencies\\Psr\\Container\\ContainerExceptionInterface' => __DIR__ . '/..' . '/psr/container/src/ContainerExceptionInterface.php',
+ 'Imagify\\Dependencies\\Psr\\Container\\ContainerInterface' => __DIR__ . '/..' . '/psr/container/src/ContainerInterface.php',
+ 'Imagify\\Dependencies\\Psr\\Container\\NotFoundExceptionInterface' => __DIR__ . '/..' . '/psr/container/src/NotFoundExceptionInterface.php',
+ 'Imagify\\Dependencies\\WPMedia\\PluginFamily\\Controller\\PluginFamily' => __DIR__ . '/..' . '/wp-media/plugin-family/src/Controller/PluginFamily.php',
+ 'Imagify\\Dependencies\\WPMedia\\PluginFamily\\Controller\\PluginFamilyInterface' => __DIR__ . '/..' . '/wp-media/plugin-family/src/Controller/PluginFamilyInterface.php',
+ 'Imagify\\Dependencies\\WPMedia\\PluginFamily\\Model\\PluginFamily' => __DIR__ . '/..' . '/wp-media/plugin-family/src/Model/PluginFamily.php',
+ 'Imagify\\Dependencies\\WPMedia\\PluginFamily\\PostInstall' => __DIR__ . '/..' . '/wp-media/plugin-family/src/PostInstall.php',
+ 'Imagify_WP_Async_Request' => __DIR__ . '/..' . '/deliciousbrains/wp-background-processing/classes/wp-async-request.php',
+ 'Imagify_WP_Background_Process' => __DIR__ . '/..' . '/deliciousbrains/wp-background-processing/classes/wp-background-process.php',
+ );
+
+ public static function getInitializer(ClassLoader $loader)
+ {
+ return \Closure::bind(function () use ($loader) {
+ $loader->prefixLengthsPsr4 = ComposerStaticInit6503970e5795e8c75f18db09788a0b40::$prefixLengthsPsr4;
+ $loader->prefixDirsPsr4 = ComposerStaticInit6503970e5795e8c75f18db09788a0b40::$prefixDirsPsr4;
+ $loader->classMap = ComposerStaticInit6503970e5795e8c75f18db09788a0b40::$classMap;
+
+ }, null, ClassLoader::class);
+ }
+}
diff --git a/classes/Dependencies/composer/installed.json b/classes/Dependencies/composer/installed.json
new file mode 100644
index 000000000..a7e9a673a
--- /dev/null
+++ b/classes/Dependencies/composer/installed.json
@@ -0,0 +1,295 @@
+{
+ "packages": {
+ "4": {
+ "name": "deliciousbrains/wp-background-processing",
+ "version": "1.4.0",
+ "version_normalized": "1.4.0.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/deliciousbrains/wp-background-processing.git",
+ "reference": "7ca7cc3504333db3a291bbab7f1917124fba4816"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/deliciousbrains/wp-background-processing/zipball/7ca7cc3504333db3a291bbab7f1917124fba4816",
+ "reference": "7ca7cc3504333db3a291bbab7f1917124fba4816",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=7.0"
+ },
+ "require-dev": {
+ "phpcompatibility/phpcompatibility-wp": "*",
+ "phpunit/phpunit": "^8.0",
+ "spryker/code-sniffer": "^0.17.18",
+ "wp-coding-standards/wpcs": "^2.3",
+ "yoast/phpunit-polyfills": "^1.0"
+ },
+ "suggest": {
+ "coenjacobs/mozart": "Easily wrap this library with your own prefix, to prevent collisions when multiple plugins use this library"
+ },
+ "time": "2024-12-17T14:04:30+00:00",
+ "type": "library",
+ "installation-source": "dist",
+ "autoload": {
+ "classmap": [
+ "classes/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "GPL-2.0-or-later"
+ ],
+ "authors": [
+ {
+ "name": "Delicious Brains",
+ "email": "nom@deliciousbrains.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.",
+ "support": {
+ "issues": "https://github.com/deliciousbrains/wp-background-processing/issues",
+ "source": "https://github.com/deliciousbrains/wp-background-processing/tree/1.4.0"
+ },
+ "install-path": "../deliciousbrains/wp-background-processing"
+ },
+ "7": {
+ "name": "league/container",
+ "version": "4.2.5",
+ "version_normalized": "4.2.5.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/thephpleague/container.git",
+ "reference": "d3cebb0ff4685ff61c749e54b27db49319e2ec00"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/thephpleague/container/zipball/d3cebb0ff4685ff61c749e54b27db49319e2ec00",
+ "reference": "d3cebb0ff4685ff61c749e54b27db49319e2ec00",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.2 || ^8.0",
+ "psr/container": "^1.1 || ^2.0"
+ },
+ "provide": {
+ "psr/container-implementation": "^1.0"
+ },
+ "replace": {
+ "orno/di": "~2.0"
+ },
+ "require-dev": {
+ "nette/php-generator": "^3.4",
+ "nikic/php-parser": "^4.10",
+ "phpstan/phpstan": "^0.12.47",
+ "phpunit/phpunit": "^8.5.17",
+ "roave/security-advisories": "dev-latest",
+ "scrutinizer/ocular": "^1.8",
+ "squizlabs/php_codesniffer": "^3.6"
+ },
+ "time": "2025-05-20T12:55:37+00:00",
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-1.x": "1.x-dev",
+ "dev-2.x": "2.x-dev",
+ "dev-3.x": "3.x-dev",
+ "dev-4.x": "4.x-dev",
+ "dev-master": "4.x-dev"
+ }
+ },
+ "installation-source": "dist",
+ "autoload": {
+ "psr-4": {
+ "Imagify\\Dependencies\\League\\Container\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Phil Bennett",
+ "email": "mail@philbennett.co.uk",
+ "role": "Developer"
+ }
+ ],
+ "description": "A fast and intuitive dependency injection container.",
+ "homepage": "https://github.com/thephpleague/container",
+ "keywords": [
+ "container",
+ "dependency",
+ "di",
+ "injection",
+ "league",
+ "provider",
+ "service"
+ ],
+ "support": {
+ "issues": "https://github.com/thephpleague/container/issues",
+ "source": "https://github.com/thephpleague/container/tree/4.2.5"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/philipobenito",
+ "type": "github"
+ }
+ ],
+ "install-path": "../league/container"
+ },
+ "32": {
+ "name": "psr/container",
+ "version": "2.0.2",
+ "version_normalized": "2.0.2.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/php-fig/container.git",
+ "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963",
+ "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=7.4.0"
+ },
+ "time": "2021-11-05T16:47:00+00:00",
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.0.x-dev"
+ }
+ },
+ "installation-source": "dist",
+ "autoload": {
+ "psr-4": {
+ "Imagify\\Dependencies\\Psr\\Container\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "PHP-FIG",
+ "homepage": "https://www.php-fig.org/"
+ }
+ ],
+ "description": "Common Container Interface (PHP FIG PSR-11)",
+ "homepage": "https://github.com/php-fig/container",
+ "keywords": [
+ "PSR-11",
+ "container",
+ "container-interface",
+ "container-interop",
+ "psr"
+ ],
+ "support": {
+ "issues": "https://github.com/php-fig/container/issues",
+ "source": "https://github.com/php-fig/container/tree/2.0.2"
+ },
+ "install-path": "../psr/container"
+ },
+ "56": {
+ "name": "wp-media/apply-filters-typed",
+ "version": "v1.2",
+ "version_normalized": "1.2.0.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/wp-media/apply-filters-typed.git",
+ "reference": "d8f5bca83e85196d1f01d92283b63ef6f886ac4d"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/wp-media/apply-filters-typed/zipball/d8f5bca83e85196d1f01d92283b63ef6f886ac4d",
+ "reference": "d8f5bca83e85196d1f01d92283b63ef6f886ac4d",
+ "shasum": ""
+ },
+ "require-dev": {
+ "phpcompatibility/phpcompatibility-wp": "^2.0",
+ "phpstan/extension-installer": "^1.4",
+ "szepeviktor/phpstan-wordpress": "^1.3",
+ "wp-coding-standards/wpcs": "^3",
+ "wp-media/phpunit": "^3"
+ },
+ "time": "2024-09-16T12:21:47+00:00",
+ "type": "library",
+ "installation-source": "dist",
+ "autoload": [],
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "GPL-3.0-or-later"
+ ],
+ "authors": [
+ {
+ "name": "WP Media",
+ "email": "contact@wp-media.me"
+ }
+ ],
+ "description": "Library for usage of WordPress filters in a safe-type way",
+ "support": {
+ "issues": "https://github.com/wp-media/apply-filters-typed/issues",
+ "source": "https://github.com/wp-media/apply-filters-typed/tree/v1.2"
+ },
+ "install-path": "../wp-media/apply-filters-typed"
+ },
+ "58": {
+ "name": "wp-media/plugin-family",
+ "version": "v1.0.8",
+ "version_normalized": "1.0.8.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/wp-media/plugin-family.git",
+ "reference": "b763b3338e19ca672c407213da4cd8739e9327c2"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/wp-media/plugin-family/zipball/b763b3338e19ca672c407213da4cd8739e9327c2",
+ "reference": "b763b3338e19ca672c407213da4cd8739e9327c2",
+ "shasum": ""
+ },
+ "require": {
+ "wp-media/apply-filters-typed": "^1.0"
+ },
+ "require-dev": {
+ "dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
+ "phpcompatibility/phpcompatibility-wp": "^2.0",
+ "phpstan/extension-installer": "^1.4",
+ "szepeviktor/phpstan-wordpress": "^1.3",
+ "wp-coding-standards/wpcs": "^3",
+ "wp-media/phpunit": "^3"
+ },
+ "time": "2025-12-29T12:10:38+00:00",
+ "type": "library",
+ "installation-source": "dist",
+ "autoload": {
+ "psr-4": {
+ "Imagify\\Dependencies\\WPMedia\\PluginFamily\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "GPL-3.0-or-later"
+ ],
+ "authors": [
+ {
+ "name": "WP Media",
+ "email": "contact@wp-media.me",
+ "homepage": "https://wp-media.me"
+ }
+ ],
+ "description": "Organizes and displays WP Media plugin family across other members.",
+ "support": {
+ "issues": "https://github.com/wp-media/plugin-family/issues",
+ "source": "https://github.com/wp-media/plugin-family/tree/v1.0.8"
+ },
+ "install-path": "../wp-media/plugin-family"
+ }
+ },
+ "dev": false,
+ "dev-package-names": []
+}
diff --git a/classes/Dependencies/composer/installed.php b/classes/Dependencies/composer/installed.php
new file mode 100644
index 000000000..03be1037e
--- /dev/null
+++ b/classes/Dependencies/composer/installed.php
@@ -0,0 +1,66 @@
+
+ array (
+ 'name' => 'wp-media/imagify-plugin',
+ 'pretty_version' => 'dev-develop',
+ 'version' => 'dev-develop',
+ 'reference' => '8131c548f32c92671ab1047e0393e8feafe06d91',
+ 'type' => 'wordpress-plugin',
+ 'install_path' => __DIR__ . '/../',
+ 'aliases' =>
+ array (
+ ),
+ 'dev' => true,
+ ),
+ 'versions' =>
+ array (
+ 'deliciousbrains/wp-background-processing' =>
+ array (
+ 'pretty_version' => '1.4.0',
+ 'version' => '1.4.0.0',
+ 'reference' => '7ca7cc3504333db3a291bbab7f1917124fba4816',
+ 'type' => 'library',
+ 'install_path' => __DIR__ . '/../deliciousbrains/wp-background-processing',
+ 'aliases' =>
+ array (
+ ),
+ 'dev_requirement' => false,
+ ),
+ 'league/container' =>
+ array (
+ 'pretty_version' => '4.2.5',
+ 'version' => '4.2.5.0',
+ 'reference' => 'd3cebb0ff4685ff61c749e54b27db49319e2ec00',
+ 'type' => 'library',
+ 'install_path' => __DIR__ . '/../league/container',
+ 'aliases' =>
+ array (
+ ),
+ 'dev_requirement' => false,
+ ),
+ 'psr/container' =>
+ array (
+ 'pretty_version' => '2.0.2',
+ 'version' => '2.0.2.0',
+ 'reference' => 'c71ecc56dfe541dbd90c5360474fbc405f8d5963',
+ 'type' => 'library',
+ 'install_path' => __DIR__ . '/../psr/container',
+ 'aliases' =>
+ array (
+ ),
+ 'dev_requirement' => false,
+ ),
+ 'wp-media/plugin-family' =>
+ array (
+ 'pretty_version' => 'v1.0.8',
+ 'version' => '1.0.8.0',
+ 'reference' => 'b763b3338e19ca672c407213da4cd8739e9327c2',
+ 'type' => 'library',
+ 'install_path' => __DIR__ . '/../wp-media/plugin-family',
+ 'aliases' =>
+ array (
+ ),
+ 'dev_requirement' => false,
+ ),
+ ),
+);
\ No newline at end of file
diff --git a/classes/Dependencies/composer/platform_check.php b/classes/Dependencies/composer/platform_check.php
new file mode 100644
index 000000000..d2225c7df
--- /dev/null
+++ b/classes/Dependencies/composer/platform_check.php
@@ -0,0 +1,25 @@
+= 70400)) {
+ $issues[] = 'Your Composer dependencies require a PHP version ">= 7.4.0". You are running ' . PHP_VERSION . '.';
+}
+
+if ($issues) {
+ if (!headers_sent()) {
+ header('HTTP/1.1 500 Internal Server Error');
+ }
+ if (!ini_get('display_errors')) {
+ if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
+ fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL);
+ } elseif (!headers_sent()) {
+ echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL;
+ }
+ }
+ throw new \RuntimeException(
+ 'Composer detected issues in your platform: ' . implode(' ', $issues)
+ );
+}
diff --git a/classes/Dependencies/deliciousbrains/wp-background-processing/.circleci/config.yml b/classes/Dependencies/deliciousbrains/wp-background-processing/.circleci/config.yml
new file mode 100644
index 000000000..212e51cee
--- /dev/null
+++ b/classes/Dependencies/deliciousbrains/wp-background-processing/.circleci/config.yml
@@ -0,0 +1,93 @@
+workflows:
+ version: 2
+ main:
+ jobs:
+ - php72-build
+ - php73-build
+ - php74-build
+ - php80-build
+
+version: 2
+
+job-references:
+ mysql_image: &mysql_image
+ cimg/mysql:5.7
+
+ setup_environment: &setup_environment
+ name: "Setup Environment Variables"
+ command: |
+ echo "export PATH=$HOME/.composer/vendor/bin:$PATH" >> $BASH_ENV
+ source /home/circleci/.bashrc
+
+ install_dependencies: &install_dependencies
+ name: "Install Dependencies"
+ command: |
+ sudo apt-get update && sudo apt-get install mysql-client subversion
+
+ php_job: &php_job
+ environment:
+ - WP_TESTS_DIR: "/tmp/wordpress-tests-lib"
+ - WP_CORE_DIR: "/tmp/wordpress/"
+ steps:
+ - checkout
+ - run: php --version
+ - run: composer --version
+ - run: *setup_environment
+ - run: *install_dependencies
+ - run:
+ name: "Run Tests"
+ command: |
+ rm -rf $WP_TESTS_DIR $WP_CORE_DIR
+ bash bin/install-wp-tests.sh wordpress_test root '' 127.0.0.1 latest
+ make test-unit
+ WP_MULTISITE=1 make test-unit
+ make test-style
+
+jobs:
+ php56-build:
+ <<: *php_job
+ docker:
+ - image: cimg/php:5.6
+ - image: *mysql_image
+
+ php70-build:
+ <<: *php_job
+ docker:
+ - image: cimg/php:7.0
+ - image: *mysql_image
+
+ php71-build:
+ <<: *php_job
+ docker:
+ - image: cimg/php:7.1
+ - image: *mysql_image
+
+ php72-build:
+ <<: *php_job
+ docker:
+ - image: cimg/php:7.2
+ - image: *mysql_image
+
+ php73-build:
+ <<: *php_job
+ docker:
+ - image: cimg/php:7.3
+ - image: *mysql_image
+
+ php74-build:
+ <<: *php_job
+ docker:
+ - image: cimg/php:7.4
+ - image: *mysql_image
+
+ php80-build:
+ <<: *php_job
+ docker:
+ - image: cimg/php:8.0
+ - image: *mysql_image
+
+ php81-build:
+ <<: *php_job
+ docker:
+ - image: cimg/php:8.1
+ - image: *mysql_image
diff --git a/classes/Dependencies/deliciousbrains/wp-background-processing/.github/CODEOWNERS b/classes/Dependencies/deliciousbrains/wp-background-processing/.github/CODEOWNERS
new file mode 100644
index 000000000..37ee520f3
--- /dev/null
+++ b/classes/Dependencies/deliciousbrains/wp-background-processing/.github/CODEOWNERS
@@ -0,0 +1,3 @@
+* @deliciousbrains/deli-eng
+
+#jira:DELI is where issues related to this repository should be ticketed]
\ No newline at end of file
diff --git a/classes/Dependencies/deliciousbrains/wp-background-processing/.gitignore b/classes/Dependencies/deliciousbrains/wp-background-processing/.gitignore
new file mode 100644
index 000000000..23505a971
--- /dev/null
+++ b/classes/Dependencies/deliciousbrains/wp-background-processing/.gitignore
@@ -0,0 +1,3 @@
+/vendor/
+/.idea
+*.cache
diff --git a/classes/Dependencies/deliciousbrains/wp-background-processing/.phpcs.xml b/classes/Dependencies/deliciousbrains/wp-background-processing/.phpcs.xml
new file mode 100644
index 000000000..903238362
--- /dev/null
+++ b/classes/Dependencies/deliciousbrains/wp-background-processing/.phpcs.xml
@@ -0,0 +1,65 @@
+
+
+ Generally-applicable sniffs for WordPress plugins.
+
+
+ .
+ /vendor/
+ /node_modules/
+ /tests/*
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/classes/Dependencies/deliciousbrains/wp-background-processing/Makefile b/classes/Dependencies/deliciousbrains/wp-background-processing/Makefile
new file mode 100644
index 000000000..68aaf82df
--- /dev/null
+++ b/classes/Dependencies/deliciousbrains/wp-background-processing/Makefile
@@ -0,0 +1,18 @@
+.PHONY: test
+test: test-unit test-style
+
+.PHONY: test-unit
+test-unit: vendor
+ vendor/bin/phpunit
+
+.PHONY: test-style
+test-style: vendor
+ vendor/bin/phpcs
+
+vendor: composer.json
+ composer install --ignore-platform-reqs
+
+.PHONY: clean
+clean:
+ rm -rf vendor
+ rm -f tests/.phpunit.result.cache .phpunit.result.cache
diff --git a/classes/Dependencies/deliciousbrains/wp-background-processing/README.md b/classes/Dependencies/deliciousbrains/wp-background-processing/README.md
new file mode 100644
index 000000000..a6e534b87
--- /dev/null
+++ b/classes/Dependencies/deliciousbrains/wp-background-processing/README.md
@@ -0,0 +1,438 @@
+# WP Background Processing
+
+WP Background Processing can be used to fire off non-blocking asynchronous requests or as a background processing tool, allowing you to queue tasks. Check out the [example plugin](https://github.com/A5hleyRich/wp-background-processing-example) or read the [accompanying article](https://deliciousbrains.com/background-processing-wordpress/).
+
+Inspired by [TechCrunch WP Asynchronous Tasks](https://github.com/techcrunch/wp-async-task).
+
+__Requires PHP 5.6+__
+
+## Install
+
+The recommended way to install this library in your project is by loading it through Composer:
+
+```shell
+composer require deliciousbrains/wp-background-processing
+```
+
+It is highly recommended to prefix wrap the library class files using [the Mozart package](https://packagist.org/packages/coenjacobs/mozart), to prevent collisions with other projects using this same library.
+
+## Usage
+
+### Async Request
+
+Async requests are useful for pushing slow one-off tasks such as sending emails to a background process. Once the request has been dispatched it will process in the background instantly.
+
+Extend the `WP_Async_Request` class:
+
+```php
+class WP_Example_Request extends WP_Async_Request {
+
+ /**
+ * @var string
+ */
+ protected $prefix = 'my_plugin';
+
+ /**
+ * @var string
+ */
+ protected $action = 'example_request';
+
+ /**
+ * Handle a dispatched request.
+ *
+ * Override this method to perform any actions required
+ * during the async request.
+ */
+ protected function handle() {
+ // Actions to perform.
+ }
+
+}
+```
+
+#### `protected $prefix`
+
+Should be set to a unique prefix associated with your plugin, theme, or site's custom function prefix.
+
+#### `protected $action`
+
+Should be set to a unique name.
+
+#### `protected function handle()`
+
+Should contain any logic to perform during the non-blocking request. The data passed to the request will be accessible via `$_POST`.
+
+#### Dispatching Requests
+
+Instantiate your request:
+
+```php
+$this->example_request = new WP_Example_Request();
+```
+
+Add data to the request if required:
+
+```php
+$this->example_request->data( array( 'value1' => $value1, 'value2' => $value2 ) );
+```
+
+Fire off the request:
+
+```php
+$this->example_request->dispatch();
+```
+
+Chaining is also supported:
+
+```php
+$this->example_request->data( array( 'data' => $data ) )->dispatch();
+```
+
+### Background Process
+
+Background processes work in a similar fashion to async requests, but they allow you to queue tasks. Items pushed onto the queue will be processed in the background once the queue has been saved and dispatched. Queues will also scale based on available server resources, so higher end servers will process more items per batch. Once a batch has completed, the next batch will start instantly.
+
+Health checks run by default every 5 minutes to ensure the queue is running when queued items exist. If the queue has failed it will be restarted.
+
+Queues work on a first in first out basis, which allows additional items to be pushed to the queue even if it’s already processing. Saving a new batch of queued items and dispatching while another background processing instance is already running will result in the dispatch shortcutting out and the existing instance eventually picking up the new items and processing them when it is their turn.
+
+Extend the `WP_Background_Process` class:
+
+```php
+class WP_Example_Process extends WP_Background_Process {
+
+ /**
+ * @var string
+ */
+ protected $prefix = 'my_plugin';
+
+ /**
+ * @var string
+ */
+ protected $action = 'example_process';
+
+ /**
+ * Perform task with queued item.
+ *
+ * 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
+ */
+ protected function task( $item ) {
+ // Actions to perform.
+
+ return false;
+ }
+
+ /**
+ * Complete processing.
+ *
+ * Override if applicable, but ensure that the below actions are
+ * performed, or, call parent::complete().
+ */
+ protected function complete() {
+ parent::complete();
+
+ // Show notice to user or perform some other arbitrary task...
+ }
+
+}
+```
+
+#### `protected $prefix`
+
+Should be set to a unique prefix associated with your plugin, theme, or site's custom function prefix.
+
+#### `protected $action`
+
+Should be set to a unique name.
+
+#### `protected function task( $item )`
+
+Should contain any logic to perform on the queued item. Return `false` to remove the item from the queue or return `$item` to push it back onto the queue for further processing. If the item has been modified and is pushed back onto the queue the current state will be saved before the batch is exited.
+
+#### `protected function complete()`
+
+Optionally contain any logic to perform once the queue has completed.
+
+#### Dispatching Processes
+
+Instantiate your process:
+
+```php
+$this->example_process = new WP_Example_Process();
+```
+
+**Note:** You must instantiate your process unconditionally. All requests should do this, even if nothing is pushed to the queue.
+
+Push items to the queue:
+
+```php
+foreach ( $items as $item ) {
+ $this->example_process->push_to_queue( $item );
+}
+```
+
+An item can be any valid PHP value, string, integer, array or object. If needed, the $item is serialized when written to the database.
+
+Save and dispatch the queue:
+
+```php
+$this->example_process->save()->dispatch();
+```
+
+#### Handling serialized objects in queue items
+
+Queue items that contain non-scalar values are serialized when stored in the database. To avoid potential security issues during unserialize, this library provides the option to set the `allowed_classes` option when calling `unserialize()` which limits which classes can be instantiated. It's kept internally as the protected `$allowed_batch_data_classes` property.
+
+To maintain backward compatibility the default value is `true`, meaning that any serialized object will be instantiated. Please note that this default behavior may change in a future major release.
+
+We encourage all users of this library to take advantage of setting a strict value for `$allowed_batch_data_classes`. If possible, set the value to `false` to disallow any objects from being instantiated, or a very limited list of class names, see examples below.
+
+Objects in the serialized string that are not allowed to be instantiated will instead get the class type `__PHP_Incomplete_Class`.
+
+##### Overriding the default `$allowed_batch_data_classes`
+
+The default behavior can be overridden by passing an array of allowed classes to the constructor:
+
+``` php
+$allowed_batch_data_classes = array( MyCustomItem::class, MyItemHelper::class );
+$this->example_process = new WP_Example_Process( $allowed_batch_data_classes );
+```
+
+Or, set the value to `false`:
+
+``` php
+$this->example_process = new WP_Example_Process( false );
+```
+
+
+Another way to change the default is to override the `$allowed_batch_data_classes` property in your process class:
+
+``` php
+class WP_Example_Process extends WP_Background_Process {
+
+ /**
+ * @var string
+ */
+ protected $prefix = 'my_plugin';
+
+ /**
+ * @var string
+ */
+ protected $action = 'example_process';
+
+ /**
+ *
+ * @var bool|array
+ */
+ protected $allowed_batch_data_classes = array( MyCustomItem::class, MyItemHelper::class );
+ ...
+
+```
+
+#### Background Process Status
+
+A background process can be queued, processing, paused, cancelled, or none of the above (not started or has completed).
+
+##### Queued
+
+To check whether a background process has queued items use `is_queued()`.
+
+```php
+if ( $this->example_process->is_queued() ) {
+ // Do something because background process has queued items, e.g. add notice in admin UI.
+}
+```
+
+##### Processing
+
+To check whether a background process is currently handling a queue of items use `is_processing()`.
+
+```php
+if ( $this->example_process->is_processing() ) {
+ // Do something because background process is running, e.g. add notice in admin UI.
+}
+```
+
+##### Paused
+
+You can pause a background process with `pause()`.
+
+```php
+$this->example_process->pause();
+```
+
+The currently processing batch will continue until it either completes or reaches the time or memory limit. At that point it'll unlock the process and either complete the batch if the queue is empty, or perform a dispatch that will result in the handler removing the healthcheck cron and firing a "paused" action.
+
+To check whether a background process is currently paused use `is_paused()`.
+
+```php
+if ( $this->example_process->is_paused() ) {
+ // Do something because background process is paused, e.g. add notice in admin UI.
+}
+```
+
+You can perform an action in response to background processing being paused by handling the "paused" action for the background process's identifier ($prefix + $action).
+
+```php
+add_action( 'my_plugin_example_process_paused', function() {
+ // Do something because background process is paused, e.g. add notice in admin UI.
+});
+```
+
+You can resume a background process with `resume()`.
+
+```php
+$this->example_process->resume();
+```
+
+You can perform an action in response to background processing being resumed by handling the "resumed" action for the background process's identifier ($prefix + $action).
+
+```php
+add_action( 'my_plugin_example_process_resumed', function() {
+ // Do something because background process is resumed, e.g. add notice in admin UI.
+});
+```
+
+##### Cancelled
+
+You can cancel a background process with `cancel()`.
+
+```php
+$this->example_process->cancel();
+```
+
+The currently processing batch will continue until it either completes or reaches the time or memory limit. At that point it'll unlock the process and either complete the batch if the queue is empty, or perform a dispatch that will result in the handler removing the healthcheck cron, deleting all batches of queued items and firing a "cancelled" action.
+
+To check whether a background process is currently cancelled use `is_cancelled()`.
+
+```php
+if ( $this->example_process->is_cancelled() ) {
+ // Do something because background process is cancelled, e.g. add notice in admin UI.
+}
+```
+
+You can perform an action in response to background processing being cancelled by handling the "cancelled" action for the background process's identifier ($prefix + $action).
+
+```php
+add_action( 'my_plugin_example_process_cancelled', function() {
+ // Do something because background process is paused, e.g. add notice in admin UI.
+});
+```
+
+The "cancelled" action fires once the queue has been cleared down and cancelled status removed. After which `is_cancelled()` will no longer be true as the background process is now dormant.
+
+##### Active
+
+To check whether a background process has queued items, is processing, is paused, or is cancelling, use `is_active()`.
+
+```php
+if ( $this->example_process->is_active() ) {
+ // Do something because background process is active, e.g. add notice in admin UI.
+}
+```
+
+If a background process is not active, then it either has not had anything queued yet and not started, or has finished processing all queued items.
+
+### BasicAuth
+
+If your site is behind BasicAuth, both async requests and background processes will fail to complete. This is because WP Background Processing relies on the [WordPress HTTP API](https://developer.wordpress.org/plugins/http-api/), which requires you to attach your BasicAuth credentials to requests. The easiest way to do this is using the following filter:
+
+```php
+function wpbp_http_request_args( $r, $url ) {
+ $r['headers']['Authorization'] = 'Basic ' . base64_encode( USERNAME . ':' . PASSWORD );
+
+ return $r;
+}
+add_filter( 'http_request_args', 'wpbp_http_request_args', 10, 2);
+```
+
+## Contributing
+
+Contributions are welcome via Pull Requests, but please do raise an issue before
+working on anything to discuss the change if there isn't already an issue. If there
+is an approved issue you'd like to tackle, please post a comment on it to let people know
+you're going to have a go at it so that effort isn't wasted through duplicated work.
+
+### Unit & Style Tests
+
+When working on the library, please add unit tests to the appropriate file in the
+`tests` directory that cover your changes.
+
+#### Setting Up
+
+We use the standard WordPress test libraries for running unit tests.
+
+Please run the following command to set up the libraries:
+
+```shell
+bin/install-wp-tests.sh db_name db_user db_pass
+```
+
+Substitute `db_name`, `db_user` and `db_pass` as appropriate.
+
+Please be aware that running the unit tests is a **destructive operation**, *database
+tables will be cleared*, so please use a database name dedicated to running unit tests.
+The standard database name usually used by the WordPress community is `wordpress_test`, e.g.
+
+```shell
+bin/install-wp-tests.sh wordpress_test root root
+```
+
+Please refer to the [Initialize the testing environment locally](https://make.wordpress.org/cli/handbook/misc/plugin-unit-tests/#3-initialize-the-testing-environment-locally)
+section of the WordPress Handbook's [Plugin Integration Tests](https://make.wordpress.org/cli/handbook/misc/plugin-unit-tests/)
+entry should you run into any issues.
+
+#### Running Unit Tests
+
+To run the unit tests, simply run:
+
+```shell
+make test-unit
+```
+
+If the `composer` dependencies aren't in place, they'll be automatically installed first.
+
+#### Running Style Tests
+
+It's important that the code in the library use a consistent style to aid in quickly
+understanding it, and to avoid some common issues. `PHP_Code_Sniffer` is used with
+mostly standard WordPress rules to help check for consistency.
+
+To run the style tests, simply run:
+
+```shell
+make test-style
+```
+
+If the `composer` dependencies aren't in place, they'll be automatically installed first.
+
+#### Running All Tests
+
+To make things super simple, just run the following to run all tests:
+
+```shell
+make
+```
+
+If the `composer` dependencies aren't in place, they'll be automatically installed first.
+
+#### Creating a PR
+
+When creating a PR, please make sure to mention which GitHub issue is being resolved
+at the top of the description, e.g.:
+
+`Resolves #123`
+
+The unit and style tests will be run automatically, the PR will not be eligible for
+merge unless they pass, and the branch is up-to-date with `master`.
+
+## License
+
+[GPLv2+](http://www.gnu.org/licenses/gpl-2.0.html)
diff --git a/classes/Dependencies/deliciousbrains/wp-background-processing/bin/install-wp-tests.sh b/classes/Dependencies/deliciousbrains/wp-background-processing/bin/install-wp-tests.sh
new file mode 100644
index 000000000..ee05775c8
--- /dev/null
+++ b/classes/Dependencies/deliciousbrains/wp-background-processing/bin/install-wp-tests.sh
@@ -0,0 +1,181 @@
+#!/usr/bin/env bash
+
+if [ $# -lt 3 ]; then
+ echo "usage: $0 [db-host] [wp-version] [skip-database-creation]"
+ exit 1
+fi
+
+DB_NAME=$1
+DB_USER=$2
+DB_PASS=$3
+DB_HOST=${4-localhost}
+WP_VERSION=${5-latest}
+SKIP_DB_CREATE=${6-false}
+
+TMPDIR=${TMPDIR-/tmp}
+TMPDIR=$(echo $TMPDIR | sed -e "s/\/$//")
+WP_TESTS_DIR=${WP_TESTS_DIR-$TMPDIR/wordpress-tests-lib}
+WP_CORE_DIR=${WP_CORE_DIR-$TMPDIR/wordpress}
+
+download() {
+ if [ `which curl` ]; then
+ curl -s "$1" > "$2";
+ elif [ `which wget` ]; then
+ wget -nv -O "$2" "$1"
+ fi
+}
+
+if [[ $WP_VERSION =~ ^[0-9]+\.[0-9]+\-(beta|RC)[0-9]+$ ]]; then
+ WP_BRANCH=${WP_VERSION%\-*}
+ WP_TESTS_TAG="branches/$WP_BRANCH"
+
+elif [[ $WP_VERSION =~ ^[0-9]+\.[0-9]+$ ]]; then
+ WP_TESTS_TAG="branches/$WP_VERSION"
+elif [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0-9]+ ]]; then
+ if [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0] ]]; then
+ # version x.x.0 means the first release of the major version, so strip off the .0 and download version x.x
+ WP_TESTS_TAG="tags/${WP_VERSION%??}"
+ else
+ WP_TESTS_TAG="tags/$WP_VERSION"
+ fi
+elif [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then
+ WP_TESTS_TAG="trunk"
+else
+ # http serves a single offer, whereas https serves multiple. we only want one
+ download http://api.wordpress.org/core/version-check/1.7/ /tmp/wp-latest.json
+ grep '[0-9]+\.[0-9]+(\.[0-9]+)?' /tmp/wp-latest.json
+ LATEST_VERSION=$(grep -o '"version":"[^"]*' /tmp/wp-latest.json | sed 's/"version":"//')
+ if [[ -z "$LATEST_VERSION" ]]; then
+ echo "Latest WordPress version could not be found"
+ exit 1
+ fi
+ WP_TESTS_TAG="tags/$LATEST_VERSION"
+fi
+set -ex
+
+install_wp() {
+
+ if [ -d $WP_CORE_DIR ]; then
+ return;
+ fi
+
+ mkdir -p $WP_CORE_DIR
+
+ if [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then
+ mkdir -p $TMPDIR/wordpress-trunk
+ rm -rf $TMPDIR/wordpress-trunk/*
+ svn export --quiet https://core.svn.wordpress.org/trunk $TMPDIR/wordpress-trunk/wordpress
+ mv $TMPDIR/wordpress-trunk/wordpress/* $WP_CORE_DIR
+ else
+ if [ $WP_VERSION == 'latest' ]; then
+ local ARCHIVE_NAME='latest'
+ elif [[ $WP_VERSION =~ [0-9]+\.[0-9]+ ]]; then
+ # https serves multiple offers, whereas http serves single.
+ download https://api.wordpress.org/core/version-check/1.7/ $TMPDIR/wp-latest.json
+ if [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0] ]]; then
+ # version x.x.0 means the first release of the major version, so strip off the .0 and download version x.x
+ LATEST_VERSION=${WP_VERSION%??}
+ else
+ # otherwise, scan the releases and get the most up to date minor version of the major release
+ local VERSION_ESCAPED=`echo $WP_VERSION | sed 's/\./\\\\./g'`
+ LATEST_VERSION=$(grep -o '"version":"'$VERSION_ESCAPED'[^"]*' $TMPDIR/wp-latest.json | sed 's/"version":"//' | head -1)
+ fi
+ if [[ -z "$LATEST_VERSION" ]]; then
+ local ARCHIVE_NAME="wordpress-$WP_VERSION"
+ else
+ local ARCHIVE_NAME="wordpress-$LATEST_VERSION"
+ fi
+ else
+ local ARCHIVE_NAME="wordpress-$WP_VERSION"
+ fi
+ download https://wordpress.org/${ARCHIVE_NAME}.tar.gz $TMPDIR/wordpress.tar.gz
+ tar --strip-components=1 -zxmf $TMPDIR/wordpress.tar.gz -C $WP_CORE_DIR
+ fi
+
+ download https://raw.github.com/markoheijnen/wp-mysqli/master/db.php $WP_CORE_DIR/wp-content/db.php
+}
+
+install_test_suite() {
+ # portable in-place argument for both GNU sed and Mac OSX sed
+ if [[ $(uname -s) == 'Darwin' ]]; then
+ local ioption='-i.bak'
+ else
+ local ioption='-i'
+ fi
+
+ # set up testing suite if it doesn't yet exist
+ if [ ! -d $WP_TESTS_DIR ]; then
+ # set up testing suite
+ mkdir -p $WP_TESTS_DIR
+ rm -rf $WP_TESTS_DIR/{includes,data}
+ svn export --quiet --ignore-externals https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes
+ svn export --quiet --ignore-externals https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/data/ $WP_TESTS_DIR/data
+ fi
+
+ if [ ! -f wp-tests-config.php ]; then
+ download https://develop.svn.wordpress.org/${WP_TESTS_TAG}/wp-tests-config-sample.php "$WP_TESTS_DIR"/wp-tests-config.php
+ # remove all forward slashes in the end
+ WP_CORE_DIR=$(echo $WP_CORE_DIR | sed "s:/\+$::")
+ sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR/':" "$WP_TESTS_DIR"/wp-tests-config.php
+ sed $ioption "s:__DIR__ . '/src/':'$WP_CORE_DIR/':" "$WP_TESTS_DIR"/wp-tests-config.php
+ sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" "$WP_TESTS_DIR"/wp-tests-config.php
+ sed $ioption "s/yourusernamehere/$DB_USER/" "$WP_TESTS_DIR"/wp-tests-config.php
+ sed $ioption "s/yourpasswordhere/$DB_PASS/" "$WP_TESTS_DIR"/wp-tests-config.php
+ sed $ioption "s|localhost|${DB_HOST}|" "$WP_TESTS_DIR"/wp-tests-config.php
+ fi
+
+}
+
+recreate_db() {
+ shopt -s nocasematch
+ if [[ $1 =~ ^(y|yes)$ ]]
+ then
+ mysqladmin drop $DB_NAME -f --user="$DB_USER" --password="$DB_PASS"$EXTRA
+ create_db
+ echo "Recreated the database ($DB_NAME)."
+ else
+ echo "Leaving the existing database ($DB_NAME) in place."
+ fi
+ shopt -u nocasematch
+}
+
+create_db() {
+ mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA
+}
+
+install_db() {
+
+ if [ ${SKIP_DB_CREATE} = "true" ]; then
+ return 0
+ fi
+
+ # parse DB_HOST for port or socket references
+ local PARTS=(${DB_HOST//\:/ })
+ local DB_HOSTNAME=${PARTS[0]};
+ local DB_SOCK_OR_PORT=${PARTS[1]};
+ local EXTRA=""
+
+ if ! [ -z $DB_HOSTNAME ] ; then
+ if [ $(echo $DB_SOCK_OR_PORT | grep -e '^[0-9]\{1,\}$') ]; then
+ EXTRA=" --host=$DB_HOSTNAME --port=$DB_SOCK_OR_PORT --protocol=tcp"
+ elif ! [ -z $DB_SOCK_OR_PORT ] ; then
+ EXTRA=" --socket=$DB_SOCK_OR_PORT"
+ elif ! [ -z $DB_HOSTNAME ] ; then
+ EXTRA=" --host=$DB_HOSTNAME --protocol=tcp"
+ fi
+ fi
+
+ # create database
+ if [ $(mysql --user="$DB_USER" --password="$DB_PASS"$EXTRA --execute='show databases;' | grep ^$DB_NAME$) ]
+ then
+ echo "Reinstalling will delete the existing test database ($DB_NAME)"
+ read -p 'Are you sure you want to proceed? [y/N]: ' DELETE_EXISTING_DB
+ recreate_db $DELETE_EXISTING_DB
+ else
+ create_db
+ fi
+}
+
+install_wp
+install_test_suite
+install_db
diff --git a/inc/classes/Dependencies/deliciousbrains/wp-background-processing/classes/wp-async-request.php b/classes/Dependencies/deliciousbrains/wp-background-processing/classes/wp-async-request.php
similarity index 100%
rename from inc/classes/Dependencies/deliciousbrains/wp-background-processing/classes/wp-async-request.php
rename to classes/Dependencies/deliciousbrains/wp-background-processing/classes/wp-async-request.php
diff --git a/inc/classes/Dependencies/deliciousbrains/wp-background-processing/classes/wp-background-process.php b/classes/Dependencies/deliciousbrains/wp-background-processing/classes/wp-background-process.php
similarity index 99%
rename from inc/classes/Dependencies/deliciousbrains/wp-background-processing/classes/wp-background-process.php
rename to classes/Dependencies/deliciousbrains/wp-background-processing/classes/wp-background-process.php
index 430bf770a..9e48b6b7b 100644
--- a/inc/classes/Dependencies/deliciousbrains/wp-background-processing/classes/wp-background-process.php
+++ b/classes/Dependencies/deliciousbrains/wp-background-processing/classes/wp-background-process.php
@@ -84,7 +84,7 @@ abstract class Imagify_WP_Background_Process extends Imagify_WP_Async_Request {
/**
* Initiate new background process.
*
- * @param bool|array $allowed_batch_data_classes Optional. Array of class Imagify_names that can be unserialized. Default true (any class).
+ * @param bool|array $allowed_batch_data_classes Optional. Array of class names that can be unserialized. Default true (any class).
*/
public function __construct( $allowed_batch_data_classes = true ) {
parent::__construct();
@@ -863,7 +863,7 @@ abstract protected function task( $item );
* Maybe unserialize data, but not if an object.
*
* @param mixed $data Data to be unserialized.
- * @param bool|array $allowed_classes Array of class Imagify_names that can be unserialized.
+ * @param bool|array $allowed_classes Array of class names that can be unserialized.
*
* @return mixed
*/
diff --git a/classes/Dependencies/deliciousbrains/wp-background-processing/composer.json b/classes/Dependencies/deliciousbrains/wp-background-processing/composer.json
new file mode 100644
index 000000000..7f65bbfb5
--- /dev/null
+++ b/classes/Dependencies/deliciousbrains/wp-background-processing/composer.json
@@ -0,0 +1,35 @@
+{
+ "name": "deliciousbrains/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": ">=7.0"
+ },
+ "suggest": {
+ "coenjacobs/mozart": "Easily wrap this library with your own prefix, to prevent collisions when multiple plugins use this library"
+ },
+ "license": "GPL-2.0-or-later",
+ "authors": [
+ {
+ "name": "Delicious Brains",
+ "email": "nom@deliciousbrains.com"
+ }
+ ],
+ "autoload": {
+ "classmap": [
+ "classes/"
+ ]
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^8.0",
+ "yoast/phpunit-polyfills": "^1.0",
+ "spryker/code-sniffer": "^0.17.18",
+ "phpcompatibility/phpcompatibility-wp": "*",
+ "wp-coding-standards/wpcs": "^2.3"
+ },
+ "config": {
+ "allow-plugins": {
+ "dealerdirect/phpcodesniffer-composer-installer": true
+ }
+ }
+}
diff --git a/classes/Dependencies/deliciousbrains/wp-background-processing/license.txt b/classes/Dependencies/deliciousbrains/wp-background-processing/license.txt
new file mode 100644
index 000000000..a0939e921
--- /dev/null
+++ b/classes/Dependencies/deliciousbrains/wp-background-processing/license.txt
@@ -0,0 +1,280 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
+
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) 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
+this service 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 make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. 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.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute 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 and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+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
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the 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 a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE 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.
+
+ END OF TERMS AND CONDITIONS
\ No newline at end of file
diff --git a/classes/Dependencies/deliciousbrains/wp-background-processing/phpunit.xml b/classes/Dependencies/deliciousbrains/wp-background-processing/phpunit.xml
new file mode 100644
index 000000000..d6218767c
--- /dev/null
+++ b/classes/Dependencies/deliciousbrains/wp-background-processing/phpunit.xml
@@ -0,0 +1,15 @@
+
+
+
+
+ ./tests/
+
+
+
diff --git a/classes/Dependencies/deliciousbrains/wp-background-processing/tests/Test_Setup.php b/classes/Dependencies/deliciousbrains/wp-background-processing/tests/Test_Setup.php
new file mode 100644
index 000000000..cfbaa8ed0
--- /dev/null
+++ b/classes/Dependencies/deliciousbrains/wp-background-processing/tests/Test_Setup.php
@@ -0,0 +1,19 @@
+assertTrue( true );
+ }
+}
diff --git a/classes/Dependencies/deliciousbrains/wp-background-processing/tests/Test_WP_Background_Process.php b/classes/Dependencies/deliciousbrains/wp-background-processing/tests/Test_WP_Background_Process.php
new file mode 100644
index 000000000..37e0e4248
--- /dev/null
+++ b/classes/Dependencies/deliciousbrains/wp-background-processing/tests/Test_WP_Background_Process.php
@@ -0,0 +1,672 @@
+wpbp = $this->getMockForAbstractClass( Imagify_WP_Background_Process::class );
+
+ $this->wpbp->expects( $this->any() )
+ ->method( 'task' )
+ ->will( $this->returnValue( false ) );
+ }
+
+ /**
+ * Get a property value from WPBP regardless of accessibility.
+ *
+ * @param string $name
+ *
+ * @return mixed
+ */
+ private function getWPBPProperty( string $name ) {
+ try {
+ $property = new ReflectionProperty( 'Imagify_WP_Background_Process', $name );
+ } catch ( Exception $e ) {
+ return new WP_Error( $e->getCode(), $e->getMessage() );
+ }
+ $property->setAccessible( true );
+
+ return $property->getValue( $this->wpbp );
+ }
+
+ /**
+ * Set a property value on WPBP regardless of accessibility.
+ *
+ * @param string $name
+ * @param mixed $value
+ *
+ * @return mixed
+ */
+ private function setWPBPProperty( string $name, $value ) {
+ try {
+ $property = new ReflectionProperty( 'Imagify_WP_Background_Process', $name );
+ } catch ( Exception $e ) {
+ return new WP_Error( $e->getCode(), $e->getMessage() );
+ }
+ $property->setAccessible( true );
+
+ return $property->setValue( $this->wpbp, $value );
+ }
+
+ /**
+ * Execute a method of WPBP regardless of accessibility.
+ *
+ * @param string $name Method name.
+ * @param mixed $args None, one or more args to pass to method.
+ *
+ * @return mixed
+ */
+ private function executeWPBPMethod( string $name, ...$args ) {
+ try {
+ $method = new ReflectionMethod( 'Imagify_WP_Background_Process', $name );
+ $method->setAccessible( true );
+
+ return $method->invoke( $this->wpbp, ...$args );
+ } catch ( Exception $e ) {
+ return new WP_Error( $e->getCode(), $e->getMessage() );
+ }
+ }
+
+ /**
+ * Test push_to_queue.
+ *
+ * @return void
+ */
+ public function test_push_to_queue() {
+ $this->assertClassHasAttribute( 'data', 'Imagify_WP_Background_Process', 'class has data property' );
+ $this->assertEmpty( $this->getWPBPProperty( 'data' ) );
+
+ $this->wpbp->push_to_queue( 'wibble' );
+ $this->assertNotEmpty( $this->getWPBPProperty( 'data' ) );
+ $this->assertEquals( array( 'wibble' ), $this->getWPBPProperty( 'data' ) );
+
+ $this->wpbp->push_to_queue( 'wobble' );
+ $this->assertEquals( array( 'wibble', 'wobble' ), $this->getWPBPProperty( 'data' ) );
+ }
+
+ /**
+ * Test save.
+ *
+ * @return void
+ */
+ public function test_save() {
+ $this->assertClassHasAttribute( 'data', 'Imagify_WP_Background_Process', 'class has data property' );
+ $this->assertEmpty( $this->getWPBPProperty( 'data' ) );
+ $this->assertEmpty( $this->wpbp->get_batches(), 'no batches until save' );
+
+ $this->wpbp->push_to_queue( 'wibble' );
+ $this->assertNotEmpty( $this->getWPBPProperty( 'data' ) );
+ $this->assertEquals( array( 'wibble' ), $this->getWPBPProperty( 'data' ) );
+ $this->wpbp->save();
+ $this->assertEmpty( $this->getWPBPProperty( 'data' ), 'data emptied after save' );
+ $this->assertNotEmpty( $this->wpbp->get_batches(), 'batches exist after save' );
+ }
+
+ /**
+ * Test get_batches.
+ *
+ * @return void
+ */
+ public function test_get_batches() {
+ $this->assertEmpty( $this->wpbp->get_batches(), 'no batches until save' );
+
+ $this->wpbp->push_to_queue( 'wibble' );
+ $this->assertNotEmpty( $this->getWPBPProperty( 'data' ) );
+ $this->assertEquals( array( 'wibble' ), $this->getWPBPProperty( 'data' ) );
+ $this->assertEmpty( $this->wpbp->get_batches(), 'no batches until save' );
+
+ $this->wpbp->push_to_queue( 'wobble' );
+ $this->assertEquals( array( 'wibble', 'wobble' ), $this->getWPBPProperty( 'data' ) );
+ $this->assertEmpty( $this->wpbp->get_batches(), 'no batches until save' );
+
+ $this->wpbp->save();
+ $first_batch = $this->wpbp->get_batches();
+ $this->assertNotEmpty( $first_batch );
+ $this->assertCount( 1, $first_batch );
+
+ $this->wpbp->push_to_queue( 'more wibble' );
+ $this->wpbp->save();
+ $this->assertCount( 2, $this->wpbp->get_batches() );
+
+ $this->wpbp->push_to_queue( 'Wibble wobble all day long.' );
+ $this->wpbp->save();
+ $this->assertCount( 3, $this->wpbp->get_batches() );
+
+ $this->assertEquals( $first_batch, $this->wpbp->get_batches( 1 ) );
+ $this->assertNotEquals( $first_batch, $this->wpbp->get_batches( 2 ) );
+ $this->assertCount( 2, $this->wpbp->get_batches( 2 ) );
+ $this->assertCount( 3, $this->wpbp->get_batches( 3 ) );
+ $this->assertCount( 3, $this->wpbp->get_batches( 5 ) );
+ }
+
+ /**
+ * Test get_batch.
+ *
+ * @return void
+ */
+ public function test_get_batch() {
+ $this->assertEmpty( $this->executeWPBPMethod( 'get_batch' ), 'no batches until save' );
+
+ $this->wpbp->push_to_queue( 'wibble' );
+ $this->assertNotEmpty( $this->getWPBPProperty( 'data' ) );
+ $this->assertEquals( array( 'wibble' ), $this->getWPBPProperty( 'data' ) );
+ $this->assertEmpty( $this->executeWPBPMethod( 'get_batch' ), 'no batches until save' );
+
+ $this->wpbp->push_to_queue( 'wobble' );
+ $this->assertEquals( array( 'wibble', 'wobble' ), $this->getWPBPProperty( 'data' ) );
+ $this->assertEmpty( $this->executeWPBPMethod( 'get_batch' ), 'no batches until save' );
+
+ $this->wpbp->save();
+ $first_batch = $this->executeWPBPMethod( 'get_batch' );
+ $this->assertNotEmpty( $first_batch );
+ $this->assertInstanceOf( 'stdClass', $first_batch );
+ $this->assertEquals( array( 'wibble', 'wobble' ), $first_batch->data );
+
+ $this->wpbp->push_to_queue( 'more wibble' );
+ $this->wpbp->save();
+ $second_batch = $this->executeWPBPMethod( 'get_batch' );
+ $this->assertNotEmpty( $second_batch );
+ $this->assertInstanceOf( 'stdClass', $second_batch );
+ $this->assertEquals( $first_batch, $second_batch, 'same 1st batch returned until deleted' );
+
+ $this->wpbp->delete( $first_batch->key );
+ $second_batch = $this->executeWPBPMethod( 'get_batch' );
+ $this->assertNotEmpty( $second_batch );
+ $this->assertInstanceOf( 'stdClass', $second_batch );
+ $this->assertNotEquals( $first_batch, $second_batch, '2nd batch returned as 1st deleted' );
+ $this->assertEquals( array( 'more wibble' ), $second_batch->data );
+
+ // Tests using a custom class for the $item.
+ $this->wpbp->delete( $second_batch->key );
+ $batch_data_object = new Test_Batch_Data();
+ $this->wpbp->push_to_queue( $batch_data_object );
+ $this->assertNotEmpty( $this->getWPBPProperty( 'data' ) );
+ $this->assertEquals( array( $batch_data_object ), $this->getWPBPProperty( 'data' ) );
+ $this->wpbp->save();
+ $third_batch = $this->executeWPBPMethod( 'get_batch' );
+ $this->assertCount( 1, $third_batch->data );
+ $this->assertInstanceOf( Test_Batch_Data::class, $third_batch->data[0] );
+
+ // Explicitly set allowed classes to Test_Batch_Data.
+ $this->setWPBPProperty( 'allowed_batch_data_classes', array( Test_Batch_Data::class ) );
+ $third_batch = $this->executeWPBPMethod( 'get_batch' );
+ $this->assertCount( 1, $third_batch->data );
+ $this->assertInstanceOf( Test_Batch_Data::class, $third_batch->data[0] );
+
+ // Allow a different class.
+ $this->setWPBPProperty( 'allowed_batch_data_classes', array( stdClass::class ) );
+ $third_batch = $this->executeWPBPMethod( 'get_batch' );
+ $this->assertCount( 1, $third_batch->data );
+ $this->assertInstanceOf( __PHP_Incomplete_Class::class, $third_batch->data[0] );
+
+ // Disallow all classes.
+ $this->setWPBPProperty( 'allowed_batch_data_classes', false );
+ $third_batch = $this->executeWPBPMethod( 'get_batch' );
+ $this->assertCount( 1, $third_batch->data );
+ $this->assertInstanceOf( __PHP_Incomplete_Class::class, $third_batch->data[0] );
+
+ // Allow everything.
+ $this->setWPBPProperty( 'allowed_batch_data_classes', true );
+ $third_batch = $this->executeWPBPMethod( 'get_batch' );
+ $this->assertCount( 1, $third_batch->data );
+ $this->assertInstanceOf( Test_Batch_Data::class, $third_batch->data[0] );
+ }
+
+ /**
+ * Test cancel.
+ *
+ * @return void
+ */
+ public function test_cancel() {
+ $this->wpbp->push_to_queue( 'wibble' );
+ $this->wpbp->save();
+ $this->assertFalse( $this->wpbp->is_cancelled() );
+ $this->wpbp->cancel();
+ $this->assertTrue( $this->wpbp->is_cancelled() );
+ }
+
+ /**
+ * Test pause.
+ *
+ * @return void
+ */
+ public function test_pause() {
+ $this->wpbp->push_to_queue( 'wibble' );
+ $this->wpbp->save();
+ $this->assertFalse( $this->wpbp->is_paused() );
+ $this->wpbp->pause();
+ $this->assertTrue( $this->wpbp->is_paused() );
+ }
+
+ /**
+ * Test resume.
+ *
+ * @return void
+ */
+ public function test_resume() {
+ $this->wpbp->push_to_queue( 'wibble' );
+ $this->wpbp->save();
+ $this->assertFalse( $this->wpbp->is_paused() );
+ $this->wpbp->pause();
+ $this->assertTrue( $this->wpbp->is_paused() );
+ $this->wpbp->resume();
+ $this->assertFalse( $this->wpbp->is_paused() );
+ }
+
+ /**
+ * Test delete.
+ *
+ * @return void
+ */
+ public function test_delete() {
+ $this->wpbp->push_to_queue( 'wibble' );
+ $this->wpbp->save();
+ $this->assertCount( 1, $this->wpbp->get_batches() );
+ $this->wpbp->push_to_queue( 'wobble' );
+ $this->wpbp->save();
+ $this->assertCount( 2, $this->wpbp->get_batches() );
+ $first_batch = $this->executeWPBPMethod( 'get_batch' );
+ $this->wpbp->delete( $first_batch->key );
+ $this->assertCount( 1, $this->wpbp->get_batches() );
+ $second_batch = $this->executeWPBPMethod( 'get_batch' );
+ $this->assertNotEquals( $first_batch, $second_batch, '2nd batch returned as 1st deleted' );
+ }
+
+ /**
+ * Test delete_all.
+ *
+ * @return void
+ */
+ public function test_delete_all() {
+ $this->wpbp->push_to_queue( 'wibble' );
+ $this->wpbp->save();
+ $this->assertCount( 1, $this->wpbp->get_batches() );
+ $this->wpbp->push_to_queue( 'wobble' );
+ $this->wpbp->save();
+ $this->assertCount( 2, $this->wpbp->get_batches() );
+ $this->wpbp->delete_all();
+ $this->assertCount( 0, $this->wpbp->get_batches() );
+ }
+
+ /**
+ * Test update.
+ *
+ * @return void
+ */
+ public function test_update() {
+ $this->wpbp->push_to_queue( 'wibble' );
+ $this->wpbp->save();
+ $this->assertCount( 1, $this->wpbp->get_batches() );
+ $this->wpbp->push_to_queue( 'wobble' );
+ $this->wpbp->save();
+ $this->assertCount( 2, $this->wpbp->get_batches() );
+ $first_batch = $this->executeWPBPMethod( 'get_batch' );
+ $this->wpbp->update( $first_batch->key, array( 'Wibble wobble all day long!' ) );
+ $this->assertCount( 2, $this->wpbp->get_batches() );
+ $updated_batch = $this->executeWPBPMethod( 'get_batch' );
+ $this->assertNotEquals( $first_batch, $updated_batch, 'fetched updated batch different to 1st fetch' );
+ $this->assertEquals( array( 'Wibble wobble all day long!' ), $updated_batch->data, 'fetched updated batch has expected data' );
+ }
+
+ /**
+ * Test maybe_handle when cancelling.
+ *
+ * @return void
+ */
+ public function test_maybe_handle_cancelled() {
+ // Cancelled status results in cleared batches and action fired.
+ $cancelled_fired = false;
+ add_action( $this->getWPBPProperty( 'identifier' ) . '_cancelled', function () use ( &$cancelled_fired ) {
+ $cancelled_fired = true;
+ } );
+ // Paused action should not be fired though.
+ $paused_fired = false;
+ add_action( $this->getWPBPProperty( 'identifier' ) . '_paused', function () use ( &$paused_fired ) {
+ $paused_fired = true;
+ } );
+ // Completed action should not be fired though.
+ $completed_fired = false;
+ add_action( $this->getWPBPProperty( 'identifier' ) . '_completed', function () use ( &$completed_fired ) {
+ $completed_fired = true;
+ } );
+ add_filter( $this->getWPBPProperty( 'identifier' ) . '_wp_die', '__return_false' );
+ $this->wpbp->push_to_queue( 'wibble' );
+ $this->wpbp->save();
+ $this->assertCount( 1, $this->wpbp->get_batches() );
+ $this->wpbp->push_to_queue( 'wobble' );
+ $this->wpbp->save();
+ $this->assertCount( 2, $this->wpbp->get_batches() );
+ update_site_option( $this->executeWPBPMethod( 'get_status_key' ), Imagify_WP_Background_Process::STATUS_CANCELLED );
+ $this->assertTrue( $this->wpbp->is_cancelled(), 'is_cancelled' );
+ $this->assertCount( 2, $this->wpbp->get_batches() );
+ $this->assertFalse( $cancelled_fired, 'cancelled action not fired yet' );
+ $this->assertFalse( $paused_fired, 'paused action not fired yet' );
+ $this->assertFalse( $completed_fired, 'completed action not fired yet' );
+ $this->wpbp->maybe_handle();
+ $this->assertCount( 0, $this->wpbp->get_batches() );
+ $this->assertTrue( $cancelled_fired, 'cancelled action fired' );
+ $this->assertFalse( $paused_fired, 'paused action still not fired yet' );
+ $this->assertFalse( $completed_fired, 'completed action not fired yet' );
+ }
+
+ /**
+ * Test maybe_handle when pausing and resuming.
+ *
+ * @return void
+ */
+ public function test_maybe_handle_paused_resumed() {
+ // Cancelled action should not be fired.
+ $cancelled_fired = false;
+ add_action( $this->getWPBPProperty( 'identifier' ) . '_cancelled', function () use ( &$cancelled_fired ) {
+ $cancelled_fired = true;
+ } );
+ // Paused action should fire and batches remain intact.
+ $paused_fired = false;
+ add_action( $this->getWPBPProperty( 'identifier' ) . '_paused', function () use ( &$paused_fired ) {
+ $paused_fired = true;
+ } );
+ // Resumed action should fire on resume before batches handled.
+ $resumed_fired = false;
+ add_action( $this->getWPBPProperty( 'identifier' ) . '_resumed', function () use ( &$resumed_fired ) {
+ $resumed_fired = true;
+ } );
+ // Completed action should fire after batches handled.
+ $completed_fired = false;
+ add_action( $this->getWPBPProperty( 'identifier' ) . '_completed', function () use ( &$completed_fired ) {
+ $completed_fired = true;
+ } );
+ add_filter( $this->getWPBPProperty( 'identifier' ) . '_wp_die', '__return_false' );
+ $this->wpbp->push_to_queue( 'wibble' );
+ $this->wpbp->save();
+ $this->assertCount( 1, $this->wpbp->get_batches() );
+ $this->wpbp->push_to_queue( 'wobble' );
+ $this->wpbp->save();
+ $this->assertCount( 2, $this->wpbp->get_batches() );
+ $this->wpbp->pause();
+ $this->assertTrue( $this->wpbp->is_paused(), 'is_paused' );
+ $this->assertCount( 2, $this->wpbp->get_batches() );
+ $this->assertFalse( $cancelled_fired, 'cancelled action not fired yet' );
+ $this->assertFalse( $paused_fired, 'paused action not fired yet' );
+ $this->assertFalse( $resumed_fired, 'resumed action not fired yet' );
+ $this->assertFalse( $completed_fired, 'completed action not fired yet' );
+ $this->wpbp->maybe_handle();
+ $this->assertCount( 2, $this->wpbp->get_batches() );
+ $this->assertFalse( $cancelled_fired, 'cancelled action still not fired yet' );
+ $this->assertTrue( $paused_fired, 'paused action fired' );
+ $this->assertFalse( $resumed_fired, 'resumed action still not fired yet' );
+ $this->assertFalse( $completed_fired, 'completed action not fired yet' );
+
+ // Reset for resume and ensure dispatch does nothing to that maybe_handle can be monitored.
+ $paused_fired = false;
+ add_filter( 'pre_http_request', '__return_true' );
+ $this->wpbp->resume();
+ remove_filter( 'pre_http_request', '__return_true' );
+ $this->assertFalse( $this->wpbp->is_paused(), 'not is_paused after resume' );
+ $this->assertCount( 2, $this->wpbp->get_batches() );
+ $this->assertFalse( $cancelled_fired, 'cancelled action not fired yet' );
+ $this->assertFalse( $paused_fired, 'paused action not fired yet' );
+ $this->assertTrue( $resumed_fired, 'resumed action fired' );
+ $this->assertFalse( $completed_fired, 'completed action not fired yet' );
+
+ // Don't expect resumed to be fired again, and batches to be handled with valid security.
+ $resumed_fired = false;
+ $_REQUEST['nonce'] = wp_create_nonce( $this->getWPBPProperty( 'identifier' ) );
+ $this->wpbp->maybe_handle();
+ $this->assertCount( 0, $this->wpbp->get_batches(), 'after resume all batches processed with maybe_handle' );
+ $this->assertFalse( $cancelled_fired, 'cancelled action still not fired yet' );
+ $this->assertFalse( $paused_fired, 'paused action not fired yet' );
+ $this->assertFalse( $resumed_fired, 'resumed action still not fired yet' );
+ $this->assertTrue( $completed_fired, 'completed action fired' );
+ }
+
+ /**
+ * Test maybe_handle when handling a single batch.
+ *
+ * @return void
+ */
+ public function test_maybe_handle_single_batch() {
+ // Cancelled action should not be fired.
+ $cancelled_fired = false;
+ add_action( $this->getWPBPProperty( 'identifier' ) . '_cancelled', function () use ( &$cancelled_fired ) {
+ $cancelled_fired = true;
+ } );
+ // Paused action should not be fired.
+ $paused_fired = false;
+ add_action( $this->getWPBPProperty( 'identifier' ) . '_paused', function () use ( &$paused_fired ) {
+ $paused_fired = true;
+ } );
+ // Resumed action should not be fired.
+ $resumed_fired = false;
+ add_action( $this->getWPBPProperty( 'identifier' ) . '_resumed', function () use ( &$resumed_fired ) {
+ $resumed_fired = true;
+ } );
+ // Completed action should fire after batches handled.
+ $completed_fired = false;
+ add_action( $this->getWPBPProperty( 'identifier' ) . '_completed', function () use ( &$completed_fired ) {
+ $completed_fired = true;
+ } );
+ add_filter( $this->getWPBPProperty( 'identifier' ) . '_wp_die', '__return_false' );
+ $this->wpbp->push_to_queue( 'wibble' );
+ $this->wpbp->save();
+ $this->assertCount( 1, $this->wpbp->get_batches() );
+ $this->assertFalse( $cancelled_fired, 'cancelled action not fired yet' );
+ $this->assertFalse( $paused_fired, 'paused action not fired yet' );
+ $this->assertFalse( $resumed_fired, 'resumed action not fired yet' );
+ $this->assertFalse( $completed_fired, 'completed action not fired yet' );
+
+ $_REQUEST['nonce'] = wp_create_nonce( $this->getWPBPProperty( 'identifier' ) );
+ $this->wpbp->maybe_handle();
+ $this->assertCount( 0, $this->wpbp->get_batches(), 'after resume all batches processed with maybe_handle' );
+ $this->assertFalse( $cancelled_fired, 'cancelled action still not fired yet' );
+ $this->assertFalse( $paused_fired, 'paused action not fired yet' );
+ $this->assertFalse( $resumed_fired, 'resumed action still not fired yet' );
+ $this->assertTrue( $completed_fired, 'completed action fired' );
+ }
+
+ /**
+ * Test maybe_handle when handling nothing.
+ *
+ * @return void
+ */
+ public function test_maybe_handle_nothing() {
+ // Cancelled action should not be fired.
+ $cancelled_fired = false;
+ add_action( $this->getWPBPProperty( 'identifier' ) . '_cancelled', function () use ( &$cancelled_fired ) {
+ $cancelled_fired = true;
+ } );
+ // Paused action should not be fired.
+ $paused_fired = false;
+ add_action( $this->getWPBPProperty( 'identifier' ) . '_paused', function () use ( &$paused_fired ) {
+ $paused_fired = true;
+ } );
+ // Resumed action should not be fired.
+ $resumed_fired = false;
+ add_action( $this->getWPBPProperty( 'identifier' ) . '_resumed', function () use ( &$resumed_fired ) {
+ $resumed_fired = true;
+ } );
+ // Completed action should not be fired.
+ $completed_fired = false;
+ add_action( $this->getWPBPProperty( 'identifier' ) . '_completed', function () use ( &$completed_fired ) {
+ $completed_fired = true;
+ } );
+ add_filter( $this->getWPBPProperty( 'identifier' ) . '_wp_die', '__return_false' );
+ $this->assertCount( 0, $this->wpbp->get_batches() );
+ $this->assertFalse( $cancelled_fired, 'cancelled action not fired yet' );
+ $this->assertFalse( $paused_fired, 'paused action not fired yet' );
+ $this->assertFalse( $resumed_fired, 'resumed action not fired yet' );
+ $this->assertFalse( $completed_fired, 'completed action not fired yet' );
+
+ $this->wpbp->maybe_handle();
+ $this->assertCount( 0, $this->wpbp->get_batches(), 'after resume all batches processed with maybe_handle' );
+ $this->assertFalse( $cancelled_fired, 'cancelled action still not fired yet' );
+ $this->assertFalse( $paused_fired, 'paused action not fired yet' );
+ $this->assertFalse( $resumed_fired, 'resumed action still not fired yet' );
+ $this->assertFalse( $completed_fired, 'completed action not fired yet' );
+ }
+
+ /**
+ * Test is_processing.
+ *
+ * @return void
+ */
+ public function test_is_processing() {
+ $this->assertFalse( $this->wpbp->is_processing(), 'not processing yet' );
+ $this->executeWPBPMethod( 'lock_process' );
+ $this->assertTrue( $this->wpbp->is_processing(), 'processing' );
+
+ // With batches to be processed, maybe_handle does nothing as "another instance is processing".
+ add_filter( $this->getWPBPProperty( 'identifier' ) . '_wp_die', '__return_false' );
+ $this->wpbp->push_to_queue( 'wibble' );
+ $this->wpbp->save();
+ $this->assertCount( 1, $this->wpbp->get_batches() );
+ $this->wpbp->maybe_handle();
+ $this->assertCount( 1, $this->wpbp->get_batches() );
+
+ // Unlock and maybe_handle can process the batch.
+ $this->executeWPBPMethod( 'unlock_process' );
+ $this->assertFalse( $this->wpbp->is_processing(), 'not processing yet' );
+ $this->assertCount( 1, $this->wpbp->get_batches() );
+ $_REQUEST['nonce'] = wp_create_nonce( $this->getWPBPProperty( 'identifier' ) );
+ $this->wpbp->maybe_handle();
+ $this->assertCount( 0, $this->wpbp->get_batches() );
+ $this->assertFalse( $this->wpbp->is_processing(), 'not left processing on complete' );
+ }
+
+ /**
+ * Test is_queued.
+ *
+ * @return void
+ */
+ public function test_is_queued() {
+ $this->assertFalse( $this->wpbp->is_queued(), 'nothing queued until save' );
+
+ $this->wpbp->push_to_queue( 'wibble' );
+ $this->assertFalse( $this->wpbp->is_queued(), 'nothing queued until save' );
+
+ $this->wpbp->save();
+ $this->assertTrue( $this->wpbp->is_queued(), 'queued items exist' );
+
+ $this->wpbp->push_to_queue( 'wobble' );
+ $this->wpbp->save();
+ $this->assertTrue( $this->wpbp->is_queued(), 'queued items exist' );
+
+ $this->wpbp->delete_all();
+ $this->assertFalse( $this->wpbp->is_queued(), 'queue emptied' );
+ }
+
+ /**
+ * Test is_active.
+ *
+ * @return void
+ */
+ public function test_is_active() {
+ $this->assertFalse( $this->wpbp->is_active(), 'not queued, processing, paused or cancelling' );
+
+ // Queued.
+ $this->wpbp->push_to_queue( 'wibble' );
+ $this->assertFalse( $this->wpbp->is_active(), 'nothing queued until save' );
+
+ $this->wpbp->save();
+ $this->assertTrue( $this->wpbp->is_active(), 'queued items exist, so now active' );
+
+ $this->wpbp->delete_all();
+ $this->assertFalse( $this->wpbp->is_active(), 'queue emptied, so no longer active' );
+
+ // Processing.
+ $this->executeWPBPMethod( 'lock_process' );
+ $this->assertTrue( $this->wpbp->is_active(), 'processing, so now active' );
+
+ $this->executeWPBPMethod( 'unlock_process' );
+ $this->assertFalse( $this->wpbp->is_active(), 'not processing, so no longer active' );
+
+ // Paused.
+ $this->wpbp->pause();
+ $this->assertTrue( $this->wpbp->is_active(), 'paused, so now active' );
+
+ $this->wpbp->resume();
+ $this->assertFalse( $this->wpbp->is_active(), 'not paused, nothing queued, so no longer active' );
+
+ $this->wpbp->push_to_queue( 'wibble' );
+ $this->wpbp->save();
+ $this->assertTrue( $this->wpbp->is_active(), 'queued items exist, so now active' );
+ $this->wpbp->pause();
+ $this->assertTrue( $this->wpbp->is_active(), 'paused, so still active' );
+ add_filter( 'pre_http_request', '__return_true' );
+ $this->wpbp->resume();
+ remove_filter( 'pre_http_request', '__return_true' );
+ $this->assertTrue( $this->wpbp->is_active(), 'resumed but with queued items, so still active' );
+ $this->wpbp->delete_all();
+ $this->assertFalse( $this->wpbp->is_active(), 'queue emptied, so no longer active' );
+
+ // Cancelled.
+ add_filter( 'pre_http_request', '__return_true' );
+ $this->wpbp->cancel();
+ remove_filter( 'pre_http_request', '__return_true' );
+ $this->assertTrue( $this->wpbp->is_active(), 'cancelling, so now active' );
+
+ add_filter( $this->getWPBPProperty( 'identifier' ) . '_wp_die', '__return_false' );
+ $this->wpbp->maybe_handle();
+ $this->assertFalse( $this->wpbp->is_active(), 'cancel handled, so no longer active' );
+
+ $this->wpbp->push_to_queue( 'wibble' );
+ $this->wpbp->save();
+ $this->assertTrue( $this->wpbp->is_active(), 'queued items exist, so now active' );
+ add_filter( 'pre_http_request', '__return_true' );
+ $this->wpbp->cancel();
+ remove_filter( 'pre_http_request', '__return_true' );
+ $this->assertTrue( $this->wpbp->is_active(), 'cancelling, so still active' );
+ $this->wpbp->maybe_handle();
+ $this->assertFalse( $this->wpbp->is_active(), 'cancel handled, queue emptied, so no longer active' );
+ }
+
+ /**
+ * Test get_cron_interval.
+ *
+ * @return void
+ */
+ public function test_get_cron_interval() {
+ // Default value.
+ $this->assertEquals( 5, $this->wpbp->get_cron_interval() );
+
+ // Override via property (usually on subclass).
+ $this->wpbp->cron_interval = 3;
+ $this->assertEquals( 3, $this->wpbp->get_cron_interval() );
+
+ // Override via filter.
+ $callback = function ( $interval ) {
+ return 1;
+ };
+ add_filter( $this->getWPBPProperty( 'identifier' ) . '_cron_interval', $callback );
+ $this->assertEquals( 1, $this->wpbp->get_cron_interval() );
+
+ remove_filter( $this->getWPBPProperty( 'identifier' ) . '_cron_interval', $callback );
+ $this->assertEquals( 3, $this->wpbp->get_cron_interval() );
+
+ unset( $this->wpbp->cron_interval );
+ $this->assertEquals( 5, $this->wpbp->get_cron_interval() );
+ }
+}
diff --git a/classes/Dependencies/deliciousbrains/wp-background-processing/tests/bootstrap.php b/classes/Dependencies/deliciousbrains/wp-background-processing/tests/bootstrap.php
new file mode 100644
index 000000000..94036dc18
--- /dev/null
+++ b/classes/Dependencies/deliciousbrains/wp-background-processing/tests/bootstrap.php
@@ -0,0 +1,38 @@
+=7.2`
+- Updated `psr/container` to ^2.0.0
+- `Container::shared` convenience method is now explicit `Container::addShared` method
+- Removed third argument `$shared` from `Container::add`, use `Container::addShared`
+- `ServiceProviderInterface` now defines return types
+- Service providers now require implementation of a `provides` method rather than relying on a class property.
+
+## 3.4.1
+
+### Added
+- Way to handle non-public controllers safely (@beryllium)
+- PHPUnit ^7.0 for PHP versions that support it (@beryllium)
+
+## 3.4.0
+
+### Removed
+- Support for `psr/container` ^2.0.0 as the interface cannot be reconciled between versions
+
+## 3.3.5
+
+### Added
+- Support for `psr/container` ^2.0.0
+
+## 3.3.4
+
+### Fixed
+- Fixed an issue that caused a recursive `register` call. @pcoutinho
+- Fixed a return type declaration. @orbex
+
+## 3.3.3
+
+### Fixed
+- Fixed bug relating to `ReflectionContainer::call` on arrow functions.
+
+## 3.3.2
+
+### Added
+- Experimental support for PHP 8.
+
+### Fixed
+- Fix issue when preventing reflection from using default value for arguments.
+
+## 3.3.1
+
+### Fixed
+- Respect `$new` argument when getting tagged definitions.
+
+## 3.3.0
+
+### Added
+- Support for PHP 7.3
+- `{set,get}LeagueContainer` methods added to ContainerAwareTrait as a temporary measure until next major release when this can be properly addressed, less hinting of `Psr\Container\ContainerInterface`
+
+### Changed
+- Various internal code improvements
+
+### Fixed
+- Fix for `setConcrete` not re-resolving class on when overriding (@jleeothon)
+- Fix stack overflow error incase a service provider lies about providing a specific service (@azjezz)
+- Fix issue where providers may be aggregated multiple times (@bwg)
+- Various documentation fixes
+
+## 3.2.2
+
+### Fixed
+- Fixed issue that prevented service providers from registering if a previous one in the aggregate was already registered.
+
+## 3.2.1
+
+### Fixed
+- Fixed issue where all service providers were registered regardless of whether they need to be.
+
+## 3.2.0
+
+### Added
+- Added ability to add definition as not shared when container is set to default to shared.
+- Added `{set|get}Concrete` to definitions to allow for better use of `extend`.
+
+## 3.1.0
+
+### Added
+- Re-added the `share` proxy method that was mistakenly removed in previous major release.
+- Added ability to set Container to "share" by default using `defaultToShared` method.
+- Added ability for `ReflectionContainer` to cache resolutions and pull from cache for following calls.
+
+## 3.0.1
+
+### Added
+- Allow definition aggregates to be built outside of container.
+
+## 3.0.0
+
+### Added
+- Service providers can now be pulled from the container if they are registered.
+- Definition logic now handled by aggregate for better separation.
+- Now able to add tags to a definition to return an array of items containing that tag.
+
+### Changed
+- Updated minimum PHP requirements to 7.0.
+- Now depend directly on PSR-11 interfaces, including providing PSR-11 exceptions.
+- Refactored inflector logic to accept type on construction and use generator to iterate.
+- Refactored service provider logic with better separation and performance.
+- Merged service provider signature logic in to one interface and abstract.
+- Heavily simplified definition logic providing more control to user.
+
+## 2.4.1
+
+### Fixed
+- Ensures `ReflectionContainer` converts class name in array callable to object.
+
+## 2.4.0
+
+### Changed
+- Can now wrap shared objects as `RawArgument`.
+- Ability to override shared items.
+
+### Fixed
+- Booleans now recognised as accepted values.
+- Various docblock fixes.
+- Unused imports removed.
+- Unreachable arguments no longer passed.
+
+## 2.3.0
+
+### Added
+- Now implementation of the PSR-11.
+
+## 2.2.0
+
+### Changed
+- Service providers can now be added multiple times by giving them a signature.
+
+## 2.1.0
+
+### Added
+- Allow resolving of `RawArgument` objects as first class dependencies.
+
+### Changed
+- Unnecessary recursion removed from `Container::get`.
+
+## 2.0.3
+
+### Fixed
+- Bug where delegating container was not passed to delegate when needed.
+- Bug where `Container::extend` would not return a shared definition to extend.
+
+## 2.0.2
+
+### Fixed
+- Bug introduced in 2.0.1 where shared definitions registered via a service provider would never be returned as shared.
+
+## 2.0.1
+
+### Fixed
+- Bug where shared definitions were not stored as shared.
+
+## 2.0.0
+
+### Added
+- Now implementation of the container-interop project.
+- `BootableServiceProviderInterface` for eagerly loaded service providers.
+- Delegate container functionality.
+- `RawArgument` to ensure scalars are not resolved from the container but seen as an argument.
+
+### Altered
+- Refactor of definition functionality.
+- `Container::share` replaces `singleton` functionality to improve understanding.
+- Auto wiring is now disabled by default.
+- Auto wiring abstracted to be a delegate container `ReflectionContainer` handling all reflection based functionality.
+- Inflection functionality abstracted to an aggregate.
+- Service provider functionality abstracted to an aggregate.
+- Much bloat removed.
+- `Container::call` now proxies to `ReflectionContainer::call` and handles argument resolution in a much more efficient way.
+
+### Removed
+- Ability to register invokables, this functionality added a layer of complexity too large for the problem it solved.
+- Container no longer accepts a configuration array, this functionality will now be provided by an external service provider package.
+
+## 1.4.0
+
+### Added
+- Added `isRegisteredCallable` method to public API.
+- Invoking `call` now accepts named arguments at runtime.
+
+### Fixed
+- Container now stores instantiated Service Providers after first instantiation.
+- Extending a definition now looks in Service Providers as well as just Definitions.
+
+## 1.3.1 - 2015-02-21
+
+### Fixed
+- Fixed bug where arbitrary values were attempted to be resolved as classes.
+
+## 1.3.0 - 2015-02-09
+
+### Added
+- Added `ServiceProvider` functionality to allow cleaner resolving of complex dependencies.
+- Added `Inflector` functionality to allow for manipulation of resolved objects of a specific type.
+- Improvements to DRY throughout the package.
+
+### Fixed
+- Setter in `ContainerAwareTrait` now returns self (`$this`).
+
+## 1.2.1 - 2015-01-29
+
+### Fixed
+- Allow arbitrary values to be registered via container config.
+
+## 1.2.0 - 2015-01-13
+
+### Added
+- Improvements to `Container::call` functionality.
+
+### Fixed
+- General code tidy.
+- Improvements to test suite.
+
+## 1.1.1 - 2015-01-13
+
+### Fixed
+- Allow singleton to be passed as method argument.
+
+## 1.1.0 - 2015-01-12
+
+### Added
+- Addition of `ContainerAwareTrait` to provide functionality from `ContainerAwareInterface`.
+
+## 1.0.0 - 2015-01-12
+
+### Added
+- Migrated from [Orno\Di](https://github.com/orno/di).
\ No newline at end of file
diff --git a/classes/Dependencies/league/container/CONTRIBUTING.md b/classes/Dependencies/league/container/CONTRIBUTING.md
new file mode 100644
index 000000000..d62f88db5
--- /dev/null
+++ b/classes/Dependencies/league/container/CONTRIBUTING.md
@@ -0,0 +1,29 @@
+# Contributing
+
+Contributions are **welcome** and will be fully **credited**.
+
+We accept contributions via Pull Requests on [GitHub](https://github.com/thephpleague/container).
+
+## Pull Requests
+
+- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer).
+
+- **Add tests!** - Your patch won't be accepted if it doesn't have tests.
+
+- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.
+
+- **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option.
+
+- **Create feature branches** - Don't ask us to pull from your master branch.
+
+- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
+
+- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please squash them before submitting.
+
+## Running Tests
+
+``` bash
+$ composer test
+```
+
+**Happy coding**!
diff --git a/classes/Dependencies/league/container/LICENSE.md b/classes/Dependencies/league/container/LICENSE.md
new file mode 100644
index 000000000..38964cd94
--- /dev/null
+++ b/classes/Dependencies/league/container/LICENSE.md
@@ -0,0 +1,21 @@
+# The MIT License (MIT)
+
+Copyright (c) 2021 Phil Bennett
+
+> 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.
diff --git a/classes/Dependencies/league/container/README.md b/classes/Dependencies/league/container/README.md
new file mode 100644
index 000000000..69c786cb5
--- /dev/null
+++ b/classes/Dependencies/league/container/README.md
@@ -0,0 +1,70 @@
+# Container (Dependency Injection)
+
+[](https://github.com/philipobenito)
+[](https://github.com/thephpleague/container/releases)
+[](LICENSE.md)
+[](https://github.com/thephpleague/container/actions/workflows/test.yml)
+[](https://scrutinizer-ci.com/g/thephpleague/container/code-structure)
+[](https://scrutinizer-ci.com/g/thephpleague/container)
+[](https://packagist.org/packages/league/container)
+
+This package is compliant with [PSR-1], [PSR-2], [PSR-12], [PSR-4], [PSR-11] and [PSR-12]. If you notice compliance oversights, please send a patch via pull request.
+
+[PSR-1]: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md
+[PSR-2]: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md
+[PSR-12]: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-12-extended-coding-style-guide.md
+[PSR-4]: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader.md
+[PSR-11]: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-11-container.md
+[PSR-12]: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-12-extended-coding-style-guide.md
+
+## Install
+
+Via Composer
+
+``` bash
+composer require league/container
+```
+
+## Requirements
+
+The following versions of PHP are supported by this version.
+
+* PHP 7.2
+* PHP 7.3
+* PHP 7.4
+* PHP 8.0
+* PHP 8.1
+* PHP 8.2
+* PHP 8.3
+* PHP 8.4
+
+## Documentation
+
+Container has [full documentation](http://container.thephpleague.com), powered by [Jekyll](http://jekyllrb.com/).
+
+Contribute to this documentation in the [docs/](https://github.com/thephpleague/container/tree/master/docs) sub-directory.
+
+## Testing
+
+Testing includes PHPUnit and PHPStan (Level 7).
+``` bash
+$ composer test
+```
+
+## Contributing
+
+Please see [CONTRIBUTING](https://github.com/thephpleague/container/blob/master/CONTRIBUTING.md) for details.
+
+## Security
+
+If you discover any security related issues, please email philipobenito@gmail.com instead of using the issue tracker.
+
+## Credits
+
+- [Phil Bennett](https://github.com/philipobenito)
+- [All Contributors](https://github.com/thephpleague/container/contributors)
+- `Orno\Di` contributors
+
+## License
+
+The MIT License (MIT). Please see [License File](https://github.com/thephpleague/container/blob/master/LICENSE.md) for more information.
diff --git a/classes/Dependencies/league/container/composer.json b/classes/Dependencies/league/container/composer.json
new file mode 100644
index 000000000..423d3b197
--- /dev/null
+++ b/classes/Dependencies/league/container/composer.json
@@ -0,0 +1,69 @@
+{
+ "name": "league/container",
+ "description": "A fast and intuitive dependency injection container.",
+ "keywords": [
+ "league",
+ "container",
+ "dependency",
+ "injection",
+ "di",
+ "service",
+ "provider"
+ ],
+ "homepage": "https://github.com/thephpleague/container",
+ "license": "MIT",
+ "authors": [
+ {
+ "name": "Phil Bennett",
+ "email": "mail@philbennett.co.uk",
+ "role": "Developer"
+ }
+ ],
+ "require": {
+ "php": "^7.2 || ^8.0",
+ "psr/container": "^1.1 || ^2.0"
+ },
+ "require-dev": {
+ "nette/php-generator": "^3.4",
+ "nikic/php-parser": "^4.10",
+ "phpstan/phpstan": "^0.12.47",
+ "phpunit/phpunit": "^8.5.17",
+ "roave/security-advisories": "dev-latest",
+ "scrutinizer/ocular": "^1.8",
+ "squizlabs/php_codesniffer": "^3.6"
+ },
+ "provide": {
+ "psr/container-implementation": "^1.0"
+ },
+ "replace": {
+ "orno/di": "~2.0"
+ },
+ "autoload": {
+ "psr-4": {
+ "League\\Container\\": "src"
+ }
+ },
+ "autoload-dev": {
+ "psr-4": {
+ "League\\Container\\Test\\": "tests"
+ },
+ "files": [
+ "tests/Asset/function.php"
+ ]
+ },
+ "extra": {
+ "branch-alias": {
+ "dev-master": "4.x-dev",
+ "dev-4.x": "4.x-dev",
+ "dev-3.x": "3.x-dev",
+ "dev-2.x": "2.x-dev",
+ "dev-1.x": "1.x-dev"
+ }
+ },
+ "scripts": {
+ "test": [
+ "phpunit",
+ "phpstan analyse"
+ ]
+ }
+}
diff --git a/classes/Dependencies/League/Container/Argument/ArgumentInterface.php b/classes/Dependencies/league/container/src/Argument/ArgumentInterface.php
similarity index 100%
rename from classes/Dependencies/League/Container/Argument/ArgumentInterface.php
rename to classes/Dependencies/league/container/src/Argument/ArgumentInterface.php
diff --git a/classes/Dependencies/League/Container/Argument/ArgumentResolverInterface.php b/classes/Dependencies/league/container/src/Argument/ArgumentResolverInterface.php
similarity index 100%
rename from classes/Dependencies/League/Container/Argument/ArgumentResolverInterface.php
rename to classes/Dependencies/league/container/src/Argument/ArgumentResolverInterface.php
diff --git a/classes/Dependencies/League/Container/Argument/ArgumentResolverTrait.php b/classes/Dependencies/league/container/src/Argument/ArgumentResolverTrait.php
similarity index 100%
rename from classes/Dependencies/League/Container/Argument/ArgumentResolverTrait.php
rename to classes/Dependencies/league/container/src/Argument/ArgumentResolverTrait.php
diff --git a/classes/Dependencies/League/Container/Argument/DefaultValueArgument.php b/classes/Dependencies/league/container/src/Argument/DefaultValueArgument.php
similarity index 100%
rename from classes/Dependencies/League/Container/Argument/DefaultValueArgument.php
rename to classes/Dependencies/league/container/src/Argument/DefaultValueArgument.php
diff --git a/classes/Dependencies/League/Container/Argument/DefaultValueInterface.php b/classes/Dependencies/league/container/src/Argument/DefaultValueInterface.php
similarity index 100%
rename from classes/Dependencies/League/Container/Argument/DefaultValueInterface.php
rename to classes/Dependencies/league/container/src/Argument/DefaultValueInterface.php
diff --git a/classes/Dependencies/League/Container/Argument/Literal/ArrayArgument.php b/classes/Dependencies/league/container/src/Argument/Literal/ArrayArgument.php
similarity index 100%
rename from classes/Dependencies/League/Container/Argument/Literal/ArrayArgument.php
rename to classes/Dependencies/league/container/src/Argument/Literal/ArrayArgument.php
diff --git a/classes/Dependencies/League/Container/Argument/Literal/BooleanArgument.php b/classes/Dependencies/league/container/src/Argument/Literal/BooleanArgument.php
similarity index 100%
rename from classes/Dependencies/League/Container/Argument/Literal/BooleanArgument.php
rename to classes/Dependencies/league/container/src/Argument/Literal/BooleanArgument.php
diff --git a/classes/Dependencies/League/Container/Argument/Literal/CallableArgument.php b/classes/Dependencies/league/container/src/Argument/Literal/CallableArgument.php
similarity index 100%
rename from classes/Dependencies/League/Container/Argument/Literal/CallableArgument.php
rename to classes/Dependencies/league/container/src/Argument/Literal/CallableArgument.php
diff --git a/classes/Dependencies/League/Container/Argument/Literal/FloatArgument.php b/classes/Dependencies/league/container/src/Argument/Literal/FloatArgument.php
similarity index 100%
rename from classes/Dependencies/League/Container/Argument/Literal/FloatArgument.php
rename to classes/Dependencies/league/container/src/Argument/Literal/FloatArgument.php
diff --git a/classes/Dependencies/League/Container/Argument/Literal/IntegerArgument.php b/classes/Dependencies/league/container/src/Argument/Literal/IntegerArgument.php
similarity index 100%
rename from classes/Dependencies/League/Container/Argument/Literal/IntegerArgument.php
rename to classes/Dependencies/league/container/src/Argument/Literal/IntegerArgument.php
diff --git a/classes/Dependencies/League/Container/Argument/Literal/ObjectArgument.php b/classes/Dependencies/league/container/src/Argument/Literal/ObjectArgument.php
similarity index 100%
rename from classes/Dependencies/League/Container/Argument/Literal/ObjectArgument.php
rename to classes/Dependencies/league/container/src/Argument/Literal/ObjectArgument.php
diff --git a/classes/Dependencies/League/Container/Argument/Literal/StringArgument.php b/classes/Dependencies/league/container/src/Argument/Literal/StringArgument.php
similarity index 100%
rename from classes/Dependencies/League/Container/Argument/Literal/StringArgument.php
rename to classes/Dependencies/league/container/src/Argument/Literal/StringArgument.php
diff --git a/classes/Dependencies/League/Container/Argument/LiteralArgument.php b/classes/Dependencies/league/container/src/Argument/LiteralArgument.php
similarity index 100%
rename from classes/Dependencies/League/Container/Argument/LiteralArgument.php
rename to classes/Dependencies/league/container/src/Argument/LiteralArgument.php
diff --git a/classes/Dependencies/League/Container/Argument/LiteralArgumentInterface.php b/classes/Dependencies/league/container/src/Argument/LiteralArgumentInterface.php
similarity index 100%
rename from classes/Dependencies/League/Container/Argument/LiteralArgumentInterface.php
rename to classes/Dependencies/league/container/src/Argument/LiteralArgumentInterface.php
diff --git a/classes/Dependencies/League/Container/Argument/ResolvableArgument.php b/classes/Dependencies/league/container/src/Argument/ResolvableArgument.php
similarity index 100%
rename from classes/Dependencies/League/Container/Argument/ResolvableArgument.php
rename to classes/Dependencies/league/container/src/Argument/ResolvableArgument.php
diff --git a/classes/Dependencies/League/Container/Argument/ResolvableArgumentInterface.php b/classes/Dependencies/league/container/src/Argument/ResolvableArgumentInterface.php
similarity index 100%
rename from classes/Dependencies/League/Container/Argument/ResolvableArgumentInterface.php
rename to classes/Dependencies/league/container/src/Argument/ResolvableArgumentInterface.php
diff --git a/classes/Dependencies/League/Container/Container.php b/classes/Dependencies/league/container/src/Container.php
similarity index 100%
rename from classes/Dependencies/League/Container/Container.php
rename to classes/Dependencies/league/container/src/Container.php
diff --git a/classes/Dependencies/League/Container/ContainerAwareInterface.php b/classes/Dependencies/league/container/src/ContainerAwareInterface.php
similarity index 100%
rename from classes/Dependencies/League/Container/ContainerAwareInterface.php
rename to classes/Dependencies/league/container/src/ContainerAwareInterface.php
diff --git a/classes/Dependencies/League/Container/ContainerAwareTrait.php b/classes/Dependencies/league/container/src/ContainerAwareTrait.php
similarity index 100%
rename from classes/Dependencies/League/Container/ContainerAwareTrait.php
rename to classes/Dependencies/league/container/src/ContainerAwareTrait.php
diff --git a/classes/Dependencies/League/Container/Definition/Definition.php b/classes/Dependencies/league/container/src/Definition/Definition.php
similarity index 91%
rename from classes/Dependencies/League/Container/Definition/Definition.php
rename to classes/Dependencies/league/container/src/Definition/Definition.php
index 0918959e8..ed441f1f5 100644
--- a/classes/Dependencies/League/Container/Definition/Definition.php
+++ b/classes/Dependencies/league/container/src/Definition/Definition.php
@@ -12,7 +12,6 @@
};
use Imagify\Dependencies\League\Container\ContainerAwareTrait;
use Imagify\Dependencies\League\Container\Exception\ContainerException;
-use Imagify\Dependencies\League\Container\Exception\NotFoundException;
use Imagify\Dependencies\Psr\Container\ContainerInterface;
use ReflectionClass;
@@ -56,11 +55,6 @@ class Definition implements ArgumentResolverInterface, DefinitionInterface
*/
protected $resolved;
- /**
- * @var array
- */
- protected $recursiveCheck = [];
-
/**
* @param string $id
* @param mixed|null $concrete
@@ -181,8 +175,12 @@ public function resolveNew()
$concrete = $concrete->getValue();
}
- if (is_string($concrete) && class_exists($concrete)) {
- $concrete = $this->resolveClass($concrete);
+ if (is_string($concrete)) {
+ if (class_exists($concrete)) {
+ $concrete = $this->resolveClass($concrete);
+ } elseif ($this->getAlias() === $concrete) {
+ return $concrete;
+ }
}
if (is_object($concrete)) {
@@ -195,16 +193,9 @@ public function resolveNew()
$container = null;
}
- // stop recursive resolving
- if (is_string($concrete) && in_array($concrete, $this->recursiveCheck)) {
- $this->resolved = $concrete;
- return $concrete;
- }
-
// if we still have a string, try to pull it from the container
// this allows for `alias -> alias -> ... -> concrete
if (is_string($concrete) && $container instanceof ContainerInterface && $container->has($concrete)) {
- $this->recursiveCheck[] = $concrete;
$concrete = $container->get($concrete);
}
diff --git a/classes/Dependencies/League/Container/Definition/DefinitionAggregate.php b/classes/Dependencies/league/container/src/Definition/DefinitionAggregate.php
similarity index 100%
rename from classes/Dependencies/League/Container/Definition/DefinitionAggregate.php
rename to classes/Dependencies/league/container/src/Definition/DefinitionAggregate.php
diff --git a/classes/Dependencies/League/Container/Definition/DefinitionAggregateInterface.php b/classes/Dependencies/league/container/src/Definition/DefinitionAggregateInterface.php
similarity index 100%
rename from classes/Dependencies/League/Container/Definition/DefinitionAggregateInterface.php
rename to classes/Dependencies/league/container/src/Definition/DefinitionAggregateInterface.php
diff --git a/classes/Dependencies/League/Container/Definition/DefinitionInterface.php b/classes/Dependencies/league/container/src/Definition/DefinitionInterface.php
similarity index 100%
rename from classes/Dependencies/League/Container/Definition/DefinitionInterface.php
rename to classes/Dependencies/league/container/src/Definition/DefinitionInterface.php
diff --git a/classes/Dependencies/League/Container/DefinitionContainerInterface.php b/classes/Dependencies/league/container/src/DefinitionContainerInterface.php
similarity index 100%
rename from classes/Dependencies/League/Container/DefinitionContainerInterface.php
rename to classes/Dependencies/league/container/src/DefinitionContainerInterface.php
diff --git a/classes/Dependencies/League/Container/Exception/ContainerException.php b/classes/Dependencies/league/container/src/Exception/ContainerException.php
similarity index 100%
rename from classes/Dependencies/League/Container/Exception/ContainerException.php
rename to classes/Dependencies/league/container/src/Exception/ContainerException.php
diff --git a/classes/Dependencies/League/Container/Exception/NotFoundException.php b/classes/Dependencies/league/container/src/Exception/NotFoundException.php
similarity index 100%
rename from classes/Dependencies/League/Container/Exception/NotFoundException.php
rename to classes/Dependencies/league/container/src/Exception/NotFoundException.php
diff --git a/classes/Dependencies/League/Container/Inflector/Inflector.php b/classes/Dependencies/league/container/src/Inflector/Inflector.php
similarity index 100%
rename from classes/Dependencies/League/Container/Inflector/Inflector.php
rename to classes/Dependencies/league/container/src/Inflector/Inflector.php
diff --git a/classes/Dependencies/League/Container/Inflector/InflectorAggregate.php b/classes/Dependencies/league/container/src/Inflector/InflectorAggregate.php
similarity index 100%
rename from classes/Dependencies/League/Container/Inflector/InflectorAggregate.php
rename to classes/Dependencies/league/container/src/Inflector/InflectorAggregate.php
diff --git a/classes/Dependencies/League/Container/Inflector/InflectorAggregateInterface.php b/classes/Dependencies/league/container/src/Inflector/InflectorAggregateInterface.php
similarity index 100%
rename from classes/Dependencies/League/Container/Inflector/InflectorAggregateInterface.php
rename to classes/Dependencies/league/container/src/Inflector/InflectorAggregateInterface.php
diff --git a/classes/Dependencies/League/Container/Inflector/InflectorInterface.php b/classes/Dependencies/league/container/src/Inflector/InflectorInterface.php
similarity index 100%
rename from classes/Dependencies/League/Container/Inflector/InflectorInterface.php
rename to classes/Dependencies/league/container/src/Inflector/InflectorInterface.php
diff --git a/classes/Dependencies/League/Container/ReflectionContainer.php b/classes/Dependencies/league/container/src/ReflectionContainer.php
similarity index 100%
rename from classes/Dependencies/League/Container/ReflectionContainer.php
rename to classes/Dependencies/league/container/src/ReflectionContainer.php
diff --git a/classes/Dependencies/League/Container/ServiceProvider/AbstractServiceProvider.php b/classes/Dependencies/league/container/src/ServiceProvider/AbstractServiceProvider.php
similarity index 100%
rename from classes/Dependencies/League/Container/ServiceProvider/AbstractServiceProvider.php
rename to classes/Dependencies/league/container/src/ServiceProvider/AbstractServiceProvider.php
diff --git a/classes/Dependencies/League/Container/ServiceProvider/BootableServiceProviderInterface.php b/classes/Dependencies/league/container/src/ServiceProvider/BootableServiceProviderInterface.php
similarity index 100%
rename from classes/Dependencies/League/Container/ServiceProvider/BootableServiceProviderInterface.php
rename to classes/Dependencies/league/container/src/ServiceProvider/BootableServiceProviderInterface.php
diff --git a/classes/Dependencies/League/Container/ServiceProvider/ServiceProviderAggregate.php b/classes/Dependencies/league/container/src/ServiceProvider/ServiceProviderAggregate.php
similarity index 100%
rename from classes/Dependencies/League/Container/ServiceProvider/ServiceProviderAggregate.php
rename to classes/Dependencies/league/container/src/ServiceProvider/ServiceProviderAggregate.php
diff --git a/classes/Dependencies/League/Container/ServiceProvider/ServiceProviderAggregateInterface.php b/classes/Dependencies/league/container/src/ServiceProvider/ServiceProviderAggregateInterface.php
similarity index 100%
rename from classes/Dependencies/League/Container/ServiceProvider/ServiceProviderAggregateInterface.php
rename to classes/Dependencies/league/container/src/ServiceProvider/ServiceProviderAggregateInterface.php
diff --git a/classes/Dependencies/League/Container/ServiceProvider/ServiceProviderInterface.php b/classes/Dependencies/league/container/src/ServiceProvider/ServiceProviderInterface.php
similarity index 100%
rename from classes/Dependencies/League/Container/ServiceProvider/ServiceProviderInterface.php
rename to classes/Dependencies/league/container/src/ServiceProvider/ServiceProviderInterface.php
diff --git a/classes/Dependencies/psr/container/.gitignore b/classes/Dependencies/psr/container/.gitignore
new file mode 100644
index 000000000..b2395aa05
--- /dev/null
+++ b/classes/Dependencies/psr/container/.gitignore
@@ -0,0 +1,3 @@
+composer.lock
+composer.phar
+/vendor/
diff --git a/classes/Dependencies/psr/container/LICENSE b/classes/Dependencies/psr/container/LICENSE
new file mode 100644
index 000000000..2877a4894
--- /dev/null
+++ b/classes/Dependencies/psr/container/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2013-2016 container-interop
+Copyright (c) 2016 PHP Framework Interoperability Group
+
+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.
diff --git a/classes/Dependencies/psr/container/README.md b/classes/Dependencies/psr/container/README.md
new file mode 100644
index 000000000..1b9d9e570
--- /dev/null
+++ b/classes/Dependencies/psr/container/README.md
@@ -0,0 +1,13 @@
+Container interface
+==============
+
+This repository holds all interfaces related to [PSR-11 (Container Interface)][psr-url].
+
+Note that this is not a Container implementation of its own. It is merely abstractions that describe the components of a Dependency Injection Container.
+
+The installable [package][package-url] and [implementations][implementation-url] are listed on Packagist.
+
+[psr-url]: https://www.php-fig.org/psr/psr-11/
+[package-url]: https://packagist.org/packages/psr/container
+[implementation-url]: https://packagist.org/providers/psr/container-implementation
+
diff --git a/classes/Dependencies/psr/container/composer.json b/classes/Dependencies/psr/container/composer.json
new file mode 100644
index 000000000..baf6cd1a0
--- /dev/null
+++ b/classes/Dependencies/psr/container/composer.json
@@ -0,0 +1,27 @@
+{
+ "name": "psr/container",
+ "type": "library",
+ "description": "Common Container Interface (PHP FIG PSR-11)",
+ "keywords": ["psr", "psr-11", "container", "container-interop", "container-interface"],
+ "homepage": "https://github.com/php-fig/container",
+ "license": "MIT",
+ "authors": [
+ {
+ "name": "PHP-FIG",
+ "homepage": "https://www.php-fig.org/"
+ }
+ ],
+ "require": {
+ "php": ">=7.4.0"
+ },
+ "autoload": {
+ "psr-4": {
+ "Psr\\Container\\": "src/"
+ }
+ },
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.0.x-dev"
+ }
+ }
+}
diff --git a/classes/Dependencies/Psr/Container/ContainerExceptionInterface.php b/classes/Dependencies/psr/container/src/ContainerExceptionInterface.php
similarity index 100%
rename from classes/Dependencies/Psr/Container/ContainerExceptionInterface.php
rename to classes/Dependencies/psr/container/src/ContainerExceptionInterface.php
diff --git a/classes/Dependencies/Psr/Container/ContainerInterface.php b/classes/Dependencies/psr/container/src/ContainerInterface.php
similarity index 100%
rename from classes/Dependencies/Psr/Container/ContainerInterface.php
rename to classes/Dependencies/psr/container/src/ContainerInterface.php
diff --git a/classes/Dependencies/Psr/Container/NotFoundExceptionInterface.php b/classes/Dependencies/psr/container/src/NotFoundExceptionInterface.php
similarity index 100%
rename from classes/Dependencies/Psr/Container/NotFoundExceptionInterface.php
rename to classes/Dependencies/psr/container/src/NotFoundExceptionInterface.php
diff --git a/classes/Dependencies/wp-media/plugin-family/composer.json b/classes/Dependencies/wp-media/plugin-family/composer.json
new file mode 100644
index 000000000..a1488e4c7
--- /dev/null
+++ b/classes/Dependencies/wp-media/plugin-family/composer.json
@@ -0,0 +1,48 @@
+{
+ "name": "wp-media/plugin-family",
+ "description": "Organizes and displays WP Media plugin family across other members.",
+ "license": "GPL-3.0-or-later",
+ "authors": [
+ {
+ "name": "WP Media",
+ "email": "contact@wp-media.me",
+ "homepage": "https://wp-media.me"
+ }
+ ],
+ "config": {
+ "sort-packages": true,
+ "allow-plugins": {
+ "dealerdirect/phpcodesniffer-composer-installer": true,
+ "phpstan/extension-installer": true
+ }
+ },
+ "require": {
+ "wp-media/apply-filters-typed": "^1.0"
+ },
+ "require-dev": {
+ "phpcompatibility/phpcompatibility-wp": "^2.0",
+ "dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
+ "wp-coding-standards/wpcs": "^3",
+ "wp-media/phpunit": "^3",
+ "phpstan/extension-installer": "^1.4",
+ "szepeviktor/phpstan-wordpress": "^1.3"
+ },
+ "autoload": {
+ "psr-4": {
+ "WPMedia\\PluginFamily\\": "src/"
+ }
+ },
+ "autoload-dev": {
+ "psr-4": {
+ "WPMedia\\PluginFamily\\Tests\\": "tests/"
+ }
+ },
+ "scripts": {
+ "install-codestandards": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin::run",
+ "phpcs": "phpcs --basepath=.",
+ "phpcs:fix": "phpcbf",
+ "test-unit": "\"vendor/bin/phpunit\" --testsuite unit --colors=always --configuration tests/Unit/phpunit.xml.dist --coverage-php tests/report/unit.cov",
+ "report-code-coverage": "\"vendor/bin/phpcov\" merge tests/report --clover tests/report/coverage.clover",
+ "phpstan": "vendor/bin/phpstan analyze --memory-limit=2G --no-progress"
+ }
+}
diff --git a/classes/Dependencies/wp-media/plugin-family/package.json b/classes/Dependencies/wp-media/plugin-family/package.json
new file mode 100644
index 000000000..fe1720769
--- /dev/null
+++ b/classes/Dependencies/wp-media/plugin-family/package.json
@@ -0,0 +1,36 @@
+{
+ "name": "plugin-family",
+ "version": "1.0.5",
+ "description": "Organizes and displays WP Media plugin family across other members.",
+ "main": "src/assets/js/index.js",
+ "directories": {
+ "test": "tests"
+ },
+ "scripts": {
+ "start": "wp-scripts start assets-src/js/index.js assets-src/js/admin.js",
+ "build": "wp-scripts build assets-src/js/index.js assets-src/js/admin.js"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/wp-media/plugin-family.git"
+ },
+ "author": "WP Media",
+ "license": "GPL-3.0-or-later",
+ "bugs": {
+ "url": "https://github.com/wp-media/plugin-family/issues"
+ },
+ "homepage": "https://github.com/wp-media/plugin-family#readme",
+ "devDependencies": {
+ "@wordpress/scripts": "^30.19.0"
+ },
+ "dependencies": {
+ "@wordpress/api-fetch": "^7.26.0",
+ "@wordpress/block-editor": "^14.21.0",
+ "@wordpress/components": "^29.12.0",
+ "@wordpress/compose": "^7.26.0",
+ "@wordpress/element": "^6.26.0",
+ "@wordpress/hooks": "^4.26.0",
+ "@wordpress/i18n": "^5.26.0",
+ "@wordpress/icons": "^10.26.0"
+ }
+}
diff --git a/classes/Dependencies/wp-media/plugin-family/src/Controller/PluginFamily.php b/classes/Dependencies/wp-media/plugin-family/src/Controller/PluginFamily.php
new file mode 100644
index 000000000..d38bb581b
--- /dev/null
+++ b/classes/Dependencies/wp-media/plugin-family/src/Controller/PluginFamily.php
@@ -0,0 +1,605 @@
+screen_ids = $screen_ids;
+ $this->notice_text = (string) $notice_text;
+ }
+
+ /**
+ * Set post install event.
+ *
+ * @return array
+ */
+ public static function get_post_install_event(): array {
+ $allowed_plugin = [
+ 'uk-cookie-consent',
+ 'backwpup',
+ 'imagify',
+ 'seo-by-rank-math',
+ 'wp-rocket',
+ ];
+
+ if ( ! isset( $_GET['action'], $_GET['_wpnonce'], $_GET['plugin_to_install'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
+ return [];
+ }
+
+ $plugin = str_replace( 'plugin_family_install_', '', sanitize_text_field( wp_unslash( $_GET['action'] ) ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
+
+ if ( ! in_array( $plugin, $allowed_plugin, true ) ) {
+ return [];
+ }
+
+ return [
+ 'admin_post_plugin_family_install_' . $plugin => 'install_activate',
+ ];
+ }
+
+ /**
+ * Process to install and activate plugin.
+ *
+ * @return void
+ */
+ public function install_activate() {
+ if ( ! $this->is_allowed() ) {
+ wp_die(
+ 'Plugin Installation is not allowed.',
+ '',
+ [ 'back_link' => true ]
+ );
+ }
+
+ // Install plugin.
+ $this->install();
+
+ // Activate plugin.
+ $result = activate_plugin( $this->get_plugin(), '', is_multisite() );
+
+ if ( is_wp_error( $result ) ) {
+ $this->set_error( $result );
+ }
+
+ wp_safe_redirect( wp_get_referer() );
+ exit;
+ }
+
+ /**
+ * Install plugin.
+ *
+ * @param string $slug Plugin slug if found.
+ * @return void
+ */
+ private function install( $slug = '' ) {
+ if ( $this->is_installed( $slug ) ) {
+ return;
+ }
+
+ $upgrader_class = ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
+
+ if ( ! defined( 'ABSPATH' ) || ! file_exists( $upgrader_class ) ) {
+ wp_die(
+ 'Plugin Installation failed. class-wp-upgrader.php not found',
+ '',
+ [ 'back_link' => true ]
+ );
+ }
+
+ require_once $upgrader_class; // @phpstan-ignore-line
+
+ $upgrader = new \Plugin_Upgrader( new \Automatic_Upgrader_Skin() );
+ $result = $upgrader->install( $this->get_download_url( $slug ) );
+
+ if ( is_wp_error( $result ) ) {
+ $this->set_error( $result );
+ }
+
+ clearstatcache();
+ }
+
+ /**
+ * Check if plugin is installed.
+ *
+ * @param string $slug Plugin slug if found.
+ * @return boolean
+ */
+ private function is_installed( $slug = '' ): bool {
+ return file_exists( WP_PLUGIN_DIR . '/' . $this->get_plugin( $slug ) );
+ }
+
+ /**
+ * Check if installation is allowed.
+ *
+ * @return boolean
+ */
+ private function is_allowed(): bool {
+ if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET['_wpnonce'] ) ), 'plugin_family_install_' . $this->get_slug() ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated
+ return false;
+ }
+
+ if ( ! current_user_can( is_multisite() ? 'manage_network_plugins' : 'install_plugins' ) ) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Get plugin slug.
+ *
+ * @return string
+ */
+ private function get_slug(): string {
+ return dirname( rawurldecode( sanitize_text_field( wp_unslash( $_GET['plugin_to_install'] ) ) ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotValidated
+ }
+
+ /**
+ * Get plugin identifier.
+ *
+ * @param string $slug Plugin slug if found.
+ * @return string
+ */
+ private function get_plugin( $slug = '' ): string {
+ if ( 'imagify' === $slug ) {
+ return 'imagify/imagify.php';
+ }
+ if ( empty( $_GET['plugin_to_install'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
+ return '';
+ }
+ return rawurldecode( sanitize_text_field( wp_unslash( $_GET['plugin_to_install'] ) ) ) . '.php'; // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotValidated
+ }
+
+ /**
+ * Get plugin download url.
+ *
+ * @param string $slug Plugin slug if found.
+ * @return string
+ */
+ private function get_download_url( $slug = '' ): string {
+
+ $custom_download_url = $this->maybe_get_custom_download_url( $slug );
+
+ if ( false !== $custom_download_url ) {
+ return $custom_download_url;
+ }
+
+ $plugin_install = ABSPATH . 'wp-admin/includes/plugin-install.php';
+
+ if ( ! defined( 'ABSPATH' ) || ! file_exists( $plugin_install ) ) {
+ wp_die(
+ 'Plugin Installation failed. plugin-install.php not found',
+ '',
+ [ 'back_link' => true ]
+ );
+ }
+
+ require_once $plugin_install; // @phpstan-ignore-line
+
+ if ( empty( $slug ) ) {
+ $slug = $this->get_slug();
+ }
+
+ $data = [
+ 'slug' => $slug,
+ 'fields' => [
+ 'download_link' => true,
+ 'short_description' => false,
+ 'sections' => false,
+ 'rating' => false,
+ 'ratings' => false,
+ 'downloaded' => false,
+ 'last_updated' => false,
+ 'added' => false,
+ 'tags' => false,
+ 'homepage' => false,
+ 'donate_link' => false,
+ ],
+ ];
+
+ // Get Plugin Infos.
+ $plugin_info = plugins_api( 'plugin_information', $data );
+
+ if ( is_wp_error( $plugin_info ) ) {
+ $this->set_error( $plugin_info );
+ }
+
+ // Ensure that $plugin_info is an object before accessing the property.
+ if ( ! is_object( $plugin_info ) || ! isset( $plugin_info->download_link ) ) {
+ return '';
+ }
+
+ return $plugin_info->download_link;
+ }
+
+ /**
+ * Maybe display error notice.
+ *
+ * @return void
+ */
+ public function display_error_notice() {
+ $errors = get_transient( $this->error_transient );
+
+ if ( ! $errors ) {
+ return;
+ }
+
+ if ( ! is_wp_error( $errors ) ) {
+ delete_transient( $this->error_transient );
+ return;
+ }
+
+ $errors = $errors->get_error_messages();
+
+ if ( ! $errors ) {
+ $errors[] = 'Installation process failed';
+ }
+
+ $notice = '' . implode( '
', $errors ) . '
';
+ echo wp_kses_post( $notice );
+
+ // Remove transient after displaying notice.
+ delete_transient( $this->error_transient );
+ }
+
+ /**
+ * Store an error message in a transient then redirect.
+ *
+ * @param object $error A WP_Error object.
+ * @return void
+ */
+ private function set_error( $error ) {
+ set_transient( $this->error_transient, $error, 30 );
+
+ wp_safe_redirect( wp_get_referer() );
+ exit;
+ }
+
+ /**
+ * Returns a custom download url for plugin if exists.
+ *
+ * @param string $plugin_slug plugin slug.
+ * @return string|bool
+ */
+ private function maybe_get_custom_download_url( string $plugin_slug ) {
+ $parent_plugin_slug = $this->get_parent_plugin_slug();
+
+ $urls = [
+ 'seo-by-rank-math' => 'https://rankmath.com/downloads/plugin-family/' . $parent_plugin_slug,
+ ];
+
+ if ( ! isset( $urls[ $plugin_slug ] ) ) {
+ return false;
+ }
+
+ return $urls[ $plugin_slug ];
+ }
+
+ /**
+ * Get parent plugin slug.
+ *
+ * @return string
+ */
+ private function get_parent_plugin_slug(): string {
+ $plugin_path = plugin_basename( __FILE__ );
+ $chunks = explode( '/', $plugin_path );
+
+ return $chunks[0];
+ }
+
+ /**
+ * Check if imagify is installed or not.
+ *
+ * @return bool
+ */
+ private function is_imagify_installed(): bool {
+ return file_exists( WP_PLUGIN_DIR . '/imagify/imagify.php' );
+ }
+
+ /**
+ * Check if imagify is activated or not.
+ *
+ * @return bool
+ */
+ private function is_imagify_activated(): bool {
+ return defined( 'IMAGIFY_VERSION' );
+ }
+
+ /**
+ * Enqueue block editor assets
+ *
+ * @return void
+ */
+ public function enqueue_assets() {
+ if (
+ $this->is_promote_imagify_dismissed()
+ ||
+ $this->is_imagify_activated()
+ ||
+ wp_script_is( 'plugin-family-script' )
+ ) {
+ return;
+ }
+
+ if ( ! $this->should_show_imagify_banner() ) {
+ return;
+ }
+
+ $script_url = plugin_dir_url( __DIR__ ) . 'assets/js/index.js';
+
+ wp_enqueue_script(
+ 'plugin-family-script',
+ $script_url,
+ [ 'react-jsx-runtime', 'wp-block-editor', 'wp-components', 'wp-compose', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-primitives' ],
+ $this->version,
+ [
+ 'in_footer' => true,
+ ]
+ );
+
+ $this->add_install_imagify_localized_script( 'plugin-family-script' );
+ }
+
+ /**
+ * Install Imagify using the ajax request.
+ *
+ * @return void
+ */
+ public function install_imagify() {
+ check_ajax_referer( 'install-imagify-nonce' );
+
+ if ( ! current_user_can( is_multisite() ? 'manage_network_plugins' : 'install_plugins' ) ) {
+ wp_send_json_error( __( 'Not Allowed', '%domain%' ) );
+ }
+
+ if ( ! $this->is_imagify_installed() ) {
+ $this->install( 'imagify' );
+ }
+
+ $activated = activate_plugin( $this->get_plugin( 'imagify' ), '', is_multisite() );
+ if ( is_wp_error( $activated ) ) {
+ wp_send_json_error( $activated->get_error_message() );
+ }
+
+ $this->set_imagify_partner( '%imagifypartnerid%' );
+ /**
+ * Fires after Imagify is installed and activated via Plugin Family.
+ * Allows integrators to track installation/activation.
+ */
+ do_action( 'wpmedia_plugin_family_imagify_installed' );
+ wp_send_json_success( __( 'Imagify installed! Click here to start using it.', '%domain%' ) );
+ }
+
+ /**
+ * Set the imagify plugin partner.
+ *
+ * @param string $plugin Current plugin.
+ * @return void
+ */
+ private function set_imagify_partner( $plugin ) {
+ update_option( 'imagifyp_id', $plugin, false );
+ }
+
+ /**
+ * Check if we can enqueue admin assets or not.
+ *
+ * @param string $page Current page ID if found.
+ * @return bool
+ */
+ private function can_enqueue_admin_assets( $page = '' ): bool {
+ if ( $this->is_promote_imagify_dismissed() ) {
+ return false;
+ }
+
+ $allowed_pages = $this->screen_ids;
+ $can_enqueue = in_array( $page, $allowed_pages, true );
+
+ if ( empty( $page ) ) {
+ // Map configured admin pages to corresponding get_current_screen()->id values.
+ $allowed_screen_ids = array_unique(
+ array_map(
+ static function ( $p ) {
+ switch ( $p ) {
+ case 'post.php':
+ case 'post-new.php':
+ return 'post';
+ case 'upload.php':
+ return 'upload';
+ default:
+ // Allow passing raw screen ids directly (e.g., custom settings screens).
+ return $p;
+ }
+ },
+ $allowed_pages
+ )
+ );
+
+ $can_enqueue = in_array( get_current_screen()->id, $allowed_screen_ids, true );
+ }
+
+ return $this->should_show_imagify_banner( $can_enqueue );
+ }
+
+ /**
+ * Add localized script to be used by scripts.
+ *
+ * @param string $script_id Script ID.
+ * @return void
+ */
+ private function add_install_imagify_localized_script( $script_id ) {
+ $data = [
+ 'ajax_url' => admin_url( 'admin-ajax.php' ),
+ 'nonce' => wp_create_nonce( 'install-imagify-nonce' ),
+ 'plugins_page_url' => admin_url( 'plugins.php' ),
+ 'notice_text' => ! empty( $this->notice_text ) ? $this->notice_text : __( 'Boost your site\'s performance by compressing images with Imagify, developed by WP Rocket.', '%domain%' ),
+ ];
+
+ wp_add_inline_script(
+ $script_id,
+ 'window.wpmedia_pluginfamily = ' . wp_json_encode( $data ) . ';',
+ 'before'
+ );
+ }
+
+ /**
+ * Enqueue Admin assets.
+ *
+ * @param string $page Page ID.
+ * @return void
+ */
+ public function enqueue_admin_assets( $page ) {
+ if ( ! $this->can_enqueue_admin_assets( $page ) ) {
+ return;
+ }
+
+ if ( $this->is_imagify_activated() || wp_script_is( 'plugin-family-admin-script' ) ) {
+ return;
+ }
+
+ $script_url = plugin_dir_url( __DIR__ ) . 'assets/js/admin.js';
+ wp_enqueue_script(
+ 'plugin-family-admin-script',
+ $script_url,
+ [ 'jquery' ], // jQuery as a dependency.
+ $this->version,
+ [
+ 'in_footer' => true,
+ ]
+ );
+
+ $this->add_install_imagify_localized_script( 'plugin-family-admin-script' );
+
+ $style_url = plugin_dir_url( __DIR__ ) . 'assets/css/style.css';
+ wp_enqueue_style(
+ 'plugin-family-admin-style',
+ $style_url,
+ [],
+ $this->version
+ );
+ }
+
+ /**
+ * Insert admin footer JS templates.
+ *
+ * @return void
+ */
+ public function insert_footer_templates() {
+ if ( ! $this->can_enqueue_admin_assets() ) {
+ return;
+ }
+ // Make notice text available to the included template while preserving default text if empty.
+ $notice = ! empty( $this->notice_text )
+ ? $this->notice_text
+ : sprintf(
+ // translators: %1$s = Plugin Name.
+ __( '%1$s recommends you to optimize your images for even better website performance.', '%domain%' ),
+ 'WP Rocket'
+ );
+ include_once __DIR__ . '/../View/promote-imagify-uploader.php';
+ }
+
+ /**
+ * Dismiss promote Imagify using the ajax request.
+ *
+ * @return void
+ */
+ public function dismiss_promote_imagify() {
+ check_ajax_referer( 'install-imagify-nonce' );
+
+ if ( ! current_user_can( is_multisite() ? 'manage_network_plugins' : 'install_plugins' ) ) {
+ wp_send_json_error( __( 'Not Allowed', '%domain%' ) );
+ }
+
+ update_option( 'plugin_family_dismiss_promote_imagify', true );
+ wp_send_json_success( __( 'Dismissed.', '%domain%' ) );
+ }
+
+ /**
+ * Check if promote imagify message is dismissed.
+ *
+ * @return bool
+ */
+ private function is_promote_imagify_dismissed() {
+ return ! empty( get_option( 'plugin_family_dismiss_promote_imagify' ) );
+ }
+
+ /**
+ * Check if the Imagify banner should be shown.
+ *
+ * Applies the filter to allow developers to control banner visibility.
+ *
+ * @since 1.0.8
+ *
+ * @param bool $default_value The default value to filter.
+ * @return bool Whether to show the Imagify banner.
+ */
+ private function should_show_imagify_banner( bool $default_value = true ): bool {
+ /**
+ * Filters whether to show the Imagify banner on Media gallery components.
+ *
+ * @since 1.0.8
+ *
+ * @param bool $show_banner Whether to show the Imagify banner.
+ */
+ return wpm_apply_filters_typed( 'boolean', 'wpmedia_plugin_family_show_imagify_banner', $default_value );
+ }
+}
diff --git a/classes/Dependencies/WPMedia/PluginFamily/Controller/PluginFamilyInterface.php b/classes/Dependencies/wp-media/plugin-family/src/Controller/PluginFamilyInterface.php
similarity index 100%
rename from classes/Dependencies/WPMedia/PluginFamily/Controller/PluginFamilyInterface.php
rename to classes/Dependencies/wp-media/plugin-family/src/Controller/PluginFamilyInterface.php
diff --git a/classes/Dependencies/WPMedia/PluginFamily/Model/PluginFamily.php b/classes/Dependencies/wp-media/plugin-family/src/Model/PluginFamily.php
similarity index 97%
rename from classes/Dependencies/WPMedia/PluginFamily/Model/PluginFamily.php
rename to classes/Dependencies/wp-media/plugin-family/src/Model/PluginFamily.php
index 2005aec88..83c5ec113 100644
--- a/classes/Dependencies/WPMedia/PluginFamily/Model/PluginFamily.php
+++ b/classes/Dependencies/wp-media/plugin-family/src/Model/PluginFamily.php
@@ -63,7 +63,7 @@ public function filter_plugins_by_activation( array $plugins, string $main_plugi
if ( is_plugin_active( $plugin_path ) && $main_plugin . '.php' !== $plugin_path ) {
// set cta data of active plugins.
$plugins[ $cat ]['plugins'][ $plugin ]['cta'] = [
- 'text' => __( 'Activated', 'imagify' ),
+ 'text' => __( 'Activated', '%domain%' ),
'url' => '#',
];
@@ -106,7 +106,7 @@ public function filter_plugins_by_activation( array $plugins, string $main_plugi
// Set Installation link.
$plugins[ $cat ]['plugins'][ $plugin ]['cta'] = [
- 'text' => __( 'Install', 'imagify' ),
+ 'text' => __( 'Install', '%domain%' ),
'url' => $install_activate_url,
];
@@ -115,7 +115,7 @@ public function filter_plugins_by_activation( array $plugins, string $main_plugi
$url = 'https://wp-rocket.me/?utm_source=' . $wpr_referrer . '-coupon&utm_medium=plugin&utm_campaign=' . $wpr_referrer;
$plugins[ $cat ]['plugins'][ $plugin ]['cta'] = [
- 'text' => __( 'Get it Now', 'imagify' ),
+ 'text' => __( 'Get it Now', '%domain%' ),
'url' => $url,
];
@@ -124,7 +124,7 @@ public function filter_plugins_by_activation( array $plugins, string $main_plugi
// Set activation text.
if ( file_exists( WP_PLUGIN_DIR . '/' . $plugin_path ) ) {
- $plugins[ $cat ]['plugins'][ $plugin ]['cta']['text'] = __( 'Activate', 'imagify' );
+ $plugins[ $cat ]['plugins'][ $plugin ]['cta']['text'] = __( 'Activate', '%domain%' );
if ( 'wp-rocket/wp-rocket' === $plugin ) {
$plugins[ $cat ]['plugins'][ $plugin ]['cta']['url'] = $install_activate_url;
diff --git a/classes/Dependencies/WPMedia/PluginFamily/Model/wp_media_plugins.php b/classes/Dependencies/wp-media/plugin-family/src/Model/wp_media_plugins.php
similarity index 77%
rename from classes/Dependencies/WPMedia/PluginFamily/Model/wp_media_plugins.php
rename to classes/Dependencies/wp-media/plugin-family/src/Model/wp_media_plugins.php
index 1bf181b14..6105644fc 100644
--- a/classes/Dependencies/WPMedia/PluginFamily/Model/wp_media_plugins.php
+++ b/classes/Dependencies/wp-media/plugin-family/src/Model/wp_media_plugins.php
@@ -5,15 +5,15 @@
return [
'optimize_performance' => [
- 'title' => __( 'Optimize Performance', 'imagify' ),
+ 'title' => __( 'Optimize Performance', '%domain%' ),
'plugins' => [
'wp-rocket/wp-rocket' => [
'logo' => [
'file' => 'logo-wp-rocket.svg',
'width' => '50%',
],
- 'title' => __( 'Speed Up Your Website, Instantly', 'imagify' ),
- 'desc' => __( 'WP Rocket is the easiest way to make your WordPress website faster and boost your Google PageSpeed score. Get more traffic, better engagement, and higher conversions effortlessly.', 'imagify' ),
+ 'title' => __( 'Speed Up Your Website, Instantly', '%domain%' ),
+ 'desc' => __( 'WP Rocket is the easiest way to make your WordPress website faster and boost your Google PageSpeed score. Get more traffic, better engagement, and higher conversions effortlessly.', '%domain%' ),
'link' => '',
],
'imagify/imagify' => [
@@ -21,36 +21,36 @@
'file' => 'logo-imagify.svg',
'width' => '50%',
],
- 'title' => __( 'Speed Up Your Website With Lighter Images', 'imagify' ),
- 'desc' => __( 'Imagify is the easiest WordPress image optimizer. It automatically compresses images, converts them to WebP and AVIF formats, and lets you resize and optimize with just one click!', 'imagify' ),
+ 'title' => __( 'Speed Up Your Website With Lighter Images', '%domain%' ),
+ 'desc' => __( 'Imagify is the easiest WordPress image optimizer. It automatically compresses images, converts them to WebP and AVIF formats, and lets you resize and optimize with just one click!', '%domain%' ),
'link' => 'https://imagify.io/',
],
],
],
'boost_traffic' => [
- 'title' => __( 'Boost Traffic', 'imagify' ),
+ 'title' => __( 'Boost Traffic', '%domain%' ),
'plugins' => [
'seo-by-rank-math/rank-math' => [
'logo' => [
'file' => 'logo-rank-math.svg',
'width' => '60%',
],
- 'title' => __( 'The Swiss Army Knife of SEO Tools', 'imagify' ),
- 'desc' => __( 'Rank Math SEO is the Best WordPress SEO plugin with the features of many SEO and AI SEO tools in a single package to help multiply your SEO traffic.', 'imagify' ),
+ 'title' => __( 'The Swiss Army Knife of SEO Tools', '%domain%' ),
+ 'desc' => __( 'Rank Math SEO is the Best WordPress SEO plugin with the features of many SEO and AI SEO tools in a single package to help multiply your SEO traffic.', '%domain%' ),
'link' => 'https://rankmath.com/wordpress/plugin/seo-suite/',
],
],
],
'protect_secure' => [
- 'title' => __( 'Protect & Secure', 'imagify' ),
+ 'title' => __( 'Protect & Secure', '%domain%' ),
'plugins' => [
'backwpup/backwpup' => [
'logo' => [
'file' => 'logo-backwpup.svg',
'width' => '60%',
],
- 'title' => __( 'The Easiest Way to Protect Your Website', 'imagify' ),
- 'desc' => __( 'BackWPup is the most comprehensive and user-friendly backup & restore plugin for WordPress. Easily schedule automatic backups, securely store and restore with just a few clicks!', 'imagify' ),
+ 'title' => __( 'The Easiest Way to Protect Your Website', '%domain%' ),
+ 'desc' => __( 'BackWPup is the most comprehensive and user-friendly backup & restore plugin for WordPress. Easily schedule automatic backups, securely store and restore with just a few clicks!', '%domain%' ),
'link' => 'https://backwpup.com/',
],
'uk-cookie-consent/uk-cookie-consent' => [
@@ -58,8 +58,8 @@
'file' => 'logo-termly.svg',
'width' => '50%',
],
- 'title' => __( 'GDPR/CCPA Cookie Consent Banner', 'imagify' ),
- 'desc' => __( 'One of the easiest, most comprehensive, and popular cookie consent plugins available. Google Gold Certified Partner to quickly comply with data privacy laws from around the world.', 'imagify' ),
+ 'title' => __( 'GDPR/CCPA Cookie Consent Banner', '%domain%' ),
+ 'desc' => __( 'One of the easiest, most comprehensive, and popular cookie consent plugins available. Google Gold Certified Partner to quickly comply with data privacy laws from around the world.', '%domain%' ),
'link' => 'https://termly.io/resources/articles/wordpress-cookies-guide/',
],
],
diff --git a/classes/Dependencies/wp-media/plugin-family/src/PostInstall.php b/classes/Dependencies/wp-media/plugin-family/src/PostInstall.php
new file mode 100644
index 000000000..a161fc10f
--- /dev/null
+++ b/classes/Dependencies/wp-media/plugin-family/src/PostInstall.php
@@ -0,0 +1,109 @@
+getIO();
+ $composer = $event->getComposer();
+ $extra = $composer->getPackage()->getExtra();
+
+ if ( ! isset( $extra['plugin_domain'] ) ) {
+ $output->writeError( self::colorize( 'Plugin domain is not set in the composer extra configuration (key: plugin_domain).', 'red' ) );
+ return;
+ }
+
+ if ( ! isset( $extra['imagify_partner'] ) ) {
+ $output->writeError( self::colorize( 'Imagify partner ID is not set in the composer extra configuration (key: imagify_partner).', 'red' ) );
+ return;
+ }
+
+ foreach ( self::$files as $file ) {
+ // Construct file path.
+ $path = __DIR__ . $file . '.php';
+
+ if ( ! file_exists( $path ) ) {
+ $output->writeError( self::colorize( 'Could not find file: ' . $path . ', Does it exist?', 'red' ) );
+ return;
+ }
+
+ // Get file contents.
+ $content = file_get_contents( $path );
+
+ if ( false === $content ) {
+ $output->writeError( self::colorize( 'Failed to read the file: ' . $path, 'red' ) );
+ return;
+ }
+
+ $mappings = [
+ '%domain%' => $extra['plugin_domain'],
+ '%imagifypartnerid%' => $extra['imagify_partner'],
+ ];
+
+ // Update file content.
+ $updated_content = str_replace(
+ array_keys( $mappings ),
+ array_values( $mappings ),
+ $content
+ );
+ $result = file_put_contents( $path, $updated_content );
+
+ if ( false === $result ) {
+ $output->writeError( self::colorize( 'Failed to write the updated content to the file: ' . $path, 'red' ) );
+ return;
+ }
+ }
+
+ // Output success feed.
+ $output->write( self::colorize( 'Text domain has been updated.', 'green' ) );
+
+ // Path to this script.
+ $script = __FILE__;
+
+ // Delete script after execution.
+ register_shutdown_function( function () use ( $script ) {
+ if ( file_exists( $script ) ) {
+ unlink( $script );
+ }
+ });
+ }
+
+ /**
+ * This function colorizes a given string with a specified color for console output.
+ *
+ * @param string $message String message to pass.
+ * @param string $color Color on the console.
+ * @return string
+ */
+ private static function colorize( string $message, string $color ): string {
+ $colors = [
+ 'red' => "\033[31m",
+ 'green' => "\033[32m",
+ 'reset' => "\033[0m",
+ ];
+
+ return $colors[$color] . $message . $colors['reset'];
+ }
+}
\ No newline at end of file
diff --git a/classes/Dependencies/wp-media/plugin-family/src/View/promote-imagify-uploader.php b/classes/Dependencies/wp-media/plugin-family/src/View/promote-imagify-uploader.php
new file mode 100644
index 000000000..0061aeb80
--- /dev/null
+++ b/classes/Dependencies/wp-media/plugin-family/src/View/promote-imagify-uploader.php
@@ -0,0 +1,18 @@
+
+
diff --git a/classes/Dependencies/wp-media/plugin-family/src/assets/css/style.css b/classes/Dependencies/wp-media/plugin-family/src/assets/css/style.css
new file mode 100644
index 000000000..12dcef42e
--- /dev/null
+++ b/classes/Dependencies/wp-media/plugin-family/src/assets/css/style.css
@@ -0,0 +1,36 @@
+.pluginfamily-promote-imagify{
+ padding: 20px 32px 20px 60px;
+ border: 1px solid #007CBA;
+ border-radius: 6px;
+ margin: 20px 0;
+ background: url("../imgs/plus.png") no-repeat 20px 20px;
+ position: relative;
+}
+.pluginfamily-promote-imagify p{
+ margin: 0 0 10px;
+}
+
+.pluginfamily-promote-imagify button{
+ font-weight: bold;
+ color: #000;
+ border: none;
+ background: transparent;
+ cursor: pointer;
+ padding: 0;
+ text-align: left;
+}
+
+.pluginfamily-promote-imagify-dismiss{
+ width: 16px;
+ height: 16px;
+ position: absolute;
+ right: 10px;
+ top: 10px;
+}
+
+.pluginfamily-promote-imagify-dismiss-icon{
+ width: 100%;
+ height: 100%;
+ object-fit: contain;
+ display: block;
+}
diff --git a/classes/Dependencies/wp-media/plugin-family/src/assets/imgs/plus.png b/classes/Dependencies/wp-media/plugin-family/src/assets/imgs/plus.png
new file mode 100644
index 000000000..60551257e
Binary files /dev/null and b/classes/Dependencies/wp-media/plugin-family/src/assets/imgs/plus.png differ
diff --git a/classes/Dependencies/wp-media/plugin-family/src/assets/js/admin.js b/classes/Dependencies/wp-media/plugin-family/src/assets/js/admin.js
new file mode 100644
index 000000000..43f061296
--- /dev/null
+++ b/classes/Dependencies/wp-media/plugin-family/src/assets/js/admin.js
@@ -0,0 +1 @@
+jQuery(document).ready(function(a){let e=!1;new MutationObserver(function(i){a(".attachment-info .details").each(function(){const i=a(this);if(0===i.find(".pluginfamily-promote-imagify").length&&!e){const e=a("#pluginfamily_promote_imagify_uploader_template").html();a(e).appendTo(i)}})}).observe(document.body,{childList:!0,subtree:!0}),a(document).on("click","#pluginfamily_install_imagify",async e=>{e.preventDefault();const i=a("#pluginfamily_install_imagify");i.fadeTo("slow",.5);try{const e=await fetch(wpmedia_pluginfamily.ajax_url,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"},body:new URLSearchParams({action:"install_imagify",_ajax_nonce:wpmedia_pluginfamily.nonce}).toString()}),n=await e.json();n.success&&(i.text(n.data).attr("id",""),window.open(wpmedia_pluginfamily.plugins_page_url,"_blank")||0===a("#pluginfamily_open_plugins_fallback").length&&a("").attr({href:wpmedia_pluginfamily.plugins_page_url,target:"_blank",id:"pluginfamily_open_plugins_fallback"}).text(n.data).insertAfter(i),i.remove())}catch(a){console.error("AJAX error: ",a)}i.fadeTo("slow",1)}),a(document).on("click",".pluginfamily-promote-imagify-dismiss-icon",async i=>{i.preventDefault();const n=a(".pluginfamily-promote-imagify");n.fadeTo("slow",.5);try{await fetch(wpmedia_pluginfamily.ajax_url,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"},body:new URLSearchParams({action:"dismiss_promote_imagify",_ajax_nonce:wpmedia_pluginfamily.nonce}).toString()})}catch(a){console.error("AJAX error: ",a)}n.fadeTo("slow",1,()=>{n.remove(),e=!0})})});
\ No newline at end of file
diff --git a/classes/Dependencies/wp-media/plugin-family/src/assets/js/index.js b/classes/Dependencies/wp-media/plugin-family/src/assets/js/index.js
new file mode 100644
index 000000000..cb1294050
--- /dev/null
+++ b/classes/Dependencies/wp-media/plugin-family/src/assets/js/index.js
@@ -0,0 +1 @@
+(()=>{"use strict";const e=window.wp.hooks,i=window.wp.compose,n=window.wp.element,t=window.wp.blockEditor,o=window.wp.components,a=window.wp.i18n,r=window.wp.primitives,s=window.ReactJSXRuntime,l=(0,s.jsx)(r.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"-2 -2 24 24",children:(0,s.jsx)(r.Path,{d:"M10 1c-5 0-9 4-9 9s4 9 9 9 9-4 9-9-4-9-9-9zm0 16c-3.9 0-7-3.1-7-7s3.1-7 7-7 7 3.1 7 7-3.1 7-7 7zm1-11H9v3H6v2h3v3h2v-3h3V9h-3V6zM10 1c-5 0-9 4-9 9s4 9 9 9 9-4 9-9-4-9-9-9zm0 16c-3.9 0-7-3.1-7-7s3.1-7 7-7 7 3.1 7 7-3.1 7-7 7zm1-11H9v3H6v2h3v3h2v-3h3V9h-3V6z"})}),c=(0,s.jsx)(r.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,s.jsx)(r.Path,{d:"M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z"})}),m=(0,i.createHigherOrderComponent)(e=>i=>{const[r,m]=(0,n.useState)(!1),[d,w]=(0,n.useState)(!1),[p,g]=(0,n.useState)(!0);return"core/image"===i.name&&p?(0,s.jsxs)(n.Fragment,{children:[(0,s.jsx)(e,{...i}),(0,s.jsxs)(t.InspectorControls,{children:[(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",fontWeight:"bold",marginBottom:"8px"},children:[(0,s.jsx)(o.Icon,{icon:l,style:{marginRight:8,marginLeft:8}}),(0,s.jsx)("span",{style:{flex:1},children:(0,a.__)("Optimize Your Images","%domain%")}),(0,s.jsx)(o.Button,{onClick:async()=>{try{await fetch(wpmedia_pluginfamily.ajax_url,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"},body:new URLSearchParams({action:"dismiss_promote_imagify",_ajax_nonce:wpmedia_pluginfamily.nonce}).toString()})}catch(e){console.error("AJAX error: ",e)}g(!1)},size:"compact",icon:c,iconPosition:"right"})]}),(0,s.jsxs)(o.PanelBody,{title:"",initialOpen:!0,children:[(0,s.jsx)("p",{style:{marginLeft:16},children:wpmedia_pluginfamily.notice_text}),d?(0,s.jsx)("a",{href:wpmedia_pluginfamily.plugins_page_url,target:"_blank",rel:"noopener noreferrer",style:{marginLeft:16,color:"green",fontWeight:"bold",display:"block"},children:(0,a.__)("Imagify installed! Click here to start using it.","%domain%")}):(0,s.jsx)(o.Button,{style:{marginLeft:16},isSecondary:!0,isBusy:r,disabled:r,onClick:async()=>{m(!0);try{const e=await fetch(wpmedia_pluginfamily.ajax_url,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"},body:new URLSearchParams({action:"install_imagify",_ajax_nonce:wpmedia_pluginfamily.nonce}).toString()});(await e.json()).success&&(w(!0),window.open(wpmedia_pluginfamily.plugins_page_url,"_blank"))}catch(e){console.error("AJAX error: ",e)}m(!1)},children:(0,a.__)("Install Imagify Now","%domain%")})]})]})]}):(0,s.jsx)(e,{...i})},"promoteImagifyButton");(0,e.addFilter)("editor.BlockEdit","wpmedia-plugin-family/promote-imagify",m)})();
\ No newline at end of file
diff --git a/classes/Dependencies/wp-media/plugin-family/webpack.config.js b/classes/Dependencies/wp-media/plugin-family/webpack.config.js
new file mode 100644
index 000000000..88bd3816f
--- /dev/null
+++ b/classes/Dependencies/wp-media/plugin-family/webpack.config.js
@@ -0,0 +1,9 @@
+const defaultConfig = require('@wordpress/scripts/config/webpack.config');
+
+module.exports = {
+ ...defaultConfig,
+ output: {
+ ...defaultConfig.output,
+ path: __dirname + '/src/assets/js',
+ },
+};
\ No newline at end of file
diff --git a/composer.json b/composer.json
index 3846ffb59..e1db7edb7 100644
--- a/composer.json
+++ b/composer.json
@@ -23,7 +23,6 @@
"allow-plugins": {
"composer/installers": true,
"dealerdirect/phpcodesniffer-composer-installer": true,
- "dangoodman/composer-for-wordpress": true,
"mnsami/composer-custom-directory-installer": true,
"phpstan/extension-installer": true
}
@@ -35,17 +34,14 @@
"require": {
"php": ">=7.0",
"composer/installers": "^1.0 || ^2.0",
- "dangoodman/composer-for-wordpress": "^2.0",
+ "deliciousbrains/wp-background-processing": "~1.0",
+ "league/container": "^4.2",
"wp-media/apply-filters-typed": "^1.0",
"wp-media/plugin-family": "^1.0"
},
"require-dev": {
"php": "^7 || ^8",
- "brain/monkey": "^2.0",
- "coenjacobs/mozart": "^0.7",
"dealerdirect/phpcodesniffer-composer-installer": "^1",
- "deliciousbrains/wp-background-processing": "~1.0",
- "league/container": "^4.2",
"mnsami/composer-custom-directory-installer": "^2.0",
"php-stubs/wordpress-tests-stubs": "^6.5",
"phpcompatibility/phpcompatibility-wp": "^2.0",
@@ -86,16 +82,25 @@
"installer-paths": {
"./inc/Dependencies/ActionScheduler/": ["woocommerce/action-scheduler"]
},
- "mozart": {
- "dep_namespace": "Imagify\\Dependencies\\",
- "dep_directory": "/classes/Dependencies/",
- "classmap_directory": "/inc/classes/Dependencies/",
+ "strauss": {
+ "namespace_prefix": "Imagify\\Dependencies\\",
"classmap_prefix": "Imagify_",
+ "target_directory": "/classes/Dependencies/",
"packages": [
"deliciousbrains/wp-background-processing",
"league/container",
"wp-media/plugin-family"
- ]
+ ],
+ "exclude_from_copy": {
+ "packages": [
+ "wp-media/apply-filters-typed"
+ ]
+ },
+ "exclude_from_prefix": {
+ "packages": [
+ "wp-media/apply-filters-typed"
+ ]
+ }
},
"plugin_domain": "imagify"
},
@@ -111,15 +116,21 @@
"@test-unit",
"@test-integration"
],
+ "prefix-namespaces": [
+ "sh -c 'test -f ./bin/strauss.phar || curl -o bin/strauss.phar -L -C - https://github.com/BrianHenryIE/strauss/releases/latest/download/strauss.phar'",
+ "php bin/strauss.phar",
+ "@composer dump-autoload"
+ ],
"post-install-cmd": [
- "[ $COMPOSER_DEV_MODE -eq 0 ] || \"vendor/bin/mozart\" compose",
- "composer dump-autoload",
- "Imagify\\Dependencies\\WPMedia\\PluginFamily\\PostInstall::apply_text_domain"
+ "@prefix-namespaces",
+ "WPMedia\\PluginFamily\\PostInstall::apply_text_domain"
],
"post-update-cmd": [
- "[ $COMPOSER_DEV_MODE -eq 0 ] || \"vendor/bin/mozart\" compose",
- "composer dump-autoload",
- "Imagify\\Dependencies\\WPMedia\\PluginFamily\\PostInstall::apply_text_domain"
+ "@prefix-namespaces",
+ "WPMedia\\PluginFamily\\PostInstall::apply_text_domain"
+ ],
+ "post-autoload-dump": [
+ "php bin/strauss.phar include-autoloader"
],
"code-coverage": "\"vendor/bin/phpunit\" --testsuite unit --colors=always --configuration Tests/Unit/phpunit.xml.dist --coverage-clover=tests/report/coverage.clover"
}
diff --git a/inc/Dependencies/ActionScheduler/action-scheduler.php b/inc/Dependencies/ActionScheduler/action-scheduler.php
index ef12ca272..1343a89bf 100644
--- a/inc/Dependencies/ActionScheduler/action-scheduler.php
+++ b/inc/Dependencies/ActionScheduler/action-scheduler.php
@@ -5,11 +5,11 @@
* Description: A robust scheduling library for use in WordPress plugins.
* Author: Automattic
* Author URI: https://automattic.com/
- * Version: 3.9.2
+ * Version: 3.9.3
* License: GPLv3
* Requires at least: 6.5
- * Tested up to: 6.7
- * Requires PHP: 7.1
+ * Tested up to: 6.8
+ * Requires PHP: 7.2
*
* Copyright 2019 Automattic, Inc. (https://automattic.com/contact/)
*
@@ -29,29 +29,29 @@
* @package ActionScheduler
*/
-if ( ! function_exists( 'action_scheduler_register_3_dot_9_dot_2' ) && function_exists( 'add_action' ) ) { // WRCS: DEFINED_VERSION.
+if ( ! function_exists( 'action_scheduler_register_3_dot_9_dot_3' ) && function_exists( 'add_action' ) ) { // WRCS: DEFINED_VERSION.
if ( ! class_exists( 'ActionScheduler_Versions', false ) ) {
require_once __DIR__ . '/classes/ActionScheduler_Versions.php';
add_action( 'plugins_loaded', array( 'ActionScheduler_Versions', 'initialize_latest_version' ), 1, 0 );
}
- add_action( 'plugins_loaded', 'action_scheduler_register_3_dot_9_dot_2', 0, 0 ); // WRCS: DEFINED_VERSION.
+ add_action( 'plugins_loaded', 'action_scheduler_register_3_dot_9_dot_3', 0, 0 ); // WRCS: DEFINED_VERSION.
// phpcs:disable Generic.Functions.OpeningFunctionBraceKernighanRitchie.ContentAfterBrace
/**
* Registers this version of Action Scheduler.
*/
- function action_scheduler_register_3_dot_9_dot_2() { // WRCS: DEFINED_VERSION.
+ function action_scheduler_register_3_dot_9_dot_3() { // WRCS: DEFINED_VERSION.
$versions = ActionScheduler_Versions::instance();
- $versions->register( '3.9.2', 'action_scheduler_initialize_3_dot_9_dot_2' ); // WRCS: DEFINED_VERSION.
+ $versions->register( '3.9.3', 'action_scheduler_initialize_3_dot_9_dot_3' ); // WRCS: DEFINED_VERSION.
}
// phpcs:disable Generic.Functions.OpeningFunctionBraceKernighanRitchie.ContentAfterBrace
/**
* Initializes this version of Action Scheduler.
*/
- function action_scheduler_initialize_3_dot_9_dot_2() { // WRCS: DEFINED_VERSION.
+ function action_scheduler_initialize_3_dot_9_dot_3() { // WRCS: DEFINED_VERSION.
// A final safety check is required even here, because historic versions of Action Scheduler
// followed a different pattern (in some unusual cases, we could reach this point and the
// ActionScheduler class is already defined—so we need to guard against that).
@@ -63,7 +63,7 @@ function action_scheduler_initialize_3_dot_9_dot_2() { // WRCS: DEFINED_VERSION.
// Support usage in themes - load this version if no plugin has loaded a version yet.
if ( did_action( 'plugins_loaded' ) && ! doing_action( 'plugins_loaded' ) && ! class_exists( 'ActionScheduler', false ) ) {
- action_scheduler_initialize_3_dot_9_dot_2(); // WRCS: DEFINED_VERSION.
+ action_scheduler_initialize_3_dot_9_dot_3(); // WRCS: DEFINED_VERSION.
do_action( 'action_scheduler_pre_theme_init' );
ActionScheduler_Versions::initialize_latest_version();
}
diff --git a/inc/Dependencies/ActionScheduler/changelog.txt b/inc/Dependencies/ActionScheduler/changelog.txt
index 43ca7829c..326bef26a 100644
--- a/inc/Dependencies/ActionScheduler/changelog.txt
+++ b/inc/Dependencies/ActionScheduler/changelog.txt
@@ -1,5 +1,18 @@
*** Changelog ***
+= 3.9.3 - 2025-07-15 =
+* Add hook 'action_scheduler_ensure_recurring_actions' specifically for scheduling recurring actions.
+* Assume an action is valid until proven otherwise.
+* Implement SKIP LOCKED during action claiming.
+* Import `get_flag_value()` from `WP_CLI\Utils` before using.
+* Make `$unique` available to all pre-creation/short-circuit hooks.
+* Make version/source information available via new class.
+* Only release claims on pending actions.
+* Tweak - WP 6.8 compatibility.
+* Update minimum supported php and phpunit versions.
+* Update readme.txt.
+* WP CLI get action command: correct parentheses/nesting of conditional checks.
+
= 3.9.2 - 2025-02-03 =
* Fixed fatal errors by moving version info methods to a new class and deprecating conflicting ones in ActionScheduler_Versions
diff --git a/inc/Dependencies/ActionScheduler/classes/ActionScheduler_DataController.php b/inc/Dependencies/ActionScheduler/classes/ActionScheduler_DataController.php
index 8bceba287..89ca4a00d 100644
--- a/inc/Dependencies/ActionScheduler/classes/ActionScheduler_DataController.php
+++ b/inc/Dependencies/ActionScheduler/classes/ActionScheduler_DataController.php
@@ -162,10 +162,19 @@ public static function free_memory() {
return;
}
- $wp_object_cache->group_ops = array();
- $wp_object_cache->stats = array();
- $wp_object_cache->memcache_debug = array();
- $wp_object_cache->cache = array();
+ // Not all drop-ins support these props, however, there may be existing installations that rely on these being cleared.
+ if ( property_exists( $wp_object_cache, 'group_ops' ) ) {
+ $wp_object_cache->group_ops = array();
+ }
+ if ( property_exists( $wp_object_cache, 'stats' ) ) {
+ $wp_object_cache->stats = array();
+ }
+ if ( property_exists( $wp_object_cache, 'memcache_debug' ) ) {
+ $wp_object_cache->memcache_debug = array();
+ }
+ if ( property_exists( $wp_object_cache, 'cache' ) ) {
+ $wp_object_cache->cache = array();
+ }
if ( is_callable( array( $wp_object_cache, '__remoteset' ) ) ) {
call_user_func( array( $wp_object_cache, '__remoteset' ) ); // important!
diff --git a/inc/Dependencies/ActionScheduler/classes/ActionScheduler_RecurringActionScheduler.php b/inc/Dependencies/ActionScheduler/classes/ActionScheduler_RecurringActionScheduler.php
new file mode 100644
index 000000000..2f393ffc8
--- /dev/null
+++ b/inc/Dependencies/ActionScheduler/classes/ActionScheduler_RecurringActionScheduler.php
@@ -0,0 +1,81 @@
+store->query_actions(
array(
- 'claimed' => false,
'status' => $status,
'per_page' => 1,
'order' => $order,
diff --git a/inc/Dependencies/ActionScheduler/classes/WP_CLI/Action/Create_Command.php b/inc/Dependencies/ActionScheduler/classes/WP_CLI/Action/Create_Command.php
index fedd417e2..403ecfee2 100644
--- a/inc/Dependencies/ActionScheduler/classes/WP_CLI/Action/Create_Command.php
+++ b/inc/Dependencies/ActionScheduler/classes/WP_CLI/Action/Create_Command.php
@@ -2,6 +2,8 @@
namespace Action_Scheduler\WP_CLI\Action;
+use function \WP_CLI\Utils\get_flag_value;
+
/**
* WP-CLI command: action-scheduler action create
*/
diff --git a/inc/Dependencies/ActionScheduler/classes/WP_CLI/Action/Get_Command.php b/inc/Dependencies/ActionScheduler/classes/WP_CLI/Action/Get_Command.php
index 95df59550..b0bbdee1c 100644
--- a/inc/Dependencies/ActionScheduler/classes/WP_CLI/Action/Get_Command.php
+++ b/inc/Dependencies/ActionScheduler/classes/WP_CLI/Action/Get_Command.php
@@ -24,7 +24,7 @@ public function execute() {
}
$only_logs = ! empty( $this->assoc_args['field'] ) && 'log_entries' === $this->assoc_args['field'];
- $only_logs = $only_logs || ( ! empty( $this->assoc_args['fields'] && 'log_entries' === $this->assoc_args['fields'] ) );
+ $only_logs = $only_logs || ( ! empty( $this->assoc_args['fields'] ) && 'log_entries' === $this->assoc_args['fields'] );
$log_entries = array();
foreach ( $logger->get_logs( $action_id ) as $log_entry ) {
diff --git a/inc/Dependencies/ActionScheduler/classes/WP_CLI/System_Command.php b/inc/Dependencies/ActionScheduler/classes/WP_CLI/System_Command.php
index a936a6341..c7c3adaf8 100644
--- a/inc/Dependencies/ActionScheduler/classes/WP_CLI/System_Command.php
+++ b/inc/Dependencies/ActionScheduler/classes/WP_CLI/System_Command.php
@@ -262,7 +262,6 @@ protected function get_action_status_date( $status, $date_type = 'oldest' ) {
$order = 'oldest' === $date_type ? 'ASC' : 'DESC';
$args = array(
- 'claimed' => false,
'status' => $status,
'per_page' => 1,
'order' => $order,
diff --git a/inc/Dependencies/ActionScheduler/classes/abstracts/ActionScheduler.php b/inc/Dependencies/ActionScheduler/classes/abstracts/ActionScheduler.php
index 774abb185..03922d8a2 100644
--- a/inc/Dependencies/ActionScheduler/classes/abstracts/ActionScheduler.php
+++ b/inc/Dependencies/ActionScheduler/classes/abstracts/ActionScheduler.php
@@ -184,10 +184,11 @@ public static function init( $plugin_file ) {
require_once self::plugin_path( 'functions.php' );
ActionScheduler_DataController::init();
- $store = self::store();
- $logger = self::logger();
- $runner = self::runner();
- $admin_view = self::admin_view();
+ $store = self::store();
+ $logger = self::logger();
+ $runner = self::runner();
+ $admin_view = self::admin_view();
+ $recurring_action_scheduler = new ActionScheduler_RecurringActionScheduler();
// Ensure initialization on plugin activation.
if ( ! did_action( 'init' ) ) {
@@ -196,6 +197,7 @@ public static function init( $plugin_file ) {
add_action( 'init', array( $store, 'init' ), 1, 0 );
add_action( 'init', array( $logger, 'init' ), 1, 0 );
add_action( 'init', array( $runner, 'init' ), 1, 0 );
+ add_action( 'init', array( $recurring_action_scheduler, 'init' ), 1, 0 );
add_action(
'init',
@@ -223,6 +225,7 @@ function () {
$store->init();
$logger->init();
$runner->init();
+ $recurring_action_scheduler->init();
self::$data_store_initialized = true;
/**
diff --git a/inc/Dependencies/ActionScheduler/classes/abstracts/ActionScheduler_Abstract_QueueRunner.php b/inc/Dependencies/ActionScheduler/classes/abstracts/ActionScheduler_Abstract_QueueRunner.php
index 1b51c3012..d5b4bf498 100644
--- a/inc/Dependencies/ActionScheduler/classes/abstracts/ActionScheduler_Abstract_QueueRunner.php
+++ b/inc/Dependencies/ActionScheduler/classes/abstracts/ActionScheduler_Abstract_QueueRunner.php
@@ -86,15 +86,16 @@ function ( $type, $message ) {
*/
try {
try {
- $valid_action = false;
+ $valid_action = true;
+
do_action( 'action_scheduler_before_execute', $action_id, $context );
if ( ActionScheduler_Store::STATUS_PENDING !== $this->store->get_status( $action_id ) ) {
+ $valid_action = false;
do_action( 'action_scheduler_execution_ignored', $action_id, $context );
return;
}
- $valid_action = true;
do_action( 'action_scheduler_begin_execute', $action_id, $context );
$action = $this->store->fetch_action( $action_id );
diff --git a/inc/Dependencies/ActionScheduler/classes/data-stores/ActionScheduler_DBStore.php b/inc/Dependencies/ActionScheduler/classes/data-stores/ActionScheduler_DBStore.php
index 25a883abd..7840fe25b 100644
--- a/inc/Dependencies/ActionScheduler/classes/data-stores/ActionScheduler_DBStore.php
+++ b/inc/Dependencies/ActionScheduler/classes/data-stores/ActionScheduler_DBStore.php
@@ -931,16 +931,8 @@ protected function claim_actions( $claim_id, $limit, ?DateTime $before_date = nu
* @var \wpdb $wpdb
*/
global $wpdb;
-
$now = as_get_datetime_object();
$date = is_null( $before_date ) ? $now : clone $before_date;
- // can't use $wpdb->update() because of the <= condition.
- $update = "UPDATE {$wpdb->actionscheduler_actions} SET claim_id=%d, last_attempt_gmt=%s, last_attempt_local=%s";
- $params = array(
- $claim_id,
- $now->format( 'Y-m-d H:i:s' ),
- current_time( 'mysql' ),
- );
// Set claim filters.
if ( ! empty( $hooks ) ) {
@@ -954,14 +946,16 @@ protected function claim_actions( $claim_id, $limit, ?DateTime $before_date = nu
$group = $this->get_claim_filter( 'group' );
}
- $where = 'WHERE claim_id = 0 AND scheduled_date_gmt <= %s AND status=%s';
- $params[] = $date->format( 'Y-m-d H:i:s' );
- $params[] = self::STATUS_PENDING;
+ $where = 'WHERE claim_id = 0 AND scheduled_date_gmt <= %s AND status=%s';
+ $where_params = array(
+ $date->format( 'Y-m-d H:i:s' ),
+ self::STATUS_PENDING,
+ );
if ( ! empty( $hooks ) ) {
$placeholders = array_fill( 0, count( $hooks ), '%s' );
- $where .= ' AND hook IN (' . join( ', ', $placeholders ) . ')';
- $params = array_merge( $params, array_values( $hooks ) );
+ $where .= ' AND hook IN (' . join( ', ', $placeholders ) . ')';
+ $where_params = array_merge( $where_params, array_values( $hooks ) );
}
$group_operator = 'IN';
@@ -996,23 +990,32 @@ protected function claim_actions( $claim_id, $limit, ?DateTime $before_date = nu
/**
* Sets the order-by clause used in the action claim query.
*
- * @since 3.4.0
- * @since 3.8.3 Made $claim_id and $hooks available.
- *
* @param string $order_by_sql
* @param string $claim_id Claim Id.
- * @param array $hooks Hooks to filter for.
+ * @param array $hooks Hooks to filter for.
+ *
+ * @since 3.8.3 Made $claim_id and $hooks available.
+ * @since 3.4.0
*/
- $order = apply_filters( 'action_scheduler_claim_actions_order_by', 'ORDER BY priority ASC, attempts ASC, scheduled_date_gmt ASC, action_id ASC', $claim_id, $hooks );
- $params[] = $limit;
+ $order = apply_filters( 'action_scheduler_claim_actions_order_by', 'ORDER BY priority ASC, attempts ASC, scheduled_date_gmt ASC, action_id ASC', $claim_id, $hooks );
+ $skip_locked = $this->db_supports_skip_locked() ? ' SKIP LOCKED' : '';
+
+ // Selecting the action_ids that we plan to claim, while skipping any locked rows to avoid deadlocking.
+ $select_sql = $wpdb->prepare( "SELECT action_id from {$wpdb->actionscheduler_actions} {$where} {$order} LIMIT %d FOR UPDATE{$skip_locked}", array_merge( $where_params, array( $limit ) ) );
- $sql = $wpdb->prepare( "{$update} {$where} {$order} LIMIT %d", $params ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders
- $rows_affected = $wpdb->query( $sql ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
+ // Now place it into an UPDATE statement by joining the result sets, allowing for the SKIP LOCKED behavior to take effect.
+ $update_sql = "UPDATE {$wpdb->actionscheduler_actions} t1 JOIN ( $select_sql ) t2 ON t1.action_id = t2.action_id SET claim_id=%d, last_attempt_gmt=%s, last_attempt_local=%s";
+ $update_params = array(
+ $claim_id,
+ $now->format( 'Y-m-d H:i:s' ),
+ current_time( 'mysql' ),
+ );
+
+ $rows_affected = $wpdb->query( $wpdb->prepare( $update_sql, $update_params ) );
if ( false === $rows_affected ) {
$error = empty( $wpdb->last_error )
? _x( 'unknown', 'database error', 'action-scheduler' )
: $wpdb->last_error;
-
throw new \RuntimeException(
sprintf(
/* translators: %s database error. */
@@ -1025,6 +1028,43 @@ protected function claim_actions( $claim_id, $limit, ?DateTime $before_date = nu
return (int) $rows_affected;
}
+ /**
+ * Determines whether the database supports using SKIP LOCKED. This logic mimicks the $wpdb::has_cap() logic.
+ *
+ * SKIP_LOCKED support was added to MariaDB in 10.6.0 and to MySQL in 8.0.1
+ *
+ * @return bool
+ */
+ private function db_supports_skip_locked() {
+ global $wpdb;
+ $db_version = $wpdb->db_version();
+ $db_server_info = $wpdb->db_server_info();
+ $is_mariadb = ( false !== strpos( $db_server_info, 'MariaDB' ) );
+
+ if ( $is_mariadb &&
+ '5.5.5' === $db_version &&
+ PHP_VERSION_ID < 80016 // PHP 8.0.15 or older.
+ ) {
+ /*
+ * Account for MariaDB version being prefixed with '5.5.5-' on older PHP versions.
+ */
+ $db_server_info = preg_replace( '/^5\.5\.5-(.*)/', '$1', $db_server_info );
+ $db_version = preg_replace( '/[^0-9.].*/', '', $db_server_info );
+ }
+
+ $is_supported = ( $is_mariadb && version_compare( $db_version, '10.6.0', '>=' ) ) ||
+ ( ! $is_mariadb && version_compare( $db_version, '8.0.1', '>=' ) );
+
+ /**
+ * Filter whether the database supports the SKIP LOCKED modifier for queries.
+ *
+ * @param bool $is_supported Whether SKIP LOCKED is supported.
+ *
+ * @since 3.9.3
+ */
+ return apply_filters( 'action_scheduler_db_supports_skip_locked', $is_supported );
+ }
+
/**
* Get the number of active claims.
*
@@ -1094,7 +1134,7 @@ public function find_actions_by_claim_id( $claim_id ) {
}
/**
- * Release actions from a claim and delete the claim.
+ * Release pending actions from a claim and delete the claim.
*
* @param ActionScheduler_ActionClaim $claim Claim object.
* @throws \RuntimeException When unable to release actions from claim.
@@ -1107,14 +1147,21 @@ public function release_claim( ActionScheduler_ActionClaim $claim ) {
*/
global $wpdb;
+ if ( 0 === intval( $claim->get_id() ) ) {
+ // Verify that the claim_id is valid before attempting to release it.
+ return;
+ }
+
/**
* Deadlock warning: This function modifies actions to release them from claims that have been processed. Earlier, we used to it in a atomic query, i.e. we would update all actions belonging to a particular claim_id with claim_id = 0.
* While this was functionally correct, it would cause deadlock, since this update query will hold a lock on the claim_id_.. index on the action table.
* This allowed the possibility of a race condition, where the claimer query is also running at the same time, then the claimer query will also try to acquire a lock on the claim_id_.. index, and in this case if claim release query has already progressed to the point of acquiring the lock, but have not updated yet, it would cause a deadlock.
*
* We resolve this by getting all the actions_id that we want to release claim from in a separate query, and then releasing the claim on each of them. This way, our lock is acquired on the action_id index instead of the claim_id index. Note that the lock on claim_id will still be acquired, but it will only when we actually make the update, rather than when we select the actions.
+ *
+ * We only release pending actions in order for them to be claimed by another process.
*/
- $action_ids = $wpdb->get_col( $wpdb->prepare( "SELECT action_id FROM {$wpdb->actionscheduler_actions} WHERE claim_id = %d", $claim->get_id() ) );
+ $action_ids = $wpdb->get_col( $wpdb->prepare( "SELECT action_id FROM {$wpdb->actionscheduler_actions} WHERE claim_id = %d AND status = %s", $claim->get_id(), self::STATUS_PENDING ) );
$row_updates = 0;
if ( count( $action_ids ) > 0 ) {
diff --git a/inc/Dependencies/ActionScheduler/classes/data-stores/ActionScheduler_HybridStore.php b/inc/Dependencies/ActionScheduler/classes/data-stores/ActionScheduler_HybridStore.php
index c0845da4e..40520cc85 100644
--- a/inc/Dependencies/ActionScheduler/classes/data-stores/ActionScheduler_HybridStore.php
+++ b/inc/Dependencies/ActionScheduler/classes/data-stores/ActionScheduler_HybridStore.php
@@ -432,7 +432,7 @@ public function get_claim_id( $action_id ) {
}
/**
- * Release a claim in the table data store.
+ * Release a claim in the table data store on any pending actions.
*
* @param ActionScheduler_ActionClaim $claim Claim object.
*/
diff --git a/inc/Dependencies/ActionScheduler/classes/data-stores/ActionScheduler_wpPostStore.php b/inc/Dependencies/ActionScheduler/classes/data-stores/ActionScheduler_wpPostStore.php
index a503c1830..8f6375a6d 100644
--- a/inc/Dependencies/ActionScheduler/classes/data-stores/ActionScheduler_wpPostStore.php
+++ b/inc/Dependencies/ActionScheduler/classes/data-stores/ActionScheduler_wpPostStore.php
@@ -791,18 +791,13 @@ public function find_actions_by_claim_id( $claim_id ) {
}
/**
- * Release claim.
+ * Release pending actions from a claim.
*
* @param ActionScheduler_ActionClaim $claim Claim object to release.
* @return void
* @throws RuntimeException When the claim is not unlocked.
*/
public function release_claim( ActionScheduler_ActionClaim $claim ) {
- $action_ids = $this->find_actions_by_claim_id( $claim->get_id() );
- if ( empty( $action_ids ) ) {
- return; // nothing to do.
- }
- $action_id_string = implode( ',', array_map( 'intval', $action_ids ) );
/**
* Global wpdb object.
*
@@ -810,6 +805,28 @@ public function release_claim( ActionScheduler_ActionClaim $claim ) {
*/
global $wpdb;
+ $claim_id = $claim->get_id();
+ if ( trim( $claim_id ) === '' ) {
+ // Verify that the claim_id is valid before attempting to release it.
+ return;
+ }
+
+ // Only attempt to release pending actions to be claimed again. Running and complete actions are no longer relevant outside of admin/analytics.
+ // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
+ $action_ids = $wpdb->get_col(
+ $wpdb->prepare(
+ "SELECT ID, post_date_gmt FROM {$wpdb->posts} WHERE post_type = %s AND post_password = %s AND post_status = %s",
+ self::POST_TYPE,
+ $claim_id,
+ self::STATUS_PENDING
+ )
+ );
+
+ if ( empty( $action_ids ) ) {
+ return; // nothing to do.
+ }
+ $action_id_string = implode( ',', array_map( 'intval', $action_ids ) );
+
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
$result = $wpdb->query(
$wpdb->prepare(
diff --git a/inc/Dependencies/ActionScheduler/classes/schema/ActionScheduler_StoreSchema.php b/inc/Dependencies/ActionScheduler/classes/schema/ActionScheduler_StoreSchema.php
index 37df226bc..e1d073f57 100644
--- a/inc/Dependencies/ActionScheduler/classes/schema/ActionScheduler_StoreSchema.php
+++ b/inc/Dependencies/ActionScheduler/classes/schema/ActionScheduler_StoreSchema.php
@@ -20,7 +20,7 @@ class ActionScheduler_StoreSchema extends ActionScheduler_Abstract_Schema {
*
* @var int
*/
- protected $schema_version = 7;
+ protected $schema_version = 8;
/**
* Construct.
@@ -80,7 +80,9 @@ protected function get_table_definition( $table ) {
KEY args (args($max_index_length)),
KEY group_id (group_id),
KEY last_attempt_gmt (last_attempt_gmt),
- KEY `claim_id_status_scheduled_date_gmt` (`claim_id`, `status`, `scheduled_date_gmt`)
+ KEY `claim_id_status_priority_scheduled_date_gmt` (`claim_id`,`status`,`priority`,`scheduled_date_gmt`),
+ KEY `status_last_attempt_gmt` (`status`,`last_attempt_gmt`),
+ KEY `status_claim_id` (`status`,`claim_id`)
) $charset_collate";
case self::CLAIMS_TABLE:
diff --git a/inc/Dependencies/ActionScheduler/functions.php b/inc/Dependencies/ActionScheduler/functions.php
index 59e5542c3..d78c23ab5 100644
--- a/inc/Dependencies/ActionScheduler/functions.php
+++ b/inc/Dependencies/ActionScheduler/functions.php
@@ -86,8 +86,9 @@ function as_schedule_single_action( $timestamp, $hook, $args = array(), $group =
* @param array $args Action arguments.
* @param string $group Action group.
* @param int $priorities Action priority.
+ * @param bool $unique Unique action.
*/
- $pre = apply_filters( 'pre_as_schedule_single_action', null, $timestamp, $hook, $args, $group, $priority );
+ $pre = apply_filters( 'pre_as_schedule_single_action', null, $timestamp, $hook, $args, $group, $priority, $unique );
if ( null !== $pre ) {
return is_int( $pre ) ? $pre : 0;
}
@@ -159,8 +160,9 @@ function as_schedule_recurring_action( $timestamp, $interval_in_seconds, $hook,
* @param array $args Action arguments.
* @param string $group Action group.
* @param int $priority Action priority.
+ * @param bool $unique Unique action.
*/
- $pre = apply_filters( 'pre_as_schedule_recurring_action', null, $timestamp, $interval_in_seconds, $hook, $args, $group, $priority );
+ $pre = apply_filters( 'pre_as_schedule_recurring_action', null, $timestamp, $interval_in_seconds, $hook, $args, $group, $priority, $unique );
if ( null !== $pre ) {
return is_int( $pre ) ? $pre : 0;
}
@@ -225,8 +227,9 @@ function as_schedule_cron_action( $timestamp, $schedule, $hook, $args = array(),
* @param array $args Action arguments.
* @param string $group Action group.
* @param int $priority Action priority.
+ * @param bool $unique Unique action.
*/
- $pre = apply_filters( 'pre_as_schedule_cron_action', null, $timestamp, $schedule, $hook, $args, $group, $priority );
+ $pre = apply_filters( 'pre_as_schedule_cron_action', null, $timestamp, $schedule, $hook, $args, $group, $priority, $unique );
if ( null !== $pre ) {
return is_int( $pre ) ? $pre : 0;
}
@@ -493,3 +496,18 @@ function as_get_datetime_object( $date_string = null, $timezone = 'UTC' ) {
}
return $date;
}
+
+/**
+ * Check if a specific feature is supported by the current version of Action Scheduler.
+ *
+ * @since 3.9.3
+ *
+ * @param string $feature The feature to check support for.
+ *
+ * @return bool True if the feature is supported, false otherwise.
+ */
+function as_supports( string $feature ): bool {
+ $supported_features = array( 'ensure_recurring_actions_hook' );
+
+ return in_array( $feature, $supported_features, true );
+}
diff --git a/inc/Dependencies/ActionScheduler/readme.txt b/inc/Dependencies/ActionScheduler/readme.txt
index 9ef478ba2..8a6aa0a8d 100644
--- a/inc/Dependencies/ActionScheduler/readme.txt
+++ b/inc/Dependencies/ActionScheduler/readme.txt
@@ -1,11 +1,11 @@
=== Action Scheduler ===
Contributors: Automattic, wpmuguru, claudiosanches, peterfabian1000, vedjain, jamosova, obliviousharmony, konamiman, sadowski, royho, barryhughes-1
Tags: scheduler, cron
-Stable tag: 3.9.2
+Stable tag: 3.9.3
License: GPLv3
Requires at least: 6.5
-Tested up to: 6.7
-Requires PHP: 7.1
+Tested up to: 6.8
+Requires PHP: 7.2
Action Scheduler - Job Queue for WordPress
@@ -29,7 +29,7 @@ If your plugin needs background processing, especially of large sets of tasks, A
## Learn More
-To learn more about how to Action Scheduler works, and how to use it in your plugin, check out the docs on [ActionScheduler.org](https://actionscheduler.org).
+To learn more about how Action Scheduler works, and how to use it in your plugin, check out the docs on [ActionScheduler.org](https://actionscheduler.org).
There you will find:
@@ -47,6 +47,19 @@ Collaboration is cool. We'd love to work with you to improve Action Scheduler. [
== Changelog ==
+= 3.9.3 - 2025-07-15 =
+* Add hook 'action_scheduler_ensure_recurring_actions' specifically for scheduling recurring actions.
+* Assume an action is valid until proven otherwise.
+* Implement SKIP LOCKED during action claiming.
+* Import `get_flag_value()` from `WP_CLI\Utils` before using.
+* Make `$unique` available to all pre-creation/short-circuit hooks.
+* Make version/source information available via new class.
+* Only release claims on pending actions.
+* Tweak - WP 6.8 compatibility.
+* Update minimum supported php and phpunit versions.
+* Update readme.txt.
+* WP CLI get action command: correct parentheses/nesting of conditional checks.
+
= 3.9.2 - 2025-02-03 =
* Fixed fatal errors by moving version info methods to a new class and deprecating conflicting ones in ActionScheduler_Versions