|
@@ 1711-1713 (lines=3) @@
|
| 1708 |
|
|
| 1709 |
|
// If it's an associative array, use the keys to check that the value is among those admitted. |
| 1710 |
|
$enum = ( count( array_filter( array_keys( $args['enum'] ), 'is_string' ) ) > 0 ) ? array_keys( $args['enum'] ) : $args['enum']; |
| 1711 |
|
if ( ! in_array( $value, $enum ) ) { |
| 1712 |
|
return new WP_Error( 'invalid_param_value', sprintf( |
| 1713 |
|
/* Translators: first variable is the parameter passed to endpoint that holds the list item, the second is a list of admitted values. */ |
| 1714 |
|
esc_html__( '%1$s must be one of %2$s', 'jetpack' ), $param, implode( ', ', $enum ) |
| 1715 |
|
) ); |
| 1716 |
|
} |
|
@@ 1739-1741 (lines=3) @@
|
| 1736 |
|
|
| 1737 |
|
$modules = Jetpack::get_available_modules(); |
| 1738 |
|
|
| 1739 |
|
if ( count( array_intersect( $value, $modules ) ) != count( $value ) ) { |
| 1740 |
|
return new WP_Error( 'invalid_param_value', sprintf( esc_html__( '%s must be a list of valid modules', 'jetpack' ), $param ) ); |
| 1741 |
|
} |
| 1742 |
|
|
| 1743 |
|
return true; |
| 1744 |
|
} |
|
@@ 1910-1912 (lines=3) @@
|
| 1907 |
|
$sharer = new Sharing_Service(); |
| 1908 |
|
$services = array_keys( $sharer->get_all_services() ); |
| 1909 |
|
|
| 1910 |
|
if ( ! empty( $value ) && ! in_array( $value, $services ) ) { |
| 1911 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s is not a registered custom sharing service.', 'jetpack' ), $param ) ); |
| 1912 |
|
} |
| 1913 |
|
|
| 1914 |
|
return true; |
| 1915 |
|
} |