• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP populate_roles_230函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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();
}
开发者ID:x3mgroup,项目名称:wordpress-mod,代码行数:16,代码来源:schema.php


示例2: populate_roles

function populate_roles()
{
    populate_roles_160();
    populate_roles_210();
    populate_roles_230();
}
开发者ID:helmonaut,项目名称:owb-mirror,代码行数:6,代码来源:schema.php


示例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))) {
//.........这里部分代码省略.........
开发者ID:beaucollins,项目名称:wp,代码行数:101,代码来源:upgrade.php


示例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;
//.........这里部分代码省略.........
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:101,代码来源:upgrade.php



注:本文中的populate_roles_230函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP populate_roles_250函数代码示例发布时间:2022-05-15
下一篇:
PHP populate_roles_210函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap