Changeset 10221
- Timestamp:
- 12/18/2008 05:23:20 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/update.php
r10150 r10221 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 58 $response = wp_remote_request($url, $options); 53 54 $response = wp_remote_get($url, $options); 59 55 60 56 if ( is_wp_error( $response ) ) … … 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; … … 127 124 $new_option->checked[ $file ] = $p['Version']; 128 125 129 if ( !isset( $current->checked[ $file ] ) ) { 130 $plugin_changed = true; 131 continue; 132 } 133 134 if ( strval($current->checked[ $file ]) !== strval($p['Version']) ) 126 if ( !isset( $current->checked[ $file ] ) || strval($current->checked[ $file ]) !== strval($p['Version']) ) 135 127 $plugin_changed = true; 136 128 } … … 140 132 if ( ! isset($plugins[ $plugin_file ]) ) { 141 133 $plugin_changed = true; 134 break; 142 135 } 143 136 } … … 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 ); 158 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 ); 165 166 $raw_response = wp_remote_request('http://api.wordpress.org/plugins/update-check/1.0/', $options); 147 $to_send = (object)compact('plugins', 'active'); 148 $body = array('plugins' => serialize( $to_send ) ); 149 150 $options = array('timeout' => 3, 'body' => $body); 151 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'] ) { 172 return false; 173 } 157 if( 200 != $raw_response['response']['code'] ) 158 return false; 174 159 175 160 $response = unserialize( $raw_response['body'] ); … … 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 ) … … 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 244 $raw_response = wp_remote_request( 'http://api.wordpress.org/themes/update-check/1.0/', $options ); 223 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 ) ) … … 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' );
Note: See TracChangeset
for help on using the changeset viewer.