Ticket #8660: 8660.diff
| File 8660.diff, 4.7 KB (added by DD32, 4 years ago) |
|---|
-
wp-includes/update.php
50 50 $url = "http://api.wordpress.org/core/version-check/1.3/?version=$wp_version&php=$php_version&locale=$locale&mysql=$mysql_version&local_package=$local_package"; 51 51 52 52 $options = array('timeout' => 3); 53 $options['headers'] = array(54 'Content-Type' => 'application/x-www-form-urlencoded; charset=' . get_option('blog_charset'),55 'User-Agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo('url')56 );57 53 58 $response = wp_remote_ request($url, $options);54 $response = wp_remote_get($url, $options); 59 55 60 56 if ( is_wp_error( $response ) ) 61 57 return false; … … 118 114 if ( ! is_object($current) ) 119 115 $current = new stdClass; 120 116 121 $new_option = '';117 $new_option = new stdClass; 122 118 $new_option->last_checked = time(); 123 $time_not_changed = isset( $current->last_checked ) && 43200 > ( time() - $current->last_checked ); 119 $timeout = 'load-plugins.php' == current_filter() ? 360 : 43200; //Check for updated every 60 minutes if hitting the themes page, Else, check every 12 hours 120 $time_not_changed = isset( $current->last_checked ) && $timeout > ( time() - $current->last_checked ); 124 121 125 122 $plugin_changed = false; 126 123 foreach ( $plugins as $file => $p ) { 127 124 $new_option->checked[ $file ] = $p['Version']; 128 125 129 if ( !isset( $current->checked[ $file ] ) ) {126 if ( !isset( $current->checked[ $file ] ) || strval($current->checked[ $file ]) !== strval($p['Version']) ) 130 127 $plugin_changed = true; 131 continue;132 }133 134 if ( strval($current->checked[ $file ]) !== strval($p['Version']) )135 $plugin_changed = true;136 128 } 137 129 138 130 if ( isset ( $current->response ) && is_array( $current->response ) ) { 139 131 foreach ( $current->response as $plugin_file => $update_details ) { 140 132 if ( ! isset($plugins[ $plugin_file ]) ) { 141 133 $plugin_changed = true; 134 break; 142 135 } 143 136 } 144 137 } … … 151 144 $current->last_checked = time(); 152 145 update_option( 'update_plugins', $current ); 153 146 154 $to_send->plugins = $plugins; 155 $to_send->active = $active; 156 $send = serialize( $to_send ); 157 $body = 'plugins=' . urlencode( $send ); 147 $to_send = (object)compact('plugins', 'active'); 148 $body = array('plugins' => serialize( $to_send ) ); 158 149 159 $options = array('method' => 'POST', 'timeout' => 3, 'body' => $body); 160 $options['headers'] = array( 161 'Content-Type' => 'application/x-www-form-urlencoded; charset=' . get_option('blog_charset'), 162 'Content-Length' => strlen($body), 163 'User-Agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo('url') 164 ); 150 $options = array('timeout' => 3, 'body' => $body); 165 151 166 $raw_response = wp_remote_ request('http://api.wordpress.org/plugins/update-check/1.0/', $options);152 $raw_response = wp_remote_post('http://api.wordpress.org/plugins/update-check/1.0/', $options); 167 153 168 154 if ( is_wp_error( $raw_response ) ) 169 155 return false; 170 156 171 if( 200 != $raw_response['response']['code'] ) {157 if( 200 != $raw_response['response']['code'] ) 172 158 return false; 173 }174 159 175 160 $response = unserialize( $raw_response['body'] ); 176 161 … … 209 194 if ( ! is_object($current_theme) ) 210 195 $current_theme = new stdClass; 211 196 212 $new_option = '';197 $new_option = new stdClass; 213 198 $new_option->last_checked = time( ); 214 $time_not_changed = isset( $current_theme->last_checked ) && 43200 > ( time( ) - $current_theme->last_checked ); 199 $timeout = 'load-themes.php' == current_filter() ? 360 : 43200; //Check for updated every 60 minutes if hitting the themes page, Else, check every 12 hours 200 $time_not_changed = isset( $current_theme->last_checked ) && $timeout > ( time( ) - $current_theme->last_checked ); 215 201 216 202 if( $time_not_changed ) 217 203 return false; … … 231 217 } 232 218 233 219 $options = array( 234 'method' => 'POST',235 220 'timeout' => 3, 236 'body' => 'themes=' . urlencode(serialize( $themes ) )221 'body' => array( 'themes' => serialize( $themes ) ) 237 222 ); 238 $options['headers'] = array(239 'Content-Type' => 'application/x-www-form-urlencoded; charset=' . get_option( 'blog_charset' ),240 'Content-Length' => strlen( $options['body'] ),241 'User-Agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )242 );243 223 244 $raw_response = wp_remote_ request( 'http://api.wordpress.org/themes/update-check/1.0/', $options );224 $raw_response = wp_remote_post( 'http://api.wordpress.org/themes/update-check/1.0/', $options ); 245 225 246 226 if( is_wp_error( $raw_response ) ) 247 227 return false; … … 295 275 add_action( 'admin_init', '_maybe_update_plugins' ); 296 276 add_action( 'wp_update_plugins', 'wp_update_plugins' ); 297 277 278 add_action( 'load-themes.php', 'wp_update_themes' ); 279 add_action( 'load-update.php', 'wp_update_themes' ); 298 280 add_action( 'admin_init', '_maybe_update_themes' ); 299 281 add_action( 'wp_update_themes', 'wp_update_themes' ); 300 282
