|
@@ 2632-2634 (lines=3) @@
|
| 2629 |
|
|
| 2630 |
|
// If it's an associative array, use the keys to check that the value is among those admitted. |
| 2631 |
|
$enum = ( count( array_filter( array_keys( $args['enum'] ), 'is_string' ) ) > 0 ) ? array_keys( $args['enum'] ) : $args['enum']; |
| 2632 |
|
if ( ! in_array( $value, $enum ) ) { |
| 2633 |
|
return new WP_Error( 'invalid_param_value', sprintf( |
| 2634 |
|
/* Translators: first variable is the parameter passed to endpoint that holds the list item, the second is a list of admitted values. */ |
| 2635 |
|
esc_html__( '%1$s must be one of %2$s', 'jetpack' ), $param, implode( ', ', $enum ) |
| 2636 |
|
) ); |
| 2637 |
|
} |
|
@@ 2660-2662 (lines=3) @@
|
| 2657 |
|
|
| 2658 |
|
$modules = Jetpack::get_available_modules(); |
| 2659 |
|
|
| 2660 |
|
if ( count( array_intersect( $value, $modules ) ) != count( $value ) ) { |
| 2661 |
|
return new WP_Error( 'invalid_param_value', sprintf( esc_html__( '%s must be a list of valid modules', 'jetpack' ), $param ) ); |
| 2662 |
|
} |
| 2663 |
|
|
| 2664 |
|
return true; |
| 2665 |
|
} |
|
@@ 2849-2851 (lines=3) @@
|
| 2846 |
|
$sharer = new Sharing_Service(); |
| 2847 |
|
$services = array_keys( $sharer->get_all_services() ); |
| 2848 |
|
|
| 2849 |
|
if ( ! empty( $value ) && ! in_array( $value, $services ) ) { |
| 2850 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s is not a registered custom sharing service.', 'jetpack' ), $param ) ); |
| 2851 |
|
} |
| 2852 |
|
|
| 2853 |
|
return true; |
| 2854 |
|
} |