本文整理汇总了PHP中Themes::get_all方法的典型用法代码示例。如果您正苦于以下问题:PHP Themes::get_all方法的具体用法?PHP Themes::get_all怎么用?PHP Themes::get_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Themes
的用法示例。
在下文中一共展示了Themes::get_all方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_init
function action_init()
{
if (!empty($_GET['theme_dir']) || !empty($_POST['theme_dir'])) {
$new_theme_dir = empty($_GET['theme_dir']) ? $_POST['theme_dir'] : $_GET['theme_dir'];
$all_themes = Themes::get_all();
if (array_key_exists($new_theme_dir, $all_themes)) {
if (!isset($_COOKIE['theme_dir']) || isset($_COOKIE['theme_dir']) && $_COOKIE['theme_dir'] != $new_theme_dir) {
$_COOKIE['theme_dir'] = $new_theme_dir;
// Without this, the cookie isn't get in time to change the theme NOW.
setcookie('theme_dir', $new_theme_dir);
}
}
}
$this->add_template('switcher', dirname(__FILE__) . '/themeswitcher.php');
}
示例2: get_active_theme_dir
/**
* Returns the active theme's full directory path.
* @params boolean $nopreview If true, return the real active theme, not the preview
* @return string The full path to the active theme directory
*/
private static function get_active_theme_dir($nopreview = false)
{
$theme_dir = self::get_theme_dir($nopreview);
$themes = Themes::get_all();
if (!isset($themes[$theme_dir])) {
$theme_exists = false;
foreach ($themes as $themedir) {
if (file_exists(Utils::end_in_slash($themedir) . 'theme.xml')) {
$theme_dir = basename($themedir);
Options::set('theme_dir', basename($themedir));
$theme_exists = true;
break;
}
}
if (!$theme_exists) {
die(_t('There is no valid theme currently installed.'));
}
}
return $themes[$theme_dir];
}
示例3: is_theme_option
/**
* Determines if an option is for a theme
*
* @param $option Name of the option being checked
* @return mixed Returns the theme name on success, or FALSE if not found
*/
public function is_theme_option($option)
{
if ($all_themes = Themes::get_all()) {
foreach ($all_themes as $theme_name => $theme_file) {
if (0 === strpos($option, strtolower($theme_name) . '_')) {
return $theme_name;
}
}
}
return FALSE;
}
示例4: get_active_theme_dir
/**
* Returns the active theme's full directory path.
* @params boolean $nopreview If true, return the real active theme, not the preview
* @return string The full path to the active theme directory
*/
private static function get_active_theme_dir( $nopreview = false )
{
$theme_dir = self::get_theme_dir( $nopreview );
$themes = Themes::get_all();
// If our active theme directory has gone missing, iterate through the others until we find one we can use and activate it.
if ( !isset( $themes[$theme_dir] ) ) {
$theme_exists = false;
foreach ( $themes as $themedir ) {
if ( file_exists( Utils::end_in_slash( $themedir ) . 'theme.xml' ) ) {
$theme_dir = basename( $themedir );
EventLog::log( _t( "Active theme directory no longer available. Falling back to '{$theme_dir}'" ), 'err', 'theme', 'habari' );
Options::set( 'theme_dir', basename( $themedir ) );
$fallback_theme = Themes::create();
Plugins::act_id( 'theme_activated', $fallback_theme->plugin_id(), $theme_dir, $fallback_theme );
$theme_exists = true;
// Refresh to the newly "activated" theme to ensure it takes the options that have just been set above and doesn't produce any errors.
Utils::redirect();
break;
}
}
if ( !$theme_exists ) {
die( _t( 'There is no valid theme currently installed.' ) );
}
}
return $themes[$theme_dir];
}