WordPress.org

Make WordPress Core

Changeset 25882


Ignore:
Timestamp:
10/23/2013 07:46:33 PM (6 years ago)
Author:
nacin
Message:

Introduce a send_core_update_notification_email filter to control whether to send update notifications.

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-upgrader.php

    r25880 r25882  
    17401740        if ( ! $skin->request_filesystem_credentials( false, $context ) || $this->is_vcs_checkout( $context ) ) {
    17411741            if ( 'core' == $type )
    1742                 $this->notify_core_update( $item );
     1742                $this->send_core_update_notification_email( $item );
    17431743            return false;
    17441744        }
     
    17711771        if ( ! $update ) {
    17721772            if ( 'core' == $type )
    1773                 $this->notify_core_update( $item );
     1773                $this->send_core_update_notification_email( $item );
    17741774            return false;
    17751775        }
     
    17991799     * @param object $item The update offer.
    18001800     */
    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 
     1801    protected function send_core_update_notification_email( $item ) {
    18061802        $notify   = true;
    18071803        $notified = get_site_option( 'auto_core_update_notified' );
     
    18091805        // Don't notify if we've already notified the same email address of the same version.
    18101806        if ( $notified && $notified['email'] == get_site_option( 'admin_email' ) && $notified['version'] == $item->current )
     1807            return false;
     1808
     1809        // See if we need to notify users of a core update.
     1810        $notify = ! empty( $item->notify_email );
     1811
     1812        /**
     1813         * Whether to notify the site administrator of a new core update.
     1814         *
     1815         * By default, administrators are notified when the update offer received from WordPress.org
     1816         * sets a particular flag. This allows for discretion in if and when to notify.
     1817         *
     1818         * This filter only fires once per release -- if the same email address was already
     1819         * notified of the same new version, we won't repeatedly email the administrator.
     1820         *
     1821         * This filter is also used on about.php to check if a plugin has disabled these notifications.
     1822         *
     1823         * @since 3.7.0
     1824         *
     1825         * @param bool $notify Whether the site administrator is notified.
     1826         * @param object $item The update offer.
     1827         */
     1828        if ( ! apply_filters( 'send_core_update_notification_email', $notify, $item ) )
    18111829            return false;
    18121830
     
    21282146         *
    21292147         * @param bool   $send        Whether to send the email. Default true.
    2130          * @param string $type        The type of email to send. Can be one of 'success', 'fail', 'manual', 'critical'.
     2148         * @param string $type        The type of email to send. Can be one of 'success', 'fail', 'critical'.
    21312149         * @param object $core_update The update offer that was attempted.
    21322150         * @param mixed  $result      The result for the core update. Can be WP_Error.
    21332151         */
    2134         if ( ! apply_filters( 'auto_core_update_send_email', true, $type, $core_update, $result ) )
     2152        if ( 'manual' !== $type && ! apply_filters( 'auto_core_update_send_email', true, $type, $core_update, $result ) )
    21352153            return;
    21362154
Note: See TracChangeset for help on using the changeset viewer.