|
@@ 2497-2499 (lines=3) @@
|
| 2494 |
|
* @return bool|WP_Error |
| 2495 |
|
*/ |
| 2496 |
|
public static function validate_alphanum( $value = '', $request, $param ) { |
| 2497 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^[a-z0-9]+$/i', $value ) ) ) { |
| 2498 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string.', 'jetpack' ), $param ) ); |
| 2499 |
|
} |
| 2500 |
|
return true; |
| 2501 |
|
} |
| 2502 |
|
|
|
@@ 2657-2659 (lines=3) @@
|
| 2654 |
|
* @return bool|WP_Error |
| 2655 |
|
*/ |
| 2656 |
|
public static function validate_custom_service_id( $value = '', $request, $param ) { |
| 2657 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/custom\-[0-1]+/i', $value ) ) ) { |
| 2658 |
|
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 ) ); |
| 2659 |
|
} |
| 2660 |
|
|
| 2661 |
|
if ( ! class_exists( 'Sharing_Service' ) && ! include_once( JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php' ) ) { |
| 2662 |
|
return new WP_Error( 'invalid_param', esc_html__( 'Failed loading required dependency Sharing_Service.', 'jetpack' ) ); |
|
@@ 2686-2688 (lines=3) @@
|
| 2683 |
|
* @return bool|WP_Error |
| 2684 |
|
*/ |
| 2685 |
|
public static function validate_twitter_username( $value = '', $request, $param ) { |
| 2686 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^@?\w{1,15}$/i', $value ) ) ) { |
| 2687 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a Twitter username.', 'jetpack' ), $param ) ); |
| 2688 |
|
} |
| 2689 |
|
return true; |
| 2690 |
|
} |
| 2691 |
|
|