|
@@ 1864-1866 (lines=3) @@
|
| 1861 |
|
|
| 1862 |
|
// If it's an associative array, use the keys to check that the value is among those admitted. |
| 1863 |
|
$enum = ( count( array_filter( array_keys( $args['enum'] ), 'is_string' ) ) > 0 ) ? array_keys( $args['enum'] ) : $args['enum']; |
| 1864 |
|
if ( ! in_array( $value, $enum ) ) { |
| 1865 |
|
return new WP_Error( 'invalid_param_value', sprintf( esc_html__( '%s must be one of %s', 'jetpack' ), $param, implode( ', ', $enum ) ) ); |
| 1866 |
|
} |
| 1867 |
|
} |
| 1868 |
|
return true; |
| 1869 |
|
} |
|
@@ 1927-1929 (lines=3) @@
|
| 1924 |
|
*/ |
| 1925 |
|
public static function validate_sharing_show( $value, $request, $param ) { |
| 1926 |
|
$views = array( 'index', 'post', 'page', 'attachment', 'jetpack-portfolio' ); |
| 1927 |
|
if ( ! array_intersect( $views, $value ) ) { |
| 1928 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be %s.', 'jetpack' ), $param, join( ', ', $views ) ) ); |
| 1929 |
|
} |
| 1930 |
|
return true; |
| 1931 |
|
} |
| 1932 |
|
|
|
@@ 2025-2027 (lines=3) @@
|
| 2022 |
|
$sharer = new Sharing_Service(); |
| 2023 |
|
$services = array_keys( $sharer->get_all_services() ); |
| 2024 |
|
|
| 2025 |
|
if ( ! empty( $value ) && ! in_array( $value, $services ) ) { |
| 2026 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s is not a registered custom sharing service.', 'jetpack' ), $param ) ); |
| 2027 |
|
} |
| 2028 |
|
|
| 2029 |
|
return true; |
| 2030 |
|
} |