|
@@ 1649-1651 (lines=3) @@
|
| 1646 |
|
|
| 1647 |
|
// If it's an associative array, use the keys to check that the value is among those admitted. |
| 1648 |
|
$enum = ( count( array_filter( array_keys( $args['enum'] ), 'is_string' ) ) > 0 ) ? array_keys( $args['enum'] ) : $args['enum']; |
| 1649 |
|
if ( ! in_array( $value, $enum ) ) { |
| 1650 |
|
return new WP_Error( 'invalid_param_value', sprintf( |
| 1651 |
|
/* Translators: first variable is the parameter passed to endpoint that holds the list item, the second is a list of admitted values. */ |
| 1652 |
|
esc_html__( '%1$s must be one of %2$s', 'jetpack' ), $param, implode( ', ', $enum ) |
| 1653 |
|
) ); |
| 1654 |
|
} |
|
@@ 1677-1679 (lines=3) @@
|
| 1674 |
|
|
| 1675 |
|
$modules = Jetpack::get_available_modules(); |
| 1676 |
|
|
| 1677 |
|
if ( count( array_intersect( $value, $modules ) ) != count( $value ) ) { |
| 1678 |
|
return new WP_Error( 'invalid_param_value', sprintf( esc_html__( '%s must be a list of valid modules', 'jetpack' ), $param ) ); |
| 1679 |
|
} |
| 1680 |
|
|
| 1681 |
|
return true; |
| 1682 |
|
} |
|
@@ 1845-1847 (lines=3) @@
|
| 1842 |
|
$sharer = new Sharing_Service(); |
| 1843 |
|
$services = array_keys( $sharer->get_all_services() ); |
| 1844 |
|
|
| 1845 |
|
if ( ! empty( $value ) && ! in_array( $value, $services ) ) { |
| 1846 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s is not a registered custom sharing service.', 'jetpack' ), $param ) ); |
| 1847 |
|
} |
| 1848 |
|
|
| 1849 |
|
return true; |
| 1850 |
|
} |