本文整理汇总了PHP中populate_roles_230函数的典型用法代码示例。如果您正苦于以下问题:PHP populate_roles_230函数的具体用法?PHP populate_roles_230怎么用?PHP populate_roles_230使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了populate_roles_230函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: populate_roles
/**
* Execute WordPress role creation for the various WordPress versions.
*
* @since 2.0.0
*/
function populate_roles()
{
populate_roles_160();
populate_roles_210();
populate_roles_230();
populate_roles_250();
populate_roles_260();
populate_roles_270();
populate_roles_280();
populate_roles_300();
}
示例2: populate_roles
function populate_roles()
{
populate_roles_160();
populate_roles_210();
populate_roles_230();
}
示例3: upgrade_230
/**
* Execute changes made in WordPress 2.3.
*
* @since 2.3.0
*/
function upgrade_230()
{
global $wp_current_db_version, $wpdb;
if ($wp_current_db_version < 5200) {
populate_roles_230();
}
// Convert categories to terms.
$tt_ids = array();
$have_tags = false;
$categories = $wpdb->get_results("SELECT * FROM {$wpdb->categories} ORDER BY cat_ID");
foreach ($categories as $category) {
$term_id = (int) $category->cat_ID;
$name = $category->cat_name;
$description = $category->category_description;
$slug = $category->category_nicename;
$parent = $category->category_parent;
$term_group = 0;
// Associate terms with the same slug in a term group and make slugs unique.
if ($exists = $wpdb->get_results($wpdb->prepare("SELECT term_id, term_group FROM {$wpdb->terms} WHERE slug = %s", $slug))) {
$term_group = $exists[0]->term_group;
$id = $exists[0]->term_id;
$num = 2;
do {
$alt_slug = $slug . "-{$num}";
$num++;
$slug_check = $wpdb->get_var($wpdb->prepare("SELECT slug FROM {$wpdb->terms} WHERE slug = %s", $alt_slug));
} while ($slug_check);
$slug = $alt_slug;
if (empty($term_group)) {
$term_group = $wpdb->get_var("SELECT MAX(term_group) FROM {$wpdb->terms} GROUP BY term_group") + 1;
$wpdb->query($wpdb->prepare("UPDATE {$wpdb->terms} SET term_group = %d WHERE term_id = %d", $term_group, $id));
}
}
$wpdb->query($wpdb->prepare("INSERT INTO {$wpdb->terms} (term_id, name, slug, term_group) VALUES\n\t\t(%d, %s, %s, %d)", $term_id, $name, $slug, $term_group));
$count = 0;
if (!empty($category->category_count)) {
$count = (int) $category->category_count;
$taxonomy = 'category';
$wpdb->query($wpdb->prepare("INSERT INTO {$wpdb->term_taxonomy} (term_id, taxonomy, description, parent, count) VALUES ( %d, %s, %s, %d, %d)", $term_id, $taxonomy, $description, $parent, $count));
$tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id;
}
if (!empty($category->link_count)) {
$count = (int) $category->link_count;
$taxonomy = 'link_category';
$wpdb->query($wpdb->prepare("INSERT INTO {$wpdb->term_taxonomy} (term_id, taxonomy, description, parent, count) VALUES ( %d, %s, %s, %d, %d)", $term_id, $taxonomy, $description, $parent, $count));
$tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id;
}
if (!empty($category->tag_count)) {
$have_tags = true;
$count = (int) $category->tag_count;
$taxonomy = 'post_tag';
$wpdb->insert($wpdb->term_taxonomy, compact('term_id', 'taxonomy', 'description', 'parent', 'count'));
$tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id;
}
if (empty($count)) {
$count = 0;
$taxonomy = 'category';
$wpdb->insert($wpdb->term_taxonomy, compact('term_id', 'taxonomy', 'description', 'parent', 'count'));
$tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id;
}
}
$select = 'post_id, category_id';
if ($have_tags) {
$select .= ', rel_type';
}
$posts = $wpdb->get_results("SELECT {$select} FROM {$wpdb->post2cat} GROUP BY post_id, category_id");
foreach ($posts as $post) {
$post_id = (int) $post->post_id;
$term_id = (int) $post->category_id;
$taxonomy = 'category';
if (!empty($post->rel_type) && 'tag' == $post->rel_type) {
$taxonomy = 'tag';
}
$tt_id = $tt_ids[$term_id][$taxonomy];
if (empty($tt_id)) {
continue;
}
$wpdb->insert($wpdb->term_relationships, array('object_id' => $post_id, 'term_taxonomy_id' => $tt_id));
}
// < 3570 we used linkcategories. >= 3570 we used categories and link2cat.
if ($wp_current_db_version < 3570) {
// Create link_category terms for link categories. Create a map of link cat IDs
// to link_category terms.
$link_cat_id_map = array();
$default_link_cat = 0;
$tt_ids = array();
$link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM " . $wpdb->prefix . 'linkcategories');
foreach ($link_cats as $category) {
$cat_id = (int) $category->cat_id;
$term_id = 0;
$name = $wpdb->escape($category->cat_name);
$slug = sanitize_title($name);
$term_group = 0;
// Associate terms with the same slug in a term group and make slugs unique.
if ($exists = $wpdb->get_results($wpdb->prepare("SELECT term_id, term_group FROM {$wpdb->terms} WHERE slug = %s", $slug))) {
//.........这里部分代码省略.........
示例4: upgrade_230
function upgrade_230() {
global $wp_current_db_version, $wpdb;
if ( $wp_current_db_version < 5200 ) {
populate_roles_230();
}
// Convert categories to terms.
$tt_ids = array();
$have_tags = false;
$categories = $wpdb->get_results("SELECT * FROM $wpdb->categories ORDER BY cat_ID");
foreach ($categories as $category) {
$term_id = (int) $category->cat_ID;
$name = $wpdb->escape($category->cat_name);
$description = $wpdb->escape($category->category_description);
$slug = $wpdb->escape($category->category_nicename);
$parent = $wpdb->escape($category->category_parent);
$term_group = 0;
// Associate terms with the same slug in a term group and make slugs unique.
if ( $exists = $wpdb->get_results("SELECT term_id, term_group FROM $wpdb->terms WHERE slug = '$slug'") ) {
$term_group = $exists[0]->term_group;
$id = $exists[0]->term_id;
$num = 2;
do {
$alt_slug = $slug . "-$num";
$num++;
$slug_check = $wpdb->get_var("SELECT slug FROM $wpdb->terms WHERE slug = '$alt_slug'");
} while ( $slug_check );
$slug = $alt_slug;
if ( empty( $term_group ) ) {
$term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms GROUP BY term_group") + 1;
$wpdb->query("UPDATE $wpdb->terms SET term_group = '$term_group' WHERE term_id = '$id'");
}
}
$wpdb->query("INSERT INTO $wpdb->terms (term_id, name, slug, term_group) VALUES ('$term_id', '$name', '$slug', '$term_group')");
$count = 0;
if ( !empty($category->category_count) ) {
$count = (int) $category->category_count;
$taxonomy = 'category';
$wpdb->query("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ('$term_id', '$taxonomy', '$description', '$parent', '$count')");
$tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id;
}
if ( !empty($category->link_count) ) {
$count = (int) $category->link_count;
$taxonomy = 'link_category';
$wpdb->query("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ('$term_id', '$taxonomy', '$description', '$parent', '$count')");
$tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id;
}
if ( !empty($category->tag_count) ) {
$have_tags = true;
$count = (int) $category->tag_count;
$taxonomy = 'post_tag';
$wpdb->query("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ('$term_id', '$taxonomy', '$description', '$parent', '$count')");
$tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id;
}
if ( empty($count) ) {
$count = 0;
$taxonomy = 'category';
$wpdb->query("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ('$term_id', '$taxonomy', '$description', '$parent', '$count')");
$tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id;
}
}
$select = 'post_id, category_id';
if ( $have_tags )
$select .= ', rel_type';
$posts = $wpdb->get_results("SELECT $select FROM $wpdb->post2cat GROUP BY post_id, category_id");
foreach ( $posts as $post ) {
$post_id = (int) $post->post_id;
$term_id = (int) $post->category_id;
$taxonomy = 'category';
if ( !empty($post->rel_type) && 'tag' == $post->rel_type)
$taxonomy = 'tag';
$tt_id = $tt_ids[$term_id][$taxonomy];
if ( empty($tt_id) )
continue;
$wpdb->query("INSERT INTO $wpdb->term_relationships (object_id, term_taxonomy_id) VALUES ('$post_id', '$tt_id')");
}
// < 3570 we used linkcategories. >= 3570 we used categories and link2cat.
if ( $wp_current_db_version < 3570 ) {
// Create link_category terms for link categories. Create a map of link cat IDs
// to link_category terms.
$link_cat_id_map = array();
$default_link_cat = 0;
$tt_ids = array();
$link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM " . $wpdb->prefix . 'linkcategories');
foreach ( $link_cats as $category) {
$cat_id = (int) $category->cat_id;
$term_id = 0;
//.........这里部分代码省略.........