|
@@ 2335-2337 (lines=3) @@
|
| 2332 |
|
|
| 2333 |
|
// If it's an associative array, use the keys to check that the value is among those admitted. |
| 2334 |
|
$enum = ( count( array_filter( array_keys( $args['enum'] ), 'is_string' ) ) > 0 ) ? array_keys( $args['enum'] ) : $args['enum']; |
| 2335 |
|
if ( ! in_array( $value, $enum ) ) { |
| 2336 |
|
return new WP_Error( 'invalid_param_value', sprintf( |
| 2337 |
|
/* Translators: first variable is the parameter passed to endpoint that holds the list item, the second is a list of admitted values. */ |
| 2338 |
|
esc_html__( '%1$s must be one of %2$s', 'jetpack' ), $param, implode( ', ', $enum ) |
| 2339 |
|
) ); |
| 2340 |
|
} |
|
@@ 2363-2365 (lines=3) @@
|
| 2360 |
|
|
| 2361 |
|
$modules = Jetpack::get_available_modules(); |
| 2362 |
|
|
| 2363 |
|
if ( count( array_intersect( $value, $modules ) ) != count( $value ) ) { |
| 2364 |
|
return new WP_Error( 'invalid_param_value', sprintf( esc_html__( '%s must be a list of valid modules', 'jetpack' ), $param ) ); |
| 2365 |
|
} |
| 2366 |
|
|
| 2367 |
|
return true; |
| 2368 |
|
} |
|
@@ 2552-2554 (lines=3) @@
|
| 2549 |
|
$sharer = new Sharing_Service(); |
| 2550 |
|
$services = array_keys( $sharer->get_all_services() ); |
| 2551 |
|
|
| 2552 |
|
if ( ! empty( $value ) && ! in_array( $value, $services ) ) { |
| 2553 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s is not a registered custom sharing service.', 'jetpack' ), $param ) ); |
| 2554 |
|
} |
| 2555 |
|
|
| 2556 |
|
return true; |
| 2557 |
|
} |