本文整理汇总了PHP中validate_current_theme函数的典型用法代码示例。如果您正苦于以下问题:PHP validate_current_theme函数的具体用法?PHP validate_current_theme怎么用?PHP validate_current_theme使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了validate_current_theme函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: admin_url
if (!is_multisite() && current_user_can('install_themes')) {
?>
<a href="<?php
echo admin_url('theme-install.php');
?>
" class="hide-if-no-js add-new-h2"><?php
echo esc_html_x('Add New', 'Add new theme');
?>
</a>
<?php
}
?>
</h2>
<?php
//k(!validate_current_theme());
if (!validate_current_theme() || isset($_GET['broken'])) {
?>
<div id="message1" class="updated notice is-dismissible"><p><?php
_e('The active theme is broken. Reverting to the default theme.');
?>
</p></div>
<?php
} elseif (isset($_GET['activated'])) {
if (isset($_GET['previewed'])) {
?>
<div id="message2" class="updated notice is-dismissible"><p><?php
printf(__('Settings saved and theme activated. <a href="%s">Visit site</a>'), home_url('/'));
?>
</p></div>
<?php
} else {
示例2: __
$help_install = '<p>' . __('Installing themes on Multisite can only be done from the Network Admin section.') . '</p>';
} else {
$help_install = '<p>' . sprintf(__('If you would like to see more themes to choose from, click on the “Install Themes” tab and you will be able to browse or search for additional themes from the <a href="%s" target="_blank">WordPress.org Theme Directory</a>. Themes in the WordPress.org Theme Directory are designed and developed by third parties, and are compatible with the license WordPress uses. Oh, and they’re free!'), 'http://wordpress.org/extend/themes/') . '</p>';
}
get_current_screen()->add_help_tab(array('id' => 'adding-themes', 'title' => __('Adding Themes'), 'content' => $help_install));
}
get_current_screen()->set_help_sidebar('<p><strong>' . __('For more information:') . '</strong></p>' . '<p>' . __('<a href="http://codex.wordpress.org/Using_Themes" target="_blank">Documentation on Using Themes</a>') . '</p>' . '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>');
add_thickbox();
wp_enqueue_script('theme-preview');
wp_enqueue_script('theme');
}
require_once './admin-header.php';
?>
<?php
if (!validate_current_theme()) {
?>
<div id="message1" class="updated"><p><?php
_e('The active theme is broken. Reverting to the default theme.');
?>
</p></div>
<?php
} elseif (isset($_GET['activated'])) {
if (isset($wp_registered_sidebars) && count((array) $wp_registered_sidebars) && current_user_can('edit_theme_options')) {
?>
<div id="message2" class="updated"><p><?php
printf(__('New theme activated. This theme supports widgets, please visit the <a href="%s">widgets settings</a> screen to configure them.'), admin_url('widgets.php'));
?>
</p></div><?php
} else {
?>
示例3: after_setup_theme
/**
* Callback to validate a theme once it is loaded
*
* @since 3.4.0
*/
public function after_setup_theme()
{
$doing_ajax_or_is_customized = $this->doing_ajax() || isset($_SERVER['customized']);
if (!$doing_ajax_or_is_customized && !validate_current_theme()) {
wp_redirect('themes.php?broken=true');
exit;
}
}
示例4: after_setup_theme
/**
* Callback to validate a theme once it is loaded
*
* @since 3.4.0
*/
public function after_setup_theme()
{
if (!$this->doing_ajax() && !validate_current_theme()) {
wp_redirect('themes.php?broken=true');
exit;
}
}
示例5: test_switch_theme
/**
* @expectedDeprecated get_themes
* @expectedDeprecated get_current_theme
*/
function test_switch_theme()
{
$themes = get_themes();
// Switch to each theme in sequence.
// Do it twice to make sure we switch to the first theme, even if it's our starting theme.
// Do it a third time to ensure switch_theme() works with one argument.
for ($i = 0; $i < 3; $i++) {
foreach ($themes as $name => $theme) {
// switch to this theme
if ($i === 2) {
switch_theme($theme['Template'], $theme['Stylesheet']);
} else {
switch_theme($theme['Stylesheet']);
}
$this->assertEquals($name, get_current_theme());
// make sure the various get_* functions return the correct values
$this->assertEquals($theme['Template'], get_template());
$this->assertEquals($theme['Stylesheet'], get_stylesheet());
$root_fs = get_theme_root();
$this->assertTrue(is_dir($root_fs));
$root_uri = get_theme_root_uri();
$this->assertTrue(!empty($root_uri));
$this->assertEquals($root_fs . '/' . get_stylesheet(), get_stylesheet_directory());
$this->assertEquals($root_uri . '/' . get_stylesheet(), get_stylesheet_directory_uri());
$this->assertEquals($root_uri . '/' . get_stylesheet() . '/style.css', get_stylesheet_uri());
# $this->assertEquals($root_uri . '/' . get_stylesheet(), get_locale_stylesheet_uri());
$this->assertEquals($root_fs . '/' . get_template(), get_template_directory());
$this->assertEquals($root_uri . '/' . get_template(), get_template_directory_uri());
//get_query_template
// template file that doesn't exist
$this->assertEquals('', get_query_template(rand_str()));
// template files that do exist
//foreach ($theme['Template Files'] as $path) {
//$file = basename($path, '.php');
// FIXME: untestable because get_query_template uses TEMPLATEPATH
//$this->assertEquals('', get_query_template($file));
//}
// these are kind of tautologies but at least exercise the code
$this->assertEquals(get_404_template(), get_query_template('404'));
$this->assertEquals(get_archive_template(), get_query_template('archive'));
$this->assertEquals(get_author_template(), get_query_template('author'));
$this->assertEquals(get_category_template(), get_query_template('category'));
$this->assertEquals(get_date_template(), get_query_template('date'));
$this->assertEquals(get_home_template(), get_query_template('home', array('home.php', 'index.php')));
$this->assertEquals(get_page_template(), get_query_template('page'));
$this->assertEquals(get_paged_template(), get_query_template('paged'));
$this->assertEquals(get_search_template(), get_query_template('search'));
$this->assertEquals(get_single_template(), get_query_template('single'));
$this->assertEquals(get_attachment_template(), get_query_template('attachment'));
// this one doesn't behave like the others
if (get_query_template('comments-popup')) {
$this->assertEquals(get_comments_popup_template(), get_query_template('comments-popup'));
} else {
$this->assertEquals(get_comments_popup_template(), ABSPATH . 'wp-includes/theme-compat/comments-popup.php');
}
$this->assertEquals(get_tag_template(), get_query_template('tag'));
// nb: this probably doesn't run because WP_INSTALLING is defined
$this->assertTrue(validate_current_theme());
}
}
}
示例6: restore_backup
//.........这里部分代码省略.........
}
// Second loop: now actually do the restoration
uksort($second_loop, array($this, 'sort_restoration_entities'));
// If continuing, then prune those already done
if (is_array($continuation_data)) {
foreach ($second_loop as $type => $files) {
if (isset($continuation_data['second_loop_entities'][$type])) {
$second_loop[$type] = $continuation_data['second_loop_entities'][$type];
}
}
}
$updraftplus->jobdata_set('second_loop_entities', $second_loop);
$updraftplus->jobdata_set('backup_timestamp', $timestamp);
// use a site option, as otherwise on multisite when all the array of options is updated via UpdraftPlus_Options::update_site_option(), it will over-write any restored UD options from the backup
update_site_option('updraft_restore_in_progress', $updraftplus->nonce);
foreach ($second_loop as $type => $files) {
# Types: uploads, themes, plugins, others, db
$info = isset($backupable_entities[$type]) ? $backupable_entities[$type] : array();
echo 'db' == $type ? "<h2>" . __('Database', 'updraftplus') . "</h2>" : "<h2>" . $info['description'] . "</h2>";
$updraftplus->log("Entity: " . $type);
if (is_string($files)) {
$files = array($files);
}
foreach ($files as $fkey => $file) {
$last_one = 1 == count($second_loop) && 1 == count($files);
$val = $updraftplus_restorer->restore_backup($file, $type, $info, $last_one);
if (is_wp_error($val)) {
$codes = $val->get_error_codes();
if (is_array($codes) && in_array('not_found', $codes) && !empty($updraftplus_restorer->ud_foreign) && apply_filters('updraftplus_foreign_allow_missing_entity', false, $type, $updraftplus_restorer->ud_foreign)) {
$updraftplus->log("Entity to move not found in this zip - but this is possible with this foreign backup type");
} else {
$updraftplus->log_e($val);
foreach ($val->get_error_messages() as $msg) {
echo '<strong>' . __('Error message', 'updraftplus') . ':</strong> ' . htmlspecialchars($msg) . '<br>';
}
$codes = $val->get_error_codes();
if (is_array($codes)) {
foreach ($codes as $code) {
$data = $val->get_error_data($code);
if (!empty($data)) {
$pdata = is_string($data) ? $data : serialize($data);
echo '<strong>' . __('Error data:', 'updraftplus') . '</strong> ' . htmlspecialchars($pdata) . '<br>';
if (false !== strpos($pdata, 'PCLZIP_ERR_BAD_FORMAT (-10)')) {
echo '<a href="https://updraftplus.com/faqs/error-message-pclzip_err_bad_format-10-invalid-archive-structure-mean/"><strong>' . __('Please consult this FAQ for help on what to do about it.', 'updraftplus') . '</strong></a><br>';
}
}
}
}
echo '</div>';
//close the updraft_restore_progress div even if we error
restore_error_handler();
return $val;
}
} elseif (false === $val) {
echo '</div>';
//close the updraft_restore_progress div even if we error
restore_error_handler();
return false;
}
unset($files[$fkey]);
$second_loop[$type] = $files;
$updraftplus->jobdata_set('second_loop_entities', $second_loop);
$updraftplus->jobdata_set('backup_timestamp', $timestamp);
do_action('updraft_restored_archive', $file, $type, $val, $fkey, $timestamp);
}
unset($second_loop[$type]);
update_site_option('updraft_restore_in_progress', $updraftplus->nonce);
$updraftplus->jobdata_set('second_loop_entities', $second_loop);
$updraftplus->jobdata_set('backup_timestamp', $timestamp);
}
// All done - remove
delete_site_option('updraft_restore_in_progress');
foreach (array('template', 'stylesheet', 'template_root', 'stylesheet_root') as $opt) {
add_filter('pre_option_' . $opt, array($this, 'option_filter_' . $opt));
}
# Clear any cached pages after the restore
$updraftplus_restorer->clear_cache();
if (!function_exists('validate_current_theme')) {
require_once ABSPATH . WPINC . '/themes';
}
# Have seen a case where the current theme in the DB began with a capital, but not on disk - and this breaks migrating from Windows to a case-sensitive system
$template = get_option('template');
if (!empty($template) && $template != WP_DEFAULT_THEME && $template != strtolower($template)) {
$theme_root = get_theme_root($template);
$theme_root2 = get_theme_root(strtolower($template));
if (!file_exists("{$theme_root}/{$template}/style.css") && file_exists("{$theme_root}/" . strtolower($template) . "/style.css")) {
$updraftplus->log_e("Theme directory (%s) not found, but lower-case version exists; updating database option accordingly", $template);
update_option('template', strtolower($template));
}
}
if (!validate_current_theme()) {
echo '<strong>';
$updraftplus->log_e("The current theme was not found; to prevent this stopping the site from loading, your theme has been reverted to the default theme");
echo '</strong>';
}
echo '</div>';
//close the updraft_restore_progress div
restore_error_handler();
return true;
}
示例7: update_option
if (isset($_GET['stylesheet'])) {
update_option('stylesheet', $_GET['stylesheet']);
}
do_action('switch_theme', get_current_theme());
header('Location: themes.php?activated=true');
}
}
$title = __('Manage Themes');
$parent_file = 'themes.php';
require_once('admin-header.php');
?>
<?php if ( ! validate_current_theme() ) : ?>
<div class="updated"><p><?php _e('The active theme is broken. Reverting to the default theme.'); ?></p></div>
<?php elseif ( isset($activated) ) : ?>
<div class="updated"><p><?php _e('New theme activated'); ?></p></div>
<?php endif; ?>
<?php
$themes = get_themes();
$current_theme = get_current_theme();
$current_title = $themes[$current_theme]['Title'];
$current_version = $themes[$current_theme]['Version'];
$current_parent_theme = $themes[$current_theme]['Parent Theme'];
$current_template_dir = $themes[$current_theme]['Template Dir'];
$current_stylesheet_dir = $themes[$current_theme]['Stylesheet Dir'];
$current_template = $themes[$current_theme]['Template'];
$current_stylesheet = $themes[$current_theme]['Stylesheet'];
示例8: add_magic_quotes
}
// Escape with wpdb.
$_GET = add_magic_quotes($_GET );
$_POST = add_magic_quotes($_POST );
$_COOKIE = add_magic_quotes($_COOKIE);
$_SERVER = add_magic_quotes($_SERVER);
do_action('sanitize_comment_cookies');
$wp_the_query =& new WP_Query();
$wp_query =& $wp_the_query;
$wp_rewrite =& new WP_Rewrite();
$wp =& new WP();
validate_current_theme();
define('TEMPLATEPATH', get_template_directory());
define('STYLESHEETPATH', get_stylesheet_directory());
// Load the default text localization domain.
load_default_textdomain();
$locale = get_locale();
$locale_file = ABSPATH . LANGDIR . "/$locale.php";
if ( is_readable($locale_file) )
require_once($locale_file);
// Pull in locale data after loading text domain.
require_once(ABSPATH . WPINC . '/locale.php');
$wp_locale =& new WP_Locale();
示例9: restore_backup
//.........这里部分代码省略.........
echo __("The backup records do not contain information about the proper size of this file.", 'updraftplus') . "<br>";
}
if (!is_readable($fullpath)) {
echo __('Could not find one of the files for restoration', 'updraftplus') . " ({$file})<br>";
$updraftplus->log("{$file}: " . __('Could not find one of the files for restoration', 'updraftplus'), 'error');
echo '</div>';
restore_error_handler();
return false;
}
}
$info = isset($backupable_entities[$type]) ? $backupable_entities[$type] : array();
$val = $updraftplus_restorer->pre_restore_backup($files, $type, $info);
if (is_wp_error($val)) {
$updraftplus->log_wp_error($val);
foreach ($val->get_error_messages() as $msg) {
echo '<strong>' . __('Error:', 'updraftplus') . '</strong> ' . htmlspecialchars($msg) . '<br>';
}
foreach ($val->get_error_codes() as $code) {
if ('already_exists' == $code) {
$this->print_delete_old_dirs_form(false);
}
}
echo '</div>';
//close the updraft_restore_progress div even if we error
restore_error_handler();
return $val;
} elseif (false === $val) {
echo '</div>';
//close the updraft_restore_progress div even if we error
restore_error_handler();
return false;
}
$second_loop[$type] = $files;
}
$updraftplus_restorer->delete = UpdraftPlus_Options::get_updraft_option('updraft_delete_local') ? true : false;
if ('none' === $service || 'email' === $service || empty($service) || is_array($service) && 1 == count($service) && (in_array('none', $service) || in_array('', $service) || in_array('email', $service))) {
if ($updraftplus_restorer->delete) {
$updraftplus->log_e('Will not delete any archives after unpacking them, because there was no cloud storage for this backup');
}
$updraftplus_restorer->delete = false;
}
// Second loop: now actually do the restoration
uksort($second_loop, array($this, 'sort_restoration_entities'));
foreach ($second_loop as $type => $files) {
# Types: uploads, themes, plugins, others, db
$info = isset($backupable_entities[$type]) ? $backupable_entities[$type] : array();
echo 'db' == $type ? "<h2>" . __('Database', 'updraftplus') . "</h2>" : "<h2>" . $info['description'] . "</h2>";
$updraftplus->log("Entity: " . $type);
if (is_string($files)) {
$files = array($files);
}
foreach ($files as $file) {
$val = $updraftplus_restorer->restore_backup($file, $type, $info);
if (is_wp_error($val)) {
$updraftplus->log_e($val);
foreach ($val->get_error_messages() as $msg) {
echo '<strong>' . __('Error message', 'updraftplus') . ':</strong> ' . htmlspecialchars($msg) . '<br>';
}
$codes = $val->get_error_codes();
if (is_array($codes)) {
foreach ($codes as $code) {
$data = $val->get_error_data($code);
if (!empty($data)) {
$pdata = is_string($data) ? $data : serialize($data);
echo '<strong>' . __('Error data:', 'updraftplus') . '</strong> ' . htmlspecialchars($pdata) . '<br>';
}
}
}
echo '</div>';
//close the updraft_restore_progress div even if we error
restore_error_handler();
return $val;
} elseif (false === $val) {
echo '</div>';
//close the updraft_restore_progress div even if we error
restore_error_handler();
return false;
}
}
}
foreach (array('template', 'stylesheet', 'template_root', 'stylesheet_root') as $opt) {
add_filter('pre_option_' . $opt, array($this, 'option_filter_' . $opt));
}
if (!function_exists('validate_current_theme')) {
require_once ABSPATH . 'wp-includes/themes';
}
if (!validate_current_theme()) {
global $updraftplus;
echo '<strong>';
$updraftplus->log_e("The current theme was not found; to prevent this stopping the site from loading, your theme has been reverted to the default theme");
echo '</strong>';
}
#foreach (array('template', 'stylesheet', 'template_root', 'stylesheet_root') as $opt) {
# remove_filter('pre_option_'.$opt, array($this, 'option_filter_'.$opt));
#}
echo '</div>';
//close the updraft_restore_progress div
restore_error_handler();
return true;
}
示例10: wp_united_display_theme_menu
function wp_united_display_theme_menu()
{
global $user_ID, $title, $parent_file, $wp_version;
$wpuConnSettings = get_settings('wputd_connection');
if (!validate_current_theme()) {
?>
<div id="message1" class="updated fade"><p><?php
_e('The active theme is broken. Reverting to the default theme.');
?>
</p></div>
<?php
} elseif (isset($_GET['activated'])) {
?>
<div id="message2" class="updated fade"><p><?php
printf(__('New theme activated. <a href="%s">View your blog »</a>'), wpu_homelink('wpu-activate-theme') . '/');
?>
</p></div>
<?php
}
$themes = get_themes();
$theme_names = array_keys($themes);
$user_theme = 'WordPress Default';
$user_template = get_usermeta($user_ID, 'WPU_MyTemplate');
$user_stylesheet = get_usermeta($user_ID, 'WPU_MyStylesheet');
$site_theme = current_theme_info();
$user_theme = $site_theme->title;
// if user hasn't set a theme yet, it is the same as site default
// get current user theme
if ($themes) {
foreach ($theme_names as $theme_name) {
if ($themes[$theme_name]['Stylesheet'] == $user_stylesheet && $themes[$theme_name]['Template'] == $user_template) {
$user_theme = $themes[$theme_name]['Name'];
break;
}
}
}
$template = $themes[$user_theme]['Template'];
$stylesheet = $themes[$user_theme]['Stylesheet'];
$title = $themes[$user_theme]['Title'];
$version = $themes[$user_theme]['Version'];
$description = $themes[$user_theme]['Description'];
$author = $themes[$user_theme]['Author'];
$screenshot = $themes[$user_theme]['Screenshot'];
$stylesheet_dir = $themes[$user_theme]['Stylesheet Dir'];
$tags = $themes[$user_theme]['Tags'];
if ($wp_version > 2.5) {
// paginate if necessary
ksort($themes);
$theme_total = count($themes);
$per_page = 15;
if (isset($_GET['pagenum'])) {
$page = absint($_GET['pagenum']);
}
if (empty($page)) {
$page = 1;
}
$start = $offset = ($page - 1) * $per_page;
$page_links = paginate_links(array('base' => add_query_arg('pagenum', '%#%') . '#themenav', 'format' => '', 'prev_text' => __('«'), 'next_text' => __('»'), 'total' => ceil($theme_total / $per_page), 'current' => $page));
$themes = array_slice($themes, $start, $per_page);
$pageTitle = __('Set Your Blog Theme');
$parent_file = 'wpu-plugin.php&wputab=themes';
?>
<div class="wrap">
<?php
screen_icon();
?>
<h2><?php
echo wp_specialchars($pageTitle);
?>
</h2>
<?php
/* CURRENT THEME */
?>
<h3><?php
_e('Current Theme');
?>
</h3>
<div id="current-theme">
<?php
if ($screenshot) {
?>
<img src="<?php
echo WP_CONTENT_URL . $stylesheet_dir . '/' . $screenshot;
?>
" alt="<?php
_e('Current theme preview');
?>
" />
<?php
}
?>
<h4><?php
printf(_c('%1$s %2$s by %3$s|1: theme title, 2: theme version, 3: theme author'), $title, $version, $author);
?>
</h4>
<p class="description"><?php
echo $description;
?>
</p>
//.........这里部分代码省略.........