本文整理汇总了PHP中WP_Theme::get_core_default_theme方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Theme::get_core_default_theme方法的具体用法?PHP WP_Theme::get_core_default_theme怎么用?PHP WP_Theme::get_core_default_theme使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WP_Theme
的用法示例。
在下文中一共展示了WP_Theme::get_core_default_theme方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate_current_theme
/**
* Checks that current theme files 'index.php' and 'style.css' exists.
*
* Does not initially check the default theme, which is the fallback and should always exist.
* But if it doesn't exist, it'll fall back to the latest core default theme that does exist.
* Will switch theme to the fallback theme if current theme does not validate.
*
* You can use the 'validate_current_theme' filter to return false to
* disable this functionality.
*
* @since 1.5.0
* @see WP_DEFAULT_THEME
*
* @return bool
*/
function validate_current_theme()
{
/**
* Filter whether to validate the current theme.
*
* @since 2.7.0
*
* @param bool $validate Whether to validate the current theme. Default true.
*/
if (wp_installing() || !apply_filters('validate_current_theme', true)) {
return true;
}
if (!file_exists(get_template_directory() . '/index.php')) {
// Invalid.
} elseif (!file_exists(get_template_directory() . '/style.css')) {
// Invalid.
} elseif (is_child_theme() && !file_exists(get_stylesheet_directory() . '/style.css')) {
// Invalid.
} else {
// Valid.
return true;
}
$default = wp_get_theme(WP_DEFAULT_THEME);
if ($default->exists()) {
switch_theme(WP_DEFAULT_THEME);
return false;
}
/**
* If we're in an invalid state but WP_DEFAULT_THEME doesn't exist,
* switch to the latest core default theme that's installed.
* If it turns out that this latest core default theme is our current
* theme, then there's nothing we can do about that, so we have to bail,
* rather than going into an infinite loop. (This is why there are
* checks against WP_DEFAULT_THEME above, also.) We also can't do anything
* if it turns out there is no default theme installed. (That's `false`.)
*/
$default = WP_Theme::get_core_default_theme();
if (false === $default || get_stylesheet() == $default->get_stylesheet()) {
return true;
}
switch_theme($default->get_stylesheet());
return false;
}
示例2: populate_network
/**
* Populate network settings.
*
* @since 3.0.0
*
* @global wpdb $wpdb
* @global object $current_site
* @global int $wp_db_version
* @global WP_Rewrite $wp_rewrite
*
* @param int $network_id ID of network to populate.
* @return bool|WP_Error True on success, or WP_Error on warning (with the install otherwise successful,
* so the error code must be checked) or failure.
*/
function populate_network($network_id = 1, $domain = '', $email = '', $site_name = '', $path = '/', $subdomain_install = false)
{
global $wpdb, $current_site, $wp_db_version, $wp_rewrite;
$errors = new WP_Error();
if ('' == $domain) {
$errors->add('empty_domain', __('You must provide a domain name.'));
}
if ('' == $site_name) {
$errors->add('empty_sitename', __('You must provide a name for your network of sites.'));
}
// Check for network collision.
if ($network_id == $wpdb->get_var($wpdb->prepare("SELECT id FROM {$wpdb->site} WHERE id = %d", $network_id))) {
$errors->add('siteid_exists', __('The network already exists.'));
}
if (!is_email($email)) {
$errors->add('invalid_email', __('You must provide a valid email address.'));
}
if ($errors->get_error_code()) {
return $errors;
}
// If a user with the provided email does not exist, default to the current user as the new network admin.
$site_user = get_user_by('email', $email);
if (false === $site_user) {
$site_user = wp_get_current_user();
}
// Set up site tables.
$template = get_option('template');
$stylesheet = get_option('stylesheet');
$allowed_themes = array($stylesheet => true);
if ($template != $stylesheet) {
$allowed_themes[$template] = true;
}
if (WP_DEFAULT_THEME != $stylesheet && WP_DEFAULT_THEME != $template) {
$allowed_themes[WP_DEFAULT_THEME] = true;
}
// If WP_DEFAULT_THEME doesn't exist, also whitelist the latest core default theme.
if (!wp_get_theme(WP_DEFAULT_THEME)->exists()) {
if ($core_default = WP_Theme::get_core_default_theme()) {
$allowed_themes[$core_default->get_stylesheet()] = true;
}
}
if (1 == $network_id) {
$wpdb->insert($wpdb->site, array('domain' => $domain, 'path' => $path));
$network_id = $wpdb->insert_id;
} else {
$wpdb->insert($wpdb->site, array('domain' => $domain, 'path' => $path, 'id' => $network_id));
}
wp_cache_delete('networks_have_paths', 'site-options');
if (!is_multisite()) {
$site_admins = array($site_user->user_login);
$users = get_users(array('fields' => array('ID', 'user_login')));
if ($users) {
foreach ($users as $user) {
if (is_super_admin($user->ID) && !in_array($user->user_login, $site_admins)) {
$site_admins[] = $user->user_login;
}
}
}
} else {
$site_admins = get_site_option('site_admins');
}
/* translators: Do not translate USERNAME, SITE_NAME, BLOG_URL, PASSWORD: those are placeholders. */
$welcome_email = __('Howdy USERNAME,
Your new SITE_NAME site has been successfully set up at:
BLOG_URL
You can log in to the administrator account with the following information:
Username: USERNAME
Password: PASSWORD
Log in here: BLOG_URLwp-login.php
We hope you enjoy your new site. Thanks!
--The Team @ SITE_NAME');
$misc_exts = array('jpg', 'jpeg', 'png', 'gif', 'mov', 'avi', 'mpg', '3gp', '3g2', 'midi', 'mid', 'pdf', 'doc', 'ppt', 'odt', 'pptx', 'docx', 'pps', 'ppsx', 'xls', 'xlsx', 'key');
$audio_exts = wp_get_audio_extensions();
$video_exts = wp_get_video_extensions();
$upload_filetypes = array_unique(array_merge($misc_exts, $audio_exts, $video_exts));
$sitemeta = array('site_name' => $site_name, 'admin_email' => $email, 'admin_user_id' => $site_user->ID, 'registration' => 'none', 'upload_filetypes' => implode(' ', $upload_filetypes), 'blog_upload_space' => 100, 'fileupload_maxk' => 1500, 'site_admins' => $site_admins, 'allowedthemes' => $allowed_themes, 'illegal_names' => array('www', 'web', 'root', 'admin', 'main', 'invite', 'administrator', 'files'), 'wpmu_upgrade_site' => $wp_db_version, 'welcome_email' => $welcome_email, 'first_post' => __('Welcome to %s. This is your first post. Edit or delete it, then start blogging!'), 'siteurl' => get_option('siteurl') . '/', 'add_new_users' => '0', 'upload_space_check_disabled' => is_multisite() ? get_site_option('upload_space_check_disabled') : '1', 'subdomain_install' => intval($subdomain_install), 'global_terms_enabled' => global_terms_enabled() ? '1' : '0', 'ms_files_rewriting' => is_multisite() ? get_site_option('ms_files_rewriting') : '0', 'initial_db_version' => get_option('initial_db_version'), 'active_sitewide_plugins' => array(), 'WPLANG' => get_locale());
if (!$subdomain_install) {
$sitemeta['illegal_names'][] = 'blog';
}
/**
* Filter meta for a network on creation.
//.........这里部分代码省略.........
示例3: test_default_theme_in_default_theme_list
/**
* Make sure we update the default theme list to include the latest default theme.
*
* @ticket 29925
*/
function test_default_theme_in_default_theme_list()
{
$latest_default_theme = WP_Theme::get_core_default_theme();
if (!$latest_default_theme->exists() || 'twenty' !== substr($latest_default_theme->get_stylesheet(), 0, 6)) {
$this->markTestSkipped('No Twenty* series default themes are installed');
}
$this->assertContains($latest_default_theme->get_stylesheet(), $this->default_themes);
}