Make WordPress Core

Ticket #33932: patch.6.diff

File patch.6.diff, 3.8 KB (added by ronalfy, 9 years ago)

Filter to disable e-mails for plugins, themes, and translations

  • wp-admin/includes/class-wp-upgrader.php

     
    34613461         */
    34623462        protected function send_debug_email() {
    34633463                $update_count = 0;
    3464                 foreach ( $this->update_results as $type => $updates )
     3464                $update_results = $this->update_results;
     3465                foreach ( $update_results as $type => $updates )
    34653466                        $update_count += count( $updates );
    34663467
    34673468                $body = array();
     
    34703471                $body[] = sprintf( __( 'WordPress site: %s' ), network_home_url( '/' ) );
    34713472
    34723473                // Core
    3473                 if ( isset( $this->update_results['core'] ) ) {
    3474                         $result = $this->update_results['core'][0];
     3474                if ( isset( $update_results['core'] ) ) {
     3475                        $result = $update_results['core'][0];
    34753476                        if ( $result->result && ! is_wp_error( $result->result ) ) {
    34763477                                $body[] = sprintf( __( 'SUCCESS: WordPress was successfully updated to %s' ), $result->name );
    34773478                        } else {
     
    34833484
    34843485                // Plugins, Themes, Translations
    34853486                foreach ( array( 'plugin', 'theme', 'translation' ) as $type ) {
    3486                         if ( ! isset( $this->update_results[ $type ] ) )
    3487                                 continue;
    3488                         $success_items = wp_list_filter( $this->update_results[ $type ], array( 'result' => true ) );
     3487                       
     3488                        /** 
     3489                        * Filter to disable notification emails on plugins/themes/translation. 
     3490                        * 
     3491                        * By default, administrators are notified when the update offer received 
     3492                        * from WordPress.org sets a particular flag. This allows some discretion 
     3493                        * in if and when to notify. This can be used to disabe automatic
     3494                        * update notifications. 
     3495                        * 
     3496                        * This filter is only evaluated once per update 
     3497                        *. 
     3498                        * 
     3499                        * @since 4.6.0 
     3500                        * 
     3501                        * @param bool   $notify Whether the site administrator is notified. 
     3502                        * @param string $type   The type of update (plugin, theme, translation). 
     3503                        * @param object $this   WP_Automatic_Updater instance 
     3504                        */ 
     3505                        if ( ! apply_filters( 'send_update_notification_email', true, $type, $this ) ) {
     3506                                if ( isset( $update_results[ $type ] ) ) {
     3507                                        unset( $update_results[ $type ] );
     3508                                } 
     3509                        } 
     3510
     3511                        if ( ! isset( $update_results[ $type ] ) )
     3512                                continue;
     3513
     3514                        $success_items = wp_list_filter( $update_results[ $type ], array( 'result' => true ) );
    34893515                        if ( $success_items ) {
    34903516                                $messages = array(
    34913517                                        'plugin'      => __( 'The following plugins were successfully updated:' ),
     
    34983524                                        $body[] = ' * ' . sprintf( __( 'SUCCESS: %s' ), $name );
    34993525                                }
    35003526                        }
    3501                         if ( $success_items != $this->update_results[ $type ] ) {
     3527                        if ( $success_items != $update_results[ $type ] ) {
    35023528                                // Failed updates
    35033529                                $messages = array(
    35043530                                        'plugin'      => __( 'The following plugins failed to update:' ),
     
    35073533                                );
    35083534
    35093535                                $body[] = $messages[ $type ];
    3510                                 foreach ( $this->update_results[ $type ] as $item ) {
     3536                                foreach ( $update_results[ $type ] as $item ) {
    35113537                                        if ( ! $item->result || is_wp_error( $item->result ) ) {
    35123538                                                $body[] = ' * ' . sprintf( __( 'FAILED: %s' ), $item->name );
    35133539                                                $failures++;
     
    35173543                        $body[] = '';
    35183544                }
    35193545
     3546                if ( empty( $update_results ) ) { 
     3547                        return;
     3548                }
     3549
    35203550                $site_title = wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES );
    35213551                if ( $failures ) {
    35223552                        $body[] = trim( __(
     
    35433573                $body[] = '';
    35443574
    35453575                foreach ( array( 'core', 'plugin', 'theme', 'translation' ) as $type ) {
    3546                         if ( ! isset( $this->update_results[ $type ] ) )
     3576                        if ( ! isset( $update_results[ $type ] ) )
    35473577                                continue;
    3548                         foreach ( $this->update_results[ $type ] as $update ) {
     3578
     3579                        foreach ( $update_results[ $type ] as $update ) {
    35493580                                $body[] = $update->name;
    35503581                                $body[] = str_repeat( '-', strlen( $update->name ) );
    35513582                                foreach ( $update->messages as $message )