Ticket #25654: 25654.2.diff
File 25654.2.diff, 8.0 KB (added by , 11 years ago) |
---|
-
wp-admin/includes/class-wp-upgrader.php
1691 1691 * should be checked. 1692 1692 */ 1693 1693 public function should_update( $type, $item, $context ) { 1694 if ( $this->is_disabled() ) 1695 return false; 1696 1697 // Checks to see if WP_Filesystem is set up to allow unattended updates. 1694 // Used to see if WP_Filesystem is set up to allow unattended updates. 1698 1695 $skin = new Automatic_Upgrader_Skin; 1699 if ( ! $skin->request_filesystem_credentials( false, $context ) )1700 return false;1701 1696 1702 if ( $this->is_vcs_checkout( $context ) ) 1697 if ( $this->is_disabled() || ! $skin->request_filesystem_credentials( false, $context ) || $this->is_vcs_checkout( $context ) ) { 1698 if ( 'core' == $type ) 1699 $this->notify_core_update( $item ); 1703 1700 return false; 1701 } 1704 1702 1705 1703 // Next up, is this an item we can update? 1706 1704 if ( 'core' == $type ) … … 1728 1726 $update = apply_filters( 'auto_update_' . $type, $update, $item ); 1729 1727 1730 1728 if ( ! $update ) { 1731 1732 // See if we need to notify users of a core update. 1733 if ( 'core' == $type && ! empty( $item->notify_email ) ) { 1734 $notify = true; 1735 $notified = get_site_option( 'auto_core_update_notified' ); 1736 1737 // Don't notify if we've already notified the same email address of the same version. 1738 if ( $notified && $notified['email'] == get_site_option( 'admin_email' ) && $notified['version'] == $item->current ) 1739 return false; 1740 1741 $this->send_email( 'manual', $item ); 1742 } 1743 1729 if ( 'core' == $type ) 1730 $this->notify_core_update( $item ); 1744 1731 return false; 1745 1732 } 1746 1733 … … 1762 1749 } 1763 1750 1764 1751 /** 1752 * Notifies an administrator of a core update. 1753 * 1754 * @since 3.7.0 1755 * 1756 * @param object $item The update offer. 1757 */ 1758 protected function notify_core_update( $core_update ) { 1759 // See if we need to notify users of a core update. 1760 if ( empty( $item->notify_email ) ) 1761 return false; 1762 1763 $notify = true; 1764 $notified = get_site_option( 'auto_core_update_notified' ); 1765 1766 // Don't notify if we've already notified the same email address of the same version. 1767 if ( $notified && $notified['email'] == get_site_option( 'admin_email' ) && $notified['version'] == $item->current ) 1768 return false; 1769 1770 $this->send_email( 'manual', $item ); 1771 return true; 1772 } 1773 1774 /** 1765 1775 * Update an item, if appropriate. 1766 1776 * 1767 1777 * @since 3.7.0 … … 2061 2071 * 2062 2072 * @since 3.7.0 2063 2073 * 2064 * @param string $type The type of update being checked: 'core', 'theme', 'plugin', 'translation'.2074 * @param string $type The type of email to send. Can be one of 'success', 'fail', 'manual', 'critical'. 2065 2075 * @param object $core_update The update offer that was attempted. 2066 2076 * @param mixed $result Optional. The result for the core update. Can be WP_Error. 2067 2077 */ 2068 p rotectedfunction send_email( $type, $core_update, $result = null ) {2078 public function send_email( $type, $core_update, $result = null ) { 2069 2079 update_site_option( 'auto_core_update_notified', array( 2070 2080 'type' => $type, 2071 2081 'email' => get_site_option( 'admin_email' ), … … 2073 2083 'timestamp' => time(), 2074 2084 ) ); 2075 2085 2086 $next_user_core_update = get_preferred_from_update_core(); 2087 // If the update transient is empty, use the update we just performed 2088 if ( ! $next_user_core_update ) 2089 $next_user_core_update = $core_update; 2090 $newer_version_available = ( 'upgrade' == $next_user_core_update->response && version_compare( $next_user_core_update->version, $core_update, '>' ) ); 2091 2092 $newer_version_available = true; 2093 $next_user_core_update->version = $next_user_core_update->current = '3.8.1'; 2076 2094 /** 2077 2095 * Filter whether to send an email following an automatic background core update. 2078 2096 * … … 2107 2125 return; 2108 2126 } 2109 2127 2110 $subject = sprintf( $subject, wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ), $core_update->current ); 2128 // If the auto update is not to the latest version, say that the current version of WP is available instead. 2129 $version = 'success' === $type ? $core_update->current : $next_user_core_update->current; 2130 $subject = sprintf( $subject, wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ), $version ); 2111 2131 2112 2132 $body = ''; 2113 2133 … … 2114 2134 switch ( $type ) { 2115 2135 case 'success' : 2116 2136 $body .= sprintf( __( 'Howdy! Your site at %1$s has been updated automatically to WordPress %2$s.' ), home_url(), $core_update->current ); 2117 $body .= "\n\n" . __( 'No further action is needed on your part.' ); 2137 $body .= "\n\n"; 2138 if ( ! $newer_version_available ) 2139 $body .= __( 'No further action is needed on your part.' ) . ' '; 2118 2140 2119 2141 // Can only reference the About screen if their update was successful. 2120 2142 list( $about_version ) = explode( '-', $core_update->current, 2 ); 2121 $body .= ' ' .sprintf( __( "For more on version %s, see the About WordPress screen:" ), $about_version );2143 $body .= sprintf( __( "For more on version %s, see the About WordPress screen:" ), $about_version ); 2122 2144 $body .= "\n" . admin_url( 'about.php' ); 2145 2146 if ( $newer_version_available ) { 2147 $body .= "\n\n" . sprintf( __( 'WordPress %s is also now available.' ), $next_user_core_update->current ) . ' '; 2148 $body .= __( 'Updating is easy and only takes a few moments:' ); 2149 $body .= "\n" . network_admin_url( 'update-core.php' ); 2150 } 2151 2123 2152 break; 2124 2153 2125 2154 case 'fail' : 2126 2155 case 'manual' : 2127 $body .= sprintf( __( 'Please update your site at %1$s to WordPress %2$s.' ), home_url(), $ core_update->current );2156 $body .= sprintf( __( 'Please update your site at %1$s to WordPress %2$s.' ), home_url(), $next_user_core_update->current ); 2128 2157 2129 2158 $body .= "\n\n"; 2130 if ( 'fail' == $type ) 2159 2160 // Don't show this message if there is a newer version available. 2161 // Potential for confusion, and also not useful for them to know at this point. 2162 if ( 'fail' == $type && ! $newer_version_available ) 2131 2163 $body .= __( 'We tried but were unable to update your site automatically.' ) . ' '; 2164 2132 2165 $body .= __( 'Updating is easy and only takes a few moments:' ); 2133 2166 $body .= "\n" . network_admin_url( 'update-core.php' ); 2134 2167 break; 2135 2168 2136 2169 case 'critical' : 2137 $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 ); 2170 if ( $newer_version_available ) 2171 $body .= sprintf( __( 'Your site at %1$s experienced a critical failure while trying to update WordPress.' ), home_url(), $core_update->current ); 2172 else 2173 $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 ); 2138 2174 2139 2175 $body .= "\n\n" . __( "This means your site may be offline or broken. Don't panic; this can be fixed." ); 2140 2176 … … 2144 2180 } 2145 2181 2146 2182 // Updates are important! 2147 if ( $type != 'success' )2183 if ( $type != 'success' || $newer_version_available ) 2148 2184 $body .= "\n\n" . __( 'Keeping your site updated is important for security. It also makes the internet a safer place for you and your readers.' ); 2149 2185 2150 2186 // Add a note about the support forums to all emails. … … 2151 2187 $body .= "\n\n" . __( 'If you experience any issues or need support, the volunteers in the WordPress.org support forums may be able to help.' ); 2152 2188 $body .= "\n" . __( 'http://wordpress.org/support/' ); 2153 2189 2154 // If things are successful , mention plugins and themes if any are out of date.2155 if ( $type == 'success' && ( get_plugin_updates() || get_theme_updates() ) ) {2190 // If things are successful and we're now on the latest, mention plugins and themes if any are out of date. 2191 if ( $type == 'success' && ! $newer_version_available && ( get_plugin_updates() || get_theme_updates() ) ) { 2156 2192 $body .= "\n\n" . __( 'You also have some plugins or themes with updates available. Update them now:' ); 2157 2193 $body .= "\n" . network_admin_url(); 2158 2194 }