Example #1
0
/**
 * 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();
}
Example #2
0
function populate_roles()
{
    populate_roles_160();
    populate_roles_210();
    populate_roles_230();
}
Example #3
0
/**
 * Execute changes made in WordPress 2.1.
 *
 * @since 2.1.0
 */
function upgrade_210()
{
    global $wpdb, $wp_current_db_version;
    if ($wp_current_db_version < 3506) {
        // Update status and type.
        $posts = $wpdb->get_results("SELECT ID, post_status FROM {$wpdb->posts}");
        if (!empty($posts)) {
            foreach ($posts as $post) {
                $status = $post->post_status;
                $type = 'post';
                if ('static' == $status) {
                    $status = 'publish';
                    $type = 'page';
                } else {
                    if ('attachment' == $status) {
                        $status = 'inherit';
                        $type = 'attachment';
                    }
                }
                $wpdb->query($wpdb->prepare("UPDATE {$wpdb->posts} SET post_status = %s, post_type = %s WHERE ID = %d", $status, $type, $post->ID));
            }
        }
    }
    if ($wp_current_db_version < 3845) {
        populate_roles_210();
    }
    if ($wp_current_db_version < 3531) {
        // Give future posts a post_status of future.
        $now = gmdate('Y-m-d H:i:59');
        $wpdb->query("UPDATE {$wpdb->posts} SET post_status = 'future' WHERE post_status = 'publish' AND post_date_gmt > '{$now}'");
        $posts = $wpdb->get_results("SELECT ID, post_date FROM {$wpdb->posts} WHERE post_status ='future'");
        if (!empty($posts)) {
            foreach ($posts as $post) {
                wp_schedule_single_event(mysql2date('U', $post->post_date, false), 'publish_future_post', array($post->ID));
            }
        }
    }
}
function upgrade_210()
{
    global $wpdb, $wp_current_db_version;
    if ($wp_current_db_version < 3506) {
        // Update status and type.
        $posts = $wpdb->get_results("SELECT ID, post_status FROM {$wpdb->posts}");
        if (!empty($posts)) {
            foreach ($posts as $post) {
                $status = $post->post_status;
                $type = 'post';
                if ('static' == $status) {
                    $status = 'publish';
                    $type = 'page';
                } else {
                    if ('attachment' == $status) {
                        $status = 'inherit';
                        $type = 'attachment';
                    }
                }
                $wpdb->query("UPDATE {$wpdb->posts} SET post_status = '{$status}', post_type = '{$type}' WHERE ID = '{$post->ID}'");
            }
        }
    }
    if ($wp_current_db_version < 3845) {
        populate_roles_210();
    }
    if ($wp_current_db_version < 3531) {
        // Give future posts a post_status of future.
        $now = gmdate('Y-m-d H:i:59');
        $wpdb->query("UPDATE {$wpdb->posts} SET post_status = 'future' WHERE post_status = 'publish' AND post_date_gmt > '{$now}'");
        $posts = $wpdb->get_results("SELECT ID, post_date FROM {$wpdb->posts} WHERE post_status ='future'");
        if (!empty($posts)) {
            foreach ($posts as $post) {
                wp_schedule_single_event(mysql2date('U', $post->post_date), 'publish_future_post', array($post->ID));
            }
        }
    }
    if ($wp_current_db_version < 3570) {
        // Create categories for link categories if a category with the same
        // name doesn't exist.  Create a map of link cat IDs to cat IDs.
        $link_cat_id_map = array();
        $link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM " . $wpdb->prefix . 'linkcategories');
        foreach ($link_cats as $link_cat) {
            if ($cat_id = category_exists($link_cat->cat_name)) {
                $link_cat_id_map[$link_cat->cat_id] = $cat_id;
                $default_link_cat = $cat_id;
            } else {
                $link_cat_id_map[$link_cat->cat_id] = wp_create_category($link_cat->cat_name);
                $default_link_cat = $link_cat_id_map[$link_cat->cat_id];
            }
        }
        // Associate links to cats.
        $links = $wpdb->get_results("SELECT link_id, link_category FROM {$wpdb->links}");
        if (!empty($links)) {
            foreach ($links as $link) {
                if (0 == $link->link_category) {
                    continue;
                }
                if (!isset($link_cat_id_map[$link->link_category])) {
                    continue;
                }
                $link_cat = $link_cat_id_map[$link->link_category];
                $cat = $wpdb->get_row("SELECT * FROM {$wpdb->link2cat} WHERE link_id = '{$link->link_id}' AND category_id = '{$link_cat}'");
                if (!$cat) {
                    $wpdb->query("INSERT INTO {$wpdb->link2cat} (link_id, category_id)\n\t\t\t\t\tVALUES ('{$link->link_id}', '{$link_cat}')");
                }
            }
        }
        // Set default to the last category we grabbed during the upgrade loop.
        update_option('default_link_category', $default_link_cat);
        // Count links per category.
        if (0 == $wpdb->get_var("SELECT SUM(link_count) FROM {$wpdb->categories}")) {
            $categories = $wpdb->get_col("SELECT cat_ID FROM {$wpdb->categories}");
            foreach ($categories as $cat_id) {
                $count = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->link2cat}, {$wpdb->links} WHERE {$wpdb->links}.link_id = {$wpdb->link2cat}.link_id AND category_id = '{$cat_id}'");
                $wpdb->query("UPDATE {$wpdb->categories} SET link_count = '{$count}' WHERE cat_ID = '{$cat_id}'");
            }
        }
    }
    if ($wp_current_db_version < 4772) {
        // Obsolete linkcategories table
        $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'linkcategories');
    }
}