|
@@ 2334-2336 (lines=3) @@
|
| 2331 |
|
* @return bool|WP_Error |
| 2332 |
|
*/ |
| 2333 |
|
public static function validate_alphanum( $value = '', $request, $param ) { |
| 2334 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^[a-z0-9]+$/i', $value ) ) ) { |
| 2335 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string.', 'jetpack' ), $param ) ); |
| 2336 |
|
} |
| 2337 |
|
return true; |
| 2338 |
|
} |
| 2339 |
|
|
|
@@ 2494-2496 (lines=3) @@
|
| 2491 |
|
* @return bool|WP_Error |
| 2492 |
|
*/ |
| 2493 |
|
public static function validate_custom_service_id( $value = '', $request, $param ) { |
| 2494 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/custom\-[0-1]+/i', $value ) ) ) { |
| 2495 |
|
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 ) ); |
| 2496 |
|
} |
| 2497 |
|
|
| 2498 |
|
if ( ! class_exists( 'Sharing_Service' ) && ! include_once( JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php' ) ) { |
| 2499 |
|
return new WP_Error( 'invalid_param', esc_html__( 'Failed loading required dependency Sharing_Service.', 'jetpack' ) ); |
|
@@ 2523-2525 (lines=3) @@
|
| 2520 |
|
* @return bool|WP_Error |
| 2521 |
|
*/ |
| 2522 |
|
public static function validate_twitter_username( $value = '', $request, $param ) { |
| 2523 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^@?\w{1,15}$/i', $value ) ) ) { |
| 2524 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a Twitter username.', 'jetpack' ), $param ) ); |
| 2525 |
|
} |
| 2526 |
|
return true; |
| 2527 |
|
} |
| 2528 |
|
|