/** * Instantiates this class * */ public function __construct() { // Set current environment key $this->current_env = EnvManager::getInstance()->getCurrentKey(); // Get paths manager $paths = PathManager::getInstance(); // Create hooks base structure $this->hooks = new Collection(['presets' => [__DIR__ . '/presets.json', $paths->get('theme', 'bebop-presets.json')], 'build' => [$paths->get('theme', 'bebop.json')]]); // Create config collection $this->config = new Collection(); // Build configuration on the after_setup_theme hook add_action('after_setup_theme', [$this, 'build']); }
/** * Instantiates UI object * */ protected function __construct() { // Get URL for current directory self::$__base_url = Utils::getPathUrl(__DIR__); // Instantiate plugins collection object $this->__plugins = new Collection(); // Add built-in plugins $this->addPlugins(array('Ponticlaro\\Bebop\\UI\\Plugins\\Media\\Media', 'Ponticlaro\\Bebop\\UI\\Plugins\\ContentList\\ContentList', 'Ponticlaro\\Bebop\\UI\\Plugins\\MultiContentList\\MultiContentList', 'Ponticlaro\\Bebop\\UI\\Plugins\\Gallery\\Gallery')); // Register common UI scripts add_action('init', array($this, 'registerScripts')); // Set assets directory $assets_dir = __DIR__ . '/UI/assets'; // Set static assets URL $paths = PathManager::getInstance(); $paths->set('_bebop/static/ui', $assets_dir); // Set static assets directory $urls = UrlManager::getInstance(); $urls->set('_bebop/static/ui', $urls->get('home', '_bebop/static/ui')); // Setup static assets server $http_api = new HttpApi('bebop_ui_static_assets', '_bebop/static/ui'); new StaticAssetsServer($http_api, $assets_dir); }
/** * Creates Bebop shortcode for usage inside content editor * * @param array $attrs Shortcode attributes * @param string $content Shortcode content * @return void */ public function __bebopShortcodes($attrs, $content = null) { if ($attrs) { if (array_key_exists('url', $attrs)) { return UrlManager::getInstance()->get($attrs['url']); } if (array_key_exists('path', $attrs)) { return PathManager::getInstance()->get($attrs['path']); } } }
/** * Builds configuration item * * @return object Current object */ public function build() { PathManager::getInstance()->set($this->getId(), $this->config->get('path')); }
/** * Returns file version * * @return string */ public function getVersion() { $version = $this->config->get('version'); $path = PathManager::getInstance()->get('theme') . '/' . $this->getPath(); if (!$version && is_readable($path)) { $version = filemtime($path); } return $version; }