|
@@ 2377-2379 (lines=3) @@
|
| 2374 |
|
|
| 2375 |
|
// If it's an associative array, use the keys to check that the value is among those admitted. |
| 2376 |
|
$enum = ( count( array_filter( array_keys( $args['enum'] ), 'is_string' ) ) > 0 ) ? array_keys( $args['enum'] ) : $args['enum']; |
| 2377 |
|
if ( ! in_array( $value, $enum ) ) { |
| 2378 |
|
return new WP_Error( 'invalid_param_value', sprintf( |
| 2379 |
|
/* Translators: first variable is the parameter passed to endpoint that holds the list item, the second is a list of admitted values. */ |
| 2380 |
|
esc_html__( '%1$s must be one of %2$s', 'jetpack' ), $param, implode( ', ', $enum ) |
| 2381 |
|
) ); |
| 2382 |
|
} |
|
@@ 2405-2407 (lines=3) @@
|
| 2402 |
|
|
| 2403 |
|
$modules = Jetpack::get_available_modules(); |
| 2404 |
|
|
| 2405 |
|
if ( count( array_intersect( $value, $modules ) ) != count( $value ) ) { |
| 2406 |
|
return new WP_Error( 'invalid_param_value', sprintf( esc_html__( '%s must be a list of valid modules', 'jetpack' ), $param ) ); |
| 2407 |
|
} |
| 2408 |
|
|
| 2409 |
|
return true; |
| 2410 |
|
} |
|
@@ 2594-2596 (lines=3) @@
|
| 2591 |
|
$sharer = new Sharing_Service(); |
| 2592 |
|
$services = array_keys( $sharer->get_all_services() ); |
| 2593 |
|
|
| 2594 |
|
if ( ! empty( $value ) && ! in_array( $value, $services ) ) { |
| 2595 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s is not a registered custom sharing service.', 'jetpack' ), $param ) ); |
| 2596 |
|
} |
| 2597 |
|
|
| 2598 |
|
return true; |
| 2599 |
|
} |