Coding Standards: Correct `sprintf()` calls for messages in `wp-admin/upload.php`.
This ensures that `sprintf()` is not unnecessarily applied to strings without any placeholders. Follow-up to [31941], [31619], [36328], [55178]. See #57839. Built from https://develop.svn.wordpress.org/trunk@55631 git-svn-id: http://core.svn.wordpress.org/trunk@55143 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
4f6e5a3b7f
commit
03c3f90824
|
@ -16,72 +16,98 @@ if ( ! current_user_can( 'upload_files' ) ) {
|
|||
$message = '';
|
||||
if ( ! empty( $_GET['posted'] ) ) {
|
||||
$message = __( 'Media file updated.' );
|
||||
|
||||
$_SERVER['REQUEST_URI'] = remove_query_arg( array( 'posted' ), $_SERVER['REQUEST_URI'] );
|
||||
unset( $_GET['posted'] );
|
||||
}
|
||||
|
||||
if ( ! empty( $_GET['attached'] ) && absint( $_GET['attached'] ) ) {
|
||||
$attached = absint( $_GET['attached'] );
|
||||
|
||||
if ( 1 === $attached ) {
|
||||
$message = __( 'Media file attached.' );
|
||||
} else {
|
||||
$message = sprintf(
|
||||
/* translators: %s: Number of media files. */
|
||||
$message = _n( '%s media file attached.', '%s media files attached.', $attached );
|
||||
_n( '%s media file attached.', '%s media files attached.', $attached ),
|
||||
number_format_i18n( $attached )
|
||||
);
|
||||
}
|
||||
$message = sprintf( $message, $attached );
|
||||
|
||||
$_SERVER['REQUEST_URI'] = remove_query_arg( array( 'detach', 'attached' ), $_SERVER['REQUEST_URI'] );
|
||||
unset( $_GET['detach'], $_GET['attached'] );
|
||||
}
|
||||
|
||||
if ( ! empty( $_GET['detach'] ) && absint( $_GET['detach'] ) ) {
|
||||
$detached = absint( $_GET['detach'] );
|
||||
|
||||
if ( 1 === $detached ) {
|
||||
$message = __( 'Media file detached.' );
|
||||
} else {
|
||||
$message = sprintf(
|
||||
/* translators: %s: Number of media files. */
|
||||
$message = _n( '%s media file detached.', '%s media files detached.', $detached );
|
||||
_n( '%s media file detached.', '%s media files detached.', $detached ),
|
||||
number_format_i18n( $detached )
|
||||
);
|
||||
}
|
||||
$message = sprintf( $message, $detached );
|
||||
|
||||
$_SERVER['REQUEST_URI'] = remove_query_arg( array( 'detach', 'attached' ), $_SERVER['REQUEST_URI'] );
|
||||
unset( $_GET['detach'], $_GET['attached'] );
|
||||
}
|
||||
|
||||
if ( ! empty( $_GET['deleted'] ) && absint( $_GET['deleted'] ) ) {
|
||||
$deleted = absint( $_GET['deleted'] );
|
||||
|
||||
if ( 1 === $deleted ) {
|
||||
$message = __( 'Media file permanently deleted.' );
|
||||
} else {
|
||||
$message = sprintf(
|
||||
/* translators: %s: Number of media files. */
|
||||
$message = _n( '%s media file permanently deleted.', '%s media files permanently deleted.', $deleted );
|
||||
_n( '%s media file permanently deleted.', '%s media files permanently deleted.', $deleted ),
|
||||
number_format_i18n( $deleted )
|
||||
);
|
||||
}
|
||||
$message = sprintf( $message, $deleted );
|
||||
|
||||
$_SERVER['REQUEST_URI'] = remove_query_arg( array( 'deleted' ), $_SERVER['REQUEST_URI'] );
|
||||
unset( $_GET['deleted'] );
|
||||
}
|
||||
|
||||
if ( ! empty( $_GET['trashed'] ) && absint( $_GET['trashed'] ) ) {
|
||||
$trashed = absint( $_GET['trashed'] );
|
||||
|
||||
if ( 1 === $trashed ) {
|
||||
$message = __( 'Media file moved to the Trash.' );
|
||||
} else {
|
||||
$message = sprintf(
|
||||
/* translators: %s: Number of media files. */
|
||||
$message = _n( '%s media file moved to the Trash.', '%s media files moved to the Trash.', $trashed );
|
||||
_n( '%s media file moved to the Trash.', '%s media files moved to the Trash.', $trashed ),
|
||||
number_format_i18n( $trashed )
|
||||
);
|
||||
}
|
||||
$message = sprintf( $message, $trashed );
|
||||
$message .= ' <a href="' . esc_url( wp_nonce_url( 'upload.php?doaction=undo&action=untrash&ids=' . ( isset( $_GET['ids'] ) ? $_GET['ids'] : '' ), 'bulk-media' ) ) . '">' . __( 'Undo' ) . '</a>';
|
||||
|
||||
$message .= sprintf(
|
||||
' <a href="%1$s">%2$s</a>',
|
||||
esc_url( wp_nonce_url( 'upload.php?doaction=undo&action=untrash&ids=' . ( isset( $_GET['ids'] ) ? $_GET['ids'] : '' ), 'bulk-media' ) ),
|
||||
__( 'Undo' )
|
||||
);
|
||||
|
||||
$_SERVER['REQUEST_URI'] = remove_query_arg( array( 'trashed' ), $_SERVER['REQUEST_URI'] );
|
||||
unset( $_GET['trashed'] );
|
||||
}
|
||||
|
||||
if ( ! empty( $_GET['untrashed'] ) && absint( $_GET['untrashed'] ) ) {
|
||||
$untrashed = absint( $_GET['untrashed'] );
|
||||
|
||||
if ( 1 === $untrashed ) {
|
||||
$message = __( 'Media file restored from the Trash.' );
|
||||
} else {
|
||||
$message = sprintf(
|
||||
/* translators: %s: Number of media files. */
|
||||
$message = _n( '%s media file restored from the Trash.', '%s media files restored from the Trash.', $untrashed );
|
||||
_n( '%s media file restored from the Trash.', '%s media files restored from the Trash.', $untrashed ),
|
||||
number_format_i18n( $untrashed )
|
||||
);
|
||||
}
|
||||
$message = sprintf( $message, $untrashed );
|
||||
|
||||
$_SERVER['REQUEST_URI'] = remove_query_arg( array( 'untrashed' ), $_SERVER['REQUEST_URI'] );
|
||||
unset( $_GET['untrashed'] );
|
||||
}
|
||||
|
@ -89,11 +115,16 @@ if ( ! empty( $_GET['untrashed'] ) && absint( $_GET['untrashed'] ) ) {
|
|||
$messages[1] = __( 'Media file updated.' );
|
||||
$messages[2] = __( 'Media file permanently deleted.' );
|
||||
$messages[3] = __( 'Error saving media file.' );
|
||||
$messages[4] = __( 'Media file moved to the Trash.' ) . ' <a href="' . esc_url( wp_nonce_url( 'upload.php?doaction=undo&action=untrash&ids=' . ( isset( $_GET['ids'] ) ? $_GET['ids'] : '' ), 'bulk-media' ) ) . '">' . __( 'Undo' ) . '</a>';
|
||||
$messages[4] = __( 'Media file moved to the Trash.' ) . sprintf(
|
||||
' <a href="%1$s">%2$s</a>',
|
||||
esc_url( wp_nonce_url( 'upload.php?doaction=undo&action=untrash&ids=' . ( isset( $_GET['ids'] ) ? $_GET['ids'] : '' ), 'bulk-media' ) ),
|
||||
__( 'Undo' )
|
||||
);
|
||||
$messages[5] = __( 'Media file restored from the Trash.' );
|
||||
|
||||
if ( ! empty( $_GET['message'] ) && isset( $messages[ $_GET['message'] ] ) ) {
|
||||
$message = $messages[ $_GET['message'] ];
|
||||
|
||||
$_SERVER['REQUEST_URI'] = remove_query_arg( array( 'message' ), $_SERVER['REQUEST_URI'] );
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.3-alpha-55630';
|
||||
$wp_version = '6.3-alpha-55631';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue