Make WordPress Core


Ignore:
Timestamp:
09/17/2023 03:21:07 PM (3 years ago)
Author:
costdev
Message:

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

Adds further usages of wp_admin_notice() in /wp-admin/includes/ on .notice-error, .notice-warning, .error, and .updated.

Ongoing task to implement new function across core.

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

Props joedolson, mukesh27, costdev.
See #57791.

File:
1 edited

Legend:

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

    r56571 r56599  
    10141014    $upload_dir = wp_upload_dir();
    10151015    if ( ! empty( $upload_dir['error'] ) ) :
    1016         ?>
    1017         <div class="error"><p><?php _e( 'Before you can upload your import file, you will need to fix the following error:' ); ?></p>
    1018         <p><strong><?php echo $upload_dir['error']; ?></strong></p></div>
    1019         <?php
     1016        $upload_directory_error  = '<p>' . __( 'Before you can upload your import file, you will need to fix the following error:' ) . '</p>';
     1017        $upload_directory_error .= '<p><strong>' . $upload_dir['error'] . '</strong></p>';
     1018        wp_admin_notice(
     1019            $upload_directory_error,
     1020            array(
     1021                'additonal_classes' => array( 'error' ),
     1022                'paragraph_wrap'    => false,
     1023            )
     1024        );
    10201025    else :
    10211026        ?>
     
    14351440                        $plugin = _get_plugin_from_callback( $box['callback'] );
    14361441                        if ( $plugin ) {
    1437                             ?>
    1438                             <div class="error inline">
    1439                                 <p>
    1440                                     <?php
    1441                                         /* translators: %s: The name of the plugin that generated this meta box. */
    1442                                         printf( __( 'This meta box, from the %s plugin, is not compatible with the block editor.' ), "<strong>{$plugin['Name']}</strong>" );
    1443                                     ?>
    1444                                 </p>
    1445                             </div>
    1446                             <?php
     1442                            $meta_box_not_compatible_message = sprintf(
     1443                                /* translators: %s: The name of the plugin that generated this meta box. */
     1444                                __( 'This meta box, from the %s plugin, is not compatible with the block editor.' ),
     1445                                "<strong>{$plugin['Name']}</strong>"
     1446                            );
     1447                            wp_admin_notice(
     1448                                $meta_box_not_compatible_message,
     1449                                array(
     1450                                    'additional_classes' => array( 'error', 'inline' ),
     1451                                )
     1452                            );
    14471453                        }
    14481454                    }
     
    26962702 */
    26972703function _local_storage_notice() {
    2698     ?>
    2699     <div id="local-storage-notice" class="hidden notice is-dismissible">
    2700     <p class="local-restore">
    2701         <?php _e( 'The backup of this post in your browser is different from the version below.' ); ?>
    2702         <button type="button" class="button restore-backup"><?php _e( 'Restore the backup' ); ?></button>
    2703     </p>
    2704     <p class="help">
    2705         <?php _e( 'This will replace the current editor content with the last backup version. You can use undo and redo in the editor to get the old content back or to return to the restored version.' ); ?>
    2706     </p>
    2707     </div>
    2708     <?php
     2704    $local_storage_message  = '<p class="local-restore">';
     2705    $local_storage_message .= __( 'The backup of this post in your browser is different from the version below.' );
     2706    $local_storage_message .= '<button type="button" class="button restore-backup">' . __( 'Restore the backup' ) . '</button></p>';
     2707    $local_storage_message .= '<p class="help">';
     2708    $local_storage_message .= __( 'This will replace the current editor content with the last backup version. You can use undo and redo in the editor to get the old content back or to return to the restored version.' );
     2709    $local_storage_message .= '</p>';
     2710
     2711    wp_admin_notice(
     2712        $local_storage_message,
     2713        array(
     2714            'id'                 => 'local-storage-notice',
     2715            'additional_classes' => array( 'hidden' ),
     2716            'dismissible'        => true,
     2717            'paragraph_wrap'     => false,
     2718        )
     2719    );
    27092720}
    27102721
Note: See TracChangeset for help on using the changeset viewer.