|
@@ 2450-2452 (lines=3) @@
|
| 2447 |
|
|
| 2448 |
|
// If it's an associative array, use the keys to check that the value is among those admitted. |
| 2449 |
|
$enum = ( count( array_filter( array_keys( $args['enum'] ), 'is_string' ) ) > 0 ) ? array_keys( $args['enum'] ) : $args['enum']; |
| 2450 |
|
if ( ! in_array( $value, $enum ) ) { |
| 2451 |
|
return new WP_Error( 'invalid_param_value', sprintf( |
| 2452 |
|
/* Translators: first variable is the parameter passed to endpoint that holds the list item, the second is a list of admitted values. */ |
| 2453 |
|
esc_html__( '%1$s must be one of %2$s', 'jetpack' ), $param, implode( ', ', $enum ) |
| 2454 |
|
) ); |
| 2455 |
|
} |
|
@@ 2478-2480 (lines=3) @@
|
| 2475 |
|
|
| 2476 |
|
$modules = Jetpack::get_available_modules(); |
| 2477 |
|
|
| 2478 |
|
if ( count( array_intersect( $value, $modules ) ) != count( $value ) ) { |
| 2479 |
|
return new WP_Error( 'invalid_param_value', sprintf( esc_html__( '%s must be a list of valid modules', 'jetpack' ), $param ) ); |
| 2480 |
|
} |
| 2481 |
|
|
| 2482 |
|
return true; |
| 2483 |
|
} |
|
@@ 2667-2669 (lines=3) @@
|
| 2664 |
|
$sharer = new Sharing_Service(); |
| 2665 |
|
$services = array_keys( $sharer->get_all_services() ); |
| 2666 |
|
|
| 2667 |
|
if ( ! empty( $value ) && ! in_array( $value, $services ) ) { |
| 2668 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s is not a registered custom sharing service.', 'jetpack' ), $param ) ); |
| 2669 |
|
} |
| 2670 |
|
|
| 2671 |
|
return true; |
| 2672 |
|
} |