|
@@ 1704-1706 (lines=3) @@
|
| 1701 |
|
|
| 1702 |
|
// If it's an associative array, use the keys to check that the value is among those admitted. |
| 1703 |
|
$enum = ( count( array_filter( array_keys( $args['enum'] ), 'is_string' ) ) > 0 ) ? array_keys( $args['enum'] ) : $args['enum']; |
| 1704 |
|
if ( ! in_array( $value, $enum ) ) { |
| 1705 |
|
return new WP_Error( 'invalid_param_value', sprintf( |
| 1706 |
|
/* Translators: first variable is the parameter passed to endpoint that holds the list item, the second is a list of admitted values. */ |
| 1707 |
|
esc_html__( '%1$s must be one of %2$s', 'jetpack' ), $param, implode( ', ', $enum ) |
| 1708 |
|
) ); |
| 1709 |
|
} |
|
@@ 1732-1734 (lines=3) @@
|
| 1729 |
|
|
| 1730 |
|
$modules = Jetpack::get_available_modules(); |
| 1731 |
|
|
| 1732 |
|
if ( count( array_intersect( $value, $modules ) ) != count( $value ) ) { |
| 1733 |
|
return new WP_Error( 'invalid_param_value', sprintf( esc_html__( '%s must be a list of valid modules', 'jetpack' ), $param ) ); |
| 1734 |
|
} |
| 1735 |
|
|
| 1736 |
|
return true; |
| 1737 |
|
} |
|
@@ 1921-1923 (lines=3) @@
|
| 1918 |
|
$sharer = new Sharing_Service(); |
| 1919 |
|
$services = array_keys( $sharer->get_all_services() ); |
| 1920 |
|
|
| 1921 |
|
if ( ! empty( $value ) && ! in_array( $value, $services ) ) { |
| 1922 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s is not a registered custom sharing service.', 'jetpack' ), $param ) ); |
| 1923 |
|
} |
| 1924 |
|
|
| 1925 |
|
return true; |
| 1926 |
|
} |