|
@@ 1631-1633 (lines=3) @@
|
| 1628 |
|
* @return bool |
| 1629 |
|
*/ |
| 1630 |
|
public static function validate_posint( $value = 0, $request, $param ) { |
| 1631 |
|
if ( ! is_numeric( $value ) || $value <= 0 ) { |
| 1632 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a positive integer.', 'jetpack' ), $param ) ); |
| 1633 |
|
} |
| 1634 |
|
return true; |
| 1635 |
|
} |
| 1636 |
|
|
|
@@ 1745-1747 (lines=3) @@
|
| 1742 |
|
*/ |
| 1743 |
|
public static function validate_sharing_show( $value, $request, $param ) { |
| 1744 |
|
$views = array( 'index', 'post', 'page', 'attachment', 'jetpack-portfolio' ); |
| 1745 |
|
if ( ! array_intersect( $views, $value ) ) { |
| 1746 |
|
return new WP_Error( 'invalid_param', sprintf( |
| 1747 |
|
/* 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 */ |
| 1748 |
|
esc_html__( '%1$s must be %2$s.', 'jetpack' ), $param, join( ', ', $views ) |
| 1749 |
|
) ); |
| 1750 |
|
} |
|
@@ 1891-1893 (lines=3) @@
|
| 1888 |
|
* @return bool |
| 1889 |
|
*/ |
| 1890 |
|
public static function validate_string( $value = '', $request, $param ) { |
| 1891 |
|
if ( ! is_string( $value ) ) { |
| 1892 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a string.', 'jetpack' ), $param ) ); |
| 1893 |
|
} |
| 1894 |
|
return true; |
| 1895 |
|
} |
| 1896 |
|
|