Make WordPress Core

Changeset 56597


Ignore:
Timestamp:
09/16/2023 09:47:22 PM (3 years ago)
Author:
costdev
Message:

Administration: Increase wp_admin_notice() usage in /wp-includes/.

Adds further usages of wp_admin_notice() in the root level of /wp-includes/ on .error and .notice-info.

Ongoing task to implement new function across core.

Follow-up to [56408], [56409], [56410], [56518], [56570], [56571], [56572], [56573], [56576], [56589], [56590].

Props joedolson, costdev.
See #57791.

Location:
trunk/src/wp-includes
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/media-template.php

    r55943 r56597  
    376376                        <?php
    377377                        if ( isset( $_GET['error'] ) && 'deprecated' === $_GET['error'] ) {
    378                                 echo '<div id="message" class="error notice"><p>' . __( 'The Edit Media screen is deprecated as of WordPress 6.3. Please use the Media Library instead.' ) . '</p></div>';
     378                                wp_admin_notice(
     379                                        __( 'The Edit Media screen is deprecated as of WordPress 6.3. Please use the Media Library instead.' ),
     380                                        array(
     381                                                'id'                 => 'message',
     382                                                'additional_classes' => array( 'error' ),
     383                                        )
     384                                );
    379385                        }
    380386                        ?>
  • trunk/src/wp-includes/widgets/class-wp-widget-media-audio.php

    r53136 r56597  
    190190                <script type="text/html" id="tmpl-wp-media-widget-audio-preview">
    191191                        <# if ( data.error && 'missing_attachment' === data.error ) { #>
    192                                 <div class="notice notice-error notice-alt notice-missing-attachment">
    193                                         <p><?php echo $this->l10n['missing_attachment']; ?></p>
    194                                 </div>
     192                                <?php
     193                                wp_admin_notice(
     194                                        $this->l10n['missing_attachment'],
     195                                        array(
     196                                                'type'               => 'error',
     197                                                'additional_classes' => array( 'notice-alt', 'notice-missing-attachment' ),
     198                                        )
     199                                );
     200                                ?>
    195201                        <# } else if ( data.error ) { #>
    196                                 <div class="notice notice-error notice-alt">
    197                                         <p><?php _e( 'Unable to preview media due to an unknown error.' ); ?></p>
    198                                 </div>
     202                                <?php
     203                                wp_admin_notice(
     204                                        __( 'Unable to preview media due to an unknown error.' ),
     205                                        array(
     206                                                'type'               => 'error',
     207                                                'additional_classes' => array( 'notice-alt' ),
     208                                        )
     209                                );
     210                                ?>
    199211                        <# } else if ( data.model && data.model.src ) { #>
    200212                                <?php wp_underscore_audio_template(); ?>
  • trunk/src/wp-includes/widgets/class-wp-widget-media-image.php

    r56154 r56597  
    364364                <script type="text/html" id="tmpl-wp-media-widget-image-preview">
    365365                        <# if ( data.error && 'missing_attachment' === data.error ) { #>
    366                                 <div class="notice notice-error notice-alt notice-missing-attachment">
    367                                         <p><?php echo $this->l10n['missing_attachment']; ?></p>
    368                                 </div>
     366                                <?php
     367                                wp_admin_notice(
     368                                        $this->l10n['missing_attachment'],
     369                                        array(
     370                                                'type'               => 'error',
     371                                                'additional_classes' => array( 'notice-alt', 'notice-missing-attachment' ),
     372                                        )
     373                                );
     374                                ?>
    369375                        <# } else if ( data.error ) { #>
    370                                 <div class="notice notice-error notice-alt">
    371                                         <p><?php _e( 'Unable to preview media due to an unknown error.' ); ?></p>
    372                                 </div>
     376                                <?php
     377                                wp_admin_notice(
     378                                        __( 'Unable to preview media due to an unknown error.' ),
     379                                        array(
     380                                                'type'               => 'error',
     381                                                'additional_classes' => array( 'notice-alt' ),
     382                                        )
     383                                );
     384                                ?>
    373385                        <# } else if ( data.url ) { #>
    374386                                <img class="attachment-thumb" src="{{ data.url }}" draggable="false" alt="{{ data.alt }}"
  • trunk/src/wp-includes/widgets/class-wp-widget-media-video.php

    r53136 r56597  
    229229                <script type="text/html" id="tmpl-wp-media-widget-video-preview">
    230230                        <# if ( data.error && 'missing_attachment' === data.error ) { #>
    231                                 <div class="notice notice-error notice-alt notice-missing-attachment">
    232                                         <p><?php echo $this->l10n['missing_attachment']; ?></p>
    233                                 </div>
     231                                <?php
     232                                wp_admin_notice(
     233                                        $this->l10n['missing_attachment'],
     234                                        array(
     235                                                'type'               => 'error',
     236                                                'additional_classes' => array( 'notice-alt', 'notice-missing-attachment' ),
     237                                        )
     238                                );
     239                                ?>
    234240                        <# } else if ( data.error && 'unsupported_file_type' === data.error ) { #>
    235                                 <div class="notice notice-error notice-alt notice-missing-attachment">
    236                                         <p><?php echo $this->l10n['unsupported_file_type']; ?></p>
    237                                 </div>
     241                                <?php
     242                                wp_admin_notice(
     243                                        $this->l10n['unsupported_file_type'],
     244                                        array(
     245                                                'type'               => 'error',
     246                                                'additional_classes' => array( 'notice-alt', 'notice-missing-attachment' ),
     247                                        )
     248                                );
     249                                ?>
    238250                        <# } else if ( data.error ) { #>
    239                                 <div class="notice notice-error notice-alt">
    240                                         <p><?php _e( 'Unable to preview media due to an unknown error.' ); ?></p>
    241                                 </div>
     251                                <?php
     252                                wp_admin_notice(
     253                                        __( 'Unable to preview media due to an unknown error.' ),
     254                                        array(
     255                                                'type'               => 'error',
     256                                                'additional_classes' => array( 'notice-alt' ),
     257                                        )
     258                                );
     259                                ?>
    242260                        <# } else if ( data.is_oembed && data.model.poster ) { #>
    243261                                <a href="{{ data.model.src }}" target="_blank" class="media-widget-video-link">
  • trunk/src/wp-includes/widgets/class-wp-widget-text.php

    r56196 r56597  
    496496                                <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $instance['title'] ); ?>" />
    497497                        </p>
    498                         <div class="notice inline notice-info notice-alt">
    499                                 <?php if ( ! isset( $instance['visual'] ) ) : ?>
    500                                         <p><?php _e( 'This widget may contain code that may work better in the &#8220;Custom HTML&#8221; widget. How about trying that widget instead?' ); ?></p>
    501                                 <?php else : ?>
    502                                         <p><?php _e( 'This widget may have contained code that may work better in the &#8220;Custom HTML&#8221; widget. If you have not yet, how about trying that widget instead?' ); ?></p>
    503                                 <?php endif; ?>
    504                         </div>
     498                        <?php
     499                        if ( ! isset( $instance['visual'] ) ) {
     500                                $widget_info_message = __( 'This widget may contain code that may work better in the &#8220;Custom HTML&#8221; widget. How about trying that widget instead?' );
     501                        } else {
     502                                $widget_info_message = __( 'This widget may have contained code that may work better in the &#8220;Custom HTML&#8221; widget. If you have not yet, how about trying that widget instead?' );
     503                        }
     504
     505                        wp_admin_notice(
     506                                $widget_info_message,
     507                                array(
     508                                        'type'               => 'info',
     509                                        'additional_classes' => array( 'notice-alt', 'inline' ),
     510                                )
     511                        );
     512                        ?>
    505513                        <p>
    506514                                <label for="<?php echo $this->get_field_id( 'text' ); ?>"><?php _e( 'Content:' ); ?></label>
Note: See TracChangeset for help on using the changeset viewer.