WordPress.org

Make WordPress Core

Changeset 47409


Ignore:
Timestamp:
03/03/2020 12:27:52 AM (20 months ago)
Author:
johnbillion
Message:

Upgrade/Install: Improved inline docs for the plugin and theme updater maintenance mode functionality.

Props bookdude13

See #49400

Location:
trunk/src/wp-admin/includes
Files:
2 edited

Legend:

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

    r47275 r47409  
    445445
    446446    /**
    447      * Turn on maintenance mode before attempting to background update an active plugin.
     447     * Turns on maintenance mode before attempting to background update an active plugin.
    448448     *
    449449     * Hooked to the {@see 'upgrader_pre_install'} filter by Plugin_Upgrader::upgrade().
     
    451451     * @since 5.4.0
    452452     *
    453      * @param bool|WP_Error  $return
    454      * @param array          $plugin
    455      * @return bool|WP_Error
     453     * @param bool|WP_Error $return Upgrade offer return.
     454     * @param array         $plugin Plugin package arguments.
     455     * @return bool|WP_Error The passed in $return param or WP_Error.
    456456     */
    457457    public function active_before( $return, $plugin ) {
     
    467467        $plugin = isset( $plugin['plugin'] ) ? $plugin['plugin'] : '';
    468468
    469         if ( ! is_plugin_active( $plugin ) ) { // If not active.
    470             return $return;
    471         }
    472 
    473         // Bulk edit handles maintenance mode separately.
     469        // Only run if plugin is active
     470        if ( ! is_plugin_active( $plugin ) ) {
     471            return $return;
     472        }
     473
     474        // Change to maintenance mode. Bulk edit handles this separately.
    474475        if ( ! $this->bulk ) {
    475476            $this->maintenance_mode( true );
     
    480481
    481482    /**
    482      * Turn off maintenance mode after upgrading an active plugin.
     483     * Turns off maintenance mode after upgrading an active plugin.
    483484     *
    484485     * Hooked to the {@see 'upgrader_post_install'} filter by Plugin_Upgrader::upgrade().
     
    486487     * @since 5.4.0
    487488     *
    488      * @param bool|WP_Error  $return
    489      * @param array          $plugin
    490      * @return bool|WP_Error
     489     * @param bool|WP_Error  $return Upgrade offer return.
     490     * @param array          $plugin Plugin package arguments.
     491     * @return bool|WP_Error The passed in $return param or WP_Error.
    491492     */
    492493    public function active_after( $return, $plugin ) {
     
    502503        $plugin = isset( $plugin['plugin'] ) ? $plugin['plugin'] : '';
    503504
    504         if ( ! is_plugin_active( $plugin ) ) { // If not active.
    505             return $return;
    506         }
    507 
    508         // Bulk edit handles maintenance mode separately.
     505        // Only run if plugin is active
     506        if ( ! is_plugin_active( $plugin ) ) {
     507            return $return;
     508        }
     509
     510        // Time to remove maintenance mode. Bulk edit handles this separately.
    509511        if ( ! $this->bulk ) {
    510512            $this->maintenance_mode( false );
     
    515517
    516518    /**
    517      * Delete the old plugin during an upgrade.
     519     * Deletes the old plugin during an upgrade.
    518520     *
    519521     * Hooked to the {@see 'upgrader_clear_destination'} filter by
     
    524526     * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
    525527     *
    526      * @param bool|WP_Error $removed
    527      * @param string        $local_destination
    528      * @param string        $remote_destination
    529      * @param array         $plugin
     528     * @param bool|WP_Error $removed            Whether the destination was cleared. true on success, WP_Error on failure.
     529     * @param string        $local_destination  The local package destination.
     530     * @param string        $remote_destination The remote package destination.
     531     * @param array         $plugin             Extra arguments passed to hooked filters.
    530532     * @return bool|WP_Error
    531533     */
  • trunk/src/wp-admin/includes/class-theme-upgrader.php

    r47219 r47409  
    529529     * @since 2.8.0
    530530     *
    531      * @param bool|WP_Error  $return
    532      * @param array          $theme
    533      * @return bool|WP_Error
     531     * @param bool|WP_Error $return Upgrade offer return.
     532     * @param array         $theme Theme arguments.
     533     * @return bool|WP_Error The passed in $return param or WP_Error.
    534534     */
    535535    public function current_before( $return, $theme ) {
     
    540540        $theme = isset( $theme['theme'] ) ? $theme['theme'] : '';
    541541
    542         if ( get_stylesheet() !== $theme ) { // If not current.
     542        // Only run if current theme
     543        if ( get_stylesheet() !== $theme ) {
    543544            return $return;
    544545        }
    545546
    546         // Change to maintenance mode now.
     547        // Change to maintenance mode. Bulk edit handles this separately.
    547548        if ( ! $this->bulk ) {
    548549            $this->maintenance_mode( true );
     
    560561     * @since 2.8.0
    561562     *
    562      * @param bool|WP_Error  $return
    563      * @param array          $theme
    564      * @return bool|WP_Error
     563     * @param bool|WP_Error $return Upgrade offer return.
     564     * @param array         $theme Theme arguments.
     565     * @return bool|WP_Error The passed in $return param or WP_Error.
    565566     */
    566567    public function current_after( $return, $theme ) {
     
    571572        $theme = isset( $theme['theme'] ) ? $theme['theme'] : '';
    572573
    573         if ( get_stylesheet() !== $theme ) { // If not current.
     574        // Only run if current theme
     575        if ( get_stylesheet() !== $theme ) {
    574576            return $return;
    575577        }
     
    582584        }
    583585
    584         // Time to remove maintenance mode.
     586        // Time to remove maintenance mode. Bulk edit handles this separately.
    585587        if ( ! $this->bulk ) {
    586588            $this->maintenance_mode( false );
Note: See TracChangeset for help on using the changeset viewer.