WP_Automatic_Updater::after_plugin_theme_update() WordPress Method

The WP_Automatic_Updater::after_plugin_theme_update() method is called after a plugin or theme has been updated. It is passed the updated plugin or theme file as an argument. This method can be used to perform any necessary cleanup or post-update tasks.

WP_Automatic_Updater::after_plugin_theme_update( array $update_results ) #

If we tried to perform plugin or theme updates, check if we should send an email.


Parameters

$update_results

(array)(Required)The results of update tasks.


Top ↑

Source

File: wp-admin/includes/class-wp-automatic-updater.php

921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
protected function after_plugin_theme_update( $update_results ) {
    $successful_updates = array();
    $failed_updates     = array();
 
    if ( ! empty( $update_results['plugin'] ) ) {
        /**
         * Filters whether to send an email following an automatic background plugin update.
         *
         * @since 5.5.0
         * @since 5.5.1 Added the `$update_results` parameter.
         *
         * @param bool  $enabled        True if plugin update notifications are enabled, false otherwise.
         * @param array $update_results The results of plugins update tasks.
         */
        $notifications_enabled = apply_filters( 'auto_plugin_update_send_email', true, $update_results['plugin'] );
 
        if ( $notifications_enabled ) {
            foreach ( $update_results['plugin'] as $update_result ) {
                if ( true === $update_result->result ) {
                    $successful_updates['plugin'][] = $update_result;
                } else {
                    $failed_updates['plugin'][] = $update_result;
                }
            }
        }
    }
 
    if ( ! empty( $update_results['theme'] ) ) {
        /**
         * Filters whether to send an email following an automatic background theme update.
         *
         * @since 5.5.0
         * @since 5.5.1 Added the `$update_results` parameter.
         *
         * @param bool  $enabled        True if theme update notifications are enabled, false otherwise.
         * @param array $update_results The results of theme update tasks.
         */
        $notifications_enabled = apply_filters( 'auto_theme_update_send_email', true, $update_results['theme'] );
 
        if ( $notifications_enabled ) {
            foreach ( $update_results['theme'] as $update_result ) {
                if ( true === $update_result->result ) {
                    $successful_updates['theme'][] = $update_result;
                } else {
                    $failed_updates['theme'][] = $update_result;
                }
            }
        }
    }
 
    if ( empty( $successful_updates ) && empty( $failed_updates ) ) {
        return;
    }
 
    if ( empty( $failed_updates ) ) {
        $this->send_plugin_theme_email( 'success', $successful_updates, $failed_updates );
    } elseif ( empty( $successful_updates ) ) {
        $this->send_plugin_theme_email( 'fail', $successful_updates, $failed_updates );
    } else {
        $this->send_plugin_theme_email( 'mixed', $successful_updates, $failed_updates );
    }
}


Top ↑

Changelog

Changelog
VersionDescription
5.5.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by the Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.