|
@@ 2619-2621 (lines=3) @@
|
| 2616 |
|
* @return bool|WP_Error |
| 2617 |
|
*/ |
| 2618 |
|
public static function validate_alphanum( $value = '', $request, $param ) { |
| 2619 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^[a-z0-9]+$/i', $value ) ) ) { |
| 2620 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string.', 'jetpack' ), $param ) ); |
| 2621 |
|
} |
| 2622 |
|
return true; |
| 2623 |
|
} |
| 2624 |
|
|
|
@@ 2779-2781 (lines=3) @@
|
| 2776 |
|
* @return bool|WP_Error |
| 2777 |
|
*/ |
| 2778 |
|
public static function validate_custom_service_id( $value = '', $request, $param ) { |
| 2779 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/custom\-[0-1]+/i', $value ) ) ) { |
| 2780 |
|
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 ) ); |
| 2781 |
|
} |
| 2782 |
|
|
| 2783 |
|
if ( ! class_exists( 'Sharing_Service' ) && ! include_once( JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php' ) ) { |
| 2784 |
|
return new WP_Error( 'invalid_param', esc_html__( 'Failed loading required dependency Sharing_Service.', 'jetpack' ) ); |
|
@@ 2808-2810 (lines=3) @@
|
| 2805 |
|
* @return bool|WP_Error |
| 2806 |
|
*/ |
| 2807 |
|
public static function validate_twitter_username( $value = '', $request, $param ) { |
| 2808 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^@?\w{1,15}$/i', $value ) ) ) { |
| 2809 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a Twitter username.', 'jetpack' ), $param ) ); |
| 2810 |
|
} |
| 2811 |
|
return true; |
| 2812 |
|
} |
| 2813 |
|
|