|
@@ 1617-1619 (lines=3) @@
|
| 1614 |
|
* @return bool |
| 1615 |
|
*/ |
| 1616 |
|
public static function validate_posint( $value = 0, $request, $param ) { |
| 1617 |
|
if ( ! is_numeric( $value ) || $value <= 0 ) { |
| 1618 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a positive integer.', 'jetpack' ), $param ) ); |
| 1619 |
|
} |
| 1620 |
|
return true; |
| 1621 |
|
} |
| 1622 |
|
|
|
@@ 1731-1733 (lines=3) @@
|
| 1728 |
|
*/ |
| 1729 |
|
public static function validate_sharing_show( $value, $request, $param ) { |
| 1730 |
|
$views = array( 'index', 'post', 'page', 'attachment', 'jetpack-portfolio' ); |
| 1731 |
|
if ( ! array_intersect( $views, $value ) ) { |
| 1732 |
|
return new WP_Error( 'invalid_param', sprintf( |
| 1733 |
|
/* 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 */ |
| 1734 |
|
esc_html__( '%1$s must be %2$s.', 'jetpack' ), $param, join( ', ', $views ) |
| 1735 |
|
) ); |
| 1736 |
|
} |
|
@@ 1877-1879 (lines=3) @@
|
| 1874 |
|
* @return bool |
| 1875 |
|
*/ |
| 1876 |
|
public static function validate_string( $value = '', $request, $param ) { |
| 1877 |
|
if ( ! is_string( $value ) ) { |
| 1878 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a string.', 'jetpack' ), $param ) ); |
| 1879 |
|
} |
| 1880 |
|
return true; |
| 1881 |
|
} |
| 1882 |
|
|