|
@@ 2676-2678 (lines=3) @@
|
| 2673 |
|
|
| 2674 |
|
// If it's an associative array, use the keys to check that the value is among those admitted. |
| 2675 |
|
$enum = ( count( array_filter( array_keys( $args['enum'] ), 'is_string' ) ) > 0 ) ? array_keys( $args['enum'] ) : $args['enum']; |
| 2676 |
|
if ( ! in_array( $value, $enum ) ) { |
| 2677 |
|
return new WP_Error( 'invalid_param_value', sprintf( |
| 2678 |
|
/* Translators: first variable is the parameter passed to endpoint that holds the list item, the second is a list of admitted values. */ |
| 2679 |
|
esc_html__( '%1$s must be one of %2$s', 'jetpack' ), $param, implode( ', ', $enum ) |
| 2680 |
|
) ); |
| 2681 |
|
} |
|
@@ 2704-2706 (lines=3) @@
|
| 2701 |
|
|
| 2702 |
|
$modules = Jetpack::get_available_modules(); |
| 2703 |
|
|
| 2704 |
|
if ( count( array_intersect( $value, $modules ) ) != count( $value ) ) { |
| 2705 |
|
return new WP_Error( 'invalid_param_value', sprintf( esc_html__( '%s must be a list of valid modules', 'jetpack' ), $param ) ); |
| 2706 |
|
} |
| 2707 |
|
|
| 2708 |
|
return true; |
| 2709 |
|
} |
|
@@ 2893-2895 (lines=3) @@
|
| 2890 |
|
$sharer = new Sharing_Service(); |
| 2891 |
|
$services = array_keys( $sharer->get_all_services() ); |
| 2892 |
|
|
| 2893 |
|
if ( ! empty( $value ) && ! in_array( $value, $services ) ) { |
| 2894 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s is not a registered custom sharing service.', 'jetpack' ), $param ) ); |
| 2895 |
|
} |
| 2896 |
|
|
| 2897 |
|
return true; |
| 2898 |
|
} |