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