Improve localization for `WP_Date_Query` error strings.

* Don't create an extra variable for the string when it's only used once.
* Avoid using `<code>` HTML tags inside of translatable string.
* Improve data types and escaping on sprintfed values.

Props dd32.
Fixes #25834.
Built from https://develop.svn.wordpress.org/trunk@30300


git-svn-id: http://core.svn.wordpress.org/trunk@30299 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Boone Gorges 2014-11-11 13:24:24 +00:00
parent 21467af4db
commit 4cf91d7c1d
2 changed files with 12 additions and 14 deletions

View File

@ -298,10 +298,6 @@ class WP_Date_Query {
$valid = $this->validate_date_values( $date_query['after'] );
}
// Message template for the min-max-check.
/* translators: Date query invalid date message: 1: invalid value, 2: type of value, 3: minimum valid value, 4: maximum valid value */
$min_max_msg = __( 'Invalid value <code>%1$s</code> for <strong>%2$s</strong>. Excepted value should between <code>%3$d</code> and </code>%4$d</code>.' );
// Array containing all min-max checks.
$min_max_checks = array();
@ -387,12 +383,14 @@ class WP_Date_Query {
$is_between = $date_query[ $key ] >= $check['min'] && $date_query[ $key ] <= $check['max'];
if ( ! $is_between ) {
$error = sprintf(
$min_max_msg,
esc_html( $date_query[ $key ] ),
$key,
$check['min'],
$check['max']
/* translators: Date query invalid date message: 1: invalid value, 2: type of value, 3: minimum valid value, 4: maximum valid value */
__( 'Invalid value %1$s for %2$s. Expected value should between %3$s and %4$s.' ),
'<code>' . esc_html( $date_query[ $key ] ) . '</code>',
'<code>' . esc_html( $key ) . '</code>',
'<code>' . esc_html( $check['min'] ) . '</code>',
'<code>' . esc_html( $check['max'] ) . '</code>'
);
_doing_it_wrong( __CLASS__, $error, '4.1.0' );
@ -417,10 +415,10 @@ class WP_Date_Query {
if ( ! checkdate( $date_query['month'], $date_query['day'], $date_query['year'] ) ) {
/* translators: 1: year, 2: month, 3: day of month */
$day_month_year_error_msg = sprintf(
__( 'The following values do not describe a valid date: year <code>%1$s</code>, month <code>%2$s</code>, day <code>%3$s</code>.' ),
esc_html( $date_query['year'] ),
esc_html( $date_query['month'] ),
esc_html( $date_query['day'] )
__( 'The following values do not describe a valid date: year %1$s, month %2$s, day %3$s.' ),
'<code>' . esc_html( $date_query['year'] ) . '</code>',
'<code>' . esc_html( $date_query['month'] ) . '</code>',
'<code>' . esc_html( $date_query['day'] ) . '</code>'
);
$valid = false;

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.1-alpha-30299';
$wp_version = '4.1-alpha-30300';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.