|
@@ 1734-1736 (lines=3) @@
|
| 1731 |
|
|
| 1732 |
|
// If it's an associative array, use the keys to check that the value is among those admitted. |
| 1733 |
|
$enum = ( count( array_filter( array_keys( $args['enum'] ), 'is_string' ) ) > 0 ) ? array_keys( $args['enum'] ) : $args['enum']; |
| 1734 |
|
if ( ! in_array( $value, $enum ) ) { |
| 1735 |
|
return new WP_Error( 'invalid_param_value', sprintf( |
| 1736 |
|
/* Translators: first variable is the parameter passed to endpoint that holds the list item, the second is a list of admitted values. */ |
| 1737 |
|
esc_html__( '%1$s must be one of %2$s', 'jetpack' ), $param, implode( ', ', $enum ) |
| 1738 |
|
) ); |
| 1739 |
|
} |
|
@@ 1762-1764 (lines=3) @@
|
| 1759 |
|
|
| 1760 |
|
$modules = Jetpack::get_available_modules(); |
| 1761 |
|
|
| 1762 |
|
if ( count( array_intersect( $value, $modules ) ) != count( $value ) ) { |
| 1763 |
|
return new WP_Error( 'invalid_param_value', sprintf( esc_html__( '%s must be a list of valid modules', 'jetpack' ), $param ) ); |
| 1764 |
|
} |
| 1765 |
|
|
| 1766 |
|
return true; |
| 1767 |
|
} |
|
@@ 1933-1935 (lines=3) @@
|
| 1930 |
|
$sharer = new Sharing_Service(); |
| 1931 |
|
$services = array_keys( $sharer->get_all_services() ); |
| 1932 |
|
|
| 1933 |
|
if ( ! empty( $value ) && ! in_array( $value, $services ) ) { |
| 1934 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s is not a registered custom sharing service.', 'jetpack' ), $param ) ); |
| 1935 |
|
} |
| 1936 |
|
|
| 1937 |
|
return true; |
| 1938 |
|
} |