|
@@ 2437-2439 (lines=3) @@
|
| 2434 |
|
|
| 2435 |
|
// If it's an associative array, use the keys to check that the value is among those admitted. |
| 2436 |
|
$enum = ( count( array_filter( array_keys( $args['enum'] ), 'is_string' ) ) > 0 ) ? array_keys( $args['enum'] ) : $args['enum']; |
| 2437 |
|
if ( ! in_array( $value, $enum ) ) { |
| 2438 |
|
return new WP_Error( 'invalid_param_value', sprintf( |
| 2439 |
|
/* Translators: first variable is the parameter passed to endpoint that holds the list item, the second is a list of admitted values. */ |
| 2440 |
|
esc_html__( '%1$s must be one of %2$s', 'jetpack' ), $param, implode( ', ', $enum ) |
| 2441 |
|
) ); |
| 2442 |
|
} |
|
@@ 2465-2467 (lines=3) @@
|
| 2462 |
|
|
| 2463 |
|
$modules = Jetpack::get_available_modules(); |
| 2464 |
|
|
| 2465 |
|
if ( count( array_intersect( $value, $modules ) ) != count( $value ) ) { |
| 2466 |
|
return new WP_Error( 'invalid_param_value', sprintf( esc_html__( '%s must be a list of valid modules', 'jetpack' ), $param ) ); |
| 2467 |
|
} |
| 2468 |
|
|
| 2469 |
|
return true; |
| 2470 |
|
} |
|
@@ 2654-2656 (lines=3) @@
|
| 2651 |
|
$sharer = new Sharing_Service(); |
| 2652 |
|
$services = array_keys( $sharer->get_all_services() ); |
| 2653 |
|
|
| 2654 |
|
if ( ! empty( $value ) && ! in_array( $value, $services ) ) { |
| 2655 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s is not a registered custom sharing service.', 'jetpack' ), $param ) ); |
| 2656 |
|
} |
| 2657 |
|
|
| 2658 |
|
return true; |
| 2659 |
|
} |