upgrade_210

The timeline below displays how wordpress function upgrade_210 has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 5.5

/**
 * Execute changes made in WordPress 2.1.
 *
 * @ignore
 * @since 2.1.0
 *
 * @global int  $wp_current_db_version The old (current) database version.
 * @global wpdb $wpdb                  WordPress database abstraction object.
 */
function upgrade_210()
{
    global $wp_current_db_version, $wpdb;
    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';
                } elseif ('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));
            }
        }
    }
}

WordPress Version: 5.3

/**
 * Execute changes made in WordPress 2.1.
 *
 * @ignore
 * @since 2.1.0
 *
 * @global int  $wp_current_db_version The old (current) database version.
 * @global wpdb $wpdb                  WordPress database abstraction object.
 */
function upgrade_210()
{
    global $wp_current_db_version, $wpdb;
    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';
                } elseif ('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));
            }
        }
    }
}

WordPress Version: 4.5

/**
 * Execute changes made in WordPress 2.1.
 *
 * @ignore
 * @since 2.1.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 * @global int  $wp_current_db_version
 */
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';
                } elseif ('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));
            }
        }
    }
}

WordPress Version: 4.4

/**
 * Execute changes made in WordPress 2.1.
 *
 * @since 2.1.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 * @global int  $wp_current_db_version
 */
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';
                } elseif ('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));
            }
        }
    }
}

WordPress Version: 4.3

/**
 * Execute changes made in WordPress 2.1.
 *
 * @since 2.1.0
 *
 * @global wpdb $wpdb
 * @global int  $wp_current_db_version
 */
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';
                } elseif ('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));
            }
        }
    }
}

WordPress Version: 4.2

/**
 * 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';
                } elseif ('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));
            }
        }
    }
}

WordPress Version: 3.7

/**
 * 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));
            }
        }
    }
}