|
@@ 1745-1747 (lines=3) @@
|
| 1742 |
|
|
| 1743 |
|
// If it's an associative array, use the keys to check that the value is among those admitted. |
| 1744 |
|
$enum = ( count( array_filter( array_keys( $args['enum'] ), 'is_string' ) ) > 0 ) ? array_keys( $args['enum'] ) : $args['enum']; |
| 1745 |
|
if ( ! in_array( $value, $enum ) ) { |
| 1746 |
|
return new WP_Error( 'invalid_param_value', sprintf( esc_html__( '%s must be one of %s', 'jetpack' ), $param, implode( ', ', $enum ) ) ); |
| 1747 |
|
} |
| 1748 |
|
} |
| 1749 |
|
return true; |
| 1750 |
|
} |
|
@@ 1808-1810 (lines=3) @@
|
| 1805 |
|
*/ |
| 1806 |
|
public static function validate_sharing_show( $value, $request, $param ) { |
| 1807 |
|
$views = array( 'index', 'post', 'page', 'attachment', 'jetpack-portfolio' ); |
| 1808 |
|
if ( ! array_intersect( $views, $value ) ) { |
| 1809 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be %s.', 'jetpack' ), $param, join( ', ', $views ) ) ); |
| 1810 |
|
} |
| 1811 |
|
return true; |
| 1812 |
|
} |
| 1813 |
|
|
|
@@ 1906-1908 (lines=3) @@
|
| 1903 |
|
$sharer = new Sharing_Service(); |
| 1904 |
|
$services = array_keys( $sharer->get_all_services() ); |
| 1905 |
|
|
| 1906 |
|
if ( ! empty( $value ) && ! in_array( $value, $services ) ) { |
| 1907 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s is not a registered custom sharing service.', 'jetpack' ), $param ) ); |
| 1908 |
|
} |
| 1909 |
|
|
| 1910 |
|
return true; |
| 1911 |
|
} |