|
@@ 2659-2661 (lines=3) @@
|
| 2656 |
|
* @return bool|WP_Error |
| 2657 |
|
*/ |
| 2658 |
|
public static function validate_alphanum( $value = '', $request, $param ) { |
| 2659 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^[a-z0-9]+$/i', $value ) ) ) { |
| 2660 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string.', 'jetpack' ), $param ) ); |
| 2661 |
|
} |
| 2662 |
|
return true; |
| 2663 |
|
} |
| 2664 |
|
|
|
@@ 2819-2821 (lines=3) @@
|
| 2816 |
|
* @return bool|WP_Error |
| 2817 |
|
*/ |
| 2818 |
|
public static function validate_custom_service_id( $value = '', $request, $param ) { |
| 2819 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/custom\-[0-1]+/i', $value ) ) ) { |
| 2820 |
|
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 ) ); |
| 2821 |
|
} |
| 2822 |
|
|
| 2823 |
|
if ( ! class_exists( 'Sharing_Service' ) && ! include_once( JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php' ) ) { |
| 2824 |
|
return new WP_Error( 'invalid_param', esc_html__( 'Failed loading required dependency Sharing_Service.', 'jetpack' ) ); |
|
@@ 2848-2850 (lines=3) @@
|
| 2845 |
|
* @return bool|WP_Error |
| 2846 |
|
*/ |
| 2847 |
|
public static function validate_twitter_username( $value = '', $request, $param ) { |
| 2848 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^@?\w{1,15}$/i', $value ) ) ) { |
| 2849 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a Twitter username.', 'jetpack' ), $param ) ); |
| 2850 |
|
} |
| 2851 |
|
return true; |
| 2852 |
|
} |
| 2853 |
|
|