Introduce a send_core_update_notification_email filter to control whether to send update notifications.
Merges [25882] to the 3.7 branch. Currently, this is dependent on whether the automatic updater is enabled (generally). This is likely to be decoupled in a future release. This refocuses the auto_core_update_send_email filter to specifically be for success/fail emails for auto updates, while the new filter is more general. see #25603. Built from https://develop.svn.wordpress.org/branches/3.7@25885 git-svn-id: http://core.svn.wordpress.org/branches/3.7@25797 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
85447a0bf3
commit
4152cb0b4b
|
@ -1739,7 +1739,7 @@ class WP_Automatic_Updater {
|
|||
// If we can't do an auto core update, we may still be able to email the user.
|
||||
if ( ! $skin->request_filesystem_credentials( false, $context ) || $this->is_vcs_checkout( $context ) ) {
|
||||
if ( 'core' == $type )
|
||||
$this->notify_core_update( $item );
|
||||
$this->send_core_update_notification_email( $item );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1770,7 +1770,7 @@ class WP_Automatic_Updater {
|
|||
|
||||
if ( ! $update ) {
|
||||
if ( 'core' == $type )
|
||||
$this->notify_core_update( $item );
|
||||
$this->send_core_update_notification_email( $item );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1798,11 +1798,7 @@ class WP_Automatic_Updater {
|
|||
*
|
||||
* @param object $item The update offer.
|
||||
*/
|
||||
protected function notify_core_update( $item ) {
|
||||
// See if we need to notify users of a core update.
|
||||
if ( empty( $item->notify_email ) )
|
||||
return false;
|
||||
|
||||
protected function send_core_update_notification_email( $item ) {
|
||||
$notify = true;
|
||||
$notified = get_site_option( 'auto_core_update_notified' );
|
||||
|
||||
|
@ -1810,6 +1806,28 @@ class WP_Automatic_Updater {
|
|||
if ( $notified && $notified['email'] == get_site_option( 'admin_email' ) && $notified['version'] == $item->current )
|
||||
return false;
|
||||
|
||||
// See if we need to notify users of a core update.
|
||||
$notify = ! empty( $item->notify_email );
|
||||
|
||||
/**
|
||||
* Whether to notify the site administrator of a new core update.
|
||||
*
|
||||
* By default, administrators are notified when the update offer received from WordPress.org
|
||||
* sets a particular flag. This allows for discretion in if and when to notify.
|
||||
*
|
||||
* This filter only fires once per release -- if the same email address was already
|
||||
* notified of the same new version, we won't repeatedly email the administrator.
|
||||
*
|
||||
* This filter is also used on about.php to check if a plugin has disabled these notifications.
|
||||
*
|
||||
* @since 3.7.0
|
||||
*
|
||||
* @param bool $notify Whether the site administrator is notified.
|
||||
* @param object $item The update offer.
|
||||
*/
|
||||
if ( ! apply_filters( 'send_core_update_notification_email', $notify, $item ) )
|
||||
return false;
|
||||
|
||||
$this->send_email( 'manual', $item );
|
||||
return true;
|
||||
}
|
||||
|
@ -2127,11 +2145,11 @@ class WP_Automatic_Updater {
|
|||
* @since 3.7.0
|
||||
*
|
||||
* @param bool $send Whether to send the email. Default true.
|
||||
* @param string $type The type of email to send. Can be one of 'success', 'fail', 'manual', 'critical'.
|
||||
* @param string $type The type of email to send. Can be one of 'success', 'fail', 'critical'.
|
||||
* @param object $core_update The update offer that was attempted.
|
||||
* @param mixed $result The result for the core update. Can be WP_Error.
|
||||
*/
|
||||
if ( ! apply_filters( 'auto_core_update_send_email', true, $type, $core_update, $result ) )
|
||||
if ( 'manual' !== $type && ! apply_filters( 'auto_core_update_send_email', true, $type, $core_update, $result ) )
|
||||
return;
|
||||
|
||||
switch ( $type ) {
|
||||
|
|
Loading…
Reference in New Issue