/** * @param $name * @param $searchIn * @param $ext * @param Plugin $plugin * * @return string * @throws \WPluginCore003\Diagnostics\Exception * @author Panagiotis Vagenas <*****@*****.**> * @since 0.0.2 */ public function locate($name, $searchIn, $ext, Plugin $plugin) { if (!preg_match('/.*\\.' . $ext . '$/', $name)) { $name .= ".{$ext}"; } foreach ((array) $searchIn as $path) { $filePath = Paths::truePath("{$path}/{$name}", true); if (!$filePath) { continue; } if ($plugin->getFactory()->fcrPlugin()->paths()->verifyPathIsUnder($filePath, $path) && file_exists($filePath) && is_readable($filePath)) { return $filePath; } } return ''; }
/** * @author Panagiotis Vagenas <*****@*****.**> * @since 0.0.2 */ public function testView() { $rootDirPath = self::$rootDir->url(); $filter = self::$WpPluginCore->getHookFactory()->getWhereTemplatesMayResideFilter(function ($paths) use($rootDirPath) { $paths[] = $rootDirPath; return $paths; }); $filter->add(); $this->assertEquals('1', self::$templateObj->view(self::$templateBaseName)); $var = 'myVarValue'; $this->assertEquals($var, self::$templateObj->view(self::$templateBaseName, compact('var'))); $filter->remove(); }
/** * Returns the *Singleton* instance of this class. * * @param Plugin $plugin * * @return $this ::class The *Singleton* instance. */ public static function getInstance(Plugin $plugin) { $class = get_called_class(); if (!isset(self::$instances[$plugin->getSlug()])) { self::$instances[$plugin->getSlug()] = array(); } if (!isset(self::$instances[$plugin->getSlug()][$class])) { self::$instances[$plugin->getSlug()][$class] = new $class($plugin); } return self::$instances[$plugin->getSlug()][$class]; }
/** * @return string * @author Panagiotis Vagenas <*****@*****.**> * @since 0.0.2 */ public function locate() { $fileObj = $this->plugin->getFactory()->fcrHelpers()->file(); return $fileObj->locate($this->handle, $this->whereMayReside, $this->fileExtension, $this->plugin); }
/** * @param Plugin $plugin * @param string $handle * @param string $wpRelPath * @param array $deps * @param bool|true $inFooter */ public function __construct(Plugin $plugin, $handle, $wpRelPath = '', array $deps = array(), $inFooter = true) { $this->inFooter = $inFooter; $this->whereMayReside = $plugin->getFactory()->fcrPlugin()->paths()->getWhereScriptsMayReside(); parent::__construct($plugin, $handle, $wpRelPath, $deps); }
/** * @param Plugin $plugin * @param string $handle * @param string $wpRelPath * @param array $deps * @param string $media */ public function __construct(Plugin $plugin, $handle, $wpRelPath = '', array $deps = array(), $media = 'all') { $this->media = $media; $this->whereMayReside = $plugin->getFactory()->fcrPlugin()->paths()->getWhereStylesMayReside(); parent::__construct($plugin, $handle, $wpRelPath, $deps); }