|
@@ 1476-1478 (lines=3) @@
|
| 1473 |
|
* @return bool |
| 1474 |
|
*/ |
| 1475 |
|
public static function validate_posint( $value = 0, $request, $param ) { |
| 1476 |
|
if ( ! is_numeric( $value ) || $value <= 0 ) { |
| 1477 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a positive integer.', 'jetpack' ), $param ) ); |
| 1478 |
|
} |
| 1479 |
|
return true; |
| 1480 |
|
} |
| 1481 |
|
|
|
@@ 1590-1592 (lines=3) @@
|
| 1587 |
|
*/ |
| 1588 |
|
public static function validate_sharing_show( $value, $request, $param ) { |
| 1589 |
|
$views = array( 'index', 'post', 'page', 'attachment', 'jetpack-portfolio' ); |
| 1590 |
|
if ( ! array_intersect( $views, $value ) ) { |
| 1591 |
|
return new WP_Error( 'invalid_param', sprintf( |
| 1592 |
|
/* Translators: first variable is the name of a parameter passed to endpoint holding the post type where Sharing will be displayed, the second is a list of post types where Sharing can be displayed */ |
| 1593 |
|
esc_html__( '%1$s must be %2$s.', 'jetpack' ), $param, join( ', ', $views ) |
| 1594 |
|
) ); |
| 1595 |
|
} |
|
@@ 1736-1738 (lines=3) @@
|
| 1733 |
|
* @return bool |
| 1734 |
|
*/ |
| 1735 |
|
public static function validate_string( $value = '', $request, $param ) { |
| 1736 |
|
if ( ! is_string( $value ) ) { |
| 1737 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a string.', 'jetpack' ), $param ) ); |
| 1738 |
|
} |
| 1739 |
|
return true; |
| 1740 |
|
} |
| 1741 |
|
|