WordPress.org

Plugin Directory

Changeset 393346


Ignore:
Timestamp:
06/05/11 08:52:32 (3 years ago)
Author:
westi
Message:

Make the Beta Tester plugin WordPress 3.2 compatible props dd32.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wordpress-beta-tester/trunk/wp-beta-tester.php

    r370070 r393346  
    55    Description: Allows you to easily upgrade to Beta releases. 
    66    Author: Peter Westwood 
    7     Version: 0.93 
     7    Version: 0.94 
    88    Author URI: http://blog.ftwr.co.uk/ 
    99 */ 
     
    1717        add_action('admin_menu', array(&$this, 'action_admin_menu')); 
    1818        add_action('init', array(&$this, 'action_init')); 
    19         add_action('admin_head-update-core.php', array(&$this, 'action_admin_head_update_core_php')); 
    20         add_action('update_option_wp_beta_tester_stream', array(&$this, 'action_update_option_wp_beta_tester_stream')); 
     19        add_filter('pre_http_request', array(&$this, 'filter_http_request'), 10, 3); 
    2120        add_action('admin_head-plugins.php', array(&$this, 'action_admin_head_plugins_php')); 
    2221        add_action('admin_head-update-core.php', array(&$this, 'action_admin_head_plugins_php')); 
     
    4342        // Load our textdomain 
    4443        load_plugin_textdomain('wp-beta-tester', false , basename(dirname(__FILE__)).'/languages'); 
    45         //Remove the default verson check function so we can add our wrapper function which plays with the version number 
    46         remove_action( 'wp_version_check', 'wp_version_check' ); 
    47         add_action( 'wp_version_check', array(&$this, 'action_wp_version_check') ); 
    48         remove_action( 'admin_init', '_maybe_update_core' ); 
    49         if (function_exists('_maybe_update_core')) { 
    50             add_action( 'admin_init', array(&$this, 'action__maybe_update_core') ); 
    51         } 
    5244    } 
    5345     
    54     function action_admin_head_update_core_php() { 
    55         //On the update page wp_version_check is called directly so we need to remangle the info by calling it again 
    56         $this->action_wp_version_check(); 
     46    function filter_http_request($result, $args, $url) { 
     47        if ( $result || isset($args['_beta_tester']) ) 
     48            return $result; 
     49        if ( 0 !== strpos($url, 'http://api.wordpress.org/core/version-check/') ) 
     50            return $result; 
     51 
     52        // It's a core-update request. 
     53        $args['_beta_tester'] = true; 
     54 
     55        global $wp_version, $wpmu_version; 
     56        $url = str_replace('version=' .  $wp_version, 'version=' . $this->mangle_wp_version(), $url); 
     57        if ( !empty($wpmu_version) ) // old 2.9.2 WPMU 
     58            $url = str_replace('wpmu_version=' .  $wpmu_version, 'wpmu_version=' . $this->mangle_wp_version(), $url); 
     59 
     60        return wp_remote_get($url, $args); 
    5761    } 
    5862     
    59     function action_wp_version_check() 
    60     { 
    61         $this->mangle_wp_version(); 
    62         wp_version_check(); 
    63         $this->restore_wp_version(); 
    64         $this->validate_upgrade_info(); 
    65     } 
    66      
    67      
    68     function action__maybe_update_core() { 
    69         $this->mangle_wp_version(); 
    70         _maybe_update_core(); 
    71         $this->restore_wp_version(); 
    72         $this->validate_upgrade_info(); 
    73     } 
    74  
    7563    function action_update_option_wp_beta_tester_stream() { 
    7664        //Our option has changed so update the cached information pronto. 
     
    10593     
    10694    function mangle_wp_version(){ 
    107         global $wp_version; 
    108         $this->real_wp_version = $wp_version; 
    109          
    11095        $stream = get_option('wp_beta_tester_stream','point'); 
    11196        $preferred = $this->_get_preferred_from_update_core(); 
     
    127112                $wp_version = $versions[0] . '.' . $versions[1] . '-wp-beta-tester'; 
    128113 
    129                 //Support for WordPress mu 2.9.2 -> 3.0 RC 
    130                 if ( isset($GLOBALS['wpmu_version'] ) ) { 
    131                     $this->real_wpmu_version = $GLOBALS['wpmu_version']; 
    132                     $GLOBALS['wpmu_version'] = $wp_version; 
    133                 }        
    134                  
    135114                break; 
    136115        } 
    137  
    138     } 
    139      
    140     function restore_wp_version() { 
    141         global $wp_version; 
    142         $wp_version = $this->real_wp_version; 
    143  
    144         //Support for WordPress mu 2.9.2 -> 3.0 RC 
    145         if ( $this->real_wpmu_version != false ) { 
    146             $this->real_wpmu_version = $GLOBALS['wpmu_version']; 
    147             $GLOBALS['wpmu_version'] = $wp_version; 
    148         } 
     116        return $wp_version; 
    149117    } 
    150118     
    151119    function check_if_settings_downgrade() { 
    152120        global $wp_version; 
    153         $this->restore_wp_version(); 
    154121        $wp_real_version = explode('-', $wp_version); 
    155         $this->mangle_wp_version(); 
    156         $wp_mangled_version = explode('-', $wp_version); 
    157         $this->restore_wp_version(); 
     122        $wp_mangled_version = explode('-', $this->mangle_wp_version()); 
    158123        return version_compare($wp_mangled_version[0], $wp_real_version[0], 'lt'); 
    159124    } 
Note: See TracChangeset for help on using the changeset viewer.