最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

core - Update to older wordpress version from admin?

programmeradmin0浏览0评论

I have a Wordpress 2.7.x setup that I would like to migrate to the latest version 3.2.1, however I need to make a stepped-upgrade as some plugins need an older version first (3.0.6 IIRC).

However Wordpress is only offering me the latest and greatest version to upgrade to. Is there a way - prefereably within the admin - to update core to a specific version? Or am I bound to manual upgrades?

Is there probably a way to tell the wordpress core upgrader which version to pick? It was downloading a zip only recently, right?

I have a Wordpress 2.7.x setup that I would like to migrate to the latest version 3.2.1, however I need to make a stepped-upgrade as some plugins need an older version first (3.0.6 IIRC).

However Wordpress is only offering me the latest and greatest version to upgrade to. Is there a way - prefereably within the admin - to update core to a specific version? Or am I bound to manual upgrades?

Is there probably a way to tell the wordpress core upgrader which version to pick? It was downloading a zip only recently, right?

Share Improve this question edited Feb 8, 2019 at 23:57 fuxia 107k38 gold badges255 silver badges459 bronze badges asked Aug 24, 2011 at 11:52 hakrehakre 12.9k6 gold badges49 silver badges85 bronze badges
Add a comment  | 

4 Answers 4

Reset to default 5

You can hook on option_update_core and edit the update url, as a plugin you can do something like this (Remember to disable the plugin after updating wordpress)

add_filter('option_update_core','wpse_26750');
add_filter('transient_update_core','wpse_26750');
function wpse_26750($options){
    global $wp_version;
    $updates=array(
        '2.5'=>'http://wordpress/wordpress-2.5.zip',
        '2.7.1'=>'http://wordpress/wordpress-2.7.1.zip',
        '2.8'=>'http://wordpress/wordpress-2.8.zip',
        '2.8.1'=>'http://wordpress/wordpress-2.8.1.zip',
        '2.8.3'=>'http://wordpress/wordpress-2.8.3.zip',
    );

    $currentUpdate=$options->updates[0];
    //Add Previous updates skipping the ones already passed
    foreach($updates as $version=>$updateUrl){
        if( version_compare($wp_version,$version) < 0){
            $update=new StdClass();
            $update->response='upgrade';
            $update->url='http://wordpress/download/';
            $update->package=$updateUrl;
            $update->current=$version;
            $update->locale=$options->updates[0]->locale;
            $options->updates[]=$update;
        }
    }
    unset($options->updates[0]);
    //Restore latest update
    $options->updates[]=$currentUpdate;
    return $options;
}

Starting 2.8 you also need to hook on transient_update_core as get_transient is used instead of get_option Also, there is version checking here, so no versions lower than itself is shown. The only (¿major?) issue, is that the list of versions need to added manually.

@grappler thnx for the solution. Used it to update to a specific version of 5.4.2. Made the version variable for easy integration.

add_filter('pre_site_option_update_core','wpse_26750' );
add_filter('site_transient_update_core','wpse_26750' );
function wpse_26750($updates){
    global $wp_version;

    // New version to update to
    $new_version = "5.4.2";

    // If current version is new_version or higher then stop
    if ( version_compare( $wp_version, $new_version ) >= 0 ) {
        return $updates;
    }

    // Override the update data
    $updates->updates[0]->download = 'https://downloads.wordpress/release/wordpress-'.$new_version.'.zip';
    $updates->updates[0]->packages->full = 'https://downloads.wordpress/release/wordpress-'.$new_version.'.zip';
    $updates->updates[0]->packages->no_content = 'https://downloads.wordpress/release/wordpress-'.$new_version.'-no-content.zip';
    $updates->updates[0]->packages->new_bundled = 'https://downloads.wordpress/release/wordpress-'.$new_version.'-new-bundled.zip';
    $updates->updates[0]->current = $new_version;

    return $updates;
}

I'm not sure of a way to do it through admin but it would be easy to accomplish with svn.

Make a copy or move wp-content and wp-config.php to a temp directory then delete all the WordPress files and check out the 2.8 branch, move wp-content and config back, then run the update script.

mv wordpress/wp-content /tmp/wp-content
mv wordpress/wp-config.php /tmp/wp-config.php
rm -rf wordpress
mkdir wordpress
cd wordpress
svn co http://core.svn.wordpress/tags/2.7.x/ .
mv /tmp/wp-content/* wordpress/wp-content/
mv /tmp/wp-config.php wordpress/wp-config.php

//Run upgrade script:  http://yoursite/wordpress/wp-admin/upgrade.php

//Check out the next version
cd wordpress
svn sw http://core.svn.wordpress/tags/2.8.x .

//Run upgrade script

//Rinse and repeat

Hansy's solution was not working for me as I was using WP 3.5. I wanted to update to WP 3.7.8. I based my solution on Hansy's with a few changes.

add_filter('pre_site_option_update_core','wpse_26750' );
add_filter('site_transient_update_core','wpse_26750' );
function wpse_26750($updates){
    global $wp_version;
    // If current version is 3.7.8 or higher then stop
    if ( version_compare( $wp_version, '3.7.8' ) >= 0 ) {
        return $updates;
    }
    $updates->updates[0]->download = 'https://downloads.wordpress/release/wordpress-3.7.8.zip';
    $updates->updates[0]->packages->full = 'https://downloads.wordpress/release/wordpress-3.7.8.zip';
    $updates->updates[0]->packages->no_content = 'https://downloads.wordpress/release/wordpress-3.7.8-no-content.zip';
    $updates->updates[0]->packages->new_bundled = 'https://downloads.wordpress/release/wordpress-3.7.8-new-bundled.zip';
    $updates->updates[0]->current = '3.7.8';

    return $updates;
}
发布评论

评论列表(0)

  1. 暂无评论