|
@@ 2382-2384 (lines=3) @@
|
| 2379 |
|
* @return bool|WP_Error |
| 2380 |
|
*/ |
| 2381 |
|
public static function validate_alphanum( $value = '', $request, $param ) { |
| 2382 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^[a-z0-9]+$/i', $value ) ) ) { |
| 2383 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string.', 'jetpack' ), $param ) ); |
| 2384 |
|
} |
| 2385 |
|
return true; |
| 2386 |
|
} |
| 2387 |
|
|
|
@@ 2542-2544 (lines=3) @@
|
| 2539 |
|
* @return bool|WP_Error |
| 2540 |
|
*/ |
| 2541 |
|
public static function validate_custom_service_id( $value = '', $request, $param ) { |
| 2542 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/custom\-[0-1]+/i', $value ) ) ) { |
| 2543 |
|
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 ) ); |
| 2544 |
|
} |
| 2545 |
|
|
| 2546 |
|
if ( ! class_exists( 'Sharing_Service' ) && ! include_once( JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php' ) ) { |
| 2547 |
|
return new WP_Error( 'invalid_param', esc_html__( 'Failed loading required dependency Sharing_Service.', 'jetpack' ) ); |
|
@@ 2571-2573 (lines=3) @@
|
| 2568 |
|
* @return bool|WP_Error |
| 2569 |
|
*/ |
| 2570 |
|
public static function validate_twitter_username( $value = '', $request, $param ) { |
| 2571 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^@?\w{1,15}$/i', $value ) ) ) { |
| 2572 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a Twitter username.', 'jetpack' ), $param ) ); |
| 2573 |
|
} |
| 2574 |
|
return true; |
| 2575 |
|
} |
| 2576 |
|
|