|
@@ 1717-1719 (lines=3) @@
|
| 1714 |
|
|
| 1715 |
|
// If it's an associative array, use the keys to check that the value is among those admitted. |
| 1716 |
|
$enum = ( count( array_filter( array_keys( $args['enum'] ), 'is_string' ) ) > 0 ) ? array_keys( $args['enum'] ) : $args['enum']; |
| 1717 |
|
if ( ! in_array( $value, $enum ) ) { |
| 1718 |
|
return new WP_Error( 'invalid_param_value', sprintf( |
| 1719 |
|
/* Translators: first variable is the parameter passed to endpoint that holds the list item, the second is a list of admitted values. */ |
| 1720 |
|
esc_html__( '%1$s must be one of %2$s', 'jetpack' ), $param, implode( ', ', $enum ) |
| 1721 |
|
) ); |
| 1722 |
|
} |
|
@@ 1745-1747 (lines=3) @@
|
| 1742 |
|
|
| 1743 |
|
$modules = Jetpack::get_available_modules(); |
| 1744 |
|
|
| 1745 |
|
if ( count( array_intersect( $value, $modules ) ) != count( $value ) ) { |
| 1746 |
|
return new WP_Error( 'invalid_param_value', sprintf( esc_html__( '%s must be a list of valid modules', 'jetpack' ), $param ) ); |
| 1747 |
|
} |
| 1748 |
|
|
| 1749 |
|
return true; |
| 1750 |
|
} |
|
@@ 1916-1918 (lines=3) @@
|
| 1913 |
|
$sharer = new Sharing_Service(); |
| 1914 |
|
$services = array_keys( $sharer->get_all_services() ); |
| 1915 |
|
|
| 1916 |
|
if ( ! empty( $value ) && ! in_array( $value, $services ) ) { |
| 1917 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s is not a registered custom sharing service.', 'jetpack' ), $param ) ); |
| 1918 |
|
} |
| 1919 |
|
|
| 1920 |
|
return true; |
| 1921 |
|
} |