Plugin Directory

Changeset 1545401


Ignore:
Timestamp:
12/04/2016 07:34:50 PM (9 years ago)
Author:
mlteal
Message:

Release version 1.0.2

Location:
wordpress-beta-tester
Files:
4 edited
1 copied

Legend:

Unmodified
Added
Removed
  • wordpress-beta-tester/tags/1.0.2/readme.txt

    r1367527 r1545401  
    11=== WordPress Beta Tester  ===
    22Tags: beta, advanced, testing
    3 Contributors: westi
    4 Tested up to: 4.5
     3Contributors: westi, mlteal
     4Tested up to: 4.7
    55Requires at least: 3.0.5
    6 Stable Tag: 1.0.1
     6Stable Tag: 1.0.2
    77License: GPLv2
    88License URI: http://www.opensource.org/licenses/GPL-2.0
     
    2222
    2323== Changelog ==
     24
     25= 1.0.2 =
     26* Update tested up to version to 4.7.
     27* Fix the location of the settings screen in Multisite (moved under Settings in Network Admin).
     28* Minor text fixes.
    2429
    2530= 1.0.1 =
  • wordpress-beta-tester/tags/1.0.2/wp-beta-tester.php

    r1367271 r1545401  
    55    Description: Allows you to easily upgrade to Beta releases.
    66    Author: Peter Westwood
    7     Version: 1.0.1
     7    Version: 1.0.2
    88    Author URI: http://blog.ftwr.co.uk/
    99    Text Domain: wordpress-beta-tester
    1010    License: GPL v2 or later
    1111*/
     12
    1213/*  Copyright 2009-2016 Peter Westwood (email : peter.westwood@ftwr.co.uk)
    1314
     
    2526    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    2627*/
     28
    2729class wp_beta_tester {
    2830    var $real_wp_version;
     
    3032
    3133    function __construct() {
    32         add_action('admin_init', array(&$this, 'action_admin_init'));
    33         add_action('admin_menu', array(&$this, 'action_admin_menu'));
    34         add_action('update_option_wp_beta_tester_stream', array(&$this, 'action_update_option_wp_beta_tester_stream'));
    35         add_filter('pre_http_request', array(&$this, 'filter_http_request'), 10, 3);
    36         add_action('admin_head-plugins.php', array(&$this, 'action_admin_head_plugins_php'));
    37         add_action('admin_head-update-core.php', array(&$this, 'action_admin_head_plugins_php'));
     34        add_action( 'admin_init', array( &$this, 'action_admin_init' ) );
     35        if ( is_multisite() ) {
     36            add_action( 'network_admin_menu', array( &$this, 'action_admin_menu' ) );
     37        } else {
     38            add_action( 'admin_menu', array( &$this, 'action_admin_menu' ) );
     39        }
     40        add_action( 'update_option_wp_beta_tester_stream', array(
     41            &$this,
     42            'action_update_option_wp_beta_tester_stream',
     43        ) );
     44        add_filter( 'pre_http_request', array( &$this, 'filter_http_request' ), 10, 3 );
     45        add_action( 'admin_head-plugins.php', array( &$this, 'action_admin_head_plugins_php' ) );
     46        add_action( 'admin_head-update-core.php', array( &$this, 'action_admin_head_plugins_php' ) );
    3847    }
    3948
     
    5362        if ( $this->check_if_settings_downgrade() ) {
    5463            ?>
    55                 <div id="message" class="error"><p><?php printf( __('<strong>Error:</strong> Your current <a href="%1$s">WordPress Beta Tester plugin configuration</a> will downgrade your install to a previous version - please reconfigure it.', 'wordpress-beta-tester'), admin_url('tools.php?page=wp_beta_tester') ); ?></p></div>
     64            <div id="message" class="error">
     65                <p><?php printf( __( '<strong>Error:</strong> Your current <a href="%1$s">WordPress Beta Tester plugin configuration</a> will downgrade your install to a previous version - please reconfigure it.', 'wordpress-beta-tester' ), admin_url( 'tools.php?page=wp_beta_tester' ) ); ?></p>
     66            </div>
    5667            <?php
    5768        }
     
    6071    function action_admin_init() {
    6172        load_plugin_textdomain( 'wordpress-beta-tester' );
    62         register_setting( 'wp_beta_tester_options', 'wp_beta_tester_stream', array(&$this,'validate_setting') );
     73        register_setting( 'wp_beta_tester_options', 'wp_beta_tester_stream', array( &$this, 'validate_setting' ) );
    6374    }
    6475
    6576    function action_admin_menu() {
    66         add_management_page(__('Beta Testing WordPress', 'wordpress-beta-tester'), __('Beta Testing', 'wordpress-beta-tester'), 'update_plugins', 'wp_beta_tester', array(&$this,'display_page'));
    67     }
    68 
    69     function filter_http_request($result, $args, $url) {
    70         if ( $result || isset($args['_beta_tester']) )
     77        $parent = 'tools.php';
     78        if ( is_multisite() ) {
     79            $parent = 'settings.php';
     80        }
     81
     82        add_submenu_page(
     83            $parent,
     84            __( 'Beta Testing WordPress', 'wordpress-beta-tester' ),
     85            __( 'Beta Testing', 'wordpress-beta-tester' ),
     86            'update_plugins',
     87            'wp_beta_tester',
     88            array( &$this, 'display_page' )
     89        );
     90    }
     91
     92    function filter_http_request( $result, $args, $url ) {
     93        if ( $result || isset( $args['_beta_tester'] ) ) {
    7194            return $result;
    72         if ( ( 0 !== strpos( $url, 'http://api.wordpress.org/core/version-check/' ) ) &&
    73              ( 0 !== strpos( $url, 'https://api.wordpress.org/core/version-check/' ) ) ) {
     95        }
     96        if ( ( 0 !== strpos( $url, 'http://api.wordpress.org/core/version-check/' ) ) &&
     97             ( 0 !== strpos( $url, 'https://api.wordpress.org/core/version-check/' ) )
     98        ) {
    7499            return $result;
    75100        }
     
    79104
    80105        global $wp_version, $wpmu_version;
    81         $url = str_replace('version=' .  $wp_version, 'version=' . $this->mangle_wp_version(), $url);
    82         if ( !empty($wpmu_version) ) // old 2.9.2 WPMU
    83             $url = str_replace('wpmu_version=' .  $wpmu_version, 'wpmu_version=' . $this->mangle_wp_version(), $url);
    84 
    85         return wp_remote_get($url, $args);
     106        $url = str_replace( 'version=' . $wp_version, 'version=' . $this->mangle_wp_version(), $url );
     107        if ( ! empty( $wpmu_version ) ) { // old 2.9.2 WPMU
     108            $url = str_replace( 'wpmu_version=' . $wpmu_version, 'wpmu_version=' . $this->mangle_wp_version(), $url );
     109        }
     110
     111        return wp_remote_get( $url, $args );
    86112    }
    87113
    88114    function action_update_option_wp_beta_tester_stream() {
    89115        //Our option has changed so update the cached information pronto.
    90         do_action('wp_version_check');
     116        do_action( 'wp_version_check' );
    91117    }
    92118
    93119    function _get_preferred_from_update_core() {
    94         if (!function_exists('get_preferred_from_update_core') )
    95             require_once(ABSPATH . 'wp-admin/includes/update.php');
     120        if ( ! function_exists( 'get_preferred_from_update_core' ) ) {
     121            require_once( ABSPATH . 'wp-admin/includes/update.php' );
     122        }
    96123
    97124        //Validate that we have api data and if not get the normal data so we always have it.
    98125        $preferred = get_preferred_from_update_core();
    99         if (false === $preferred) {
     126        if ( false === $preferred ) {
    100127            wp_version_check();
    101             $preferred =  get_preferred_from_update_core();
    102         }
     128            $preferred = get_preferred_from_update_core();
     129        }
     130
    103131        return $preferred;
    104132    }
    105133
    106     function mangle_wp_version(){
    107         $stream = get_option('wp_beta_tester_stream','point');
     134    function mangle_wp_version() {
     135        $stream    = get_option( 'wp_beta_tester_stream', 'point' );
    108136        $preferred = $this->_get_preferred_from_update_core();
    109137        // If we're getting no updates back from get_preferred_from_update_core(), let an HTTP request go through unmangled.
    110         if ( ! isset( $preferred->current ) )
     138        if ( ! isset( $preferred->current ) ) {
    111139            return $GLOBALS['wp_version'];
    112 
    113         switch ($stream) {
     140        }
     141
     142        switch ( $stream ) {
    114143            case 'point':
    115                 $versions = explode('.', $preferred->current);
    116                 $versions[2] = isset($versions[2]) ? $versions[2] + 1 : 1;
    117                 $wp_version = $versions[0] . '.' . $versions[1] . '.' . $versions[2] . '-wp-beta-tester';
     144                $versions    = explode( '.', $preferred->current );
     145                $versions[2] = isset( $versions[2] ) ? $versions[2] + 1 : 1;
     146                $wp_version  = $versions[0] . '.' . $versions[1] . '.' . $versions[2] . '-wp-beta-tester';
    118147                break;
    119148            case 'unstable':
    120                 $versions = explode('.', $preferred->current);
     149                $versions = explode( '.', $preferred->current );
    121150                $versions[1] += 1;
    122                 if (10 == $versions[1]) {
     151                if ( 10 == $versions[1] ) {
    123152                    $versions[0] += 1;
    124153                    $versions[1] = 0;
    125154                }
    126                
     155
    127156                $wp_version = $versions[0] . '.' . $versions[1] . '-wp-beta-tester';
    128157
    129158                break;
    130159        }
     160
    131161        return $wp_version;
    132162    }
     
    134164    function check_if_settings_downgrade() {
    135165        global $wp_version;
    136         $wp_real_version = explode('-', $wp_version);
    137         $wp_mangled_version = explode('-', $this->mangle_wp_version());
    138         return version_compare($wp_mangled_version[0], $wp_real_version[0], 'lt');
    139     }
    140 
    141     function validate_setting($setting) {
    142         if (!in_array($setting, array('point','unstable')))
    143         {
     166        $wp_real_version    = explode( '-', $wp_version );
     167        $wp_mangled_version = explode( '-', $this->mangle_wp_version() );
     168
     169        return version_compare( $wp_mangled_version[0], $wp_real_version[0], 'lt' );
     170    }
     171
     172    function validate_setting( $setting ) {
     173        if ( ! in_array( $setting, array( 'point', 'unstable' ) ) ) {
    144174            $setting = 'point';
    145175        }
     176
    146177        return $setting;
    147178    }
    148179
    149180    function display_page() {
    150         if (!current_user_can('update_plugins'))
    151         {
    152             wp_die( __('You do not have sufficient permissions to access this page.', 'wordpress-beta-tester') );
     181        if ( ! current_user_can( 'update_plugins' ) ) {
     182            wp_die( __( 'You do not have sufficient permissions to access this page.', 'wordpress-beta-tester' ) );
    153183        }
    154184        $preferred = $this->_get_preferred_from_update_core();
    155185
    156186        ?>
    157     <div class="wrap"><?php screen_icon(); ?>
    158         <h2><?php _e('Beta Testing WordPress', 'wordpress-beta-tester'); ?></h2>
    159         <div class="updated fade">
    160             <p><?php _e('<strong>Please note:</strong> Once you have switched your blog to one of these beta versions of software, it will not always be possible to downgrade, as the database structure may be updated during the development of a major release.', 'wordpress-beta-tester'); ?></p> 
     187        <div class="wrap"><?php screen_icon(); ?>
     188            <h2><?php _e( 'Beta Testing WordPress', 'wordpress-beta-tester' ); ?></h2>
     189            <div class="updated fade">
     190                <p><?php _e( '<strong>Please note:</strong> Once you have switched your blog to one of these beta versions of software, it will not always be possible to downgrade, as the database structure may be updated during the development of a major release.', 'wordpress-beta-tester' ); ?></p>
     191            </div>
     192            <?php if ( 'development' != $preferred->response ) : ?>
     193                <div class="updated fade">
     194                    <p><?php _e( '<strong>Please note:</strong> There are no development builds of the beta stream you have choosen available, so you will receive normal update notifications.', 'wordpress-beta-tester' ); ?></p>
     195                </div>
     196            <?php endif; ?>
     197            <?php $this->action_admin_head_plugins_php(); //Check configuration?>
     198            <div>
     199                <p><?php echo sprintf( __( 'By their nature, these releases are unstable and should not be used anyplace where your data is important. So please <a href="%1$s">back up your database</a> before upgrading to a test release. In order to hear about the latest beta releases, your best bet is to watch the <a href="%2$s">development blog</a> and the <a href="%3$s">beta forum</a>.', 'wordpress-beta-tester' ),
     200                        _x( 'https://codex.wordpress.org/Backing_Up_Your_Database', 'Url to database backup instructions', 'wordpress-beta-tester' ),
     201                        'https://make.wordpress.org/core/',
     202                        _x( 'https://wordpress.org/support/forum/alphabeta', 'Url to beta support forum', 'wordpress-beta-tester' ) ); ?></p>
     203                <p><?php echo sprintf( __( 'Thank you for helping by testing WordPress. Please <a href="%s">report any bugs you find</a>.', 'wordpress-beta-tester' ),
     204                        'https://core.trac.wordpress.org/newticket' ); ?></p>
     205
     206                <p><?php _e( 'By default, your WordPress install uses the stable update stream. To return to this, please deactivate this plugin.', 'wordpress-beta-tester' ); ?></p>
     207                <form method="post" action="options.php"><?php settings_fields( 'wp_beta_tester_options' ); ?>
     208                    <fieldset>
     209                        <legend><?php _e( 'Please select the update stream you would like this blog to use:', 'wordpress-beta-tester' ); ?></legend>
     210                        <?php
     211                        // in multisite, this option is stored in the primary blog options table
     212                        $stream = get_option( 'wp_beta_tester_stream', 'point' );
     213                        ?>
     214                        <table class="form-table">
     215                            <tr>
     216                                <th><label><input name="wp_beta_tester_stream"
     217                                                  id="update-stream-point-nightlies" type="radio" value="point"
     218                                                  class="tog" <?php checked( 'point', $stream ); ?> /><?php _e( 'Point release nightlies', 'wordpress-beta-tester' ); ?>
     219                                    </label></th>
     220                                <td><?php _e( 'This contains the work that is occurring on a branch in preparation for a x.x.x point release.  This should also be fairly stable but will be available before the branch is ready for beta.', 'wordpress-beta-tester' ); ?></td>
     221                            </tr>
     222                            <tr>
     223                                <th><label><input name="wp_beta_tester_stream"
     224                                                  id="update-stream-bleeding-nightlies" type="radio" value="unstable"
     225                                                  class="tog" <?php checked( 'unstable', $stream ); ?> /><?php _e( 'Bleeding edge nightlies', 'wordpress-beta-tester' ); ?>
     226                                    </label></th>
     227                                <td><?php _e( 'This is the bleeding edge development code which may be unstable at times. <em>Only use this if you really know what you are doing</em>.', 'wordpress-beta-tester' ); ?></td>
     228                            </tr>
     229                        </table>
     230                    </fieldset>
     231                    <p class="submit"><input type="submit" class="button-primary"
     232                                             value="<?php _e( 'Save Changes', 'wordpress-beta-tester' ); ?>"/></p>
     233                </form>
     234                <p><?php echo sprintf( __( 'Why don\'t you <a href="%s">head on over and upgrade now</a>.', 'wordpress-beta-tester' ), 'update-core.php' ); ?></p>
     235            </div>
    161236        </div>
    162             <?php if ('development' != $preferred->response) : ?>
    163         <div class="updated fade">
    164             <p><?php _e('<strong>Please note:</strong> There are no development builds of the beta stream you have choosen available, so you will receive normal update notifications.', 'wordpress-beta-tester'); ?></p>
    165         </div>
    166             <?php endif;?>
    167             <?php $this->action_admin_head_plugins_php(); //Check configuration?>
    168         <div>
    169             <p><?php echo sprintf(__(   'By their nature, these releases are unstable and should not be used anyplace where your data is important. So please <a href="%1$s">back up your database</a> before upgrading to a test release. In order to hear about the latest beta releases, your best bet is to watch the <a href="%2$s">development blog</a> and the <a href="%3$s">beta forum</a>.', 'wordpress-beta-tester'),
    170                                         _x('https://codex.wordpress.org/Backing_Up_Your_Database', 'Url to database backup instructions', 'wordpress-beta-tester'),
    171                                         'https://make.wordpress.org/core/',
    172                                         _x('https://wordpress.org/support/forum/alphabeta', 'Url to beta support forum', 'wordpress-beta-tester') ); ?></p>
    173             <p><?php echo sprintf(__(   'Thank you for helping by testing WordPress. Please <a href="%s">report any bugs you find</a>.', 'wordpress-beta-tester'),
    174                                         'https://core.trac.wordpress.org/newticket' ); ?></p>
    175 
    176             <p><?php _e('By default, your WordPress install uses the stable update stream. To return to this, please deactivate this plugin.', 'wordpress-beta-tester'); ?></p>
    177             <form method="post" action="options.php"><?php settings_fields('wp_beta_tester_options'); ?>
    178             <fieldset><legend><?php _e('Please select the update stream you would like this blog to use:', 'wordpress-beta-tester'); ?></legend>
    179                 <?php
    180                 $stream = get_option('wp_beta_tester_stream','point');
    181                 ?>
    182             <table class="form-table">
    183                 <tr>
    184                     <th><label><input name="wp_beta_tester_stream"
    185                         id="update-stream-point-nightlies" type="radio" value="point"
    186                         class="tog" <?php checked('point', $stream); ?> /><?php _e('Point release nightlies', 'wordpress-beta-tester'); ?></label></th>
    187                     <td><?php _e('This contains the work that is occurring on a branch in preparation for a x.x.x point release.  This should also be fairly stable but will be available before the branch is ready for beta.', 'wordpress-beta-tester'); ?></td>
    188                 </tr>
    189                 <tr>
    190                     <th><label><input name="wp_beta_tester_stream"
    191                         id="update-stream-bleeding-nightlies" type="radio" value="unstable"
    192                         class="tog" <?php checked('unstable', $stream); ?> /><?php _e('Bleeding edge nightlies', 'wordpress-beta-tester'); ?></label></th>
    193                     <td><?php _e('This is the bleeding edge development code which may be unstable at times. <em>Only use this if you really know what you are doing</em>.', 'wordpress-beta-tester'); ?></td>
    194                 </tr>
    195             </table>
    196             </fieldset>
    197             <p class="submit"><input type="submit" class="button-primary"
    198                 value="<?php _e('Save Changes', 'wordpress-beta-tester'); ?>" /></p>
    199             </form>
    200             <p><?php echo sprintf(__( 'Why don\'t you <a href="%s">head on over and upgrade now</a>.', 'wordpress-beta-tester' ), 'update-core.php'); ?></p>
    201         </div>
    202     </div>
    203 <?php
     237        <?php
    204238    }
    205239}
     240
    206241/* Initialise outselves */
    207 add_action('plugins_loaded', create_function('','global $wp_beta_tester_instance; $wp_beta_tester_instance = new wp_beta_tester();'));
     242add_action( 'plugins_loaded', create_function( '', 'global $wp_beta_tester_instance; $wp_beta_tester_instance = new wp_beta_tester();' ) );
    208243
    209244// Clear down
     
    211246    delete_site_transient( 'update_core' );
    212247}
     248
    213249register_activation_hook( __FILE__, 'wordpress_beta_tester_deactivate_or_activate' );
    214250register_deactivation_hook( __FILE__, 'wordpress_beta_tester_deactivate_or_activate' );
  • wordpress-beta-tester/trunk/readme.txt

    r1367527 r1545401  
    11=== WordPress Beta Tester  ===
    22Tags: beta, advanced, testing
    3 Contributors: westi
    4 Tested up to: 4.5
     3Contributors: westi, mlteal
     4Tested up to: 4.7
    55Requires at least: 3.0.5
    6 Stable Tag: 1.0.1
     6Stable Tag: 1.0.2
    77License: GPLv2
    88License URI: http://www.opensource.org/licenses/GPL-2.0
     
    2222
    2323== Changelog ==
     24
     25= 1.0.2 =
     26* Update tested up to version to 4.7.
     27* Fix the location of the settings screen in Multisite (moved under Settings in Network Admin).
     28* Minor text fixes.
    2429
    2530= 1.0.1 =
  • wordpress-beta-tester/trunk/wp-beta-tester.php

    r1367271 r1545401  
    55    Description: Allows you to easily upgrade to Beta releases.
    66    Author: Peter Westwood
    7     Version: 1.0.1
     7    Version: 1.0.2
    88    Author URI: http://blog.ftwr.co.uk/
    99    Text Domain: wordpress-beta-tester
    1010    License: GPL v2 or later
    1111*/
     12
    1213/*  Copyright 2009-2016 Peter Westwood (email : peter.westwood@ftwr.co.uk)
    1314
     
    2526    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    2627*/
     28
    2729class wp_beta_tester {
    2830    var $real_wp_version;
     
    3032
    3133    function __construct() {
    32         add_action('admin_init', array(&$this, 'action_admin_init'));
    33         add_action('admin_menu', array(&$this, 'action_admin_menu'));
    34         add_action('update_option_wp_beta_tester_stream', array(&$this, 'action_update_option_wp_beta_tester_stream'));
    35         add_filter('pre_http_request', array(&$this, 'filter_http_request'), 10, 3);
    36         add_action('admin_head-plugins.php', array(&$this, 'action_admin_head_plugins_php'));
    37         add_action('admin_head-update-core.php', array(&$this, 'action_admin_head_plugins_php'));
     34        add_action( 'admin_init', array( &$this, 'action_admin_init' ) );
     35        if ( is_multisite() ) {
     36            add_action( 'network_admin_menu', array( &$this, 'action_admin_menu' ) );
     37        } else {
     38            add_action( 'admin_menu', array( &$this, 'action_admin_menu' ) );
     39        }
     40        add_action( 'update_option_wp_beta_tester_stream', array(
     41            &$this,
     42            'action_update_option_wp_beta_tester_stream',
     43        ) );
     44        add_filter( 'pre_http_request', array( &$this, 'filter_http_request' ), 10, 3 );
     45        add_action( 'admin_head-plugins.php', array( &$this, 'action_admin_head_plugins_php' ) );
     46        add_action( 'admin_head-update-core.php', array( &$this, 'action_admin_head_plugins_php' ) );
    3847    }
    3948
     
    5362        if ( $this->check_if_settings_downgrade() ) {
    5463            ?>
    55                 <div id="message" class="error"><p><?php printf( __('<strong>Error:</strong> Your current <a href="%1$s">WordPress Beta Tester plugin configuration</a> will downgrade your install to a previous version - please reconfigure it.', 'wordpress-beta-tester'), admin_url('tools.php?page=wp_beta_tester') ); ?></p></div>
     64            <div id="message" class="error">
     65                <p><?php printf( __( '<strong>Error:</strong> Your current <a href="%1$s">WordPress Beta Tester plugin configuration</a> will downgrade your install to a previous version - please reconfigure it.', 'wordpress-beta-tester' ), admin_url( 'tools.php?page=wp_beta_tester' ) ); ?></p>
     66            </div>
    5667            <?php
    5768        }
     
    6071    function action_admin_init() {
    6172        load_plugin_textdomain( 'wordpress-beta-tester' );
    62         register_setting( 'wp_beta_tester_options', 'wp_beta_tester_stream', array(&$this,'validate_setting') );
     73        register_setting( 'wp_beta_tester_options', 'wp_beta_tester_stream', array( &$this, 'validate_setting' ) );
    6374    }
    6475
    6576    function action_admin_menu() {
    66         add_management_page(__('Beta Testing WordPress', 'wordpress-beta-tester'), __('Beta Testing', 'wordpress-beta-tester'), 'update_plugins', 'wp_beta_tester', array(&$this,'display_page'));
    67     }
    68 
    69     function filter_http_request($result, $args, $url) {
    70         if ( $result || isset($args['_beta_tester']) )
     77        $parent = 'tools.php';
     78        if ( is_multisite() ) {
     79            $parent = 'settings.php';
     80        }
     81
     82        add_submenu_page(
     83            $parent,
     84            __( 'Beta Testing WordPress', 'wordpress-beta-tester' ),
     85            __( 'Beta Testing', 'wordpress-beta-tester' ),
     86            'update_plugins',
     87            'wp_beta_tester',
     88            array( &$this, 'display_page' )
     89        );
     90    }
     91
     92    function filter_http_request( $result, $args, $url ) {
     93        if ( $result || isset( $args['_beta_tester'] ) ) {
    7194            return $result;
    72         if ( ( 0 !== strpos( $url, 'http://api.wordpress.org/core/version-check/' ) ) &&
    73              ( 0 !== strpos( $url, 'https://api.wordpress.org/core/version-check/' ) ) ) {
     95        }
     96        if ( ( 0 !== strpos( $url, 'http://api.wordpress.org/core/version-check/' ) ) &&
     97             ( 0 !== strpos( $url, 'https://api.wordpress.org/core/version-check/' ) )
     98        ) {
    7499            return $result;
    75100        }
     
    79104
    80105        global $wp_version, $wpmu_version;
    81         $url = str_replace('version=' .  $wp_version, 'version=' . $this->mangle_wp_version(), $url);
    82         if ( !empty($wpmu_version) ) // old 2.9.2 WPMU
    83             $url = str_replace('wpmu_version=' .  $wpmu_version, 'wpmu_version=' . $this->mangle_wp_version(), $url);
    84 
    85         return wp_remote_get($url, $args);
     106        $url = str_replace( 'version=' . $wp_version, 'version=' . $this->mangle_wp_version(), $url );
     107        if ( ! empty( $wpmu_version ) ) { // old 2.9.2 WPMU
     108            $url = str_replace( 'wpmu_version=' . $wpmu_version, 'wpmu_version=' . $this->mangle_wp_version(), $url );
     109        }
     110
     111        return wp_remote_get( $url, $args );
    86112    }
    87113
    88114    function action_update_option_wp_beta_tester_stream() {
    89115        //Our option has changed so update the cached information pronto.
    90         do_action('wp_version_check');
     116        do_action( 'wp_version_check' );
    91117    }
    92118
    93119    function _get_preferred_from_update_core() {
    94         if (!function_exists('get_preferred_from_update_core') )
    95             require_once(ABSPATH . 'wp-admin/includes/update.php');
     120        if ( ! function_exists( 'get_preferred_from_update_core' ) ) {
     121            require_once( ABSPATH . 'wp-admin/includes/update.php' );
     122        }
    96123
    97124        //Validate that we have api data and if not get the normal data so we always have it.
    98125        $preferred = get_preferred_from_update_core();
    99         if (false === $preferred) {
     126        if ( false === $preferred ) {
    100127            wp_version_check();
    101             $preferred =  get_preferred_from_update_core();
    102         }
     128            $preferred = get_preferred_from_update_core();
     129        }
     130
    103131        return $preferred;
    104132    }
    105133
    106     function mangle_wp_version(){
    107         $stream = get_option('wp_beta_tester_stream','point');
     134    function mangle_wp_version() {
     135        $stream    = get_option( 'wp_beta_tester_stream', 'point' );
    108136        $preferred = $this->_get_preferred_from_update_core();
    109137        // If we're getting no updates back from get_preferred_from_update_core(), let an HTTP request go through unmangled.
    110         if ( ! isset( $preferred->current ) )
     138        if ( ! isset( $preferred->current ) ) {
    111139            return $GLOBALS['wp_version'];
    112 
    113         switch ($stream) {
     140        }
     141
     142        switch ( $stream ) {
    114143            case 'point':
    115                 $versions = explode('.', $preferred->current);
    116                 $versions[2] = isset($versions[2]) ? $versions[2] + 1 : 1;
    117                 $wp_version = $versions[0] . '.' . $versions[1] . '.' . $versions[2] . '-wp-beta-tester';
     144                $versions    = explode( '.', $preferred->current );
     145                $versions[2] = isset( $versions[2] ) ? $versions[2] + 1 : 1;
     146                $wp_version  = $versions[0] . '.' . $versions[1] . '.' . $versions[2] . '-wp-beta-tester';
    118147                break;
    119148            case 'unstable':
    120                 $versions = explode('.', $preferred->current);
     149                $versions = explode( '.', $preferred->current );
    121150                $versions[1] += 1;
    122                 if (10 == $versions[1]) {
     151                if ( 10 == $versions[1] ) {
    123152                    $versions[0] += 1;
    124153                    $versions[1] = 0;
    125154                }
    126                
     155
    127156                $wp_version = $versions[0] . '.' . $versions[1] . '-wp-beta-tester';
    128157
    129158                break;
    130159        }
     160
    131161        return $wp_version;
    132162    }
     
    134164    function check_if_settings_downgrade() {
    135165        global $wp_version;
    136         $wp_real_version = explode('-', $wp_version);
    137         $wp_mangled_version = explode('-', $this->mangle_wp_version());
    138         return version_compare($wp_mangled_version[0], $wp_real_version[0], 'lt');
    139     }
    140 
    141     function validate_setting($setting) {
    142         if (!in_array($setting, array('point','unstable')))
    143         {
     166        $wp_real_version    = explode( '-', $wp_version );
     167        $wp_mangled_version = explode( '-', $this->mangle_wp_version() );
     168
     169        return version_compare( $wp_mangled_version[0], $wp_real_version[0], 'lt' );
     170    }
     171
     172    function validate_setting( $setting ) {
     173        if ( ! in_array( $setting, array( 'point', 'unstable' ) ) ) {
    144174            $setting = 'point';
    145175        }
     176
    146177        return $setting;
    147178    }
    148179
    149180    function display_page() {
    150         if (!current_user_can('update_plugins'))
    151         {
    152             wp_die( __('You do not have sufficient permissions to access this page.', 'wordpress-beta-tester') );
     181        if ( ! current_user_can( 'update_plugins' ) ) {
     182            wp_die( __( 'You do not have sufficient permissions to access this page.', 'wordpress-beta-tester' ) );
    153183        }
    154184        $preferred = $this->_get_preferred_from_update_core();
    155185
    156186        ?>
    157     <div class="wrap"><?php screen_icon(); ?>
    158         <h2><?php _e('Beta Testing WordPress', 'wordpress-beta-tester'); ?></h2>
    159         <div class="updated fade">
    160             <p><?php _e('<strong>Please note:</strong> Once you have switched your blog to one of these beta versions of software, it will not always be possible to downgrade, as the database structure may be updated during the development of a major release.', 'wordpress-beta-tester'); ?></p> 
     187        <div class="wrap"><?php screen_icon(); ?>
     188            <h2><?php _e( 'Beta Testing WordPress', 'wordpress-beta-tester' ); ?></h2>
     189            <div class="updated fade">
     190                <p><?php _e( '<strong>Please note:</strong> Once you have switched your blog to one of these beta versions of software, it will not always be possible to downgrade, as the database structure may be updated during the development of a major release.', 'wordpress-beta-tester' ); ?></p>
     191            </div>
     192            <?php if ( 'development' != $preferred->response ) : ?>
     193                <div class="updated fade">
     194                    <p><?php _e( '<strong>Please note:</strong> There are no development builds of the beta stream you have choosen available, so you will receive normal update notifications.', 'wordpress-beta-tester' ); ?></p>
     195                </div>
     196            <?php endif; ?>
     197            <?php $this->action_admin_head_plugins_php(); //Check configuration?>
     198            <div>
     199                <p><?php echo sprintf( __( 'By their nature, these releases are unstable and should not be used anyplace where your data is important. So please <a href="%1$s">back up your database</a> before upgrading to a test release. In order to hear about the latest beta releases, your best bet is to watch the <a href="%2$s">development blog</a> and the <a href="%3$s">beta forum</a>.', 'wordpress-beta-tester' ),
     200                        _x( 'https://codex.wordpress.org/Backing_Up_Your_Database', 'Url to database backup instructions', 'wordpress-beta-tester' ),
     201                        'https://make.wordpress.org/core/',
     202                        _x( 'https://wordpress.org/support/forum/alphabeta', 'Url to beta support forum', 'wordpress-beta-tester' ) ); ?></p>
     203                <p><?php echo sprintf( __( 'Thank you for helping by testing WordPress. Please <a href="%s">report any bugs you find</a>.', 'wordpress-beta-tester' ),
     204                        'https://core.trac.wordpress.org/newticket' ); ?></p>
     205
     206                <p><?php _e( 'By default, your WordPress install uses the stable update stream. To return to this, please deactivate this plugin.', 'wordpress-beta-tester' ); ?></p>
     207                <form method="post" action="options.php"><?php settings_fields( 'wp_beta_tester_options' ); ?>
     208                    <fieldset>
     209                        <legend><?php _e( 'Please select the update stream you would like this blog to use:', 'wordpress-beta-tester' ); ?></legend>
     210                        <?php
     211                        // in multisite, this option is stored in the primary blog options table
     212                        $stream = get_option( 'wp_beta_tester_stream', 'point' );
     213                        ?>
     214                        <table class="form-table">
     215                            <tr>
     216                                <th><label><input name="wp_beta_tester_stream"
     217                                                  id="update-stream-point-nightlies" type="radio" value="point"
     218                                                  class="tog" <?php checked( 'point', $stream ); ?> /><?php _e( 'Point release nightlies', 'wordpress-beta-tester' ); ?>
     219                                    </label></th>
     220                                <td><?php _e( 'This contains the work that is occurring on a branch in preparation for a x.x.x point release.  This should also be fairly stable but will be available before the branch is ready for beta.', 'wordpress-beta-tester' ); ?></td>
     221                            </tr>
     222                            <tr>
     223                                <th><label><input name="wp_beta_tester_stream"
     224                                                  id="update-stream-bleeding-nightlies" type="radio" value="unstable"
     225                                                  class="tog" <?php checked( 'unstable', $stream ); ?> /><?php _e( 'Bleeding edge nightlies', 'wordpress-beta-tester' ); ?>
     226                                    </label></th>
     227                                <td><?php _e( 'This is the bleeding edge development code which may be unstable at times. <em>Only use this if you really know what you are doing</em>.', 'wordpress-beta-tester' ); ?></td>
     228                            </tr>
     229                        </table>
     230                    </fieldset>
     231                    <p class="submit"><input type="submit" class="button-primary"
     232                                             value="<?php _e( 'Save Changes', 'wordpress-beta-tester' ); ?>"/></p>
     233                </form>
     234                <p><?php echo sprintf( __( 'Why don\'t you <a href="%s">head on over and upgrade now</a>.', 'wordpress-beta-tester' ), 'update-core.php' ); ?></p>
     235            </div>
    161236        </div>
    162             <?php if ('development' != $preferred->response) : ?>
    163         <div class="updated fade">
    164             <p><?php _e('<strong>Please note:</strong> There are no development builds of the beta stream you have choosen available, so you will receive normal update notifications.', 'wordpress-beta-tester'); ?></p>
    165         </div>
    166             <?php endif;?>
    167             <?php $this->action_admin_head_plugins_php(); //Check configuration?>
    168         <div>
    169             <p><?php echo sprintf(__(   'By their nature, these releases are unstable and should not be used anyplace where your data is important. So please <a href="%1$s">back up your database</a> before upgrading to a test release. In order to hear about the latest beta releases, your best bet is to watch the <a href="%2$s">development blog</a> and the <a href="%3$s">beta forum</a>.', 'wordpress-beta-tester'),
    170                                         _x('https://codex.wordpress.org/Backing_Up_Your_Database', 'Url to database backup instructions', 'wordpress-beta-tester'),
    171                                         'https://make.wordpress.org/core/',
    172                                         _x('https://wordpress.org/support/forum/alphabeta', 'Url to beta support forum', 'wordpress-beta-tester') ); ?></p>
    173             <p><?php echo sprintf(__(   'Thank you for helping by testing WordPress. Please <a href="%s">report any bugs you find</a>.', 'wordpress-beta-tester'),
    174                                         'https://core.trac.wordpress.org/newticket' ); ?></p>
    175 
    176             <p><?php _e('By default, your WordPress install uses the stable update stream. To return to this, please deactivate this plugin.', 'wordpress-beta-tester'); ?></p>
    177             <form method="post" action="options.php"><?php settings_fields('wp_beta_tester_options'); ?>
    178             <fieldset><legend><?php _e('Please select the update stream you would like this blog to use:', 'wordpress-beta-tester'); ?></legend>
    179                 <?php
    180                 $stream = get_option('wp_beta_tester_stream','point');
    181                 ?>
    182             <table class="form-table">
    183                 <tr>
    184                     <th><label><input name="wp_beta_tester_stream"
    185                         id="update-stream-point-nightlies" type="radio" value="point"
    186                         class="tog" <?php checked('point', $stream); ?> /><?php _e('Point release nightlies', 'wordpress-beta-tester'); ?></label></th>
    187                     <td><?php _e('This contains the work that is occurring on a branch in preparation for a x.x.x point release.  This should also be fairly stable but will be available before the branch is ready for beta.', 'wordpress-beta-tester'); ?></td>
    188                 </tr>
    189                 <tr>
    190                     <th><label><input name="wp_beta_tester_stream"
    191                         id="update-stream-bleeding-nightlies" type="radio" value="unstable"
    192                         class="tog" <?php checked('unstable', $stream); ?> /><?php _e('Bleeding edge nightlies', 'wordpress-beta-tester'); ?></label></th>
    193                     <td><?php _e('This is the bleeding edge development code which may be unstable at times. <em>Only use this if you really know what you are doing</em>.', 'wordpress-beta-tester'); ?></td>
    194                 </tr>
    195             </table>
    196             </fieldset>
    197             <p class="submit"><input type="submit" class="button-primary"
    198                 value="<?php _e('Save Changes', 'wordpress-beta-tester'); ?>" /></p>
    199             </form>
    200             <p><?php echo sprintf(__( 'Why don\'t you <a href="%s">head on over and upgrade now</a>.', 'wordpress-beta-tester' ), 'update-core.php'); ?></p>
    201         </div>
    202     </div>
    203 <?php
     237        <?php
    204238    }
    205239}
     240
    206241/* Initialise outselves */
    207 add_action('plugins_loaded', create_function('','global $wp_beta_tester_instance; $wp_beta_tester_instance = new wp_beta_tester();'));
     242add_action( 'plugins_loaded', create_function( '', 'global $wp_beta_tester_instance; $wp_beta_tester_instance = new wp_beta_tester();' ) );
    208243
    209244// Clear down
     
    211246    delete_site_transient( 'update_core' );
    212247}
     248
    213249register_activation_hook( __FILE__, 'wordpress_beta_tester_deactivate_or_activate' );
    214250register_deactivation_hook( __FILE__, 'wordpress_beta_tester_deactivate_or_activate' );
Note: See TracChangeset for help on using the changeset viewer.