Make WordPress Core


Ignore:
Timestamp:
09/14/2023 01:11:29 AM (10 months ago)
Author:
joedolson
Message:

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

Add usages of wp_admin_notice() and wp_get_admin_notice() on .notice-[type] in the root level of /wp-admin/includes. Ongoing task to implement new function across core.

Props costdev, joedolson.
See #57791.

File:
1 edited

Legend:

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

    r56446 r56571  
    818818
    819819    if ( ! $compatible_php ) {
    820         echo '<div class="notice notice-error notice-alt"><p>';
    821         _e( '<strong>Error:</strong> This plugin <strong>requires a newer version of PHP</strong>.' );
     820        $compatible_php_notice_message  = '<p>';
     821        $compatible_php_notice_message .= __( '<strong>Error:</strong> This plugin <strong>requires a newer version of PHP</strong>.' );
     822
    822823        if ( current_user_can( 'update_php' ) ) {
    823             printf(
     824            $compatible_php_notice_message .= sprintf(
    824825                /* translators: %s: URL to Update PHP page. */
    825826                ' ' . __( '<a href="%s" target="_blank">Click here to learn more about updating PHP</a>.' ),
    826827                esc_url( wp_get_update_php_url() )
    827             );
    828 
    829             wp_update_php_annotation( '</p><p><em>', '</em>' );
     828            ) . wp_update_php_annotation( '</p><p><em>', '</em>', false );
    830829        } else {
    831             echo '</p>';
    832         }
    833         echo '</div>';
     830            $compatible_php_notice_message .= '</p>';
     831        }
     832
     833        wp_admin_notice(
     834            $compatible_php_notice_message,
     835            array(
     836                'type'               => 'error',
     837                'additional_classes' => array( 'notice-alt' ),
     838                'paragraph_wrap'     => false,
     839            )
     840        );
    834841    }
    835842
    836843    if ( ! $tested_wp ) {
    837         echo '<div class="notice notice-warning notice-alt"><p>';
    838         _e( '<strong>Warning:</strong> This plugin <strong>has not been tested</strong> with your current version of WordPress.' );
    839         echo '</p></div>';
     844        wp_admin_notice(
     845            __( '<strong>Warning:</strong> This plugin <strong>has not been tested</strong> with your current version of WordPress.' ),
     846            array(
     847                'type'               => 'warning',
     848                'additional_classes' => array( 'notice-alt' ),
     849            )
     850        );
    840851    } elseif ( ! $compatible_wp ) {
    841         echo '<div class="notice notice-error notice-alt"><p>';
    842         _e( '<strong>Error:</strong> This plugin <strong>requires a newer version of WordPress</strong>.' );
     852        $compatible_wp_notice_message = __( '<strong>Error:</strong> This plugin <strong>requires a newer version of WordPress</strong>.' );
    843853        if ( current_user_can( 'update_core' ) ) {
    844             printf(
     854            $compatible_wp_notice_message .= sprintf(
    845855                /* translators: %s: URL to WordPress Updates screen. */
    846856                ' ' . __( '<a href="%s" target="_parent">Click here to update WordPress</a>.' ),
     
    848858            );
    849859        }
    850         echo '</p></div>';
     860
     861        wp_admin_notice(
     862            $compatible_wp_notice_message,
     863            array(
     864                'type'               => 'error',
     865                'additional_classes' => array( 'notice-alt' ),
     866            )
     867        );
    851868    }
    852869
Note: See TracChangeset for help on using the changeset viewer.