Ticket #25716: 25716.4.diff
File 25716.4.diff, 2.1 KB (added by , 11 years ago) |
---|
-
hotfix.php
11 11 WP_Hotfix_Controller::init(); 12 12 13 13 class WP_Hotfix_Controller { 14 const DB_VERSION = 2; 15 14 16 public static function init() { 15 17 add_action( 'init', 'wp_hotfix_init' ); 16 18 register_activation_hook( __FILE__, array( __CLASS__, 'activate' ) ); 17 19 register_deactivation_hook( __FILE__, array( __CLASS__, 'deactivate' ) ); 20 add_action( 'admin_init', array( __CLASS__, 'upgrade' ) ); 18 21 } 19 22 public static function activate() { 20 add_option( 'hotfix_version', '1');23 add_option( 'hotfix_version', self::DB_VERSION ); 21 24 register_uninstall_hook( __FILE__, array( __CLASS__, 'uninstall' ) ); 22 25 } 23 26 public static function deactivate() { … … 26 29 public static function uninstall() { 27 30 self::deactivate(); // The same, for now 28 31 } 32 public static function upgrade() { 33 $current_db_version = get_option( 'hotfix_version' ); 34 if ( self::DB_VERSION == $current_db_version ) 35 return; 36 37 if ( $current_db_version < 2 ) { 38 $block_ssl_requests = wp_http_supports( array( 'ssl' ) ) && is_wp_error( wp_remote_get( 'https://api.wordpress.org/' ) ); 39 update_option( 'hotfix_370_block_ssl_requests', $block_ssl_requests ); 40 } 41 42 update_option( 'hotfix_version', self::DB_VERSION ); 43 } 29 44 } 30 45 31 46 function wp_hotfix_init() { … … 34 49 $hotfixes = array(); 35 50 36 51 switch ( $wp_version ) { 52 case '3.7' : 53 $hotfixes = array( '370_http_ssl_support' ); 54 break; 37 55 case '3.5' : 38 56 $hotfixes = array( '350_twentytwelve', '350_iis_http_failure' ); 39 57 break; … … 238 256 return $temp; 239 257 return false; 240 258 } 259 260 function wp_hotfix_370_http_ssl_support() { 261 add_filter( 'use_curl_transport', 'wp_hotfix_370_ssl_not_supported', 10, 2 ); 262 add_filter( 'use_streams_transport', 'wp_hotfix_370_ssl_not_supported', 10, 2 ); 263 } 264 265 function wp_hotfix_370_ssl_not_supported( $test, $args ) { 266 if ( get_option( 'hotfix_370_block_ssl_requests' ) && ! empty( $args['ssl'] ) ) 267 return false; 268 return $test; 269 }