Skip to content

Commit

Permalink
Add promoting notice library
Browse files Browse the repository at this point in the history
  • Loading branch information
pablo-sg-pacheco committed May 25, 2021
1 parent 9ada15b commit 79fc543
Show file tree
Hide file tree
Showing 46 changed files with 2,197 additions and 254 deletions.
9 changes: 8 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
"modal",
"popup"
],
"repositories": [
{
"type": "vcs",
"url": "https://github.com/wpcodefactory/wpf-promoting-notice"
}
],
"license": "MIT",
"authors": [
{
Expand All @@ -24,7 +30,8 @@
"require": {
"php": ">=5.3.2",
"composer/installers": ">=v1.2.0",
"thanks-to-it/wp-admin-notices": "dev-master"
"thanks-to-it/wp-admin-notices": "dev-master",
"wpfactory/wpf-promoting-notice":"dev-master"
},
"extra": {
"installer-paths": {
Expand Down
88 changes: 75 additions & 13 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions src/classes/class-notices.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ public function init() {
* @since 1.2.8
*/
function handle_notices() {
require_once( WP_PLUGIN_DIR . '/wpf-promoting-notice/vendor/autoload.php' );
$promoting_notice = new \WPFactory\Promoting_Notice\Core();
$promoting_notice = wpf_promoting_notice();
$promoting_notice->set_args( array(
'enable' => apply_filters( 'ttt_pnwc_license_data', true, 'test' ),
'template_variables' => array(
Expand Down
38 changes: 36 additions & 2 deletions vendor/composer/ClassLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Jordi Boggiano <j.boggiano@seld.be>
* @see http://www.php-fig.org/psr/psr-0/
* @see http://www.php-fig.org/psr/psr-4/
* @see https://www.php-fig.org/psr/psr-0/
* @see https://www.php-fig.org/psr/psr-4/
*/
class ClassLoader
{
private $vendorDir;

// PSR-4
private $prefixLengthsPsr4 = array();
private $prefixDirsPsr4 = array();
Expand All @@ -57,6 +59,13 @@ class ClassLoader
private $missingClasses = array();
private $apcuPrefix;

private static $registeredLoaders = array();

public function __construct($vendorDir = null)
{
$this->vendorDir = $vendorDir;
}

public function getPrefixes()
{
if (!empty($this->prefixesPsr0)) {
Expand Down Expand Up @@ -300,6 +309,17 @@ public function getApcuPrefix()
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;
}
}

/**
Expand All @@ -308,6 +328,10 @@ public function register($prepend = false)
public function unregister()
{
spl_autoload_unregister(array($this, 'loadClass'));

if (null !== $this->vendorDir) {
unset(self::$registeredLoaders[$this->vendorDir]);
}
}

/**
Expand Down Expand Up @@ -367,6 +391,16 @@ public function findFile($class)
return $file;
}

/**
* Returns the currently registered loaders indexed by their corresponding vendor directories.
*
* @return self[]
*/
public static function getRegisteredLoaders()
{
return self::$registeredLoaders;
}

private function findFileWithExtension($class, $ext)
{
// PSR-4 lookup
Expand Down
Loading

0 comments on commit 79fc543

Please sign in to comment.