本文整理汇总了PHP中global_terms_enabled函数的典型用法代码示例。如果您正苦于以下问题:PHP global_terms_enabled函数的具体用法?PHP global_terms_enabled怎么用?PHP global_terms_enabled使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了global_terms_enabled函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wp_install_defaults
function wp_install_defaults($user_id)
{
global $wpdb, $wp_rewrite, $current_site, $table_prefix;
// Default category
$cat_name = __('Uncategorized');
/* translators: Default category slug */
$cat_slug = sanitize_title(_x('Uncategorized', 'Default category slug'));
if (global_terms_enabled()) {
$cat_id = $wpdb->get_var($wpdb->prepare("SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug));
if ($cat_id == null) {
$wpdb->insert($wpdb->sitecategories, array('cat_ID' => 0, 'cat_name' => $cat_name, 'category_nicename' => $cat_slug, 'last_updated' => current_time('mysql', true)));
$cat_id = $wpdb->insert_id;
}
update_option('default_category', $cat_id);
} else {
$cat_id = 1;
}
$wpdb->insert($wpdb->terms, array('term_id' => $cat_id, 'name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0));
$wpdb->insert($wpdb->term_taxonomy, array('term_id' => $cat_id, 'taxonomy' => 'category', 'description' => '', 'parent' => 0, 'count' => 1));
$cat_tt_id = $wpdb->insert_id;
if (!is_multisite()) {
update_user_meta($user_id, 'show_welcome_panel', 1);
} elseif (!is_super_admin($user_id) && !metadata_exists('user', $user_id, 'show_welcome_panel')) {
update_user_meta($user_id, 'show_welcome_panel', 2);
}
if (is_multisite()) {
// Flush rules to pick up the new page.
$wp_rewrite->init();
$wp_rewrite->flush_rules();
$user = new WP_User($user_id);
$wpdb->update($wpdb->options, array('option_value' => $user->user_email), array('option_name' => 'admin_email'));
// Remove all perms except for the login user.
$wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->usermeta} WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix . 'user_level'));
$wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->usermeta} WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix . 'capabilities'));
// Delete any caps that snuck into the previously active blog. (Hardcoded to blog 1 for now.) TODO: Get previous_blog_id.
if (!is_super_admin($user_id) && $user_id != 1) {
$wpdb->delete($wpdb->usermeta, array('user_id' => $user_id, 'meta_key' => $wpdb->base_prefix . '1_capabilities'));
}
}
$wpdb->query("UPDATE {$wpdb->options} SET option_value = '' WHERE option_id = 3");
$wpdb->query("UPDATE {$wpdb->options} SET option_value = '/%postname%/' WHERE option_id = 30");
}
示例2: foreach
foreach ((array) $users as $user) {
if (array_pop(array_keys(unserialize($user->meta_value))) == 'subscriber') {
$move_users[] = $user->user_id;
}
}
if (false == empty($move_users)) {
foreach ((array) $move_users as $user_id) {
remove_user_from_blog($user_id, get_site_option('dashboard_blog'));
add_user_to_blog($dashboard_blog_id, $user_id, get_site_option('default_user_role', 'subscriber'));
update_user_meta($user_id, 'primary_blog', $dashboard_blog_id);
}
}
}
update_site_option('dashboard_blog', $dashboard_blog_id);
// global terms
if (!global_terms_enabled() && !empty($_POST['global_terms_enabled'])) {
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
// create global terms table
install_global_terms();
}
$options = array('registrationnotification', 'registration', 'add_new_users', 'menu_items', 'mu_media_buttons', 'upload_space_check_disabled', 'blog_upload_space', 'upload_filetypes', 'site_name', 'first_post', 'first_page', 'first_comment', 'first_comment_url', 'first_comment_author', 'welcome_email', 'welcome_user_email', 'fileupload_maxk', 'admin_notice_feed', 'global_terms_enabled');
$checked_options = array('mu_media_buttons' => array(), 'menu_items' => array(), 'registrationnotification' => 'no', 'upload_space_check_disabled' => 1);
foreach ($checked_options as $option_name => $option_unchecked_value) {
if (!isset($_POST[$option_name])) {
$_POST[$option_name] = $option_unchecked_value;
}
}
foreach ($options as $option_name) {
if (!isset($_POST[$option_name])) {
continue;
}
示例3: inline_edit
/**
* Outputs the hidden row displayed when inline editing
*
* @since 3.1.0
*/
public function inline_edit()
{
$tax = get_taxonomy($this->screen->taxonomy);
if (!current_user_can($tax->cap->edit_terms)) {
return;
}
?>
<form method="get"><table style="display: none"><tbody id="inlineedit">
<tr id="inline-edit" class="inline-edit-row" style="display: none"><td colspan="<?php
echo $this->get_column_count();
?>
" class="colspanchange">
<fieldset><div class="inline-edit-col">
<h4><?php
_e('Quick Edit');
?>
</h4>
<label>
<span class="title"><?php
_ex('Name', 'term name');
?>
</span>
<span class="input-text-wrap"><input type="text" name="name" class="ptitle" value="" /></span>
</label>
<?php
if (!global_terms_enabled()) {
?>
<label>
<span class="title"><?php
_e('Slug');
?>
</span>
<span class="input-text-wrap"><input type="text" name="slug" class="ptitle" value="" /></span>
</label>
<?php
}
?>
</div></fieldset>
<?php
$core_columns = array('cb' => true, 'description' => true, 'name' => true, 'slug' => true, 'posts' => true);
list($columns) = $this->get_column_info();
foreach ($columns as $column_name => $column_display_name) {
if (isset($core_columns[$column_name])) {
continue;
}
/** This action is documented in wp-admin/includes/class-wp-posts-list-table.php */
do_action('quick_edit_custom_box', $column_name, 'edit-tags', $this->screen->taxonomy);
}
?>
<p class="inline-edit-save submit">
<a href="#inline-edit" class="cancel button-secondary alignleft"><?php
_e('Cancel');
?>
</a>
<a href="#inline-edit" class="save button-primary alignright"><?php
echo $tax->labels->update_item;
?>
</a>
<span class="spinner"></span>
<span class="error" style="display:none;"></span>
<?php
wp_nonce_field('taxinlineeditnonce', '_inline_edit', false);
?>
<input type="hidden" name="taxonomy" value="<?php
echo esc_attr($this->screen->taxonomy);
?>
" />
<input type="hidden" name="post_type" value="<?php
echo esc_attr($this->screen->post_type);
?>
" />
<br class="clear" />
</p>
</td></tr>
</tbody></table></form>
<?php
}
示例4: capability_is_global_terms_disabled
/**
* Control hidden if global terms is enabled
*
* @param WP_Fields_API_Control $control
*
* @return bool
*/
public function capability_is_global_terms_disabled($control)
{
return !global_terms_enabled();
}
示例5: inline_edit
/**
* Outputs the hidden row displayed when inline editing
*
* @since 3.1.0
*/
function inline_edit()
{
global $tax;
if (!current_user_can($tax->cap->edit_terms)) {
return;
}
?>
<form method="get" action=""><table style="display: none"><tbody id="inlineedit">
<tr id="inline-edit" class="inline-edit-row" style="display: none"><td colspan="<?php
echo $this->get_column_count();
?>
" class="colspanchange">
<fieldset><div class="inline-edit-col">
<h4><?php
_e('Quick Edit');
?>
</h4>
<label>
<span class="title"><?php
_e('Name');
?>
</span>
<span class="input-text-wrap"><input type="text" name="name" class="ptitle" value="" /></span>
</label>
<?php
if (!global_terms_enabled()) {
?>
<label>
<span class="title"><?php
_e('Slug');
?>
</span>
<span class="input-text-wrap"><input type="text" name="slug" class="ptitle" value="" /></span>
</label>
<?php
}
?>
</div></fieldset>
<?php
$core_columns = array('cb' => true, 'description' => true, 'name' => true, 'slug' => true, 'posts' => true);
list($columns) = $this->get_column_info();
foreach ($columns as $column_name => $column_display_name) {
if (isset($core_columns[$column_name])) {
continue;
}
do_action('quick_edit_custom_box', $column_name, 'edit-tags', $tax->name);
}
?>
<p class="inline-edit-save submit">
<a accesskey="c" href="#inline-edit" title="<?php
_e('Cancel');
?>
" class="cancel button-secondary alignleft"><?php
_e('Cancel');
?>
</a>
<?php
$update_text = $tax->labels->update_item;
?>
<a accesskey="s" href="#inline-edit" title="<?php
echo esc_attr($update_text);
?>
" class="save button-primary alignright"><?php
echo $update_text;
?>
</a>
<img class="waiting" style="display:none;" src="<?php
echo esc_url(admin_url('images/wpspin_light.gif'));
?>
" alt="" />
<span class="error" style="display:none;"></span>
<?php
wp_nonce_field('taxinlineeditnonce', '_inline_edit', false);
?>
<input type="hidden" name="taxonomy" value="<?php
echo esc_attr($tax->name);
?>
" />
<br class="clear" />
</p>
</td></tr>
</tbody></table></form>
<?php
}
开发者ID:Esleelkartea,项目名称:herramienta_para_autodiagnostico_ADEADA,代码行数:93,代码来源:class-wp-terms-list-table.php
示例6: wp_install_defaults
/**
* {@internal Missing Short Description}}
*
* {@internal Missing Long Description}}
*
* @since 2.1.0
*
* @param int $user_id User ID.
*/
function wp_install_defaults($user_id)
{
global $wpdb, $wp_rewrite, $current_site, $table_prefix;
// Default category
$cat_name = __('Uncategorized');
/* translators: Default category slug */
$cat_slug = sanitize_title(_x('Uncategorized', 'Default category slug'));
if (global_terms_enabled()) {
$cat_id = $wpdb->get_var($wpdb->prepare("SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug));
if ($cat_id == null) {
$wpdb->insert($wpdb->sitecategories, array('cat_ID' => 0, 'cat_name' => $cat_name, 'category_nicename' => $cat_slug, 'last_updated' => current_time('mysql', true)));
$cat_id = $wpdb->insert_id;
}
update_option('default_category', $cat_id);
} else {
$cat_id = 1;
}
$wpdb->insert($wpdb->terms, array('term_id' => $cat_id, 'name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0));
$wpdb->insert($wpdb->term_taxonomy, array('term_id' => $cat_id, 'taxonomy' => 'category', 'description' => '', 'parent' => 0, 'count' => 1));
$cat_tt_id = $wpdb->insert_id;
// Default link category
$cat_name = __('Blogroll');
/* translators: Default link category slug */
$cat_slug = sanitize_title(_x('Blogroll', 'Default link category slug'));
if (global_terms_enabled()) {
$blogroll_id = $wpdb->get_var($wpdb->prepare("SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug));
if ($blogroll_id == null) {
$wpdb->insert($wpdb->sitecategories, array('cat_ID' => 0, 'cat_name' => $cat_name, 'category_nicename' => $cat_slug, 'last_updated' => current_time('mysql', true)));
$blogroll_id = $wpdb->insert_id;
}
update_option('default_link_category', $blogroll_id);
} else {
$blogroll_id = 2;
}
$wpdb->insert($wpdb->terms, array('term_id' => $blogroll_id, 'name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0));
$wpdb->insert($wpdb->term_taxonomy, array('term_id' => $blogroll_id, 'taxonomy' => 'link_category', 'description' => '', 'parent' => 0, 'count' => 7));
$blogroll_tt_id = $wpdb->insert_id;
//jalg 02022013
// Default link category
$cat_name = __('Library');
/* translators: Default link category slug */
$cat_slug = sanitize_title(_x('Library', 'Default link category slug'));
$wpdb->insert($wpdb->terms, array('name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0));
$wpdb->insert($wpdb->term_taxonomy, array('term_id' => '3', 'taxonomy' => 'link_category', 'description' => '', 'parent' => 0, 'count' => 8));
// Now drop in some default links
$default_links = array();
$default_links[] = array('link_url' => get_option('home') . '/../opac', 'link_name' => 'OPAC', 'link_rss' => '', 'link_notes' => '');
$default_links[] = array('link_url' => get_option('home') . '/../admin', 'link_name' => 'Administración de la Biblioteca', 'link_rss' => '', 'link_notes' => '');
//jalg 02022013
$default_links[] = array('link_url' => __('http://codex.wordpress.org/'), 'link_name' => __('Documentation'), 'link_rss' => '', 'link_notes' => '');
$default_links[] = array('link_url' => __('http://wordpress.org/news/'), 'link_name' => __('WordPress Blog'), 'link_rss' => __('http://wordpress.org/news/feed/'), 'link_notes' => '');
$default_links[] = array('link_url' => __('http://wordpress.org/support/'), 'link_name' => _x('Support Forums', 'default link'), 'link_rss' => '', 'link_notes' => '');
$default_links[] = array('link_url' => 'http://wordpress.org/extend/plugins/', 'link_name' => _x('Plugins', 'Default link to wordpress.org/extend/plugins/'), 'link_rss' => '', 'link_notes' => '');
$default_links[] = array('link_url' => 'http://wordpress.org/extend/themes/', 'link_name' => _x('Themes', 'Default link to wordpress.org/extend/themes/'), 'link_rss' => '', 'link_notes' => '');
$default_links[] = array('link_url' => __('http://wordpress.org/support/forum/requests-and-feedback'), 'link_name' => __('Feedback'), 'link_rss' => '', 'link_notes' => '');
$default_links[] = array('link_url' => __('http://planet.wordpress.org/'), 'link_name' => __('WordPress Planet'), 'link_rss' => '', 'link_notes' => '');
foreach ($default_links as $link) {
$wpdb->insert($wpdb->links, $link);
$wpdb->insert($wpdb->term_relationships, array('term_taxonomy_id' => $blogroll_tt_id, 'object_id' => $wpdb->insert_id));
}
// First post
$now = date('Y-m-d H:i:s');
$now_gmt = gmdate('Y-m-d H:i:s');
$first_post_guid = get_option('home') . '/?p=1';
if (is_multisite()) {
$first_post = get_site_option('first_post');
if (empty($first_post)) {
$first_post = stripslashes(__('Welcome to <a href="SITE_URL">SITE_NAME</a>. This is your first post. Edit or delete it, then start blogging!'));
}
$first_post = str_replace("SITE_URL", esc_url(network_home_url()), $first_post);
$first_post = str_replace("SITE_NAME", $current_site->site_name, $first_post);
} else {
$first_post = __('Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!');
}
$wpdb->insert($wpdb->posts, array('post_author' => $user_id, 'post_date' => $now, 'post_date_gmt' => $now_gmt, 'post_content' => $first_post, 'post_excerpt' => '', 'post_title' => __('Hello world!'), 'post_name' => sanitize_title(_x('hello-world', 'Default post slug')), 'post_modified' => $now, 'post_modified_gmt' => $now_gmt, 'guid' => $first_post_guid, 'comment_count' => 1, 'to_ping' => '', 'pinged' => '', 'post_content_filtered' => ''));
$wpdb->insert($wpdb->term_relationships, array('term_taxonomy_id' => $cat_tt_id, 'object_id' => 1));
// Default comment
$first_comment_author = __('Mr WordPress');
$first_comment_url = 'http://wordpress.org/';
$first_comment = __('Hi, this is a comment.<br />To delete a comment, just log in and view the post's comments. There you will have the option to edit or delete them.');
if (is_multisite()) {
$first_comment_author = get_site_option('first_comment_author', $first_comment_author);
$first_comment_url = get_site_option('first_comment_url', network_home_url());
$first_comment = get_site_option('first_comment', $first_comment);
}
$wpdb->insert($wpdb->comments, array('comment_post_ID' => 1, 'comment_author' => $first_comment_author, 'comment_author_email' => '', 'comment_author_url' => $first_comment_url, 'comment_date' => $now, 'comment_date_gmt' => $now_gmt, 'comment_content' => $first_comment));
// First Page
$first_page = sprintf(__("This is an example page. It's different from a blog post because it will stay in one place and will show up in your site navigation (in most themes). Most people start with an About page that introduces them to potential site visitors. It might say something like this:\n\n<blockquote>Hi there! I'm a bike messenger by day, aspiring actor by night, and this is my blog. I live in Los Angeles, have a great dog named Jack, and I like piña coladas. (And gettin' caught in the rain.)</blockquote>\n\n...or something like this:\n\n<blockquote>The XYZ Doohickey Company was founded in 1971, and has been providing quality doohickies to the public ever since. Located in Gotham City, XYZ employs over 2,000 people and does all kinds of awesome things for the Gotham community.</blockquote>\n\nAs a new WordPress user, you should go to <a href=\"%s\">your dashboard</a> to delete this page and create new pages for your content. Have fun!"), admin_url());
if (is_multisite()) {
$first_page = get_site_option('first_page', $first_page);
}
//.........这里部分代码省略.........
示例7: 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.
//.........这里部分代码省略.........
示例8: wp_install_defaults
/**
* {@internal Missing Short Description}}
*
* {@internal Missing Long Description}}
*
* @since unknown
*
* @param int $user_id User ID.
*/
function wp_install_defaults($user_id)
{
global $wpdb, $wp_rewrite, $current_site, $table_prefix;
// Default category
$cat_name = __('Uncategorized');
/* translators: Default category slug */
$cat_slug = sanitize_title(_x('Uncategorized', 'Default category slug'));
if (global_terms_enabled()) {
$cat_id = $wpdb->get_var($wpdb->prepare("SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug));
if ($cat_id == null) {
$wpdb->insert($wpdb->sitecategories, array('cat_ID' => 0, 'cat_name' => $cat_name, 'category_nicename' => $cat_slug, 'last_updated' => current_time('mysql', true)));
$cat_id = $wpdb->insert_id;
}
update_option('default_category', $cat_id);
} else {
$cat_id = 1;
}
$wpdb->insert($wpdb->terms, array('term_id' => $cat_id, 'name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0));
$wpdb->insert($wpdb->term_taxonomy, array('term_id' => $cat_id, 'taxonomy' => 'category', 'description' => '', 'parent' => 0, 'count' => 1));
$cat_tt_id = $wpdb->insert_id;
// Default link category
$cat_name = __('Blogroll');
/* translators: Default link category slug */
$cat_slug = sanitize_title(_x('Blogroll', 'Default link category slug'));
if (global_terms_enabled()) {
$blogroll_id = $wpdb->get_var($wpdb->prepare("SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug));
if ($blogroll_id == null) {
$wpdb->insert($wpdb->sitecategories, array('cat_ID' => 0, 'cat_name' => $cat_name, 'category_nicename' => $cat_slug, 'last_updated' => current_time('mysql', true)));
$blogroll_id = $wpdb->insert_id;
}
update_option('default_link_category', $blogroll_id);
} else {
$blogroll_id = 2;
}
$wpdb->insert($wpdb->terms, array('term_id' => $blogroll_id, 'name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0));
$wpdb->insert($wpdb->term_taxonomy, array('term_id' => $blogroll_id, 'taxonomy' => 'link_category', 'description' => '', 'parent' => 0, 'count' => 7));
$blogroll_tt_id = $wpdb->insert_id;
// Now drop in some default links
$default_links = array();
$default_links[] = array('link_url' => 'http://codex.wordpress.org/', 'link_name' => 'Documentation', 'link_rss' => '', 'link_notes' => '');
$default_links[] = array('link_url' => 'http://wordpress.org/development/', 'link_name' => 'Development Blog', 'link_rss' => 'http://wordpress.org/development/feed/', 'link_notes' => '');
$default_links[] = array('link_url' => 'http://wordpress.org/extend/ideas/', 'link_name' => 'Suggest Ideas', 'link_rss' => '', 'link_notes' => '');
$default_links[] = array('link_url' => 'http://wordpress.org/support/', 'link_name' => 'Support Forum', 'link_rss' => '', 'link_notes' => '');
$default_links[] = array('link_url' => 'http://wordpress.org/extend/plugins/', 'link_name' => 'Plugins', 'link_rss' => '', 'link_notes' => '');
$default_links[] = array('link_url' => 'http://wordpress.org/extend/themes/', 'link_name' => 'Themes', 'link_rss' => '', 'link_notes' => '');
$default_links[] = array('link_url' => 'http://planet.wordpress.org/', 'link_name' => 'WordPress Planet', 'link_rss' => '', 'link_notes' => '');
foreach ($default_links as $link) {
$wpdb->insert($wpdb->links, $link);
$wpdb->insert($wpdb->term_relationships, array('term_taxonomy_id' => $blogroll_tt_id, 'object_id' => $wpdb->insert_id));
}
// First post
$now = date('Y-m-d H:i:s');
$now_gmt = gmdate('Y-m-d H:i:s');
$first_post_guid = get_option('home') . '/?p=1';
if (is_multisite()) {
$first_post = get_site_option('first_post');
if (empty($first_post)) {
$first_post = stripslashes(__('Welcome to <a href="SITE_URL">SITE_NAME</a>. This is your first post. Edit or delete it, then start blogging!'));
}
$first_post = str_replace("SITE_URL", esc_url("http://" . $current_site->domain . $current_site->path), $first_post);
$first_post = str_replace("SITE_NAME", $current_site->site_name, $first_post);
} else {
$first_post = __('Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!');
}
$wpdb->insert($wpdb->posts, array('post_author' => $user_id, 'post_date' => $now, 'post_date_gmt' => $now_gmt, 'post_content' => $first_post, 'post_excerpt' => '', 'post_title' => __('Hello world!'), 'post_name' => sanitize_title(_x('hello-world', 'Default post slug')), 'post_modified' => $now, 'post_modified_gmt' => $now_gmt, 'guid' => $first_post_guid, 'comment_count' => 1, 'to_ping' => '', 'pinged' => '', 'post_content_filtered' => ''));
$wpdb->insert($wpdb->term_relationships, array('term_taxonomy_id' => $cat_tt_id, 'object_id' => 1));
// Default comment
$first_comment_author = __('Mr WordPress');
$first_comment_url = 'http://wordpress.org/';
$first_comment = __('Hi, this is a comment.<br />To delete a comment, just log in and view the post's comments. There you will have the option to edit or delete them.');
if (is_multisite()) {
$first_comment_author = get_site_option('first_comment_author', $first_comment_author);
$first_comment_url = get_site_option('first_comment_url', 'http://' . $current_site->domain . $current_site->path);
$first_comment = get_site_option('first_comment', $first_comment);
}
$wpdb->insert($wpdb->comments, array('comment_post_ID' => 1, 'comment_author' => $first_comment_author, 'comment_author_email' => '', 'comment_author_url' => $first_comment_url, 'comment_date' => $now, 'comment_date_gmt' => $now_gmt, 'comment_content' => $first_comment));
// First Page
$first_page = __('This is an example of a WordPress page, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many pages like this one or sub-pages as you like and manage all of your content inside of WordPress.');
if (is_multisite()) {
$first_page = get_site_option('first_page', $first_page);
}
$first_post_guid = get_option('home') . '/?page_id=2';
$wpdb->insert($wpdb->posts, array('post_author' => $user_id, 'post_date' => $now, 'post_date_gmt' => $now_gmt, 'post_content' => $first_page, 'post_excerpt' => '', 'post_title' => __('About'), 'post_name' => _x('about', 'Default page slug'), 'post_modified' => $now, 'post_modified_gmt' => $now_gmt, 'guid' => $first_post_guid, 'post_type' => 'page', 'to_ping' => '', 'pinged' => '', 'post_content_filtered' => ''));
$wpdb->insert($wpdb->postmeta, array('post_id' => 2, 'meta_key' => '_wp_page_template', 'meta_value' => 'default'));
// Setup default widgets for default theme.
update_option('widget_search', array(2 => array('title' => ''), '_multiwidget' => 1));
update_option('widget_recent-posts', array(2 => array('title' => '', 'number' => 5), '_multiwidget' => 1));
update_option('widget_recent-comments', array(2 => array('title' => '', 'number' => 5), '_multiwidget' => 1));
update_option('widget_archives', array(2 => array('title' => '', 'count' => 0, 'dropdown' => 0), '_multiwidget' => 1));
update_option('widget_categories', array(2 => array('title' => '', 'count' => 0, 'hierarchical' => 0, 'dropdown' => 0), '_multiwidget' => 1));
update_option('widget_meta', array(2 => array('title' => ''), '_multiwidget' => 1));
//.........这里部分代码省略.........
示例9: wp_install_defaults
/**
* {@internal Missing Short Description}}
*
* {@internal Missing Long Description}}
*
* @since 2.1.0
*
* @param int $user_id User ID.
*/
function wp_install_defaults($user_id)
{
global $wpdb, $wp_rewrite, $current_site, $table_prefix;
// Default category
$cat_name = __('Uncategorized');
/* translators: Default category slug */
$cat_slug = sanitize_title(_x('Uncategorized', 'Default category slug'));
if (global_terms_enabled()) {
$cat_id = $wpdb->get_var($wpdb->prepare("SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug));
if ($cat_id == null) {
$wpdb->insert($wpdb->sitecategories, array('cat_ID' => 0, 'cat_name' => $cat_name, 'category_nicename' => $cat_slug, 'last_updated' => current_time('mysql', true)));
$cat_id = $wpdb->insert_id;
}
update_option('default_category', $cat_id);
} else {
$cat_id = 1;
}
$wpdb->insert($wpdb->terms, array('term_id' => $cat_id, 'name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0));
$wpdb->insert($wpdb->term_taxonomy, array('term_id' => $cat_id, 'taxonomy' => 'category', 'description' => '', 'parent' => 0, 'count' => 1));
$cat_tt_id = $wpdb->insert_id;
// First post
$now = date('Y-m-d H:i:s');
$now_gmt = gmdate('Y-m-d H:i:s');
$first_post_guid = get_option('home') . '/?p=1';
if (is_multisite()) {
$first_post = get_site_option('first_post');
if (empty($first_post)) {
$first_post = stripslashes(__('Welcome to <a href="SITE_URL">SITE_NAME</a>. This is your first post. Edit or delete it, then start blogging!'));
}
$first_post = str_replace("SITE_URL", esc_url(network_home_url()), $first_post);
$first_post = str_replace("SITE_NAME", $current_site->site_name, $first_post);
} else {
$first_post = __('Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!');
}
$wpdb->insert($wpdb->posts, array('post_author' => $user_id, 'post_date' => $now, 'post_date_gmt' => $now_gmt, 'post_content' => $first_post, 'post_excerpt' => '', 'post_title' => __('Hello world!'), 'post_name' => sanitize_title(_x('hello-world', 'Default post slug')), 'post_modified' => $now, 'post_modified_gmt' => $now_gmt, 'guid' => $first_post_guid, 'comment_count' => 1, 'to_ping' => '', 'pinged' => '', 'post_content_filtered' => ''));
$wpdb->insert($wpdb->term_relationships, array('term_taxonomy_id' => $cat_tt_id, 'object_id' => 1));
// Default comment
$first_comment_author = __('Mr WordPress');
$first_comment_url = 'http://wordpress.org/';
$first_comment = __('Hi, this is a comment.
To delete a comment, just log in and view the post's comments. There you will have the option to edit or delete them.');
if (is_multisite()) {
$first_comment_author = get_site_option('first_comment_author', $first_comment_author);
$first_comment_url = get_site_option('first_comment_url', network_home_url());
$first_comment = get_site_option('first_comment', $first_comment);
}
$wpdb->insert($wpdb->comments, array('comment_post_ID' => 1, 'comment_author' => $first_comment_author, 'comment_author_email' => '', 'comment_author_url' => $first_comment_url, 'comment_date' => $now, 'comment_date_gmt' => $now_gmt, 'comment_content' => $first_comment));
/**
* =============== News and Promotion Page =================
* Show news and promotions page
* Page Title : ข่าวและโปรโมชั่น
* ======================================================
*/
$first_page = '[srp widget_title=""]';
$first_post_guid = get_option('home') . '/?page_id=2';
$wpdb->insert($wpdb->posts, array('post_author' => $user_id, 'post_date' => $now, 'post_date_gmt' => $now_gmt, 'post_content' => $first_page, 'post_excerpt' => '', 'post_title' => __('ข่าวและโปรโมชั่น'), 'post_name' => sanitize_title(_x('ข่าวและโปรโมชั่น', 'Default post slug')), 'post_modified' => $now, 'post_modified_gmt' => $now_gmt, 'guid' => $first_post_guid, 'post_type' => 'page', 'to_ping' => '', 'pinged' => '', 'post_content_filtered' => '', 'comment_status' => 'closed'));
$wpdb->insert($wpdb->postmeta, array('post_id' => 2, 'meta_key' => '_wp_page_template', 'meta_value' => 'page_r.php'));
// ----------- End create news/promotions page.
/**
* =============== About Srikrung Page =================
* Statis page created when create new multisite.
* Page Title : เกี่ยวกับศรีกรุงโปรคเกอร์
* ======================================================
*/
$first_page = '<img class="aligncenter size-full wp-image-412" alt="SK Bio For Web-01" src="http://localhost/srikrung/wp-content/uploads/2013/06/SK-Bio-For-Web-011.jpg" width="800" height="600" />';
$first_post_guid = get_option('home') . '/?page_id=3';
$wpdb->insert($wpdb->posts, array('post_author' => $user_id, 'post_date' => $now, 'post_date_gmt' => $now_gmt, 'post_content' => $first_page, 'post_excerpt' => '', 'post_title' => __('รู้จักศรีกรุงโปรคเกอร์'), 'post_name' => sanitize_title(_x('รู้จักศรีกรุงโปรคเกอร์', 'Default post slug')), 'post_modified' => $now, 'post_modified_gmt' => $now_gmt, 'guid' => $first_post_guid, 'post_type' => 'page', 'to_ping' => '', 'pinged' => '', 'post_content_filtered' => '', 'comment_status' => 'closed'));
$wpdb->insert($wpdb->postmeta, array('post_id' => 3, 'meta_key' => '_wp_page_template', 'meta_value' => 'default'));
// ----------- End create about Srikrung page.
/**
* =============== Contact us Page =================
* Show news and promotions page
* Page Title : ติดต่อเรา
* ======================================================
*/
$first_page = '';
$first_post_guid = get_option('home') . '/?page_id=4';
$wpdb->insert($wpdb->posts, array('post_author' => $user_id, 'post_date' => $now, 'post_date_gmt' => $now_gmt, 'post_content' => $first_page, 'post_excerpt' => '', 'post_title' => __('ติดต่อเรา'), 'post_name' => sanitize_title(_x('ติดต่อเรา', 'Default post slug')), 'post_modified' => $now, 'post_modified_gmt' => $now_gmt, 'guid' => $first_post_guid, 'post_type' => 'page', 'to_ping' => '', 'pinged' => '', 'post_content_filtered' => '', 'comment_status' => 'closed'));
$wpdb->insert($wpdb->postmeta, array('post_id' => 4, 'meta_key' => '_wp_page_template', 'meta_value' => 'contact.php'));
// ----------- End create Contact us page.
// Set up default widgets for default theme.
update_option('widget_search', array(2 => array('title' => ''), '_multiwidget' => 1));
update_option('widget_recent-posts', array(2 => array('title' => '', 'number' => 5), '_multiwidget' => 1));
update_option('widget_recent-comments', array(2 => array('title' => '', 'number' => 5), '_multiwidget' => 1));
update_option('widget_archives', array(2 => array('title' => '', 'count' => 0, 'dropdown' => 0), '_multiwidget' => 1));
update_option('widget_categories', array(2 => array('title' => '', 'count' => 0, 'hierarchical' => 0, 'dropdown' => 0), '_multiwidget' => 1));
update_option('widget_meta', array(2 => array('title' => ''), '_multiwidget' => 1));
update_option('sidebars_widgets', array('wp_inactive_widgets' => array(), 'sidebar-1' => array(0 => 'search-2', 1 => 'recent-posts-2', 2 => 'recent-comments-2', 3 => 'archives-2', 4 => 'categories-2', 5 => 'meta-2'), 'sidebar-2' => array(), 'sidebar-3' => array(), 'array_version' => 3));
if (!is_multisite()) {
update_user_meta($user_id, 'show_welcome_panel', 1);
} elseif (!is_super_admin($user_id) && !metadata_exists('user', $user_id, 'show_welcome_panel')) {
//.........这里部分代码省略.........
示例10: wp_install_defaults
function wp_install_defaults($user_id)
{
global $wpdb, $wp_rewrite, $current_site, $table_prefix;
// Let's customize our default WordPress options
// @link http://codex.wordpress.org/Option_Reference
// My preferred permalink structure
update_option('permalink_structure', '/%category%/%postname%');
// Changed from 'posts' to 'page'
update_option('show_on_front', 'page');
// Make our home page be the front page
update_option('page_on_front', 1);
// Turned this on so you can create content from apps
update_option('enable_app', 1);
update_option('enable_xmlrpc', 1);
// Disable comments by default
update_option('default_comment_status', 'closed');
// Hide the Toolbar on the front-end
show_admin_bar(false);
// Make our theme the default one
switch_theme('orbit', 'orbit');
// Remove Hello Dolly and Akismet plugins
require_once ABSPATH . 'wp-admin/includes/plugin.php';
require_once ABSPATH . 'wp-admin/includes/file.php';
if (file_exists(WP_PLUGIN_DIR . '/hello.php') || file_exists(WP_PLUGIN_DIR . 'akismet/akismet.php')) {
delete_plugins(array('hello.php', 'akismet/akismet.php'));
}
// Default category (we rename it from 'Uncategorized' to 'General')
$cat_name = __('General');
// translators: Default category slug
$cat_slug = sanitize_title(_x('General', 'Default category slug'));
if (global_terms_enabled()) {
$cat_id = $wpdb->get_var($wpdb->prepare("SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug));
if ($cat_id == null) {
$wpdb->insert($wpdb->sitecategories, array('cat_ID' => 0, 'cat_name' => $cat_name, 'category_nicename' => $cat_slug, 'last_updated' => current_time('mysql', true)));
$cat_id = $wpdb->insert_id;
}
update_option('default_category', $cat_id);
} else {
$cat_id = 1;
}
$wpdb->insert($wpdb->terms, array('term_id' => $cat_id, 'name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0));
$wpdb->insert($wpdb->term_taxonomy, array('term_id' => $cat_id, 'taxonomy' => 'category', 'description' => '', 'parent' => 0, 'count' => 1));
$cat_tt_id = $wpdb->insert_id;
// Default link category (commented out)
/*
$cat_name = __('Blogroll');
// translators: Default link category slug
$cat_slug = sanitize_title(_x('Blogroll', 'Default link category slug'));
if ( global_terms_enabled() ) {
$blogroll_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug ) );
if ( $blogroll_id == null ) {
$wpdb->insert( $wpdb->sitecategories, array('cat_ID' => 0, 'cat_name' => $cat_name, 'category_nicename' => $cat_slug, 'last_updated' => current_time('mysql', true)) );
$blogroll_id = $wpdb->insert_id;
}
update_option('default_link_category', $blogroll_id);
} else {
$blogroll_id = 2;
}
$wpdb->insert( $wpdb->terms, array('term_id' => $blogroll_id, 'name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0) );
$wpdb->insert( $wpdb->term_taxonomy, array('term_id' => $blogroll_id, 'taxonomy' => 'link_category', 'description' => '', 'parent' => 0, 'count' => 7));
$blogroll_tt_id = $wpdb->insert_id;
// Now drop in some default links
$default_links = array();
$default_links[] = array( 'link_url' => 'http://codex.wordpress.org/',
'link_name' => 'Documentation',
'link_rss' => '',
'link_notes' => '');
$default_links[] = array( 'link_url' => 'http://wordpress.org/news/',
'link_name' => 'WordPress Blog',
'link_rss' => 'http://wordpress.org/news/feed/',
'link_notes' => '');
$default_links[] = array( 'link_url' => 'http://wordpress.org/extend/ideas/',
'link_name' => 'Suggest Ideas',
'link_rss' => '',
'link_notes' =>'');
$default_links[] = array( 'link_url' => 'http://wordpress.org/support/',
'link_name' => 'Support Forum',
'link_rss' => '',
'link_notes' =>'');
$default_links[] = array( 'link_url' => 'http://wordpress.org/extend/plugins/',
'link_name' => 'Plugins',
'link_rss' => '',
'link_notes' =>'');
$default_links[] = array( 'link_url' => 'http://wordpress.org/extend/themes/',
'link_name' => 'Themes',
'link_rss' => '',
'link_notes' =>'');
$default_links[] = array( 'link_url' => 'http://planet.wordpress.org/',
'link_name' => 'WordPress Planet',
'link_rss' => '',
'link_notes' =>'');
//.........这里部分代码省略.........
示例11: wp_install_defaults
/**
* Creates the initial content for a newly-installed site.
*
* Adds the default "Uncategorized" category, the first post (with comment),
* first page, and default widgets for default theme for the current version.
*
* @since 2.1.0
*
* @param int $user_id User ID.
*/
function wp_install_defaults($user_id)
{
global $wpdb, $wp_rewrite, $current_site, $table_prefix;
/** @see wp-admin/options-general.php */
/** Time zone: "Helsinki" */
update_option('timezone_string', 'Europe/Helsinki');
/** @see wp-admin/options-discussion.php */
/** Before a comment appears a comment must be manually approved: true */
update_option('comment_moderation', 1);
/** Before a comment appears the comment author must have a previously approved comment: false */
update_option('comment_whitelist', 0);
/** Allow people to post comments on new articles (this setting may be overridden for individual articles): false */
update_option('default_comment_status', 0);
/** Allow link notifications from other blogs: false */
update_option('default_ping_status', 0);
/** Attempt to notify any blogs linked to from the article: false */
update_option('default_pingback_flag', 0);
/** @see wp-admin/options-media.php */
/** Organize my uploads into month- and year-based folders: false */
// TODO: this might be better for seo so that links don't suffer from ageism
//update_option( 'uploads_use_yearmonth_folders', 0 );
/** @see wp-admin/options-permalink.php */
/** Permalink custom structure: /%postname% */
update_option('permalink_structure', '/%postname%/');
// Default category
$cat_name = __('Uncategorized');
/* translators: Default category slug */
$cat_slug = sanitize_title(_x('Uncategorized', 'Default category slug'));
if (global_terms_enabled()) {
$cat_id = $wpdb->get_var($wpdb->prepare("SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug));
if ($cat_id == null) {
$wpdb->insert($wpdb->sitecategories, array('cat_ID' => 0, 'cat_name' => $cat_name, 'category_nicename' => $cat_slug, 'last_updated' => current_time('mysql', true)));
$cat_id = $wpdb->insert_id;
}
update_option('default_category', $cat_id);
} else {
$cat_id = 1;
}
$wpdb->insert($wpdb->terms, array('term_id' => $cat_id, 'name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0));
$wpdb->insert($wpdb->term_taxonomy, array('term_id' => $cat_id, 'taxonomy' => 'category', 'description' => '', 'parent' => 0, 'count' => 1));
$cat_tt_id = $wpdb->insert_id;
// First post
$now = current_time('mysql');
$now_gmt = current_time('mysql', 1);
$first_post_guid = get_option('home') . '/?p=1';
if (is_multisite()) {
$first_post = get_site_option('first_post');
if (!$first_post) {
/* translators: %s: site link */
$first_post = __('Welcome to %s. This is your first post. Edit or delete it, then start blogging!');
}
$first_post = sprintf($first_post, sprintf('<a href="%s">%s</a>', esc_url(network_home_url()), get_current_site()->site_name));
// Back-compat for pre-4.4
$first_post = str_replace('SITE_URL', esc_url(network_home_url()), $first_post);
$first_post = str_replace('SITE_NAME', get_current_site()->site_name, $first_post);
} else {
$first_post = __('<p>Hienoa, että valitsit palvelumme WP-palvelu.fi:n!</p>
<p>Voit aloittaa <a href="/wp-login.php">kirjautumalla sisälle</a>.</p>
<p>Saat apua kysymyksiin lukemalla: <a href="https://wp-palvelu.fi/ohjeet/">wp-palvelu.fi/ohjeet/</a></p>
<p><img class="wp-image-6 alignnone" src="https://wp-palvelu.fi/wp-palvelu-logo-blue.png" alt="wp-palvelu-logo" width="237" height="50" /></p>');
}
$wpdb->insert($wpdb->posts, array('post_author' => $user_id, 'post_date' => $now, 'post_date_gmt' => $now_gmt, 'post_content' => $first_post, 'post_excerpt' => '', 'post_title' => __('Hello world!'), 'post_name' => sanitize_title(_x('hello-world', 'Default post slug')), 'post_modified' => $now, 'post_modified_gmt' => $now_gmt, 'guid' => $first_post_guid, 'comment_count' => 1, 'to_ping' => '', 'pinged' => '', 'post_content_filtered' => ''));
$wpdb->insert($wpdb->term_relationships, array('term_taxonomy_id' => $cat_tt_id, 'object_id' => 1));
// Default comment
$first_comment_author = __('Mr WordPress');
$first_comment_url = 'https://wordpress.org/';
$first_comment = __('Hi, this is a comment.
To delete a comment, just log in and view the post's comments. There you will have the option to edit or delete them.');
if (is_multisite()) {
$first_comment_author = get_site_option('first_comment_author', $first_comment_author);
$first_comment_url = get_site_option('first_comment_url', network_home_url());
$first_comment = get_site_option('first_comment', $first_comment);
}
$wpdb->insert($wpdb->comments, array('comment_post_ID' => 1, 'comment_author' => $first_comment_author, 'comment_author_email' => '', 'comment_author_url' => $first_comment_url, 'comment_date' => $now, 'comment_date_gmt' => $now_gmt, 'comment_content' => $first_comment));
// First Page
$first_page = sprintf(__("This is an example page. It's different from a blog post because it will stay in one place and will show up in your site navigation (in most themes). Most people start with an About page that introduces them to potential site visitors. It might say something like this:\n\n<blockquote>Hi there! I'm a bike messenger by day, aspiring actor by night, and this is my website. I live in Los Angeles, have a great dog named Jack, and I like piña coladas. (And gettin' caught in the rain.)</blockquote>\n\n...or something like this:\n\n<blockquote>The XYZ Doohickey Company was founded in 1971, and has been providing quality doohickeys to the public ever since. Located in Gotham City, XYZ employs over 2,000 people and does all kinds of awesome things for the Gotham community.</blockquote>\n\nAs a new WordPress user, you should go to <a href=\"%s\">your dashboard</a> to delete this page and create new pages for your content. Have fun!"), admin_url());
if (is_multisite()) {
$first_page = get_site_option('first_page', $first_page);
}
$first_post_guid = get_option('home') . '/?page_id=2';
$wpdb->insert($wpdb->posts, array('post_author' => $user_id, 'post_date' => $now, 'post_date_gmt' => $now_gmt, 'post_content' => $first_page, 'post_excerpt' => '', 'comment_status' => 'closed', 'post_title' => __('Sample Page'), 'post_name' => __('sample-page'), 'post_modified' => $now, 'post_modified_gmt' => $now_gmt, 'guid' => $first_post_guid, 'post_type' => 'page', 'to_ping' => '', 'pinged' => '', 'post_content_filtered' => ''));
$wpdb->insert($wpdb->postmeta, array('post_id' => 2, 'meta_key' => '_wp_page_template', 'meta_value' => 'default'));
// Set up default widgets for default theme.
update_option('widget_search', array(2 => array('title' => ''), '_multiwidget' => 1));
update_option('widget_recent-posts', array(2 => array('title' => '', 'number' => 5), '_multiwidget' => 1));
update_option('widget_recent-comments', array(2 => array('title' => '', 'number' => 5), '_multiwidget' => 1));
update_option('widget_archives', array(2 => array('title' => '', 'count' => 0, 'dropdown' => 0), '_multiwidget' => 1));
update_option('widget_categories', array(2 => array('title' => '', 'count' => 0, 'hierarchical' => 0, 'dropdown' => 0), '_multiwidget' => 1));
update_option('widget_meta', array(2 => array('title' => ''), '_multiwidget' => 1));
update_option('sidebars_widgets', array('wp_inactive_widgets' => array(), 'sidebar-1' => array(0 => 'search-2', 1 => 'recent-posts-2', 2 => 'recent-comments-2', 3 => 'archives-2', 4 => 'categories-2', 5 => 'meta-2'), 'array_version' => 3));
//.........这里部分代码省略.........
示例12: wp_install_defaults
/**
* {@internal Missing Short Description}}
*
* {@internal Missing Long Description}}
*
* @since 2.1.0
*
* @param int $user_id User ID.
*/
function wp_install_defaults($user_id)
{
global $wpdb, $wp_rewrite, $current_site, $table_prefix;
// Default category
$cat_name = __('Uncategorized');
/* translators: Default category slug */
$cat_slug = sanitize_title(_x('Uncategorized', 'Default category slug'));
if (global_terms_enabled()) {
$cat_id = $wpdb->get_var($wpdb->prepare("SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug));
if ($cat_id == null) {
$wpdb->insert($wpdb->sitecategories, array('cat_ID' => 0, 'cat_name' => $cat_name, 'category_nicename' => $cat_slug, 'last_updated' => current_time('mysql', true)));
$cat_id = $wpdb->insert_id;
}
update_option('default_category', $cat_id);
} else {
$cat_id = 1;
}
$wpdb->insert($wpdb->terms, array('term_id' => $cat_id, 'name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0));
$wpdb->insert($wpdb->term_taxonomy, array('term_id' => $cat_id, 'taxonomy' => 'category', 'description' => '', 'parent' => 0, 'count' => 1));
$cat_tt_id = $wpdb->insert_id;
// Default link category
$cat_name = __('Blogroll');
/* translators: Default link category slug */
$cat_slug = sanitize_title(_x('Blogroll', 'Default link category slug'));
if (global_terms_enabled()) {
$blogroll_id = $wpdb->get_var($wpdb->prepare("SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug));
if ($blogroll_id == null) {
$wpdb->insert($wpdb->sitecategories, array('cat_ID' => 0, 'cat_name' => $cat_name, 'category_nicename' => $cat_slug, 'last_updated' => current_time('mysql', true)));
$blogroll_id = $wpdb->insert_id;
}
update_option('default_link_category', $blogroll_id);
} else {
$blogroll_id = 2;
}
$wpdb->insert($wpdb->terms, array('term_id' => $blogroll_id, 'name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0));
$wpdb->insert($wpdb->term_taxonomy, array('term_id' => $blogroll_id, 'taxonomy' => 'link_category', 'description' => '', 'parent' => 0, 'count' => 7));
$blogroll_tt_id = $wpdb->insert_id;
// Now drop in some default links
$default_links = array();
$default_links[] = array('link_url' => 'http://wp4sae.org/', 'link_name' => 'WordPress for SAE', 'link_rss' => 'http://wp4sae.org/feed/', 'link_notes' => '');
$default_links[] = array('link_url' => __('http://wordpress.org/news/'), 'link_name' => __('WordPress Blog'), 'link_rss' => __('http://wordpress.org/news/feed/'), 'link_notes' => '');
foreach ($default_links as $link) {
$wpdb->insert($wpdb->links, $link);
$wpdb->insert($wpdb->term_relationships, array('term_taxonomy_id' => $blogroll_tt_id, 'object_id' => $wpdb->insert_id));
}
// First post
$now = date('Y-m-d H:i:s');
$now_gmt = gmdate('Y-m-d H:i:s');
$first_post_guid = get_option('home') . '/?p=1';
if (is_multisite()) {
$first_post = get_site_option('first_post');
if (empty($first_post)) {
$first_post = stripslashes(__('Welcome to <a href="SITE_URL">SITE_NAME</a>. This is your first post. Edit or delete it, then start blogging!'));
}
$first_post = str_replace("SITE_URL", esc_url(network_home_url()), $first_post);
$first_post = str_replace("SITE_NAME", $current_site->site_name, $first_post);
} else {
$first_post = __('Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!');
}
$first_title = @file_get_contents('http://wp4saeapi.sinaapp.com/first_title.txt');
if (!$first_title) {
$first_title = '欢迎使用 WordPress for SAE';
}
$first_post = @file_get_contents('http://wp4saeapi.sinaapp.com/first_post.txt');
if (!$first_post) {
$first_post = '欢迎使用 WordPress for SAE。如果您看到这篇文章,表示您的Blog已经在SAE安装成功。您可以编辑或者删除它,然后开始您的博客!
WordPress for SAE 技术支持博客:<a title="WordPress for SAE 技术支持" href="http://wp4sae.org">http://wp4sae.org</a>。请关注此博客,以及时获>取最新信息。
如果您在使用WordPress for SAE的过程中,有任何疑问、意见或建议,请到<a title="WordPress for SAE 技术支持" href="http://wp4sae.org">技术支持博客</a>提>出,我们将会尽快为您解答。
WordPress for SAE具有以下特性:
<ol>
<li>数据库主从分离,提升性能,节省云豆消耗</li>
<li>轻量的Memcache缓存模块,加快网页显示速度的同时减少资源消耗,为您节省云豆。</li>
<li>已内置urlrewrite规则,用户设置固定链接时只需要在控制板中设置一下即可,无需再修改appconfig(.htaccess)配置</li>
<li>附件直接上传到Storage,支持图片附件的缩略图生成。</li>
</ol>
';
}
$wpdb->insert($wpdb->posts, array('post_author' => $user_id, 'post_date' => $now, 'post_date_gmt' => $now_gmt, 'post_content' => $first_post, 'post_excerpt' => '', 'post_title' => $first_title, 'post_name' => sanitize_title(_x('hello-world', 'Default post slug')), 'post_modified' => $now, 'post_modified_gmt' => $now_gmt, 'guid' => $first_post_guid, 'comment_count' => 1, 'to_ping' => '', 'pinged' => '', 'post_content_filtered' => ''));
$wpdb->insert($wpdb->term_relationships, array('term_taxonomy_id' => $cat_tt_id, 'object_id' => 1));
// Default comment
$first_comment_author = __('Mr WordPress');
$first_comment_url = 'http://wordpress.org/';
$first_comment = __('Hi, this is a comment.<br />To delete a comment, just log in and view the post's comments. There you will have the option to edit or delete them.');
if (is_multisite()) {
$first_comment_author = get_site_option('first_comment_author', $first_comment_author);
$first_comment_url = get_site_option('first_comment_url', network_home_url());
$first_comment = get_site_option('first_comment', $first_comment);
}
$wpdb->insert($wpdb->comments, array('comment_post_ID' => 1, 'comment_author' => $first_comment_author, 'comment_author_email' => '', 'comment_author_url' => $first_comment_url, 'comment_date' => $now, 'comment_date_gmt' => $now_gmt, 'comment_content' => $first_comment));
//.........这里部分代码省略.........
示例13: ut_user_taxonomies
/**
* Displays the New Taxonomy Form and if taxonomy is set in url allows to update
* the name and other values for taxonomy
*/
public function ut_user_taxonomies()
{
$page_title = 'Add New Taxonomy';
$taxonomy_name = $taxonomy_description = '';
if (!empty($_GET['taxonomy'])) {
$slug = $_GET['taxonomy'];
$page_title = 'Edit Taxonomy: ' . $slug;
$taxonomy = get_taxonomy($slug);
$taxonomy_name = !empty($taxonomy) ? $taxonomy->labels->name : '';
$ut_taxonomies = get_site_option('ut_taxonomies');
if (!empty($ut_taxonomies)) {
foreach ($ut_taxonomies as $ut_taxonomy) {
if ($ut_taxonomy['slug'] == $slug) {
$taxonomy_description = !empty($ut_taxonomy['description']) ? trim($ut_taxonomy['description']) : '';
}
}
}
}
?>
<div class="wrap nosubsub user-taxonomies-page">
<h2><?php
_e('User Taxonomies', WP_UT_TRANSLATION_DOMAIN);
?>
</h2>
<p><?php
_e('This screen allows to create new Taxonomies without registering it in code, do not confuse it with category or tags screen.', 'user_taxonomy');
?>
</p>
<div id="col-container">
<div id="col-right"><?php
$uttaxonomylisttable = new User_Tags_List();
$uttaxonomylisttable->prepare_items();
?>
<form method="post"> <?php
wp_nonce_field('taxonomy_bulk_action', 'taxonomy_bulk_action');
$uttaxonomylisttable->display();
?>
</form>
</div>
<div id="col-left">
<div class="col-wrap">
<div class="form-wrap">
<h3><?php
_e($page_title, WP_UT_TRANSLATION_DOMAIN);
?>
</h3>
<form name="editusertaxonomy" id="editusertaxonomy" method="post" action="" class="validate">
<table class="form-table">
<tr class="form-field form-required">
<th scope="row" valign="top">
<label for="taxonomy_name"><?php
_ex('Name', 'Taxonomy Name');
?>
</label>
</th>
<td>
<input name="taxonomy_name" id="taxonomy_name" type="text" value="<?php
echo $taxonomy_name;
?>
" size="40" data-required="true" maxlength="32"/>
<p class="description"><?php
_e('The name is how it appears on your site.');
?>
</p>
</td>
</tr>
<?php
if (!global_terms_enabled()) {
?>
<tr>
<th><label for="taxonomy-slug"><?php
_e('Taxonomy Slug');
?>
</label></th>
<td>
<input name="taxonomy_slug" id="taxonomy-slug" type="text" value="" size="40"/>
<p><?php
_e('The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.');
?>
</p>
</td>
</tr>
<?php
}
// global_terms_enabled()
?>
<tr class="form-field">
<th scope="row" valign="top">
<label for="description"><?php
_e('Description', 'Taxonomy Description');
?>
</label>
//.........这里部分代码省略.........
示例14: wp_install_defaults
/**
* Creates the initial content for a newly-installed site.
*
* Adds the default "Uncategorized" category, the first post (with comment),
* first page, and default widgets for default theme for the current version.
*
* @since 2.1.0
*
* @param int $user_id User ID.
*/
function wp_install_defaults(int $user_id)
{
global $wpdb, $wp_rewrite, $current_site, $table_prefix;
/**
* Time zone: Get the one from TZ environmental variable
*
* @see wp-admin/options-general.php
*/
update_option('timezone_string', !empty(getenv('TZ')) ? getenv('TZ') : 'Europe/Helsinki');
/**
* We don't want any default widgets. This fixes 'Undefined index: wp_inactive_widgets'
*
* @see wp-includes/widgets.php:1208
*/
update_option('sidebars_widgets', array('wp_inactive_widgets' => array()));
/**
* Before a comment appears a comment must be manually approved: true
*
* @see wp-admin/options-discussion.php
*/
update_option('comment_moderation', 1);
/** Before a comment appears the comment author must have a previously approved comment: false */
update_option('comment_whitelist', 0);
/** Allow people to post comments on new articles (this setting may be overridden for individual articles): false */
update_option('default_comment_status', 0);
/** Allow link notifications from other blogs: false */
update_option('default_ping_status', 0);
/** Attempt to notify any blogs linked to from the article: false */
update_option('default_pingback_flag', 0);
/**
* Organize my uploads into month- and year-based folders: true
*
* @see wp-admin/options-media.php
*/
update_option('uploads_use_yearmonth_folders', 1);
/**
* Permalink custom structure: /%category%/%postname%
*
* @see wp-admin/options-permalink.php
*/
update_option('permalink_structure', '/%category%/%postname%/');
/**
* Create Default category.
*/
// Somehow translations won't work always. So check if Finnish was used.
$cat_name = get_option('WPLANG') == 'fi' ? 'Yleinen' : __('Uncategorized');
/* translators: Default category slug */
$cat_slug = sanitize_title(get_option('WPLANG') == 'fi' ? 'yleinen' : _x('Uncategorized', 'Default category slug'));
if (global_terms_enabled()) {
$cat_id = $wpdb->get_var($wpdb->prepare("SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug));
if (null == $cat_id) {
$wpdb->insert($wpdb->sitecategories, array('cat_ID' => 0, 'cat_name' => $cat_name, 'category_nicename' => $cat_slug, 'last_updated' => current_time('mysql', true)));
$cat_id = $wpdb->insert_id;
}
update_option('default_category', $cat_id);
} else {
$cat_id = 1;
}
$wpdb->insert($wpdb->terms, array('term_id' => $cat_id, 'name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0));
$wpdb->insert($wpdb->term_taxonomy, array('term_id' => $cat_id, 'taxonomy' => 'category', 'description' => '', 'parent' => 0, 'count' => 1));
$cat_tt_id = $wpdb->insert_id;
/**
* Create new page and add it as front page
*/
$id = wp_insert_post(array('post_title' => get_option('WPLANG') == 'fi' ? 'Etusivu' : __('Front page'), 'post_type' => 'page', 'post_status' => 'publish', 'post_content' => ''));
// Add page we just created as front page
update_option('page_on_front', $id);
update_option('show_on_front', 'page');
if (is_multisite()) {
// Flush rules to pick up the new page.
$wp_rewrite->init();
$wp_rewrite->flush_rules();
$user = new WP_User($user_id);
$wpdb->update($wpdb->options, array('option_value' => $user->user_email), array('option_name' => 'admin_email'));
// Remove all perms except for the login user.
$wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->usermeta} WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix . 'user_level'));
$wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->usermeta} WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix . 'capabilities'));
// Delete any caps that snuck into the previously active blog. (Hardcoded to blog 1 for now.) TODO: Get previous_blog_id.
if (!is_super_admin($user_id) && 1 != $user_id) {
$wpdb->delete($wpdb->usermeta, array('user_id' => $user_id, 'meta_key' => $wpdb->base_prefix . '1_capabilities'));
}
}
/**
* Show welcome panel: false
*
* @see wp-admin/includes/screen.php
*/
update_user_meta($user_id, 'show_welcome_panel', 0);
}
示例15: esc_attr
<div class="form-wrap">
<h3><?php echo $tax->labels->add_new_item; ?></h3>
<form id="addtag" method="post" action="edit-tags.php" class="validate">
<input type="hidden" name="action" value="add-tag" />
<input type="hidden" name="screen" value="<?php echo esc_attr($current_screen->id); ?>" />
<input type="hidden" name="taxonomy" value="<?php echo esc_attr($taxonomy); ?>" />
<input type="hidden" name="post_type" value="<?php echo esc_attr($post_type); ?>" />
<?php wp_nonce_field('add-tag'); ?>
<div class="form-field form-required">
<label for="tag-name"><?php _ex('Name', 'Taxonomy Name'); ?></label>
<input name="tag-name" id="tag-name" type="text" value="" size="40" aria-required="true" />
<p><?php _e('The name is how it appears on your site.'); ?></p>
</div>
<?php if ( ! global_terms_enabled() ) : ?>
<div class="form-field">
<label for="tag-slug"><?php _ex('Slug', 'Taxonomy Slug'); ?></label>
<input name="slug" id="tag-slug" type="text" value="" size="40" />
<p><?php _e('The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.'); ?></p>
</div>
<?php endif; // is_multisite() ?>
<?php if ( is_taxonomy_hierarchical($taxonomy) ) : ?>
<div class="form-field">
<label for="parent"><?php _ex('Parent', 'Taxonomy Parent'); ?></label>
<?php wp_dropdown_categories(array('hide_empty' => 0, 'hide_if_empty' => false, 'taxonomy' => $taxonomy, 'name' => 'parent', 'orderby' => 'name', 'hierarchical' => true, 'show_option_none' => __('None'))); ?>
<?php if ( 'category' == $taxonomy ) : // @todo: Generic text for hierarchical taxonomies ?>
<p><?php _e('Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have children categories for Bebop and Big Band. Totally optional.'); ?></p>
<?php endif; ?>
</div>
<?php endif; // is_taxonomy_hierarchical() ?>