Make WordPress Core


Ignore:
Timestamp:
09/17/2023 03:31:32 PM (3 years ago)
Author:
joedolson
Message:

Administration: Use wp_admin_notice() more in wp-admin/.

Add additional usage of wp_admin_notice() in wp-admin/ on .error and miscellaneous usages previously overlooked.

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

Props costdev, joedolson.
See #57791.

File:
1 edited

Legend:

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

    r56573 r56600  
    346346
    347347if ( $current_theme->errors() && ( ! is_multisite() || current_user_can( 'manage_network_themes' ) ) ) {
    348         echo '<div class="error"><p>' . __( 'Error:' ) . ' ' . $current_theme->errors()->get_error_message() . '</p></div>';
     348        wp_admin_notice(
     349                __( 'Error:' ) . ' ' . $current_theme->errors()->get_error_message(),
     350                array(
     351                        'additional_classes' => array( 'error' ),
     352                )
     353        );
    349354}
    350355
     
    439444
    440445        <?php if ( $theme['hasUpdate'] ) : ?>
    441                 <?php if ( $theme['updateResponse']['compatibleWP'] && $theme['updateResponse']['compatiblePHP'] ) : ?>
    442                         <div class="update-message notice inline notice-warning notice-alt"><p>
    443                                 <?php if ( $theme['hasPackage'] ) : ?>
    444                                         <?php _e( 'New version available. <button class="button-link" type="button">Update now</button>' ); ?>
    445                                 <?php else : ?>
    446                                         <?php _e( 'New version available.' ); ?>
    447                                 <?php endif; ?>
    448                         </p></div>
    449                 <?php else : ?>
    450                         <div class="update-message notice inline notice-error notice-alt"><p>
    451                                 <?php
    452                                 if ( ! $theme['updateResponse']['compatibleWP'] && ! $theme['updateResponse']['compatiblePHP'] ) {
    453                                         printf(
    454                                                 /* translators: %s: Theme name. */
    455                                                 __( 'There is a new version of %s available, but it does not work with your versions of WordPress and PHP.' ),
    456                                                 $theme['name']
    457                                         );
    458                                         if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
    459                                                 printf(
    460                                                         /* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
    461                                                         ' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
    462                                                         self_admin_url( 'update-core.php' ),
    463                                                         esc_url( wp_get_update_php_url() )
    464                                                 );
    465                                                 wp_update_php_annotation( '</p><p><em>', '</em>' );
    466                                         } elseif ( current_user_can( 'update_core' ) ) {
    467                                                 printf(
    468                                                         /* translators: %s: URL to WordPress Updates screen. */
    469                                                         ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
    470                                                         self_admin_url( 'update-core.php' )
    471                                                 );
    472                                         } elseif ( current_user_can( 'update_php' ) ) {
    473                                                 printf(
    474                                                         /* translators: %s: URL to Update PHP page. */
    475                                                         ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
    476                                                         esc_url( wp_get_update_php_url() )
    477                                                 );
    478                                                 wp_update_php_annotation( '</p><p><em>', '</em>' );
    479                                         }
    480                                 } elseif ( ! $theme['updateResponse']['compatibleWP'] ) {
    481                                         printf(
    482                                                 /* translators: %s: Theme name. */
    483                                                 __( 'There is a new version of %s available, but it does not work with your version of WordPress.' ),
    484                                                 $theme['name']
    485                                         );
    486                                         if ( current_user_can( 'update_core' ) ) {
    487                                                 printf(
    488                                                         /* translators: %s: URL to WordPress Updates screen. */
    489                                                         ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
    490                                                         self_admin_url( 'update-core.php' )
    491                                                 );
    492                                         }
    493                                 } elseif ( ! $theme['updateResponse']['compatiblePHP'] ) {
    494                                         printf(
    495                                                 /* translators: %s: Theme name. */
    496                                                 __( 'There is a new version of %s available, but it does not work with your version of PHP.' ),
    497                                                 $theme['name']
    498                                         );
    499                                         if ( current_user_can( 'update_php' ) ) {
    500                                                 printf(
    501                                                         /* translators: %s: URL to Update PHP page. */
    502                                                         ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
    503                                                         esc_url( wp_get_update_php_url() )
    504                                                 );
    505                                                 wp_update_php_annotation( '</p><p><em>', '</em>' );
    506                                         }
     446                <?php
     447                if ( $theme['updateResponse']['compatibleWP'] && $theme['updateResponse']['compatiblePHP'] ) :
     448                        if ( $theme['hasPackage'] ) {
     449                                $new_version_available = __( 'New version available. <button class="button-link" type="button">Update now</button>' );
     450                        } else {
     451                                $new_version_available = __( 'New version available.' );
     452                        }
     453                        wp_admin_notice(
     454                                $new_version_available,
     455                                array(
     456                                        'type'               => 'warning',
     457                                        'additional_classes' => array( 'notice-alt', 'inline', 'update-message' ),
     458                                )
     459                        );
     460                else :
     461                        $theme_update_error = '';
     462                        if ( ! $theme['updateResponse']['compatibleWP'] && ! $theme['updateResponse']['compatiblePHP'] ) {
     463                                $theme_update_error .= sprintf(
     464                                        /* translators: %s: Theme name. */
     465                                        __( 'There is a new version of %s available, but it does not work with your versions of WordPress and PHP.' ),
     466                                        $theme['name']
     467                                );
     468                                if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
     469                                        $theme_update_error .= sprintf(
     470                                                /* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
     471                                                ' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
     472                                                self_admin_url( 'update-core.php' ),
     473                                                esc_url( wp_get_update_php_url() )
     474                                        );
     475                                        wp_update_php_annotation( '</p><p><em>', '</em>', false );
     476                                } elseif ( current_user_can( 'update_core' ) ) {
     477                                        $theme_update_error .= sprintf(
     478                                                /* translators: %s: URL to WordPress Updates screen. */
     479                                                ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
     480                                                self_admin_url( 'update-core.php' )
     481                                        );
     482                                } elseif ( current_user_can( 'update_php' ) ) {
     483                                        $theme_update_error .= sprintf(
     484                                                /* translators: %s: URL to Update PHP page. */
     485                                                ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
     486                                                esc_url( wp_get_update_php_url() )
     487                                        );
     488                                        wp_update_php_annotation( '</p><p><em>', '</em>', false );
    507489                                }
    508                                 ?>
    509                         </p></div>
    510                 <?php endif; ?>
    511         <?php endif; ?>
    512 
    513         <?php
     490                        } elseif ( ! $theme['updateResponse']['compatibleWP'] ) {
     491                                $theme_update_error .= sprintf(
     492                                        /* translators: %s: Theme name. */
     493                                        __( 'There is a new version of %s available, but it does not work with your version of WordPress.' ),
     494                                        $theme['name']
     495                                );
     496                                if ( current_user_can( 'update_core' ) ) {
     497                                        $theme_update_error .= sprintf(
     498                                                /* translators: %s: URL to WordPress Updates screen. */
     499                                                ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
     500                                                self_admin_url( 'update-core.php' )
     501                                        );
     502                                }
     503                        } elseif ( ! $theme['updateResponse']['compatiblePHP'] ) {
     504                                $theme_update_error .= sprintf(
     505                                        /* translators: %s: Theme name. */
     506                                        __( 'There is a new version of %s available, but it does not work with your version of PHP.' ),
     507                                        $theme['name']
     508                                );
     509                                if ( current_user_can( 'update_php' ) ) {
     510                                        $theme_update_error .= sprintf(
     511                                                /* translators: %s: URL to Update PHP page. */
     512                                                ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
     513                                                esc_url( wp_get_update_php_url() )
     514                                        );
     515                                        wp_update_php_annotation( '</p><p><em>', '</em>', false );
     516                                }
     517                        }
     518                        wp_admin_notice(
     519                                $theme_update_error,
     520                                array(
     521                                        'type'               => 'error',
     522                                        'additional_classes' => array( 'notice-alt', 'inline', 'update-message' ),
     523                                )
     524                        );
     525                endif;
     526        endif;
     527
    514528        if ( ! $theme['compatibleWP'] || ! $theme['compatiblePHP'] ) {
    515529                $message = '';
     
    567581                );
    568582        }
    569         ?>
    570 
    571         <?php
     583
    572584        /* translators: %s: Theme name. */
    573585        $details_aria_label = sprintf( _x( 'View Theme Details for %s', 'theme' ), $theme['name'] );
     
    663675                <?php } ?>
    664676        </tr>
    665         <?php foreach ( $broken_themes as $broken_theme ) : ?>
     677        <?php
     678        foreach ( $broken_themes as $broken_theme ) :
     679                ?>
    666680                <tr>
    667681                        <td><?php echo $broken_theme->get( 'Name' ) ? $broken_theme->display( 'Name' ) : esc_html( $broken_theme->get_stylesheet() ); ?></td>
     
    724738                        ?>
    725739                </tr>
    726         <?php endforeach; ?>
     740                <?php
     741        endforeach;
     742        ?>
    727743</table>
    728744</div>
Note: See TracChangeset for help on using the changeset viewer.