Make WordPress Core

Changeset 18550


Ignore:
Timestamp:
08/16/2011 12:12:02 AM (13 years ago)
Author:
nacin
Message:

Clean up message handling logic in upload.php.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/upload.php

    r17900 r18550  
    156156<?php screen_icon(); ?>
    157157<h2><?php echo esc_html( $title ); ?> <a href="media-new.php" class="add-new-h2"><?php echo esc_html_x('Add New', 'file'); ?></a> <?php
    158 if ( isset($_REQUEST['s']) && $_REQUEST['s'] )
     158if ( ! empty( $_REQUEST['s'] ) )
    159159    printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', get_search_query() ); ?>
    160160</h2>
     
    162162<?php
    163163$message = '';
    164 if ( isset($_GET['posted']) && (int) $_GET['posted'] ) {
     164if ( ! empty( $_GET['posted'] ) ) {
    165165    $message = __('Media attachment updated.');
    166166    $_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']);
    167167}
    168168
    169 if ( isset($_GET['attached']) && (int) $_GET['attached'] ) {
    170     $attached = (int) $_GET['attached'];
     169if ( ! empty( $_GET['attached'] ) && $attached = absint( $_GET['attached'] ) ) {
    171170    $message = sprintf( _n('Reattached %d attachment.', 'Reattached %d attachments.', $attached), $attached );
    172171    $_SERVER['REQUEST_URI'] = remove_query_arg(array('attached'), $_SERVER['REQUEST_URI']);
    173172}
    174173
    175 if ( isset($_GET['deleted']) && (int) $_GET['deleted'] ) {
    176     $message = sprintf( _n( 'Media attachment permanently deleted.', '%d media attachments permanently deleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) );
     174if ( ! empty( $_GET['deleted'] ) && $deleted = absint( $_GET['deleted'] ) ) {
     175    $message = sprintf( _n( 'Media attachment permanently deleted.', '%d media attachments permanently deleted.', $deleted ), number_format_i18n( $_GET['deleted'] ) );
    177176    $_SERVER['REQUEST_URI'] = remove_query_arg(array('deleted'), $_SERVER['REQUEST_URI']);
    178177}
    179178
    180 if ( isset($_GET['trashed']) && (int) $_GET['trashed'] ) {
    181     $message = sprintf( _n( 'Media attachment moved to the trash.', '%d media attachments moved to the trash.', $_GET['trashed'] ), number_format_i18n( $_GET['trashed'] ) );
     179if ( ! empty( $_GET['trashed'] ) && $trashed = absint( $_GET['trashed'] ) ) {
     180    $message = sprintf( _n( 'Media attachment moved to the trash.', '%d media attachments moved to the trash.', $trashed ), number_format_i18n( $_GET['trashed'] ) );
    182181    $message .= ' <a href="' . esc_url( wp_nonce_url( 'upload.php?doaction=undo&action=untrash&ids='.(isset($_GET['ids']) ? $_GET['ids'] : ''), "bulk-media" ) ) . '">' . __('Undo') . '</a>';
    183182    $_SERVER['REQUEST_URI'] = remove_query_arg(array('trashed'), $_SERVER['REQUEST_URI']);
    184183}
    185184
    186 if ( isset($_GET['untrashed']) && (int) $_GET['untrashed'] ) {
    187     $message = sprintf( _n( 'Media attachment restored from the trash.', '%d media attachments restored from the trash.', $_GET['untrashed'] ), number_format_i18n( $_GET['untrashed'] ) );
     185if ( ! empty( $_GET['untrashed'] ) && $untrashed = absint( $_GET['untrashed'] ) ) {
     186    $message = sprintf( _n( 'Media attachment restored from the trash.', '%d media attachments restored from the trash.', $untrashed ), number_format_i18n( $_GET['untrashed'] ) );
    188187    $_SERVER['REQUEST_URI'] = remove_query_arg(array('untrashed'), $_SERVER['REQUEST_URI']);
    189188}
     
    195194$messages[5] = __('Media restored from the trash.');
    196195
    197 if ( isset($_GET['message']) && (int) $_GET['message'] ) {
    198     $message = $messages[$_GET['message']];
     196if ( ! empty( $_GET['message'] ) && isset( $messages[ $_GET['message'] ] ) ) {
     197    $message = $messages[ $_GET['message'] ];
    199198    $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']);
    200199}
Note: See TracChangeset for help on using the changeset viewer.