|
@@ 1658-1660 (lines=3) @@
|
| 1655 |
|
|
| 1656 |
|
// If it's an associative array, use the keys to check that the value is among those admitted. |
| 1657 |
|
$enum = ( count( array_filter( array_keys( $args['enum'] ), 'is_string' ) ) > 0 ) ? array_keys( $args['enum'] ) : $args['enum']; |
| 1658 |
|
if ( ! in_array( $value, $enum ) ) { |
| 1659 |
|
return new WP_Error( 'invalid_param_value', sprintf( |
| 1660 |
|
/* Translators: first variable is the parameter passed to endpoint that holds the list item, the second is a list of admitted values. */ |
| 1661 |
|
esc_html__( '%1$s must be one of %2$s', 'jetpack' ), $param, implode( ', ', $enum ) |
| 1662 |
|
) ); |
| 1663 |
|
} |
|
@@ 1686-1688 (lines=3) @@
|
| 1683 |
|
|
| 1684 |
|
$modules = Jetpack::get_available_modules(); |
| 1685 |
|
|
| 1686 |
|
if ( count( array_intersect( $value, $modules ) ) != count( $value ) ) { |
| 1687 |
|
return new WP_Error( 'invalid_param_value', sprintf( esc_html__( '%s must be a list of valid modules', 'jetpack' ), $param ) ); |
| 1688 |
|
} |
| 1689 |
|
|
| 1690 |
|
return true; |
| 1691 |
|
} |
|
@@ 1854-1856 (lines=3) @@
|
| 1851 |
|
$sharer = new Sharing_Service(); |
| 1852 |
|
$services = array_keys( $sharer->get_all_services() ); |
| 1853 |
|
|
| 1854 |
|
if ( ! empty( $value ) && ! in_array( $value, $services ) ) { |
| 1855 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s is not a registered custom sharing service.', 'jetpack' ), $param ) ); |
| 1856 |
|
} |
| 1857 |
|
|
| 1858 |
|
return true; |
| 1859 |
|
} |