|
@@ 2723-2725 (lines=3) @@
|
| 2720 |
|
* @return bool|WP_Error |
| 2721 |
|
*/ |
| 2722 |
|
public static function validate_alphanum( $value = '', $request, $param ) { |
| 2723 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^[a-z0-9]+$/i', $value ) ) ) { |
| 2724 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string.', 'jetpack' ), $param ) ); |
| 2725 |
|
} |
| 2726 |
|
return true; |
| 2727 |
|
} |
| 2728 |
|
|
|
@@ 2883-2885 (lines=3) @@
|
| 2880 |
|
* @return bool|WP_Error |
| 2881 |
|
*/ |
| 2882 |
|
public static function validate_custom_service_id( $value = '', $request, $param ) { |
| 2883 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/custom\-[0-1]+/i', $value ) ) ) { |
| 2884 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( "%s must be a string prefixed with 'custom-' and followed by a numeric ID.", 'jetpack' ), $param ) ); |
| 2885 |
|
} |
| 2886 |
|
|
| 2887 |
|
if ( ! class_exists( 'Sharing_Service' ) && ! include_once( JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php' ) ) { |
| 2888 |
|
return new WP_Error( 'invalid_param', esc_html__( 'Failed loading required dependency Sharing_Service.', 'jetpack' ) ); |
|
@@ 2912-2914 (lines=3) @@
|
| 2909 |
|
* @return bool|WP_Error |
| 2910 |
|
*/ |
| 2911 |
|
public static function validate_twitter_username( $value = '', $request, $param ) { |
| 2912 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^@?\w{1,15}$/i', $value ) ) ) { |
| 2913 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a Twitter username.', 'jetpack' ), $param ) ); |
| 2914 |
|
} |
| 2915 |
|
return true; |
| 2916 |
|
} |
| 2917 |
|
|