first commit
This commit is contained in:
25
wp-content/plugins/essential-addons-for-elementor-lite/vendor/autoload.php
vendored
Normal file
25
wp-content/plugins/essential-addons-for-elementor-lite/vendor/autoload.php
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
// autoload.php @generated by Composer
|
||||
|
||||
if (PHP_VERSION_ID < 50600) {
|
||||
if (!headers_sent()) {
|
||||
header('HTTP/1.1 500 Internal Server Error');
|
||||
}
|
||||
$err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
|
||||
if (!ini_get('display_errors')) {
|
||||
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
|
||||
fwrite(STDERR, $err);
|
||||
} elseif (!headers_sent()) {
|
||||
echo $err;
|
||||
}
|
||||
}
|
||||
trigger_error(
|
||||
$err,
|
||||
E_USER_ERROR
|
||||
);
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit6cfcc814dcead02ac0a50bb72e4439c0::getLoader();
|
||||
579
wp-content/plugins/essential-addons-for-elementor-lite/vendor/composer/ClassLoader.php
vendored
Normal file
579
wp-content/plugins/essential-addons-for-elementor-lite/vendor/composer/ClassLoader.php
vendored
Normal file
@@ -0,0 +1,579 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Composer.
|
||||
*
|
||||
* (c) Nils Adermann <naderman@naderman.de>
|
||||
* Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
/**
|
||||
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
|
||||
*
|
||||
* $loader = new \Composer\Autoload\ClassLoader();
|
||||
*
|
||||
* // register classes with namespaces
|
||||
* $loader->add('Symfony\Component', __DIR__.'/component');
|
||||
* $loader->add('Symfony', __DIR__.'/framework');
|
||||
*
|
||||
* // activate the autoloader
|
||||
* $loader->register();
|
||||
*
|
||||
* // to enable searching the include path (eg. for PEAR packages)
|
||||
* $loader->setUseIncludePath(true);
|
||||
*
|
||||
* In this example, if you try to use a class in the Symfony\Component
|
||||
* namespace or one of its children (Symfony\Component\Console for instance),
|
||||
* the autoloader will first look for the class under the component/
|
||||
* directory, and it will then fallback to the framework/ directory if not
|
||||
* found before giving up.
|
||||
*
|
||||
* This class is loosely based on the Symfony UniversalClassLoader.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @see 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<string, array<string, int>>
|
||||
*/
|
||||
private $prefixLengthsPsr4 = array();
|
||||
/**
|
||||
* @var array<string, list<string>>
|
||||
*/
|
||||
private $prefixDirsPsr4 = array();
|
||||
/**
|
||||
* @var list<string>
|
||||
*/
|
||||
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<string, array<string, list<string>>>
|
||||
*/
|
||||
private $prefixesPsr0 = array();
|
||||
/**
|
||||
* @var list<string>
|
||||
*/
|
||||
private $fallbackDirsPsr0 = array();
|
||||
|
||||
/** @var bool */
|
||||
private $useIncludePath = false;
|
||||
|
||||
/**
|
||||
* @var array<string, string>
|
||||
*/
|
||||
private $classMap = array();
|
||||
|
||||
/** @var bool */
|
||||
private $classMapAuthoritative = false;
|
||||
|
||||
/**
|
||||
* @var array<string, bool>
|
||||
*/
|
||||
private $missingClasses = array();
|
||||
|
||||
/** @var string|null */
|
||||
private $apcuPrefix;
|
||||
|
||||
/**
|
||||
* @var array<string, self>
|
||||
*/
|
||||
private static $registeredLoaders = array();
|
||||
|
||||
/**
|
||||
* @param string|null $vendorDir
|
||||
*/
|
||||
public function __construct($vendorDir = null)
|
||||
{
|
||||
$this->vendorDir = $vendorDir;
|
||||
self::initializeIncludeClosure();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, list<string>>
|
||||
*/
|
||||
public function getPrefixes()
|
||||
{
|
||||
if (!empty($this->prefixesPsr0)) {
|
||||
return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, list<string>>
|
||||
*/
|
||||
public function getPrefixesPsr4()
|
||||
{
|
||||
return $this->prefixDirsPsr4;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<string>
|
||||
*/
|
||||
public function getFallbackDirs()
|
||||
{
|
||||
return $this->fallbackDirsPsr0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<string>
|
||||
*/
|
||||
public function getFallbackDirsPsr4()
|
||||
{
|
||||
return $this->fallbackDirsPsr4;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string> Array of classname => path
|
||||
*/
|
||||
public function getClassMap()
|
||||
{
|
||||
return $this->classMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, string> $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>|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>|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>|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>|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<string, self>
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
359
wp-content/plugins/essential-addons-for-elementor-lite/vendor/composer/InstalledVersions.php
vendored
Normal file
359
wp-content/plugins/essential-addons-for-elementor-lite/vendor/composer/InstalledVersions.php
vendored
Normal file
@@ -0,0 +1,359 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Composer.
|
||||
*
|
||||
* (c) Nils Adermann <naderman@naderman.de>
|
||||
* Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Composer;
|
||||
|
||||
use Composer\Autoload\ClassLoader;
|
||||
use 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<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}|array{}|null
|
||||
*/
|
||||
private static $installed;
|
||||
|
||||
/**
|
||||
* @var bool|null
|
||||
*/
|
||||
private static $canGetVendors;
|
||||
|
||||
/**
|
||||
* @var array[]
|
||||
* @psalm-var array<string, array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
|
||||
*/
|
||||
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<string>
|
||||
*/
|
||||
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<string>
|
||||
*/
|
||||
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<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}
|
||||
*/
|
||||
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<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
|
||||
*/
|
||||
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<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $data
|
||||
*/
|
||||
public static function reload($data)
|
||||
{
|
||||
self::$installed = $data;
|
||||
self::$installedByVendor = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array[]
|
||||
* @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
|
||||
*/
|
||||
private static function getInstalled()
|
||||
{
|
||||
if (null === self::$canGetVendors) {
|
||||
self::$canGetVendors = method_exists('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<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $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<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
|
||||
$required = require __DIR__ . '/installed.php';
|
||||
self::$installed = $required;
|
||||
} else {
|
||||
self::$installed = array();
|
||||
}
|
||||
}
|
||||
|
||||
if (self::$installed !== array()) {
|
||||
$installed[] = self::$installed;
|
||||
}
|
||||
|
||||
return $installed;
|
||||
}
|
||||
}
|
||||
21
wp-content/plugins/essential-addons-for-elementor-lite/vendor/composer/LICENSE
vendored
Normal file
21
wp-content/plugins/essential-addons-for-elementor-lite/vendor/composer/LICENSE
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
Copyright (c) Nils Adermann, Jordi Boggiano
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
18
wp-content/plugins/essential-addons-for-elementor-lite/vendor/composer/autoload_classmap.php
vendored
Normal file
18
wp-content/plugins/essential-addons-for-elementor-lite/vendor/composer/autoload_classmap.php
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
// autoload_classmap.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(__DIR__);
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
|
||||
'PriyoMukul\\WPNotice\\Dismiss' => $vendorDir . '/priyomukul/wp-notice/src/Dismiss.php',
|
||||
'PriyoMukul\\WPNotice\\Notice' => $vendorDir . '/priyomukul/wp-notice/src/Notice.php',
|
||||
'PriyoMukul\\WPNotice\\Notices' => $vendorDir . '/priyomukul/wp-notice/src/Notices.php',
|
||||
'PriyoMukul\\WPNotice\\Utils\\Base' => $vendorDir . '/priyomukul/wp-notice/src/Utils/Base.php',
|
||||
'PriyoMukul\\WPNotice\\Utils\\CacheBank' => $vendorDir . '/priyomukul/wp-notice/src/Utils/CacheBank.php',
|
||||
'PriyoMukul\\WPNotice\\Utils\\Helper' => $vendorDir . '/priyomukul/wp-notice/src/Utils/Helper.php',
|
||||
'PriyoMukul\\WPNotice\\Utils\\NoticeRemover' => $vendorDir . '/priyomukul/wp-notice/src/Utils/NoticeRemover.php',
|
||||
'PriyoMukul\\WPNotice\\Utils\\Storage' => $vendorDir . '/priyomukul/wp-notice/src/Utils/Storage.php',
|
||||
);
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
// autoload_namespaces.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(__DIR__);
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
);
|
||||
10
wp-content/plugins/essential-addons-for-elementor-lite/vendor/composer/autoload_psr4.php
vendored
Normal file
10
wp-content/plugins/essential-addons-for-elementor-lite/vendor/composer/autoload_psr4.php
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
// autoload_psr4.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(__DIR__);
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'PriyoMukul\\WPNotice\\' => array($vendorDir . '/priyomukul/wp-notice/src'),
|
||||
);
|
||||
36
wp-content/plugins/essential-addons-for-elementor-lite/vendor/composer/autoload_real.php
vendored
Normal file
36
wp-content/plugins/essential-addons-for-elementor-lite/vendor/composer/autoload_real.php
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit6cfcc814dcead02ac0a50bb72e4439c0
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
public static function loadClassLoader($class)
|
||||
{
|
||||
if ('Composer\Autoload\ClassLoader' === $class) {
|
||||
require __DIR__ . '/ClassLoader.php';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Composer\Autoload\ClassLoader
|
||||
*/
|
||||
public static function getLoader()
|
||||
{
|
||||
if (null !== self::$loader) {
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit6cfcc814dcead02ac0a50bb72e4439c0', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit6cfcc814dcead02ac0a50bb72e4439c0', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit6cfcc814dcead02ac0a50bb72e4439c0::getInitializer($loader));
|
||||
|
||||
$loader->register(true);
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
||||
44
wp-content/plugins/essential-addons-for-elementor-lite/vendor/composer/autoload_static.php
vendored
Normal file
44
wp-content/plugins/essential-addons-for-elementor-lite/vendor/composer/autoload_static.php
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
// autoload_static.php @generated by Composer
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit6cfcc814dcead02ac0a50bb72e4439c0
|
||||
{
|
||||
public static $prefixLengthsPsr4 = array (
|
||||
'P' =>
|
||||
array (
|
||||
'PriyoMukul\\WPNotice\\' => 20,
|
||||
),
|
||||
);
|
||||
|
||||
public static $prefixDirsPsr4 = array (
|
||||
'PriyoMukul\\WPNotice\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/priyomukul/wp-notice/src',
|
||||
),
|
||||
);
|
||||
|
||||
public static $classMap = array (
|
||||
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
|
||||
'PriyoMukul\\WPNotice\\Dismiss' => __DIR__ . '/..' . '/priyomukul/wp-notice/src/Dismiss.php',
|
||||
'PriyoMukul\\WPNotice\\Notice' => __DIR__ . '/..' . '/priyomukul/wp-notice/src/Notice.php',
|
||||
'PriyoMukul\\WPNotice\\Notices' => __DIR__ . '/..' . '/priyomukul/wp-notice/src/Notices.php',
|
||||
'PriyoMukul\\WPNotice\\Utils\\Base' => __DIR__ . '/..' . '/priyomukul/wp-notice/src/Utils/Base.php',
|
||||
'PriyoMukul\\WPNotice\\Utils\\CacheBank' => __DIR__ . '/..' . '/priyomukul/wp-notice/src/Utils/CacheBank.php',
|
||||
'PriyoMukul\\WPNotice\\Utils\\Helper' => __DIR__ . '/..' . '/priyomukul/wp-notice/src/Utils/Helper.php',
|
||||
'PriyoMukul\\WPNotice\\Utils\\NoticeRemover' => __DIR__ . '/..' . '/priyomukul/wp-notice/src/Utils/NoticeRemover.php',
|
||||
'PriyoMukul\\WPNotice\\Utils\\Storage' => __DIR__ . '/..' . '/priyomukul/wp-notice/src/Utils/Storage.php',
|
||||
);
|
||||
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit6cfcc814dcead02ac0a50bb72e4439c0::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit6cfcc814dcead02ac0a50bb72e4439c0::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit6cfcc814dcead02ac0a50bb72e4439c0::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
}
|
||||
41
wp-content/plugins/essential-addons-for-elementor-lite/vendor/composer/installed.json
vendored
Normal file
41
wp-content/plugins/essential-addons-for-elementor-lite/vendor/composer/installed.json
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"packages": [
|
||||
{
|
||||
"name": "priyomukul/wp-notice",
|
||||
"version": "v2.x-dev",
|
||||
"version_normalized": "2.9999999.9999999.9999999-dev",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "git@github.com:priyomukul/wp-notice.git",
|
||||
"reference": "f3d02f6e772cb459e9b89d77605e02646f9c5d65"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/priyomukul/wp-notice/zipball/f3d02f6e772cb459e9b89d77605e02646f9c5d65",
|
||||
"reference": "f3d02f6e772cb459e9b89d77605e02646f9c5d65",
|
||||
"shasum": ""
|
||||
},
|
||||
"time": "2023-11-20T08:03:13+00:00",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"PriyoMukul\\WPNotice\\": "src/"
|
||||
}
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
"name": "Priyo Mukul",
|
||||
"email": "17237437+priyomukul@users.noreply.github.com"
|
||||
}
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/priyomukul/wp-notice/tree/v2",
|
||||
"issues": "https://github.com/priyomukul/wp-notice/issues"
|
||||
},
|
||||
"install-path": "../priyomukul/wp-notice"
|
||||
}
|
||||
],
|
||||
"dev": true,
|
||||
"dev-package-names": []
|
||||
}
|
||||
32
wp-content/plugins/essential-addons-for-elementor-lite/vendor/composer/installed.php
vendored
Normal file
32
wp-content/plugins/essential-addons-for-elementor-lite/vendor/composer/installed.php
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php return array(
|
||||
'root' => array(
|
||||
'name' => 'mukul/essential-addons-for-elementor-lite',
|
||||
'pretty_version' => 'dev-master',
|
||||
'version' => 'dev-master',
|
||||
'reference' => '121d81bbe09fd3f6d431fce576b3901317b96416',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
'dev' => true,
|
||||
),
|
||||
'versions' => array(
|
||||
'mukul/essential-addons-for-elementor-lite' => array(
|
||||
'pretty_version' => 'dev-master',
|
||||
'version' => 'dev-master',
|
||||
'reference' => '121d81bbe09fd3f6d431fce576b3901317b96416',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'priyomukul/wp-notice' => array(
|
||||
'pretty_version' => 'v2.x-dev',
|
||||
'version' => '2.9999999.9999999.9999999-dev',
|
||||
'reference' => 'f3d02f6e772cb459e9b89d77605e02646f9c5d65',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../priyomukul/wp-notice',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
),
|
||||
);
|
||||
165
wp-content/plugins/essential-addons-for-elementor-lite/vendor/priyomukul/wp-notice/src/Dismiss.php
vendored
Normal file
165
wp-content/plugins/essential-addons-for-elementor-lite/vendor/priyomukul/wp-notice/src/Dismiss.php
vendored
Normal file
@@ -0,0 +1,165 @@
|
||||
<?php
|
||||
|
||||
namespace PriyoMukul\WPNotice;
|
||||
|
||||
use PriyoMukul\WPNotice\Utils\Base;
|
||||
use PriyoMukul\WPNotice\Utils\Helper;
|
||||
|
||||
#[\AllowDynamicProperties]
|
||||
class Dismiss extends Base {
|
||||
use Helper;
|
||||
|
||||
private $id;
|
||||
private $scope = 'user';
|
||||
|
||||
/**
|
||||
* @var Notices
|
||||
*/
|
||||
private $app;
|
||||
private $hook;
|
||||
|
||||
public function __construct( $id, $options, $app ) {
|
||||
$this->id = $id;
|
||||
$this->app = $app;
|
||||
|
||||
if ( ! empty( $options ) ) {
|
||||
foreach ( $options as $key => $_value ) {
|
||||
$this->{$key} = $_value;
|
||||
}
|
||||
}
|
||||
|
||||
$this->hook = $this->app->app . '_wpnotice_dismiss_notice';
|
||||
|
||||
add_action( 'wp_ajax_' . $this->hook, [ $this, 'ajax_maybe_dismiss_notice' ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Print the script for dismissing the notice.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
* @since 1.0
|
||||
*/
|
||||
public function print_script() {
|
||||
$nonce = wp_create_nonce( 'wpnotice_dismiss_notice_' . $this->id );
|
||||
$_id = '#wpnotice-' . esc_attr( $this->app->app ) . '-' . esc_attr( $this->id );
|
||||
?>
|
||||
<script>
|
||||
window.addEventListener('load', function () {
|
||||
var dismissBtn = document.querySelector('<?php echo $_id ?> .notice-dismiss');
|
||||
var extraDismissBtn = document.querySelectorAll('<?php echo $_id ?> .dismiss-btn');
|
||||
|
||||
function wpNoticeDismissFunc(event) {
|
||||
event.preventDefault();
|
||||
|
||||
var httpRequest = new XMLHttpRequest(),
|
||||
postData = '',
|
||||
dismiss = event.target.dataset?.hasOwnProperty('dismiss') && event.target.dataset.dismiss || false,
|
||||
later = event.target.dataset?.hasOwnProperty('later') && event.target.dataset.later || false;
|
||||
|
||||
if (dismiss || later) {
|
||||
jQuery(event.target.offsetParent).slideUp(200);
|
||||
}
|
||||
|
||||
// Data has to be formatted as a string here.
|
||||
postData += 'id=<?php echo esc_attr( rawurlencode( $this->id ) ); ?>';
|
||||
postData += '&action=<?php echo esc_attr( $this->hook ); ?>';
|
||||
if (dismiss) {
|
||||
postData += '&dismiss=' + dismiss;
|
||||
}
|
||||
if (later) {
|
||||
postData += '&later=' + later;
|
||||
}
|
||||
|
||||
postData += '&nonce=<?php echo esc_html( $nonce ); ?>';
|
||||
|
||||
httpRequest.open('POST', '<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>');
|
||||
httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||||
httpRequest.send(postData);
|
||||
}
|
||||
|
||||
// Add an event listener to the dismiss button.
|
||||
dismissBtn && dismissBtn.addEventListener('click', wpNoticeDismissFunc);
|
||||
if (extraDismissBtn.length > 0) {
|
||||
extraDismissBtn.forEach(btn => btn.addEventListener('click', wpNoticeDismissFunc))
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Run check to see if we need to dismiss the notice.
|
||||
* If all tests are successful then call the dismiss_notice() method.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
* @since 1.0
|
||||
*/
|
||||
public function ajax_maybe_dismiss_notice() {
|
||||
// Sanity check: Early exit if we're not on a _dismiss_notice action.
|
||||
if ( ! isset( $_POST['action'] ) || $this->hook !== $_POST['action'] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Sanity check: Early exit if the ID of the notice is not the one from this object.
|
||||
if ( ! isset( $_POST['id'] ) || $this->id !== $_POST['id'] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Security check: Make sure nonce is OK.
|
||||
check_ajax_referer( 'wpnotice_dismiss_notice_' . $this->id, 'nonce', true );
|
||||
|
||||
if ( isset( $_POST['later'] ) ) {
|
||||
$_recurrence = intval( $this->recurrence ) || 15;
|
||||
$_queue = $this->app->storage()->get();
|
||||
|
||||
$_queue[ $this->id ]['start'] = $this->strtotime( "+$_recurrence days" );
|
||||
$_queue[ $this->id ]['expire'] = $this->strtotime( "+" . ( $_recurrence + 3 ) . " days" );
|
||||
$this->app->storage()->save( $_queue );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// If we got this far, we need to dismiss the notice.
|
||||
$this->dismiss_notice();
|
||||
}
|
||||
|
||||
/**
|
||||
* Actually dismisses the notice.
|
||||
*
|
||||
* @access private
|
||||
* @return bool
|
||||
* @since 1.0
|
||||
*/
|
||||
public function dismiss_notice() {
|
||||
if ( ! defined( 'WPNOTICE_EXPIRED_TIME' ) ) {
|
||||
define( 'WPNOTICE_EXPIRED_TIME', HOUR_IN_SECONDS * 10 );
|
||||
}
|
||||
|
||||
set_transient( 'wpnotice_priority_time_expired', true, time() + WPNOTICE_EXPIRED_TIME );
|
||||
|
||||
if ( 'user' === $this->scope ) {
|
||||
return $this->app->storage()->save_meta( $this->id );
|
||||
}
|
||||
|
||||
$_key = $this->app->app . '_' . $this->id . '_notice_dismissed';
|
||||
|
||||
return $this->app->storage()->save( $_key );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if is dismissed or not
|
||||
* @return boolean
|
||||
*/
|
||||
public function is_dismissed() {
|
||||
if ( 'user' === $this->scope ) {
|
||||
return $this->app->storage()->get_meta( $this->id );
|
||||
}
|
||||
|
||||
$_key = $this->app->app . '_' . $this->id . '_notice_dismissed';
|
||||
|
||||
return $this->app->storage()->get( $_key );
|
||||
}
|
||||
}
|
||||
294
wp-content/plugins/essential-addons-for-elementor-lite/vendor/priyomukul/wp-notice/src/Notice.php
vendored
Normal file
294
wp-content/plugins/essential-addons-for-elementor-lite/vendor/priyomukul/wp-notice/src/Notice.php
vendored
Normal file
@@ -0,0 +1,294 @@
|
||||
<?php
|
||||
|
||||
namespace PriyoMukul\WPNotice;
|
||||
|
||||
use PriyoMukul\WPNotice\Utils\Base;
|
||||
use PriyoMukul\WPNotice\Utils\Helper;
|
||||
use WP_Screen;
|
||||
use function property_exists;
|
||||
|
||||
#[\AllowDynamicProperties]
|
||||
class Notice extends Base {
|
||||
use Helper;
|
||||
|
||||
private $app = null;
|
||||
|
||||
private $id = null;
|
||||
private $content = null;
|
||||
|
||||
/**
|
||||
* @var Dismiss
|
||||
*/
|
||||
public $dismiss;
|
||||
|
||||
private $queue = [];
|
||||
|
||||
/**
|
||||
* @var int start
|
||||
* @var int expire
|
||||
* @var int recurrence Meaning this notice will appear after 10, 20 days.
|
||||
* @var string scope
|
||||
* @var array screens
|
||||
* @var string type Notice type
|
||||
* @var string capability
|
||||
* @var bool dismissible
|
||||
*/
|
||||
private $options = [
|
||||
// 'start' => 192933, // timestamp
|
||||
// 'expire' => 1029339, // timestamp
|
||||
'classes' => '',
|
||||
'recurrence' => false,
|
||||
'scope' => 'user',
|
||||
'screens' => null,
|
||||
'type' => 'info',
|
||||
'capability' => null,
|
||||
'dismissible' => false,
|
||||
];
|
||||
|
||||
public function __construct( ...$args ) {
|
||||
list( $id, $content, $options, $queue, $app ) = $args;
|
||||
|
||||
$this->app = $app;
|
||||
$this->id = $id;
|
||||
$this->content = $content;
|
||||
$this->queue = $queue;
|
||||
$this->options = wp_parse_args( $options, $this->options );
|
||||
|
||||
$this->dismiss = new Dismiss( $this->id, $this->options, $this->app );
|
||||
|
||||
if ( ! isset( $queue[ $id ] ) || ( ! empty( $this->options['refresh'] ) && ( empty( $queue[ $id ]['refresh'] ) || $queue[ $id ]['refresh'] != $this->options['refresh'] ) ) ) {
|
||||
$queue[ $id ] = [];
|
||||
$_eligible_keys = [ 'start', 'expire', 'recurrence', 'refresh' ];
|
||||
array_walk( $options, function ( $value, $key ) use ( $id, &$queue, $_eligible_keys ) {
|
||||
if ( in_array( $key, $_eligible_keys, true ) ) {
|
||||
$queue[ $id ][ $key ] = $value;
|
||||
}
|
||||
} );
|
||||
|
||||
$this->queue = $queue;
|
||||
$this->app->storage()->save( $queue ); // saved in queue
|
||||
} else {
|
||||
$this->options = wp_parse_args( $queue[ $id ], $this->options );
|
||||
}
|
||||
|
||||
if ( isset( $this->options['do_action'] ) ) {
|
||||
add_action( 'admin_init', [ $this, 'do_action' ] );
|
||||
}
|
||||
}
|
||||
|
||||
public function do_action() {
|
||||
do_action( $this->options['do_action'], $this );
|
||||
}
|
||||
|
||||
private function get_content() {
|
||||
if ( is_callable( $this->content ) ) {
|
||||
ob_start();
|
||||
call_user_func( $this->content );
|
||||
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
public function display( $force = false ) {
|
||||
if ( ! $force && ! $this->show() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$content = $this->get_content();
|
||||
if ( empty( $content ) ) {
|
||||
return; // Return if notice is empty.
|
||||
}
|
||||
|
||||
$links = $this->get_links();
|
||||
|
||||
// Print the notice.
|
||||
printf( '<div style="display: flex; flex-wrap: nowrap; gap: 15px; align-items: center;" id="%1$s" class="%2$s">%3$s<div class="wpnotice-content-wrapper">%4$s%5$s</div></div>', 'wpnotice-' . esc_attr( $this->app->app ) . '-' . esc_attr( $this->id ), // The ID.
|
||||
esc_attr( $this->get_classes() ), // The classes.
|
||||
! empty( $content['thumbnail'] ) ? $this->get_thumbnail( $content['thumbnail'] ) : '', ! empty( $content['html'] ) ? $content['html'] : $content, ! empty( $links ) ? $this->links( $links ) : '' );
|
||||
}
|
||||
|
||||
public function get_links() {
|
||||
return ! empty( $this->content['links'] ) ? $this->content['links'] : ( ! empty( $this->options['links'] ) ? $this->options['links'] : [] );
|
||||
}
|
||||
|
||||
public function links( $links ) {
|
||||
$_attributes = '';
|
||||
$output = '<ul style="display: flex; width: 100%; align-items: center;" class="notice-links ' . $this->app->id . '-notice-links">';
|
||||
foreach ( $links as $link ) {
|
||||
$class = ! empty( $link['class'] ) ? $link['class'] : '';
|
||||
|
||||
if ( ! empty( $link['attributes'] ) ) {
|
||||
$link['attributes']['target'] = '_top';
|
||||
$_attributes = $this->attributes( $link['attributes'] );
|
||||
$link['link'] = '#';
|
||||
}
|
||||
|
||||
$output .= '<li style="margin: 0 15px 0 0;" class="notice-link-item ' . $class . '">';
|
||||
$output .= ! empty( $link['link'] ) ? '<a href="' . esc_url( $link['link'] ) . '" ' . $_attributes . '>' : '';
|
||||
if ( isset( $link['icon_class'] ) ) {
|
||||
$output .= '<span style="margin-right: 5px" class="' . esc_attr( $link['icon_class'] ) . '"></span>';
|
||||
}
|
||||
$output .= $link['label'];
|
||||
$output .= ! empty( $link['link'] ) ? '</a>' : '';
|
||||
$output .= '</li>';
|
||||
}
|
||||
|
||||
$output .= '</ul>';
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
public function attributes( $params = [] ) {
|
||||
$_attr = [];
|
||||
$classname = 'dismiss-btn ';
|
||||
|
||||
if ( ! empty( $params['class'] ) ) {
|
||||
$classname .= $params['class'];
|
||||
unset( $params['class'] );
|
||||
}
|
||||
|
||||
$_attr[] = 'class="' . esc_attr( $classname ) . '"';
|
||||
|
||||
$_attr[] = 'target="_blank"';
|
||||
if ( ! empty( $params ) ) {
|
||||
foreach ( $params as $key => $value ) {
|
||||
$_attr[] = "$key='$value'";
|
||||
}
|
||||
}
|
||||
|
||||
return \implode( ' ', $_attr );
|
||||
}
|
||||
|
||||
public function url( $params = [] ) {
|
||||
$nonce = wp_create_nonce( 'wpnotice_dismiss_notice_' . $this->id );
|
||||
|
||||
return esc_url( add_query_arg( [
|
||||
'action' => 'wpnotice_dismiss_notice',
|
||||
'id' => $this->id,
|
||||
'nonce' => $nonce,
|
||||
], admin_url( '/' ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notice classes.
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
* @since 1.0
|
||||
*/
|
||||
public function get_classes() {
|
||||
$classes = [ 'wpnotice-wrapper notice', $this->app->id ];
|
||||
|
||||
// Add the class for notice-type.
|
||||
$classes[] = $this->options['classes'];
|
||||
$classes[] = 'notice-' . $this->options['type'];
|
||||
$classes[] = 'notice-' . $this->app->id . '-' . $this->id;
|
||||
|
||||
if ( $this->options['dismissible'] ) {
|
||||
$classes[] = 'is-dismissible';
|
||||
}
|
||||
|
||||
// Combine classes to a string.
|
||||
return implode( ' ', $classes );
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the notice should be shown or not.
|
||||
*
|
||||
* @access public
|
||||
* @return bool
|
||||
* @since 1.0
|
||||
*/
|
||||
public function show() {
|
||||
// External Condition Check
|
||||
if ( isset( $this->options['display_if'] ) && ! $this->options['display_if'] ) {
|
||||
return false;
|
||||
}
|
||||
// Don't show if the user doesn't have the required capability.
|
||||
if ( ! is_null( $this->options['capability'] ) && ! current_user_can( $this->options['capability'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Don't show if we're not on the right screen.
|
||||
if ( ! $this->is_screen() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Don't show if notice has been dismissed.
|
||||
if ( $this->dismiss->is_dismissed() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Start and Expiration Check.
|
||||
if ( $this->time() <= $this->options['start'] ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( $this->is_expired() ) {
|
||||
if ( $this->options['recurrence'] ) {
|
||||
$_recurrence = intval( $this->options['recurrence'] );
|
||||
$this->queue[ $this->id ]['start'] = $this->strtotime( "+$_recurrence days" );
|
||||
$this->queue[ $this->id ]['expire'] = $this->strtotime( "+" . ( $_recurrence + 3 ) . " days" );
|
||||
$this->app->storage()->save( $this->queue );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluate if we're on the right place depending on the "screens" argument.
|
||||
*
|
||||
* @access private
|
||||
* @return bool
|
||||
* @since 1.0
|
||||
*/
|
||||
private function is_screen() {
|
||||
// Make sure the get_current_screen function exists.
|
||||
if ( ! function_exists( 'get_current_screen' ) ) {
|
||||
require_once ABSPATH . 'wp-admin/includes/screen.php';
|
||||
}
|
||||
|
||||
/** @var WP_Screen $current_screen */
|
||||
$current_screen = get_current_screen();
|
||||
|
||||
if ( $current_screen->id === 'update' ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If screen is empty we want this shown on all screens.
|
||||
if ( empty( $this->options['screens'] ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return ( in_array( $current_screen->id, $this->options['screens'], true ) );
|
||||
}
|
||||
|
||||
public function is_expired() {
|
||||
if ( isset( $this->options['expire'] ) && $this->time() >= $this->options['expire'] ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function __call( $name, $args ) {
|
||||
if ( property_exists( $this, $name ) ) {
|
||||
return $this->{$name}[ $args[0] ];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function get_thumbnail( $image ) {
|
||||
$output = '<div class="wpnotice-thumbnail-wrapper">';
|
||||
$output .= '<img style="max-width: 100%;" src="' . esc_url( $image ) . '">';
|
||||
$output .= '</div>';
|
||||
|
||||
return wp_kses_post( $output );
|
||||
}
|
||||
}
|
||||
234
wp-content/plugins/essential-addons-for-elementor-lite/vendor/priyomukul/wp-notice/src/Notices.php
vendored
Normal file
234
wp-content/plugins/essential-addons-for-elementor-lite/vendor/priyomukul/wp-notice/src/Notices.php
vendored
Normal file
@@ -0,0 +1,234 @@
|
||||
<?php
|
||||
|
||||
namespace PriyoMukul\WPNotice;
|
||||
|
||||
use Exception;
|
||||
use PriyoMukul\WPNotice\Utils\Base;
|
||||
use PriyoMukul\WPNotice\Utils\CacheBank;
|
||||
use PriyoMukul\WPNotice\Utils\Helper;
|
||||
|
||||
|
||||
/**
|
||||
* @property $notices []
|
||||
* @property $queue []
|
||||
* @property $id string
|
||||
* @property $stylesheet_url string
|
||||
*/
|
||||
#[\AllowDynamicProperties]
|
||||
final class Notices extends Base {
|
||||
use Helper;
|
||||
|
||||
const VERSION = '1.1.0';
|
||||
|
||||
private $version = '1.1.0';
|
||||
|
||||
public $system_id = 'wpnotice_system';
|
||||
public $app = 'wpnotice';
|
||||
private $storage = null;
|
||||
private $scripts = null;
|
||||
|
||||
private $args;
|
||||
|
||||
/**
|
||||
* A list of notice
|
||||
* @var array
|
||||
*/
|
||||
private $notices = [];
|
||||
|
||||
/**
|
||||
* A list of notice based to timestamp (A Queue)
|
||||
* @var false|mixed
|
||||
*/
|
||||
private $queue;
|
||||
|
||||
/**
|
||||
* @var CacheBank
|
||||
*/
|
||||
private static $cache_bank;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $dev_mode = false;
|
||||
|
||||
/**
|
||||
* Default notice system options
|
||||
* @var array
|
||||
*/
|
||||
private $options = [
|
||||
'id' => '',
|
||||
'stylesheet_url' => '',
|
||||
'priority' => 1
|
||||
];
|
||||
|
||||
private $deprecated_options = [
|
||||
'system_id' => 'id',
|
||||
'app' => 'id',
|
||||
'scripts' => 'stylesheet_url'
|
||||
];
|
||||
|
||||
private $default_options = [
|
||||
'scripts_handle' => ''
|
||||
];
|
||||
|
||||
/**
|
||||
* This method takes an array as argument.
|
||||
*
|
||||
* @template $args
|
||||
*
|
||||
* @param $args
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct( $args ) {
|
||||
self::$cache_bank = CacheBank::get_instance();
|
||||
|
||||
/**
|
||||
* Check all the property is passed or not
|
||||
*/
|
||||
if ( ! isset( $args['version'] ) && self::VERSION === '1.1.0' ) {
|
||||
if ( ! is_array( $args ) ) {
|
||||
$this->error( "Argument of " . __CLASS__ . " should be an array. " . gettype( $args ) . " given." );
|
||||
}
|
||||
|
||||
if ( empty( $args ) ) {
|
||||
$this->error( "Argument of " . __CLASS__ . " should not be an empty array." );
|
||||
}
|
||||
|
||||
foreach ( $this->options as $key => $value ) {
|
||||
if ( ! isset( $args[ $key ] ) ) {
|
||||
$this->error( "Missing $key from argument list." );
|
||||
}
|
||||
}
|
||||
|
||||
$this->options = wp_parse_args( $args, $this->options );
|
||||
$this->scripts = $this->stylesheet_url;
|
||||
}
|
||||
|
||||
$this->system_id = ! empty( $args['id'] ) ? $args['id'] . '-notice-system' : 'wpnotice_system';
|
||||
$this->app = ! empty( $args['id'] ) ? $args['id'] : 'wpnotice';
|
||||
$this->dev_mode = ! empty( $args['dev_mode'] ) ? $args['dev_mode'] : $this->dev_mode;
|
||||
$this->args = $args;
|
||||
|
||||
if ( ! empty( $args['styles'] ) ) {
|
||||
$this->scripts = $args['styles'];
|
||||
unset( $args['styles'] );
|
||||
}
|
||||
|
||||
$this->queue = $this->storage()->get( '', [] );
|
||||
|
||||
self::$cache_bank->create_account( $this );
|
||||
}
|
||||
|
||||
public function __get( $name ) {
|
||||
if ( property_exists( $this, $name ) ) {
|
||||
return $this->$name;
|
||||
}
|
||||
|
||||
if ( ! empty( $this->options[ $name ] ) ) {
|
||||
return $this->options[ $name ];
|
||||
}
|
||||
|
||||
if ( isset( $this->deprecated_options[ $name ] ) && ! empty( $this->options[ $this->deprecated_options[ $name ] ] ) ) {
|
||||
return $this->options[ $this->deprecated_options[ $name ] ];
|
||||
}
|
||||
|
||||
if ( ! empty( $this->args[ $name ] ) ) {
|
||||
return $this->args[ $name ];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function storage() {
|
||||
return $this->database( $this->args );
|
||||
}
|
||||
|
||||
public function init() {
|
||||
}
|
||||
|
||||
public function notices() {
|
||||
wp_enqueue_style( $this->system_id, $this->scripts );
|
||||
|
||||
if ( ! $this->dev_mode ) {
|
||||
/**
|
||||
* @var Notice $notice
|
||||
*/
|
||||
$notice = $this->current_notice();
|
||||
if ( $notice ) {
|
||||
$notice->display();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Print all notices while dev_mode is enabled.
|
||||
*/
|
||||
$this->print_notices_for_dev_mode();
|
||||
}
|
||||
|
||||
public function eligible_notices( $notices = [], $queue = [] ) {
|
||||
$_sorted_queue = [];
|
||||
$notices = empty( $notices ) ? $this->notices : $notices;
|
||||
$queue = empty( $queue ) ? $this->queue : $queue;
|
||||
|
||||
if ( ! empty ( $queue ) ) {
|
||||
array_walk( $queue, function ( $value, $key ) use ( &$_sorted_queue, $notices ) {
|
||||
$notice = isset( $notices[ $key ] ) ? $notices[ $key ] : null;
|
||||
if ( ! is_null( $notice ) ) {
|
||||
if ( ! $notice->dismiss->is_dismissed() && ! $notice->is_expired() ) {
|
||||
$_sorted_queue[ $notice->options( 'start' ) ] = $key;
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
ksort( $_sorted_queue );
|
||||
|
||||
return $_sorted_queue;
|
||||
}
|
||||
|
||||
public function scripts() {
|
||||
if ( ! $this->dev_mode ) {
|
||||
/**
|
||||
* @var Notice $notice
|
||||
*/
|
||||
$notice = $this->current_notice();
|
||||
|
||||
if ( $notice && $notice->show() ) {
|
||||
$notice->dismiss->print_script();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Print scripts for all notices while dev_mode is enabled.
|
||||
*/
|
||||
$this->print_notices_for_dev_mode( true );
|
||||
}
|
||||
|
||||
public function add( $id, $content, $options = [] ) {
|
||||
$this->notices[ $id ] = new Notice( $id, $content, $options, $this->queue, $this );
|
||||
|
||||
self::$cache_bank->deposit( $this->id, $id, $this->notices[ $id ] );
|
||||
}
|
||||
|
||||
private function current_notice() {
|
||||
$current_notice = current( $this->eligible_notices() );
|
||||
|
||||
return isset( $this->notices[ $current_notice ] ) ? $this->notices[ $current_notice ] : false;
|
||||
}
|
||||
|
||||
private function print_notices_for_dev_mode( $scripts = false ) {
|
||||
if ( $this->dev_mode ) {
|
||||
/**
|
||||
* @var Notice $notice
|
||||
*/
|
||||
foreach ( $this->notices as $notice ) {
|
||||
if ( $scripts ) {
|
||||
$notice->dismiss->print_script();
|
||||
} else {
|
||||
$notice->display( true );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace PriyoMukul\WPNotice\Utils;
|
||||
|
||||
#[\AllowDynamicProperties]
|
||||
abstract class Base {
|
||||
/**
|
||||
* Holds the plugin instance.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @access protected
|
||||
* @static
|
||||
*
|
||||
* @var Base
|
||||
*/
|
||||
private static $instances = [];
|
||||
|
||||
/**
|
||||
* Sets up a single instance of the plugin.
|
||||
*
|
||||
* @return static An instance of the class.
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @static
|
||||
*
|
||||
*/
|
||||
public static function get_instance( ...$args ) {
|
||||
$module = get_called_class();
|
||||
$module_id = $module;
|
||||
|
||||
if ( $module === 'PriyoMukul\WPNotice\Notice' || $module === 'PriyoMukul\WPNotice\Dismiss' ) {
|
||||
$module_id = $module . '::' . $args[0];
|
||||
}
|
||||
|
||||
if ( ! isset( self::$instances[ $module_id ] ) ) {
|
||||
self::$instances[ $module_id ] = new $module( ...$args );
|
||||
}
|
||||
|
||||
return self::$instances[ $module_id ];
|
||||
}
|
||||
|
||||
protected function database( $args = null ) {
|
||||
return new Storage( $args );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
<?php
|
||||
|
||||
namespace PriyoMukul\WPNotice\Utils;
|
||||
|
||||
use PriyoMukul\WPNotice\Notices;
|
||||
|
||||
#[\AllowDynamicProperties]
|
||||
class CacheBank {
|
||||
private static $instance;
|
||||
|
||||
private static $accounts = [];
|
||||
|
||||
private static $notices = [];
|
||||
|
||||
private $priority_key = 'wpnotice_priority_time_expired';
|
||||
|
||||
public static function get_instance() {
|
||||
if ( self::$instance === null ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
public function __construct() {
|
||||
add_action( 'admin_notices', [ $this, 'notices' ] );
|
||||
add_action( 'admin_footer', [ $this, 'scripts' ] );
|
||||
}
|
||||
|
||||
|
||||
public function create_account( $app ) {
|
||||
$priority = isset( $app->options['priority'] ) ? $app->priority : count( self::$accounts );
|
||||
|
||||
if ( isset( $app->args['version'] ) && $app->args['version'] === '1.0.0' ) {
|
||||
$priority = 999 + count( self::$accounts );
|
||||
}
|
||||
|
||||
if ( isset( self::$accounts[ $priority ] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
self::$accounts[ $priority ] = $app;
|
||||
|
||||
ksort( self::$accounts );
|
||||
}
|
||||
|
||||
public function calculate_deposits( $app ) {
|
||||
if ( ! $app instanceof Notices ) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ( $app->notices as $id => $notice ) {
|
||||
$this->deposit( $app->id, $id, $notice );
|
||||
}
|
||||
}
|
||||
|
||||
public function deposit( $account, $id, $value ) {
|
||||
self::$notices[ $account ][ $id ] = $value;
|
||||
}
|
||||
|
||||
private function get_current_account() {
|
||||
if ( ! empty( self::$accounts ) ) {
|
||||
/**
|
||||
* @var Notices $account
|
||||
*/
|
||||
foreach ( self::$accounts as $account ) {
|
||||
$notices = $this->eligible_notices( $account->notices, $account->queue );
|
||||
|
||||
$notices = array_filter( $notices, function ( $notice_key ) use ( $account ) {
|
||||
$notice = self::$notices[ $account->id ][ $notice_key ];
|
||||
|
||||
return $notice->show();
|
||||
} );
|
||||
|
||||
if ( ! empty( $notices ) ) {
|
||||
return $account;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Notices
|
||||
*/
|
||||
public function get() {
|
||||
/**
|
||||
* @var Notices $current_notice ;
|
||||
*/
|
||||
return $this->get_current_account();
|
||||
}
|
||||
|
||||
public function notices() {
|
||||
if ( get_transient( $this->priority_key ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$notice = $this->get();
|
||||
|
||||
if ( $notice instanceof Notices ) {
|
||||
$notice->notices();
|
||||
}
|
||||
}
|
||||
|
||||
public function scripts() {
|
||||
if ( get_transient( $this->priority_key ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$notice = $this->get();
|
||||
|
||||
if ( $notice instanceof Notices ) {
|
||||
$notice->scripts();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a fallback method of Notices::eligible_notices.
|
||||
* Please make sure changes are done in both classes.
|
||||
*
|
||||
* @param $notices
|
||||
* @param $queue
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function eligible_notices( $notices = [], $queue = [] ) {
|
||||
$_sorted_queue = [];
|
||||
|
||||
if ( ! empty ( $queue ) ) {
|
||||
array_walk( $queue, function ( $value, $key ) use ( &$_sorted_queue, $notices ) {
|
||||
$notice = isset( $notices[ $key ] ) ? $notices[ $key ] : null;
|
||||
if ( ! is_null( $notice ) ) {
|
||||
if ( ! $notice->dismiss->is_dismissed() && ! $notice->is_expired() ) {
|
||||
$_sorted_queue[ $notice->options( 'start' ) ] = $key;
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
ksort( $_sorted_queue );
|
||||
|
||||
return $_sorted_queue;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace PriyoMukul\WPNotice\Utils;
|
||||
|
||||
use Exception;
|
||||
|
||||
trait Helper {
|
||||
|
||||
public function is_installed( $plugin ) {
|
||||
if ( ! function_exists( 'get_plugins' ) ) {
|
||||
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||||
}
|
||||
$plugins = get_plugins();
|
||||
|
||||
return isset( $plugins[ $plugin ] ) ? $plugins[ $plugin ] : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current timestamp
|
||||
* @return integer
|
||||
*/
|
||||
public function time() {
|
||||
return intval( current_time( 'timestamp' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Make timestamp for a number
|
||||
*
|
||||
* @param string $time
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function strtotime( $time = '+7 day' ) {
|
||||
return intval( strtotime( date( 'r', $this->time() ) . " $time" ) );
|
||||
}
|
||||
|
||||
public function date( $time ) {
|
||||
return date( 'd-m-Y h:i:s', $time );
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
private function error( $message ) {
|
||||
throw new Exception( $message );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace PriyoMukul\WPNotice\Utils;
|
||||
|
||||
use PriyoMukul\WPNotice\Notices;
|
||||
|
||||
class NoticeRemover {
|
||||
private static $instance = null;
|
||||
|
||||
public static function get_instance( $version ) {
|
||||
if ( self::$instance == null ) {
|
||||
self::$instance = new static( $version );
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
public function __construct( $version = '1.0.0', $instanceOf = null ) {
|
||||
add_action( 'init', function () use ( $version, $instanceOf ) {
|
||||
global $wp_filter;
|
||||
|
||||
if ( $instanceOf === null ) {
|
||||
$instanceOf = Notices::class;
|
||||
}
|
||||
|
||||
foreach ( $wp_filter['admin_notices']->callbacks[10] as $callback ) {
|
||||
if ( is_array( $callback['function'] ) && $callback['function'][0] instanceof $instanceOf ) {
|
||||
$notice = $callback['function'][0];
|
||||
|
||||
if ( $notice->version === $version ) {
|
||||
remove_action( 'admin_notices', [ $notice, 'notices' ] );
|
||||
remove_action( 'admin_footer', [ $notice, 'scripts' ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace PriyoMukul\WPNotice\Utils;
|
||||
|
||||
use function property_exists;
|
||||
|
||||
#[\AllowDynamicProperties]
|
||||
class Storage extends Base {
|
||||
private $id = 'wpnotice';
|
||||
private $type = 'options';
|
||||
private $version = '1.1.0';
|
||||
private $storage_key = 'notices';
|
||||
|
||||
public function __construct( $args ) {
|
||||
$this->id = ! empty( $args['id'] ) ? $args['id'] : $this->id;
|
||||
$this->type = ! empty( $args['store'] ) ? $args['store'] : $this->type;
|
||||
$this->storage_key = ! empty( $args['storage_key'] ) ? $this->id . '_' . $args['storage_key'] : "{$this->id}_{$this->storage_key}";
|
||||
}
|
||||
|
||||
public function __get( $name ) {
|
||||
return property_exists( $this, $name ) ? $this->$name : null;
|
||||
}
|
||||
|
||||
public function save( $value, $key = '' ) {
|
||||
if ( empty( $key ) ) {
|
||||
$key = $this->storage_key;
|
||||
$value['version'] = $this->version;
|
||||
}
|
||||
|
||||
if ( $this->type === 'options' ) {
|
||||
return update_site_option( $key, $value );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function get( $key = '', $default = false ) {
|
||||
$key = empty( $key ) ? $this->storage_key : $key;
|
||||
|
||||
if ( $this->type === 'options' ) {
|
||||
return get_site_option( $key, $default );
|
||||
}
|
||||
|
||||
return $default;
|
||||
}
|
||||
|
||||
public function save_meta( $id, $value = true ) {
|
||||
return update_user_meta( get_current_user_id(), "{$this->id}_{$id}_notice_dismissed", $value );
|
||||
}
|
||||
|
||||
public function get_meta( $id ) {
|
||||
return boolval( get_user_meta( get_current_user_id(), "{$this->id}_{$id}_notice_dismissed", true ) );
|
||||
}
|
||||
|
||||
public function remove_meta( $id ) {
|
||||
return delete_user_meta( get_current_user_id(), "{$this->id}_{$id}_notice_dismissed" );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user