Skip to content

Commit

Permalink
Administration: Increase wp_admin_notice() usage in /wp-includes/.
Browse files Browse the repository at this point in the history
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.

git-svn-id: https://develop.svn.wordpress.org/trunk@56597 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
costdev committed Sep 16, 2023
1 parent 8161a8c commit 5cfb817
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 29 deletions.
8 changes: 7 additions & 1 deletion src/wp-includes/media-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,13 @@ function wp_print_media_templates() {
<div class="attachment-media-view {{ data.orientation }}">
<?php
if ( isset( $_GET['error'] ) && 'deprecated' === $_GET['error'] ) {
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>';
wp_admin_notice(
__( 'The Edit Media screen is deprecated as of WordPress 6.3. Please use the Media Library instead.' ),
array(
'id' => 'message',
'additional_classes' => array( 'error' ),
)
);
}
?>
<h2 class="screen-reader-text"><?php /* translators: Hidden accessibility text. */ _e( 'Attachment Preview' ); ?></h2>
Expand Down
24 changes: 18 additions & 6 deletions src/wp-includes/widgets/class-wp-widget-media-audio.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,25 @@ public function render_control_template_scripts() {
?>
<script type="text/html" id="tmpl-wp-media-widget-audio-preview">
<# if ( data.error && 'missing_attachment' === data.error ) { #>
<div class="notice notice-error notice-alt notice-missing-attachment">
<p><?php echo $this->l10n['missing_attachment']; ?></p>
</div>
<?php
wp_admin_notice(
$this->l10n['missing_attachment'],
array(
'type' => 'error',
'additional_classes' => array( 'notice-alt', 'notice-missing-attachment' ),
)
);
?>
<# } else if ( data.error ) { #>
<div class="notice notice-error notice-alt">
<p><?php _e( 'Unable to preview media due to an unknown error.' ); ?></p>
</div>
<?php
wp_admin_notice(
__( 'Unable to preview media due to an unknown error.' ),
array(
'type' => 'error',
'additional_classes' => array( 'notice-alt' ),
)
);
?>
<# } else if ( data.model && data.model.src ) { #>
<?php wp_underscore_audio_template(); ?>
<# } #>
Expand Down
24 changes: 18 additions & 6 deletions src/wp-includes/widgets/class-wp-widget-media-image.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,13 +363,25 @@ public function render_control_template_scripts() {
</script>
<script type="text/html" id="tmpl-wp-media-widget-image-preview">
<# if ( data.error && 'missing_attachment' === data.error ) { #>
<div class="notice notice-error notice-alt notice-missing-attachment">
<p><?php echo $this->l10n['missing_attachment']; ?></p>
</div>
<?php
wp_admin_notice(
$this->l10n['missing_attachment'],
array(
'type' => 'error',
'additional_classes' => array( 'notice-alt', 'notice-missing-attachment' ),
)
);
?>
<# } else if ( data.error ) { #>
<div class="notice notice-error notice-alt">
<p><?php _e( 'Unable to preview media due to an unknown error.' ); ?></p>
</div>
<?php
wp_admin_notice(
__( 'Unable to preview media due to an unknown error.' ),
array(
'type' => 'error',
'additional_classes' => array( 'notice-alt' ),
)
);
?>
<# } else if ( data.url ) { #>
<img class="attachment-thumb" src="{{ data.url }}" draggable="false" alt="{{ data.alt }}"
<# if ( ! data.alt && data.currentFilename ) { #>
Expand Down
36 changes: 27 additions & 9 deletions src/wp-includes/widgets/class-wp-widget-media-video.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,17 +228,35 @@ public function render_control_template_scripts() {
?>
<script type="text/html" id="tmpl-wp-media-widget-video-preview">
<# if ( data.error && 'missing_attachment' === data.error ) { #>
<div class="notice notice-error notice-alt notice-missing-attachment">
<p><?php echo $this->l10n['missing_attachment']; ?></p>
</div>
<?php
wp_admin_notice(
$this->l10n['missing_attachment'],
array(
'type' => 'error',
'additional_classes' => array( 'notice-alt', 'notice-missing-attachment' ),
)
);
?>
<# } else if ( data.error && 'unsupported_file_type' === data.error ) { #>
<div class="notice notice-error notice-alt notice-missing-attachment">
<p><?php echo $this->l10n['unsupported_file_type']; ?></p>
</div>
<?php
wp_admin_notice(
$this->l10n['unsupported_file_type'],
array(
'type' => 'error',
'additional_classes' => array( 'notice-alt', 'notice-missing-attachment' ),
)
);
?>
<# } else if ( data.error ) { #>
<div class="notice notice-error notice-alt">
<p><?php _e( 'Unable to preview media due to an unknown error.' ); ?></p>
</div>
<?php
wp_admin_notice(
__( 'Unable to preview media due to an unknown error.' ),
array(
'type' => 'error',
'additional_classes' => array( 'notice-alt' ),
)
);
?>
<# } else if ( data.is_oembed && data.model.poster ) { #>
<a href="{{ data.model.src }}" target="_blank" class="media-widget-video-link">
<img src="{{ data.model.poster }}" />
Expand Down
22 changes: 15 additions & 7 deletions src/wp-includes/widgets/class-wp-widget-text.php
Original file line number Diff line number Diff line change
Expand Up @@ -495,13 +495,21 @@ public function form( $instance ) {
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
<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'] ); ?>" />
</p>
<div class="notice inline notice-info notice-alt">
<?php if ( ! isset( $instance['visual'] ) ) : ?>
<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>
<?php else : ?>
<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>
<?php endif; ?>
</div>
<?php
if ( ! isset( $instance['visual'] ) ) {
$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?' );
} else {
$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?' );
}

wp_admin_notice(
$widget_info_message,
array(
'type' => 'info',
'additional_classes' => array( 'notice-alt', 'inline' ),
)
);
?>
<p>
<label for="<?php echo $this->get_field_id( 'text' ); ?>"><?php _e( 'Content:' ); ?></label>
<textarea class="widefat" rows="16" cols="20" id="<?php echo $this->get_field_id( 'text' ); ?>" name="<?php echo $this->get_field_name( 'text' ); ?>"><?php echo esc_textarea( $instance['text'] ); ?></textarea>
Expand Down

0 comments on commit 5cfb817

Please sign in to comment.