PHP Cross Reference of WordPress Subversion HEAD |
| [ Index ] [ Classes ] [ Functions ] [ Variables ] [ Constants ] |
[Summary view] [Print] [Text view]
1 <?php 2 3 // The admin side of our 1.0 update system 4 5 function core_update_footer( $msg ) { 6 if ( !current_user_can('manage_options') ) 7 return sprintf( '| '.__( 'Version %s' ), $GLOBALS['wp_version'] ); 8 9 $cur = get_option( 'update_core' ); 10 11 switch ( $cur->response ) { 12 case 'development' : 13 return sprintf( '| '.__( 'You are using a development version (%s). Cool! Please <a href="%s">stay updated</a>.' ), $GLOBALS['wp_version'], 'http://wordpress.org/download/svn/' ); 14 break; 15 16 case 'upgrade' : 17 return sprintf( '| <strong>'.__( 'Your WordPress %s is out of date. <a href="%s">Please update</a>.' ).'</strong>', $GLOBALS['wp_version'], $cur->url ); 18 break; 19 20 case 'latest' : 21 default : 22 return sprintf( '| '.__( 'Version %s' ), $GLOBALS['wp_version'] ); 23 break; 24 } 25 } 26 add_filter( 'update_footer', 'core_update_footer' ); 27 28 function update_nag() { 29 $cur = get_option( 'update_core' ); 30 31 if ( ! isset( $cur->response ) || $cur->response != 'upgrade' ) 32 return false; 33 34 if ( current_user_can('manage_options') ) 35 $msg = sprintf( __('A new version of WordPress is available! <a href="%s">Please update now</a>.'), $cur->url ); 36 else 37 $msg = __('A new version of WordPress is available! Please notify the site administrator.'); 38 39 echo "<div id='update-nag'>$msg</div>"; 40 } 41 add_action( 'admin_notices', 'update_nag', 3 ); 42 43 function wp_update_plugins() { 44 global $wp_version; 45 46 if ( !function_exists('fsockopen') ) 47 return false; 48 49 $plugins = get_plugins(); 50 $active = get_option( 'active_plugins' ); 51 $current = get_option( 'update_plugins' ); 52 53 $new_option = ''; 54 $new_option->last_checked = time(); 55 56 $plugin_changed = false; 57 foreach ( $plugins as $file => $p ) { 58 $new_option->checked[ $file ] = $p['Version']; 59 60 if ( !isset( $current->checked[ $file ] ) ) { 61 $plugin_changed = true; 62 continue; 63 } 64 65 if ( $current->checked[ $file ] != $p['Version'] ) 66 $plugin_changed = true; 67 } 68 69 if ( 70 isset( $current->last_checked ) && 71 43200 > ( time() - $current->last_checked ) && 72 !$plugin_changed 73 ) 74 return false; 75 76 $to_send->plugins = $plugins; 77 $to_send->active = $active; 78 $send = serialize( $to_send ); 79 80 $request = 'plugins=' . urlencode( $send ); 81 $http_request = "POST /plugins/update-check/1.0/ HTTP/1.0\r\n"; 82 $http_request .= "Host: api.wordpress.org\r\n"; 83 $http_request .= "Content-Type: application/x-www-form-urlencoded; charset=" . get_option('blog_charset') . "\r\n"; 84 $http_request .= "Content-Length: " . strlen($request) . "\r\n"; 85 $http_request .= 'User-Agent: WordPress/' . $wp_version . '; ' . get_bloginfo('url') . "\r\n"; 86 $http_request .= "\r\n"; 87 $http_request .= $request; 88 89 $response = ''; 90 if( false != ( $fs = @fsockopen( 'api.wordpress.org', 80, $errno, $errstr, 3) ) && is_resource($fs) ) { 91 fwrite($fs, $http_request); 92 93 while ( !feof($fs) ) 94 $response .= fgets($fs, 1160); // One TCP-IP packet 95 fclose($fs); 96 $response = explode("\r\n\r\n", $response, 2); 97 } 98 99 $response = unserialize( $response[1] ); 100 101 if ( $response ) 102 $new_option->response = $response; 103 104 update_option( 'update_plugins', $new_option ); 105 } 106 add_action( 'load-plugins.php', 'wp_update_plugins' ); 107 108 function wp_plugin_update_row( $file ) { 109 global $plugin_data; 110 $current = get_option( 'update_plugins' ); 111 if ( !isset( $current->response[ $file ] ) ) 112 return false; 113 114 $r = $current->response[ $file ]; 115 116 echo "<tr><td colspan='5' class='plugin-update'>"; 117 printf( __('There is a new version of %s available. <a href="%s">Download version %s here</a>.'), $plugin_data['Name'], $r->url, $r->new_version ); 118 echo "</td></tr>"; 119 } 120 add_action( 'after_plugin_row', 'wp_plugin_update_row' ); 121 122 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated Thu Dec 6 06:47:08 2007 for RedAlt XRefs | Cross-referenced by PHPXref 0.6 and RedAlt |