|
@@ 1712-1714 (lines=3) @@
|
| 1709 |
|
|
| 1710 |
|
// If it's an associative array, use the keys to check that the value is among those admitted. |
| 1711 |
|
$enum = ( count( array_filter( array_keys( $args['enum'] ), 'is_string' ) ) > 0 ) ? array_keys( $args['enum'] ) : $args['enum']; |
| 1712 |
|
if ( ! in_array( $value, $enum ) ) { |
| 1713 |
|
return new WP_Error( 'invalid_param_value', sprintf( |
| 1714 |
|
/* Translators: first variable is the parameter passed to endpoint that holds the list item, the second is a list of admitted values. */ |
| 1715 |
|
esc_html__( '%1$s must be one of %2$s', 'jetpack' ), $param, implode( ', ', $enum ) |
| 1716 |
|
) ); |
| 1717 |
|
} |
|
@@ 1799-1801 (lines=3) @@
|
| 1796 |
|
*/ |
| 1797 |
|
public static function validate_sharing_show( $value, $request, $param ) { |
| 1798 |
|
$views = array( 'index', 'post', 'page', 'attachment', 'jetpack-portfolio' ); |
| 1799 |
|
if ( ! is_array( $value ) ) { |
| 1800 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an array of post types.', 'jetpack' ), $param ) ); |
| 1801 |
|
} |
| 1802 |
|
if ( ! array_intersect( $views, $value ) ) { |
| 1803 |
|
return new WP_Error( 'invalid_param', sprintf( |
| 1804 |
|
/* 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 */ |
|
@@ 1802-1804 (lines=3) @@
|
| 1799 |
|
if ( ! is_array( $value ) ) { |
| 1800 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an array of post types.', 'jetpack' ), $param ) ); |
| 1801 |
|
} |
| 1802 |
|
if ( ! array_intersect( $views, $value ) ) { |
| 1803 |
|
return new WP_Error( 'invalid_param', sprintf( |
| 1804 |
|
/* 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 */ |
| 1805 |
|
esc_html__( '%1$s must be %2$s.', 'jetpack' ), $param, join( ', ', $views ) |
| 1806 |
|
) ); |
| 1807 |
|
} |
|
@@ 1911-1913 (lines=3) @@
|
| 1908 |
|
$sharer = new Sharing_Service(); |
| 1909 |
|
$services = array_keys( $sharer->get_all_services() ); |
| 1910 |
|
|
| 1911 |
|
if ( ! empty( $value ) && ! in_array( $value, $services ) ) { |
| 1912 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s is not a registered custom sharing service.', 'jetpack' ), $param ) ); |
| 1913 |
|
} |
| 1914 |
|
|
| 1915 |
|
return true; |
| 1916 |
|
} |