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. git-svn-id: https://develop.svn.wordpress.org/trunk@30300 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
c2fb136b47
commit
a26cf7ba6e
|
@ -298,10 +298,6 @@ class WP_Date_Query {
|
||||||
$valid = $this->validate_date_values( $date_query['after'] );
|
$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.
|
// Array containing all min-max checks.
|
||||||
$min_max_checks = array();
|
$min_max_checks = array();
|
||||||
|
|
||||||
|
@ -387,12 +383,14 @@ class WP_Date_Query {
|
||||||
$is_between = $date_query[ $key ] >= $check['min'] && $date_query[ $key ] <= $check['max'];
|
$is_between = $date_query[ $key ] >= $check['min'] && $date_query[ $key ] <= $check['max'];
|
||||||
|
|
||||||
if ( ! $is_between ) {
|
if ( ! $is_between ) {
|
||||||
|
|
||||||
$error = sprintf(
|
$error = sprintf(
|
||||||
$min_max_msg,
|
/* translators: Date query invalid date message: 1: invalid value, 2: type of value, 3: minimum valid value, 4: maximum valid value */
|
||||||
esc_html( $date_query[ $key ] ),
|
__( 'Invalid value %1$s for %2$s. Expected value should between %3$s and %4$s.' ),
|
||||||
$key,
|
'<code>' . esc_html( $date_query[ $key ] ) . '</code>',
|
||||||
$check['min'],
|
'<code>' . esc_html( $key ) . '</code>',
|
||||||
$check['max']
|
'<code>' . esc_html( $check['min'] ) . '</code>',
|
||||||
|
'<code>' . esc_html( $check['max'] ) . '</code>'
|
||||||
);
|
);
|
||||||
|
|
||||||
_doing_it_wrong( __CLASS__, $error, '4.1.0' );
|
_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'] ) ) {
|
if ( ! checkdate( $date_query['month'], $date_query['day'], $date_query['year'] ) ) {
|
||||||
/* translators: 1: year, 2: month, 3: day of month */
|
/* translators: 1: year, 2: month, 3: day of month */
|
||||||
$day_month_year_error_msg = sprintf(
|
$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>.' ),
|
__( 'The following values do not describe a valid date: year %1$s, month %2$s, day %3$s.' ),
|
||||||
esc_html( $date_query['year'] ),
|
'<code>' . esc_html( $date_query['year'] ) . '</code>',
|
||||||
esc_html( $date_query['month'] ),
|
'<code>' . esc_html( $date_query['month'] ) . '</code>',
|
||||||
esc_html( $date_query['day'] )
|
'<code>' . esc_html( $date_query['day'] ) . '</code>'
|
||||||
);
|
);
|
||||||
|
|
||||||
$valid = false;
|
$valid = false;
|
||||||
|
|
Loading…
Reference in New Issue