Make WordPress Core


Ignore:
Timestamp:
08/17/2023 09:01:17 PM (6 months ago)
Author:
joedolson
Message:

Administration: Apply admin notice functions in multisite.

Use wp_get_admin_notice and wp_admin_notice to handle multisite settings notices.

Props costdev.
See #57791.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/network/themes.php

    r55988 r56409  
    368368
    369369<?php
     370$message = '';
     371$type    = 'success';
     372
    370373if ( isset( $_GET['enabled'] ) ) {
    371374    $enabled = absint( $_GET['enabled'] );
     
    373376        $message = __( 'Theme enabled.' );
    374377    } else {
    375         /* translators: %s: Number of themes. */
    376         $message = _n( '%s theme enabled.', '%s themes enabled.', $enabled );
    377     }
    378     echo '<div id="message" class="notice notice-success is-dismissible"><p>' . sprintf( $message, number_format_i18n( $enabled ) ) . '</p></div>';
     378        $message = sprintf(
     379            /* translators: %s: Number of themes. */
     380            _n( '%s theme enabled.', '%s themes enabled.', $enabled ),
     381            number_format_i18n( $enabled )
     382        );
     383    }
    379384} elseif ( isset( $_GET['disabled'] ) ) {
    380385    $disabled = absint( $_GET['disabled'] );
     
    382387        $message = __( 'Theme disabled.' );
    383388    } else {
    384         /* translators: %s: Number of themes. */
    385         $message = _n( '%s theme disabled.', '%s themes disabled.', $disabled );
    386     }
    387     echo '<div id="message" class="notice notice-success is-dismissible"><p>' . sprintf( $message, number_format_i18n( $disabled ) ) . '</p></div>';
     389        $message = sprintf(
     390            /* translators: %s: Number of themes. */
     391            _n( '%s theme disabled.', '%s themes disabled.', $disabled ),
     392            number_format_i18n( $disabled )
     393        );
     394    }
    388395} elseif ( isset( $_GET['deleted'] ) ) {
    389396    $deleted = absint( $_GET['deleted'] );
     
    391398        $message = __( 'Theme deleted.' );
    392399    } else {
    393         /* translators: %s: Number of themes. */
    394         $message = _n( '%s theme deleted.', '%s themes deleted.', $deleted );
    395     }
    396     echo '<div id="message" class="notice notice-success is-dismissible"><p>' . sprintf( $message, number_format_i18n( $deleted ) ) . '</p></div>';
     400        $message = sprintf(
     401            /* translators: %s: Number of themes. */
     402            _n( '%s theme deleted.', '%s themes deleted.', $deleted ),
     403            number_format_i18n( $deleted )
     404        );
     405    }
    397406} elseif ( isset( $_GET['enabled-auto-update'] ) ) {
    398407    $enabled = absint( $_GET['enabled-auto-update'] );
     
    400409        $message = __( 'Theme will be auto-updated.' );
    401410    } else {
    402         /* translators: %s: Number of themes. */
    403         $message = _n( '%s theme will be auto-updated.', '%s themes will be auto-updated.', $enabled );
    404     }
    405     echo '<div id="message" class="notice notice-success is-dismissible"><p>' . sprintf( $message, number_format_i18n( $enabled ) ) . '</p></div>';
     411        $message = sprintf(
     412            /* translators: %s: Number of themes. */
     413            _n( '%s theme will be auto-updated.', '%s themes will be auto-updated.', $enabled ),
     414            number_format_i18n( $enabled )
     415        );
     416    }
    406417} elseif ( isset( $_GET['disabled-auto-update'] ) ) {
    407418    $disabled = absint( $_GET['disabled-auto-update'] );
     
    409420        $message = __( 'Theme will no longer be auto-updated.' );
    410421    } else {
    411         /* translators: %s: Number of themes. */
    412         $message = _n( '%s theme will no longer be auto-updated.', '%s themes will no longer be auto-updated.', $disabled );
    413     }
    414     echo '<div id="message" class="notice notice-success is-dismissible"><p>' . sprintf( $message, number_format_i18n( $disabled ) ) . '</p></div>';
     422        $message = sprintf(
     423            /* translators: %s: Number of themes. */
     424            _n( '%s theme will no longer be auto-updated.', '%s themes will no longer be auto-updated.', $disabled ),
     425            number_format_i18n( $disabled )
     426        );
     427    }
    415428} elseif ( isset( $_GET['error'] ) && 'none' === $_GET['error'] ) {
    416     echo '<div id="message" class="notice notice-error is-dismissible"><p>' . __( 'No theme selected.' ) . '</p></div>';
     429    $message = __( 'No theme selected.' );
     430    $type    = 'error';
    417431} elseif ( isset( $_GET['error'] ) && 'main' === $_GET['error'] ) {
    418     echo '<div id="message" class="notice notice-error is-dismissible"><p>' . __( 'You cannot delete a theme while it is active on the main site.' ) . '</p></div>';
    419 }
    420 
     432    $message = __( 'You cannot delete a theme while it is active on the main site.' );
     433    $type    = 'error';
     434}
     435
     436if ( '' !== $message ) {
     437    wp_admin_notice(
     438        $message,
     439        array(
     440            'type'        => $type,
     441            'dismissible' => true,
     442            'id'          => 'message',
     443        )
     444    );
     445}
    421446?>
    422447
Note: See TracChangeset for help on using the changeset viewer.