Changeset 25873
- Timestamp:
- 10/22/2013 09:18:09 PM (11 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-upgrader.php
r25871 r25873 1653 1653 * This filter parallels the AUTOMATIC_UPDATER_DISABLED constant in name. 1654 1654 * 1655 * This also disables update notification emails. That may change in the future. 1656 * 1655 1657 * @since 3.7.0 1656 1658 * @param bool $disabled Whether the updater should be disabled. … … 1729 1731 */ 1730 1732 public function should_update( $type, $item, $context ) { 1733 // Used to see if WP_Filesystem is set up to allow unattended updates. 1734 $skin = new Automatic_Upgrader_Skin; 1735 1731 1736 if ( $this->is_disabled() ) 1732 1737 return false; 1733 1738 1734 // Checks to see if WP_Filesystem is set up to allow unattended updates. 1735 $skin = new Automatic_Upgrader_Skin; 1736 if ( ! $skin->request_filesystem_credentials( false, $context ) ) 1739 // If we can't do an auto core update, we may still be able to email the user. 1740 if ( ! $skin->request_filesystem_credentials( false, $context ) || $this->is_vcs_checkout( $context ) ) { 1741 if ( 'core' == $type ) 1742 $this->notify_core_update( $item ); 1737 1743 return false; 1738 1739 if ( $this->is_vcs_checkout( $context ) ) 1740 return false; 1744 } 1741 1745 1742 1746 // Next up, is this an item we can update? … … 1766 1770 1767 1771 if ( ! $update ) { 1768 1769 // See if we need to notify users of a core update. 1770 if ( 'core' == $type && ! empty( $item->notify_email ) ) { 1771 $notify = true; 1772 $notified = get_site_option( 'auto_core_update_notified' ); 1773 1774 // Don't notify if we've already notified the same email address of the same version. 1775 if ( $notified && $notified['email'] == get_site_option( 'admin_email' ) && $notified['version'] == $item->current ) 1776 return false; 1777 1778 $this->send_email( 'manual', $item ); 1779 } 1780 1772 if ( 'core' == $type ) 1773 $this->notify_core_update( $item ); 1781 1774 return false; 1782 1775 } … … 1796 1789 } 1797 1790 1791 return true; 1792 } 1793 1794 /** 1795 * Notifies an administrator of a core update. 1796 * 1797 * @since 3.7.0 1798 * 1799 * @param object $item The update offer. 1800 */ 1801 protected function notify_core_update( $item ) { 1802 // See if we need to notify users of a core update. 1803 if ( empty( $item->notify_email ) ) 1804 return false; 1805 1806 $notify = true; 1807 $notified = get_site_option( 'auto_core_update_notified' ); 1808 1809 // Don't notify if we've already notified the same email address of the same version. 1810 if ( $notified && $notified['email'] == get_site_option( 'admin_email' ) && $notified['version'] == $item->current ) 1811 return false; 1812 1813 $this->send_email( 'manual', $item ); 1798 1814 return true; 1799 1815 } … … 1891 1907 global $wpdb, $wp_version; 1892 1908 1909 if ( $this->is_disabled() ) 1910 return; 1911 1893 1912 if ( ! is_main_network() || ! is_main_site() ) 1894 1913 return; … … 2083 2102 * @since 3.7.0 2084 2103 * 2085 * @param string $type The type of update being checked: 'core', 'theme', 'plugin', 'translation'.2104 * @param string $type The type of email to send. Can be one of 'success', 'fail', 'manual', 'critical'. 2086 2105 * @param object $core_update The update offer that was attempted. 2087 2106 * @param mixed $result Optional. The result for the core update. Can be WP_Error. … … 2095 2114 ) ); 2096 2115 2116 $next_user_core_update = get_preferred_from_update_core(); 2117 // If the update transient is empty, use the update we just performed 2118 if ( ! $next_user_core_update ) 2119 $next_user_core_update = $core_update; 2120 $newer_version_available = ( 'upgrade' == $next_user_core_update->response && version_compare( $next_user_core_update->version, $core_update, '>' ) ); 2121 2122 $newer_version_available = true; 2123 $next_user_core_update->version = $next_user_core_update->current = '3.8.1'; 2097 2124 /** 2098 2125 * Filter whether to send an email following an automatic background core update. … … 2129 2156 } 2130 2157 2131 $subject = sprintf( $subject, wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ), $core_update->current ); 2158 // If the auto update is not to the latest version, say that the current version of WP is available instead. 2159 $version = 'success' === $type ? $core_update->current : $next_user_core_update->current; 2160 $subject = sprintf( $subject, wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ), $version ); 2132 2161 2133 2162 $body = ''; … … 2136 2165 case 'success' : 2137 2166 $body .= sprintf( __( 'Howdy! Your site at %1$s has been updated automatically to WordPress %2$s.' ), home_url(), $core_update->current ); 2138 $body .= "\n\n" . __( 'No further action is needed on your part.' ); 2167 $body .= "\n\n"; 2168 if ( ! $newer_version_available ) 2169 $body .= __( 'No further action is needed on your part.' ) . ' '; 2139 2170 2140 2171 // Can only reference the About screen if their update was successful. 2141 2172 list( $about_version ) = explode( '-', $core_update->current, 2 ); 2142 $body .= ' ' .sprintf( __( "For more on version %s, see the About WordPress screen:" ), $about_version );2173 $body .= sprintf( __( "For more on version %s, see the About WordPress screen:" ), $about_version ); 2143 2174 $body .= "\n" . admin_url( 'about.php' ); 2175 2176 if ( $newer_version_available ) { 2177 $body .= "\n\n" . sprintf( __( 'WordPress %s is also now available.' ), $next_user_core_update->current ) . ' '; 2178 $body .= __( 'Updating is easy and only takes a few moments:' ); 2179 $body .= "\n" . network_admin_url( 'update-core.php' ); 2180 } 2181 2144 2182 break; 2145 2183 2146 2184 case 'fail' : 2147 2185 case 'manual' : 2148 $body .= sprintf( __( 'Please update your site at %1$s to WordPress %2$s.' ), home_url(), $ core_update->current );2186 $body .= sprintf( __( 'Please update your site at %1$s to WordPress %2$s.' ), home_url(), $next_user_core_update->current ); 2149 2187 2150 2188 $body .= "\n\n"; 2151 if ( 'fail' == $type ) 2189 2190 // Don't show this message if there is a newer version available. 2191 // Potential for confusion, and also not useful for them to know at this point. 2192 if ( 'fail' == $type && ! $newer_version_available ) 2152 2193 $body .= __( 'We tried but were unable to update your site automatically.' ) . ' '; 2194 2153 2195 $body .= __( 'Updating is easy and only takes a few moments:' ); 2154 2196 $body .= "\n" . network_admin_url( 'update-core.php' ); … … 2156 2198 2157 2199 case 'critical' : 2158 $body .= sprintf( __( 'Your site at %1$s experienced a critical failure while trying to update to the latest version of WordPress, %2$s.' ), home_url(), $core_update->current ); 2200 if ( $newer_version_available ) 2201 $body .= sprintf( __( 'Your site at %1$s experienced a critical failure while trying to update WordPress to version %2$s.' ), home_url(), $core_update->current ); 2202 else 2203 $body .= sprintf( __( 'Your site at %1$s experienced a critical failure while trying to update to the latest version of WordPress, %2$s.' ), home_url(), $core_update->current ); 2159 2204 2160 2205 $body .= "\n\n" . __( "This means your site may be offline or broken. Don't panic; this can be fixed." ); … … 2166 2211 2167 2212 // Updates are important! 2168 if ( $type != 'success' )2213 if ( $type != 'success' || $newer_version_available ) 2169 2214 $body .= "\n\n" . __( 'Keeping your site updated is important for security. It also makes the internet a safer place for you and your readers.' ); 2170 2215 … … 2173 2218 $body .= "\n" . __( 'http://wordpress.org/support/' ); 2174 2219 2175 // If things are successful , mention plugins and themes if any are out of date.2176 if ( $type == 'success' && ( get_plugin_updates() || get_theme_updates() ) ) {2220 // If things are successful and we're now on the latest, mention plugins and themes if any are out of date. 2221 if ( $type == 'success' && ! $newer_version_available && ( get_plugin_updates() || get_theme_updates() ) ) { 2177 2222 $body .= "\n\n" . __( 'You also have some plugins or themes with updates available. Update them now:' ); 2178 2223 $body .= "\n" . network_admin_url(); … … 2183 2228 if ( 'critical' == $type && is_wp_error( $result ) ) { 2184 2229 $body .= "\n***\n\n"; 2185 $body .= __( 'We have some data that describes the error your site encountered.' ); 2230 $body .= sprintf( __( 'Your site was running version %s.' ), $GLOBALS['wp_version'] ); 2231 $body .= ' ' . __( 'We have some data that describes the error your site encountered.' ); 2186 2232 $body .= ' ' . __( 'Your hosting company, support forum volunteers, or a friendly developer may be able to use this information to help you:' ); 2187 2233 -
trunk/src/wp-includes/update.php
r25841 r25873 416 416 417 417 $upgrader = new WP_Automatic_Updater; 418 if ( $upgrader->is_disabled() )419 return;420 421 418 $upgrader->run(); 422 419 }
Note: See TracChangeset
for help on using the changeset viewer.