/*
Register Themes
557367
public function registerCustomTheme(){
        Yii::app()->clientScript->registerCssFile( Yii::app()->baseUrl.'/themes/'.$this->customThemeName );
    }
866676
protected function registerPlugins()
    {
        if (isset($this->clientOptions['plugins']) && count($this->clientOptions['plugins'])) {
            foreach ($this->clientOptions['plugins'] as $plugin) {
                $js = 'plugins/' . $plugin . '/' . $plugin . '.js';
                if (file_exists($this->sourcePath . DIRECTORY_SEPARATOR . $js)) {
                    $this->assetBundle->js[] = $js;
                }
                $css = 'plugins/' . $plugin . '/' . $plugin . '.css';
                if (file_exists($this->sourcePath . DIRECTORY_SEPARATOR . $css)) {
                    $this->assetBundle->css[] = $css;
                }
            }
        }
    }
910370
public function registerAssets()
    {
        $view = $this->getView();

        $asset = NotificationsAsset::register($view);

        // Register the theme assets
        if (!is_null($this->theme)) {
            if (!in_array($this->theme, self::$_builtinThemes)) {
                throw new Exception("Unknown theme: " . $this->theme, 501);
            }
            foreach (['js' => 'registerJsFile', 'css' => 'registerCssFile'] as $type => $method) {
                $filename = NotificationsAsset::getFilename($this->theme, $type);
                if ($filename) {
                    $view->$method($asset->baseUrl . '/' . $filename, [
                        'depends' => NotificationsAsset::className()
                    ]);
                }
            }
        }

        // Register timeago i18n file
        if ($filename = NotificationsAsset::getTimeAgoI18n($this->timeAgoLocale)) {
            $view->registerJsFile($asset->baseUrl . '/' . $filename, [
                'depends' => NotificationsAsset::className()
            ]);
        }

        $params = [
            'url' => Url::to(['/notifications/notifications/poll']),
            'xhrTimeout' => Html::encode($this->xhrTimeout),
            'delay' => Html::encode($this->delay),
            'options' => $this->clientOptions,
            'pollSeen' => !!$this->pollSeen,
            'pollInterval' => Html::encode($this->pollInterval),
            'counters' => $this->counters,
        ];

        if ($this->theme) {
            $params['theme'] = Html::encode($this->theme);
        }

        if ($this->markAllSeenSelector) {
            $params['markAllSeenSelector'] = $this->markAllSeenSelector;
            $params['seenAllUrl'] = Url::to(['/notifications/notifications/read-all']);
        }

        if ($this->deleteAllSelector) {
            $params['deleteAllSelector'] = $this->deleteAllSelector;
            $params['deleteAllUrl'] = Url::to(['/notifications/notifications/delete-all']);
        }

        if ($this->listSelector) {
            $params['seenUrl'] = Url::to(['/notifications/notifications/read']);
            $params['deleteUrl'] = Url::to(['/notifications/notifications/delete']);
            $params['flashUrl'] = Url::to(['/notifications/notifications/flash']);
            $params['listSelector'] = $this->listSelector;
            if ($this->listItemTemplate) {
                $params['listItemTemplate'] = $this->listItemTemplate;
            }
            if ($this->listItemBeforeRender instanceof JsExpression) {
                $params['listItemBeforeRender'] = $this->listItemBeforeRender;
            }
        }

        $js = 'Notifications(' . Json::encode($params) . ');';

        $view->registerJs($js);
    }
312095
public static function loadThemes()
    {
        $themesFolder = new Folder(ROOT . DS . 'themes');
        $themes = $themesFolder->read()[0];
        $loader = require ROOT . DS . 'vendor' . DS . 'autoload.php';
        foreach ($themes as $theme) {
            $loader->addPsr4('WasabiTheme\\' . $theme . '\\', [$themesFolder->path . DS . $theme . DS . 'src']);
            Plugin::load('WasabiTheme/' . $theme, [
                'path' => $themesFolder->path . DS . $theme . DS,
                'bootstrap' => true,
                'routes' => false
            ]);
        }
    }
26718
public function register()
	{
        $this->mergeConfigFrom(
		    __DIR__.'/../config/themes.php', 'themes'
		);
		
		$this->registerServices();
		$this->registerNamespaces();

        $this->commands([
            GenerateTheme::class
        ]);
	}
313217
public function registerAssets()
    {
        $view = $this->getView();
        JsTreeAsset::register($view);

        $config = [
            'core' => array_merge(['data' => $this->data], $this->core),
            'checkbox' => $this->checkbox,
            'contextmenu' => $this->contextmenu,
            'dnd' => $this->dnd,
            'search' => $this->search,
            'sort' => $this->sort,
            'state' => $this->state,
            'plugins' => $this->plugins,
            'types' => $this->types
        ];
        $defaults = Json::encode($config);

        $inputId = (!$this->hasModel()) ? $this->options['id'] : Html::getInputId($this->model, $this->attribute);

        $js = <<<SCRIPT
;(function($, window, document, undefined) {
    $('#jsTree_{$this->options['id']}')
        .bind("loaded.jstree", function (event, data) {
                $("#{$inputId}").val(JSON.stringify(data.selected));
            })
        .bind("changed.jstree", function(e, data, x){
                $("#{$inputId}").val(JSON.stringify(data.selected));
        })
        .jstree({$defaults});
})(window.jQuery, window, document);
SCRIPT;
        $view->registerJs($js);
    }
1284850
protected function registerMediaConversionsFromTheme()
    {
        $namespace = (new ReflectionClass($this))->getNamespaceName();
        $className = strtolower(explode('\\', $namespace)[1]);
        $themeOptions = app('setting.themeOptions')->getOption("{$className}.medialibrary");

        if (! $themeOptions) {
            return;
        }

        foreach ($themeOptions as $themeOption) {
            $this->addMediaConversion($themeOption->name)
                ->setManipulations((array) $themeOption->manipulation)
                ->performOnCollections($themeOption->collection);
        }
    }
1001800
protected function registerCoreScripts()
	{
		$cs=Yii::app()->getClientScript();
		if(is_string($this->cssFile))
			$cs->registerCssFile($this->themeUrl.'/'.$this->theme.'/'.$this->cssFile);
		elseif(is_array($this->cssFile))
		{
			foreach($this->cssFile as $cssFile)
				$cs->registerCssFile($this->themeUrl.'/'.$this->theme.'/'.$cssFile);
		}

		$cs->registerCoreScript('jquery');
		if(is_string($this->scriptFile))
			$this->registerScriptFile($this->scriptFile);
		elseif(is_array($this->scriptFile))
		{
			foreach($this->scriptFile as $scriptFile)
				$this->registerScriptFile($scriptFile);
		}
	}
1323919
@Override
	public void installTheme(Theme theme) {
		this.removeCssLinks();
		if (this.currentTheme != null) {
			for (CssLink link : this.currentTheme.getLinks()) {
				link.getLink().removeFromParent();
			}
		}
		this.currentTheme = theme;
		this.resetTheme();
	}
50246
public function registerNamespaces()
    {
        foreach ($this->all() as $theme) {
            foreach (array('views', 'lang') as $hint) {
                $this->{$hint}->addNamespace($theme->getLowerName(), $theme->getPath($hint));
            }

            $theme->boot();
        }
    }
1140984
function initThemes() {
        var activeThemeName = settingsCache.get('active_theme'),
            self = this;

        debug('init themes', activeThemeName);

        // Register a listener for server-start to load all themes
        common.events.on('server.start', function readAllThemesOnServerStart() {
            themeLoader.loadAllThemes();
        });

        // Just read the active theme for now
        return themeLoader
            .loadOneTheme(activeThemeName)
            .then(function activeThemeHasLoaded(theme) {
                // Validate
                return validate
                    .check(theme)
                    .then(function validationSuccess(checkedTheme) {
                        if (!validate.canActivate(checkedTheme)) {
                            const checkError = new common.errors.ThemeValidationError({
                                message: common.i18n.t('errors.middleware.themehandler.invalidTheme', {theme: activeThemeName}),
                                errorDetails: Object.assign(
                                    _.pick(checkedTheme, ['checkedVersion', 'name', 'path', 'version']), {
                                        errors: checkedTheme.results.error
                                    }
                                )
                            });

                            common.logging.error(checkError);

                            self.activate(theme, checkedTheme, checkError);
                        } else {
                            // CASE: inform that the theme has errors, but not fatal (theme still works)
                            if (checkedTheme.results.error.length) {
                                common.logging.warn(new common.errors.ThemeValidationError({
                                    errorType: 'ThemeWorksButHasErrors',
                                    message: common.i18n.t('errors.middleware.themehandler.themeHasErrors', {theme: activeThemeName}),
                                    errorDetails: Object.assign(
                                        _.pick(checkedTheme, ['checkedVersion', 'name', 'path', 'version']), {
                                            errors: checkedTheme.results.error
                                        }
                                    )
                                }));
                            }

                            debug('Activating theme (method A on boot)', activeThemeName);

                            self.activate(theme, checkedTheme);
                        }
                    });
            })
            .catch(common.errors.NotFoundError, function (err) {
                // CASE: active theme is missing, we don't want to exit because the admin panel will still work
                err.message = common.i18n.t('errors.middleware.themehandler.missingTheme', {theme: activeThemeName});
                common.logging.error(err);
            })
            .catch(function (err) {
                // CASE: theme threw an odd error, we don't want to exit because the admin panel will still work
                // This is the absolute catch-all, at this point, we do not know what went wrong!
                common.logging.error(err);
            });
    }
1093997
function registerThemeDirectories() {

		/**
		 * Register additional theme directories.
		 *
		 * Additional theme directories (e.g. those within another plugin, or custom
		 * subdirectories of wp-content) may be registered via this action hook.
		 *
		 * @since 3.8.0
		 */
		do_action( 'pressbooks_register_theme_directory' );

		if ( is_admin() ) {
			if ( Book::isBook() ) {
				add_filter( 'allowed_themes', [ $this, 'allowedBookThemes' ] );
			} elseif ( ! is_network_admin() ) {
				add_filter( 'allowed_themes', [ $this, 'allowedRootThemes' ] );
			}
		}
	}
618970
public static function setup_theme() {

		global $pagenow;

		if ( ( is_admin() && 'themes.php' == $pagenow ) || ! self::can_switch_themes() ) {
			return;
		}

		self::check_reset();
		self::load_cookie();

		if ( empty( self::$theme ) ) {
			return;
		}

		add_filter( 'pre_option_template', array( self::$theme, 'get_template' ) );
		add_filter( 'pre_option_stylesheet', array( self::$theme, 'get_stylesheet' ) );
		add_filter( 'pre_option_stylesheet_root', array( self::$theme, 'get_theme_root' ) );
		$parent = self::$theme->parent();
		add_filter( 'pre_option_template_root', array( empty( $parent ) ? self::$theme : $parent, 'get_theme_root' ) );
		add_filter( 'pre_option_current_theme', '__return_false' );
	}
1309728
protected function registerAssets()
    {
        $view = $this->getView();
        MarkdownEditorAsset::register($view);
        $varName = Inflector::variablize('editor_' . $this->id);
        $script = "var {$varName} = new SimpleMDE(" . $this->getEditorOptions() . ');';
        $view->registerJs($script);
        $css = <<<CSS
.wonail-markdown{z-index:{$this->zIndex};}
.wonail-markdown .editor-toolbar.fullscreen{z-index:{$this->zIndex}}
.wonail-markdown .CodeMirror-fullscreen{z-index: {$this->zIndex}}
.wonail-markdown .editor-statusbar{z-index: {$this->zIndex}}
CSS;
        $view->registerCss($css);
    }
600391
public function registerAssets()
    {
        $data = $this->getData();

        // Read the assets manifest file if it exists
        $manifest = $this->loadManifest();

        if (isset($data['styles']))
        {
            foreach ($data['styles'] as $handle => $props)
            {
                $this->handleStyleAction('register', $handle, $props, $manifest);
            }
        }

        if (isset($data['scripts']))
        {
            foreach ($data['scripts'] as $handle => $props)
            {
                $this->handleScriptAction('register', $handle, $props, $manifest);
            }
        }
    }
601290
protected function setThemeAutoloading()
    {
        foreach ($this->config->get('theme.autoloading', []) as $ns => $path) {
            $path = $this->dirPath.'/'.trim($path, '\/');
            $this->loader->addPsr4($ns, $path);
        }

        $this->loader->register();
    }
1312061
protected function register_assets() {
		$icon_picker = Icon_Picker::instance();

		if ( defined( 'ICON_PICKER_SCRIPT_DEBUG' ) && ICON_PICKER_SCRIPT_DEBUG ) {
			$assets_url = '//localhost:8080';
			$suffix     = '';
		} else {
			$assets_url = $icon_picker->url;
			$suffix     = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
		}

		wp_register_script(
			'icon-picker',
			"{$assets_url}/js/icon-picker{$suffix}.js",
			array( 'media-views' ),
			Icon_Picker::VERSION,
			true
		);
		$this->add_script( 'icon-picker' );

		wp_register_style(
			'icon-picker',
			"{$icon_picker->url}/css/icon-picker{$suffix}.css",
			false,
			Icon_Picker::VERSION
		);
		$this->add_style( 'icon-picker' );
	}