Changeset 1545401
- Timestamp:
- 12/04/2016 07:34:50 PM (9 years ago)
- Location:
- wordpress-beta-tester
- Files:
-
- 4 edited
- 1 copied
-
tags/1.0.2 (copied) (copied from wordpress-beta-tester/trunk)
-
tags/1.0.2/readme.txt (modified) (2 diffs)
-
tags/1.0.2/wp-beta-tester.php (modified) (8 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/wp-beta-tester.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wordpress-beta-tester/tags/1.0.2/readme.txt
r1367527 r1545401 1 1 === WordPress Beta Tester === 2 2 Tags: beta, advanced, testing 3 Contributors: westi 4 Tested up to: 4. 53 Contributors: westi, mlteal 4 Tested up to: 4.7 5 5 Requires at least: 3.0.5 6 Stable Tag: 1.0. 16 Stable Tag: 1.0.2 7 7 License: GPLv2 8 8 License URI: http://www.opensource.org/licenses/GPL-2.0 … … 22 22 23 23 == 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. 24 29 25 30 = 1.0.1 = -
wordpress-beta-tester/tags/1.0.2/wp-beta-tester.php
r1367271 r1545401 5 5 Description: Allows you to easily upgrade to Beta releases. 6 6 Author: Peter Westwood 7 Version: 1.0. 17 Version: 1.0.2 8 8 Author URI: http://blog.ftwr.co.uk/ 9 9 Text Domain: wordpress-beta-tester 10 10 License: GPL v2 or later 11 11 */ 12 12 13 /* Copyright 2009-2016 Peter Westwood (email : peter.westwood@ftwr.co.uk) 13 14 … … 25 26 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 26 27 */ 28 27 29 class wp_beta_tester { 28 30 var $real_wp_version; … … 30 32 31 33 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' ) ); 38 47 } 39 48 … … 53 62 if ( $this->check_if_settings_downgrade() ) { 54 63 ?> 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> 56 67 <?php 57 68 } … … 60 71 function action_admin_init() { 61 72 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' ) ); 63 74 } 64 75 65 76 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'] ) ) { 71 94 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 ) { 74 99 return $result; 75 100 } … … 79 104 80 105 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 ); 86 112 } 87 113 88 114 function action_update_option_wp_beta_tester_stream() { 89 115 //Our option has changed so update the cached information pronto. 90 do_action( 'wp_version_check');116 do_action( 'wp_version_check' ); 91 117 } 92 118 93 119 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 } 96 123 97 124 //Validate that we have api data and if not get the normal data so we always have it. 98 125 $preferred = get_preferred_from_update_core(); 99 if ( false === $preferred) {126 if ( false === $preferred ) { 100 127 wp_version_check(); 101 $preferred = get_preferred_from_update_core(); 102 } 128 $preferred = get_preferred_from_update_core(); 129 } 130 103 131 return $preferred; 104 132 } 105 133 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' ); 108 136 $preferred = $this->_get_preferred_from_update_core(); 109 137 // 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 ) ) { 111 139 return $GLOBALS['wp_version']; 112 113 switch ($stream) { 140 } 141 142 switch ( $stream ) { 114 143 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'; 118 147 break; 119 148 case 'unstable': 120 $versions = explode( '.', $preferred->current);149 $versions = explode( '.', $preferred->current ); 121 150 $versions[1] += 1; 122 if ( 10 == $versions[1]) {151 if ( 10 == $versions[1] ) { 123 152 $versions[0] += 1; 124 153 $versions[1] = 0; 125 154 } 126 155 127 156 $wp_version = $versions[0] . '.' . $versions[1] . '-wp-beta-tester'; 128 157 129 158 break; 130 159 } 160 131 161 return $wp_version; 132 162 } … … 134 164 function check_if_settings_downgrade() { 135 165 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' ) ) ) { 144 174 $setting = 'point'; 145 175 } 176 146 177 return $setting; 147 178 } 148 179 149 180 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' ) ); 153 183 } 154 184 $preferred = $this->_get_preferred_from_update_core(); 155 185 156 186 ?> 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> 161 236 </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 204 238 } 205 239 } 240 206 241 /* Initialise outselves */ 207 add_action( 'plugins_loaded', create_function('','global $wp_beta_tester_instance; $wp_beta_tester_instance = new wp_beta_tester();'));242 add_action( 'plugins_loaded', create_function( '', 'global $wp_beta_tester_instance; $wp_beta_tester_instance = new wp_beta_tester();' ) ); 208 243 209 244 // Clear down … … 211 246 delete_site_transient( 'update_core' ); 212 247 } 248 213 249 register_activation_hook( __FILE__, 'wordpress_beta_tester_deactivate_or_activate' ); 214 250 register_deactivation_hook( __FILE__, 'wordpress_beta_tester_deactivate_or_activate' ); -
wordpress-beta-tester/trunk/readme.txt
r1367527 r1545401 1 1 === WordPress Beta Tester === 2 2 Tags: beta, advanced, testing 3 Contributors: westi 4 Tested up to: 4. 53 Contributors: westi, mlteal 4 Tested up to: 4.7 5 5 Requires at least: 3.0.5 6 Stable Tag: 1.0. 16 Stable Tag: 1.0.2 7 7 License: GPLv2 8 8 License URI: http://www.opensource.org/licenses/GPL-2.0 … … 22 22 23 23 == 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. 24 29 25 30 = 1.0.1 = -
wordpress-beta-tester/trunk/wp-beta-tester.php
r1367271 r1545401 5 5 Description: Allows you to easily upgrade to Beta releases. 6 6 Author: Peter Westwood 7 Version: 1.0. 17 Version: 1.0.2 8 8 Author URI: http://blog.ftwr.co.uk/ 9 9 Text Domain: wordpress-beta-tester 10 10 License: GPL v2 or later 11 11 */ 12 12 13 /* Copyright 2009-2016 Peter Westwood (email : peter.westwood@ftwr.co.uk) 13 14 … … 25 26 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 26 27 */ 28 27 29 class wp_beta_tester { 28 30 var $real_wp_version; … … 30 32 31 33 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' ) ); 38 47 } 39 48 … … 53 62 if ( $this->check_if_settings_downgrade() ) { 54 63 ?> 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> 56 67 <?php 57 68 } … … 60 71 function action_admin_init() { 61 72 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' ) ); 63 74 } 64 75 65 76 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'] ) ) { 71 94 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 ) { 74 99 return $result; 75 100 } … … 79 104 80 105 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 ); 86 112 } 87 113 88 114 function action_update_option_wp_beta_tester_stream() { 89 115 //Our option has changed so update the cached information pronto. 90 do_action( 'wp_version_check');116 do_action( 'wp_version_check' ); 91 117 } 92 118 93 119 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 } 96 123 97 124 //Validate that we have api data and if not get the normal data so we always have it. 98 125 $preferred = get_preferred_from_update_core(); 99 if ( false === $preferred) {126 if ( false === $preferred ) { 100 127 wp_version_check(); 101 $preferred = get_preferred_from_update_core(); 102 } 128 $preferred = get_preferred_from_update_core(); 129 } 130 103 131 return $preferred; 104 132 } 105 133 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' ); 108 136 $preferred = $this->_get_preferred_from_update_core(); 109 137 // 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 ) ) { 111 139 return $GLOBALS['wp_version']; 112 113 switch ($stream) { 140 } 141 142 switch ( $stream ) { 114 143 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'; 118 147 break; 119 148 case 'unstable': 120 $versions = explode( '.', $preferred->current);149 $versions = explode( '.', $preferred->current ); 121 150 $versions[1] += 1; 122 if ( 10 == $versions[1]) {151 if ( 10 == $versions[1] ) { 123 152 $versions[0] += 1; 124 153 $versions[1] = 0; 125 154 } 126 155 127 156 $wp_version = $versions[0] . '.' . $versions[1] . '-wp-beta-tester'; 128 157 129 158 break; 130 159 } 160 131 161 return $wp_version; 132 162 } … … 134 164 function check_if_settings_downgrade() { 135 165 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' ) ) ) { 144 174 $setting = 'point'; 145 175 } 176 146 177 return $setting; 147 178 } 148 179 149 180 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' ) ); 153 183 } 154 184 $preferred = $this->_get_preferred_from_update_core(); 155 185 156 186 ?> 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> 161 236 </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 204 238 } 205 239 } 240 206 241 /* Initialise outselves */ 207 add_action( 'plugins_loaded', create_function('','global $wp_beta_tester_instance; $wp_beta_tester_instance = new wp_beta_tester();'));242 add_action( 'plugins_loaded', create_function( '', 'global $wp_beta_tester_instance; $wp_beta_tester_instance = new wp_beta_tester();' ) ); 208 243 209 244 // Clear down … … 211 246 delete_site_transient( 'update_core' ); 212 247 } 248 213 249 register_activation_hook( __FILE__, 'wordpress_beta_tester_deactivate_or_activate' ); 214 250 register_deactivation_hook( __FILE__, 'wordpress_beta_tester_deactivate_or_activate' );
Note: See TracChangeset
for help on using the changeset viewer.