本文整理汇总了PHP中Themes::cancel_preview方法的典型用法代码示例。如果您正苦于以下问题:PHP Themes::cancel_preview方法的具体用法?PHP Themes::cancel_preview怎么用?PHP Themes::cancel_preview使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Themes
的用法示例。
在下文中一共展示了Themes::cancel_preview方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_preview_theme
/**
* Configures a theme to be active for the current user's session.
*/
public function get_preview_theme()
{
$theme_name = $this->handler_vars['theme_name'];
$theme_dir = $this->handler_vars['theme_dir'];
if (isset($theme_name) && isset($theme_dir)) {
if (Themes::get_theme_dir() == $theme_dir) {
Themes::cancel_preview();
Session::notice(_t("Ended the preview of the theme '%s'", array($theme_name)));
} else {
if (Themes::preview_theme($theme_name, $theme_dir)) {
Session::notice(_t("Previewing theme '%s'", array($theme_name)));
}
}
}
Utils::redirect(URL::get('admin', 'page=themes'));
}
示例2: activate_theme
/**
* function activate_theme
* Updates the database with the name of the new theme to use
* @param string the name of the theme
**/
public static function activate_theme($theme_name, $theme_dir)
{
$ok = Themes::validate_theme($theme_dir);
$ok = Plugins::filter('activate_theme', $ok, $theme_name);
// Allow plugins to reject activation
if ($ok) {
Themes::cancel_preview();
$old_active_theme = Themes::create();
Plugins::act_id('theme_deactivated', $old_active_theme->plugin_id(), $old_active_theme->name, $old_active_theme);
// For the theme itself to react to its deactivation
Plugins::act('theme_deactivated_any', $old_active_theme->name, $old_active_theme);
// For any plugin to react to its deactivation
Options::set('theme_name', $theme_name);
Options::set('theme_dir', $theme_dir);
$new_active_theme = Themes::create($theme_name);
// Set version of theme if it wasn't installed before
$versions = Options::get('pluggable_versions');
if (!isset($versions[get_class($new_active_theme)])) {
$versions[get_class($new_active_theme)] = $new_active_theme->get_version();
Options::set('pluggable_versions', $versions);
}
// Run activation hooks for theme activation
Plugins::act_id('theme_activated', $new_active_theme->plugin_id(), $theme_name, $new_active_theme);
// For the theme itself to react to its activation
Plugins::act('theme_activated_any', $theme_name, $new_active_theme);
// For any plugin to react to its activation
EventLog::log(_t('Activated Theme: %s', array($theme_name)), 'notice', 'theme', 'habari');
}
return $ok;
}