Switch site's theme.

@return void
3034
public function main()
    {
        if (empty($this->params['theme'])) {
            $this->err(__d('installer', 'You must provide a theme.'));

            return false;
        }

        if (!Plugin::exists($this->params['theme'])) {
            $this->err(__d('installer', 'Theme "{0}" was not found.', $this->params['theme']));

            return false;
        }

        $plugin = plugin($this->params['theme']);
        if (!$plugin->isTheme) {
            $this->err(__d('installer', '"{0}" is not a theme.', $plugin->humanName));

            return false;
        }

        if (in_array($this->params['theme'], [option('front_theme'), option('back_theme')])) {
            $this->err(__d('installer', 'Theme "{0}" is already active.', $plugin->humanName));

            return false;
        }

        // MENTAL NOTE: As theme is "inactive" its listeners are not attached to the
        // system, so we need to manually attach them in order to trigger callbacks.
        if (!$this->params['no-callbacks']) {
            $this->_attachListeners($plugin->name, "{$plugin->path}/");

            try {
                $event = $this->trigger("Plugin.{$plugin->name}.beforeActivate");
                if ($event->isStopped() || $event->result === false) {
                    $this->err(__d('installer', 'Task was explicitly rejected by the theme.'));
                    $this->_detachListeners();

                    return false;
                }
            } catch (\Exception $ex) {
                $this->err(__d('installer', 'Internal error, theme did not respond to "beforeActivate" callback properly.'));
                $this->_detachListeners();

                return false;
            }
        }

        if (isset($plugin->composer['extra']['admin']) && $plugin->composer['extra']['admin']) {
            $prefix = 'back_';
            $previousTheme = option('back_theme');
        } else {
            $prefix = 'front_';
            $previousTheme = option('front_theme');
        }

        $this->loadModel('System.Options');
        $this->loadModel('System.Plugins');

        if ($this->Plugins->updateAll(['status' => 0], ['name' => $previousTheme]) &&
            $this->Plugins->updateAll(['status' => 1], ['name' => $this->params['theme']])
        ) {
            if ($this->Options->update("{$prefix}theme", $this->params['theme'])) {
                $this->_copyBlockPositions($this->params['theme'], $previousTheme);
            } else {
                $this->err(__d('installer', 'Internal error, the option "{0}" could not be persisted on database.', "{$prefix}theme"));
                $this->_detachListeners();

                return false;
            }
        } else {
            $this->err(__d('installer', 'Internal error, unable to turnoff current theme ({0}) and active new one ({1}).', $previousTheme, $this->params['theme']));

            return false;
        }

        if (!$this->params['no-callbacks']) {
            try {
                $this->trigger("Plugin.{$plugin->name}.afterActivate");
            } catch (\Exception $e) {
                $this->err(__d('installer', 'Theme did not respond to "afterActivate" callback.'));
            }
        }

        return true;
    }
1282185
protected function themeOptionsOverrides() {

		// --------------------------------------------------------------------
		// CSS

		$scss = '';
		$scss = apply_filters( 'pb_pdf_css_override', $scss ) . "\n";

		// Copyright
		// Please be kind, help Pressbooks grow by leaving this on!
		if ( empty( $GLOBALS['PB_SECRET_SAUCE']['TURN_OFF_FREEBIE_NOTICES_PDF'] ) ) {
			$freebie_notice = __( 'This book was produced with Pressbooks (https://pressbooks.com) and rendered with Prince.', 'pressbooks' );
			$scss .= '#copyright-page .ugc > p:last-of-type::after { display:block; margin-top: 1em; content: "' . $freebie_notice . '" }' . "\n";
		}

		$this->cssOverrides = $scss;

		// --------------------------------------------------------------------
		// Hacks

		$hacks = [];
		$hacks = apply_filters( 'pb_pdf_hacks', $hacks );

		// Append endnotes to URL?
		if ( isset( $hacks['pdf_footnotes_style'] ) && 'endnotes' === $hacks['pdf_footnotes_style'] ) {
			$this->url .= '&endnotes=true';
		}

	}
841502
public function change()
    {
        $table = $this->table('calendar_events');
        $table->addIndex(['calendar_id']);
        $table->addIndex(['is_recurring']);
        $table->addIndex(['start_date']);
        $table->addIndex(['end_date']);
        $table->update();
    }
1143635
public function loadSiteStyles()
    {
        $this->loadCdnStyles();

        $mainHandle = 'site';
        $this->loadMainStyleByHandle($mainHandle);

        $viewHandle = $this->getViewHandle();

        if (file_exists(sprintf('%s/css/views/%s.css', $this->paths->getThemeAssetsDir(), $viewHandle))) {
            $viewSrc = sprintf('%s/css/views/%s.css', $this->paths->getThemeAssetsUri(), $viewHandle);
            $this->loadStyle($viewHandle, $viewSrc, [$mainHandle]);
        }
    }
972030
protected function setThemeConstants()
    {
        $this->parsedHeaders = $this->headers($this->dirPath.'/style.css', $this->headers);

        // Theme text domain.
        $textdomain = (isset($this->parsedHeaders['text_domain']) && ! empty($this->parsedHeaders['text_domain']))
            ? $this->parsedHeaders['text_domain']
            : 'themosis_theme';

        defined('THEME_TD') ? THEME_TD : define('THEME_TD', $textdomain);
    }
701399
public function change()
    {
        $table = $this->table('calendar_events');
        $hasSource = $table->hasColumn('event_source');
        $hasSourceId = $table->hasColumn('event_source_id');

        if ($hasSource) {
            $table->renameColumn('event_source', 'source');
        }

        if ($hasSourceId) {
            $table->renameColumn('event_source_id', 'source_id');
        }
    }
691711
public function switchSiteContext($site_name) {
    $this->logger->debug("Switching site context to <comment>$site_name</comment>.");
    $config_initializer = new ConfigInitializer($this->getConfigValue('repo.root'), $this->input());
    $config_initializer->setSite($site_name);
    $new_config = $config_initializer->initialize();

    // Replaces config.
    $this->getConfig()->import($new_config->export());
  }
410472
public function setTheme(string $theme)
    {
        if (!$this->isPathValid($theme)) {
            throw new NotFoundException('The theme cannot be found.');
        }

        $this->validateTheme($theme);

        $themeInfo = $this->getThemeInfo($theme);

        if (array_key_exists('parent', $themeInfo)) {
            $this->childTheme = $themeInfo;

            $this->setTheme($themeInfo['parent']);
        } else {
            $this->theme = $themeInfo;
        }
    }
1292439
function() {
			switch(that.settings.position) {
				case 'top':
					that.bar.css('top', 0);
					break;
				case 'bottom':
					that.bar.css('bottom', 0);
					break;
				default:
					that.bar.css('top', 0);
			}
		}
1055428
public function multisite_branch_switcher( $theme_key, $theme ) {
		if ( empty( static::$options['branch_switch'] ) ) {
			return false;
		}

		$enclosure         = $this->update_row_enclosure( $theme_key, 'theme', true );
		$id                = $theme_key . '-id';
		$branches          = isset( $this->config[ $theme_key ]->branches )
			? $this->config[ $theme_key ]->branches
			: null;
		$nonced_update_url = wp_nonce_url(
			$this->get_update_url( 'theme', 'upgrade-theme', $theme_key ),
			'upgrade-theme_' . $theme_key
		);

		// Get current branch.
		$repo   = $this->config[ $theme_key ];
		$branch = Singleton::get_instance( 'Branch', $this )->get_current_branch( $repo );

		$branch_switch_data                      = [];
		$branch_switch_data['slug']              = $theme_key;
		$branch_switch_data['nonced_update_url'] = $nonced_update_url;
		$branch_switch_data['id']                = $id;
		$branch_switch_data['branch']            = $branch;
		$branch_switch_data['branches']          = $branches;

		/*
		 * Create after_theme_row_
		 */
		echo $enclosure['open'];
		$this->make_branch_switch_row( $branch_switch_data );
		echo $enclosure['close'];

		return true;
	}
1097781
public function register()
    {
        $this->registerTheme();
        $this->app->alias('theme', 'AvoRed\Framework\Theme\Manager');
        $this->registerThemeConsoleProvider();
        $themes = Theme::all();
    }
1027713
private function configureSiteTheme( $site ) {

		$theme = $site->theme;

		// Site Theme
		if( Yii::$app->id == Yii::$app->core->appFrontend ) {

			// Theme Found
			if( isset( $theme ) ) {

				$themePath = 'themes\\' . $theme->slug . '\\Theme';

				Yii::$app->view->theme = new $themePath;

				Yii::$app->assetManager->bundles = require( Yii::getAlias( '@themes' ) . "/assets/$theme->slug/" . ( YII_ENV_PROD ? 'prod.php' : 'dev.php' ) );
			}
		}
		// Admin Theme
		else if( Yii::$app->id == Yii::$app->core->appAdmin ) {

			Yii::$app->assetManager->bundles = require( Yii::getAlias( '@themes' ) . "/assets/admin/" . ( YII_ENV_PROD ? 'prod.php' : 'dev.php' ) );
		}
	}
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();
    }
623626
public function theme_should_be_activated( $theme )
	{
		$theme = $this->replace_variables( $theme );
		$current_theme = $this->get_current_theme();

		if ( $theme !== $current_theme ) {
			throw new \Exception( sprintf(
				"The current theme is %s, but it should be %s",
				$current_theme,
				$theme
			) );
		}
	}
813950
public function after_setup_theme(): void {

		foreach ( $this->event_configs as $config ) {
			$this->add_events( $config->get_events() );
		}
	}
865616
public function editSettings()
    {
        $this->setTitleEditSettings();
        $this->setBreadcrumbEditSettings();

        $this->setData('stores', $this->store->getList());
        $this->setData('settings', $this->module->getSettings('device'));
        $this->setData('themes', $this->getFrontendThemesSettings());

        $this->submitSettings();
        $this->outputEditSettings();
    }
1365061
private function mirrorThemes()
    {
        $filesystem = $this->app['filesystem'];
        $themes = $filesystem->find()
            ->directories()
            ->in('root://vendor/bolt/themes')
            ->depth(0)
        ;

        $confirm = $this->io->confirm('Continuing will copy/update the example themes into your installation, overwriting older copies. Is this OK?');
        if (!$confirm) {
            $this->io->note('Skipping theme copy');

            return;
        }

        foreach ($themes as $theme) {
            /** @var Directory $theme */
            $origin = $theme->getFullPath();
            $target = 'themes://' . $theme->getFilename();

            $this->io->title('Installing theme: ' . $theme->getFilename());
            $filesystem->mirror($origin, $target, ['override' => true]);
            $this->io->success('');
        }
    }