|
@@ 2480-2482 (lines=3) @@
|
| 2477 |
|
* @return bool|WP_Error |
| 2478 |
|
*/ |
| 2479 |
|
public static function validate_alphanum( $value = '', $request, $param ) { |
| 2480 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^[a-z0-9]+$/i', $value ) ) ) { |
| 2481 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string.', 'jetpack' ), $param ) ); |
| 2482 |
|
} |
| 2483 |
|
return true; |
| 2484 |
|
} |
| 2485 |
|
|
|
@@ 2640-2642 (lines=3) @@
|
| 2637 |
|
* @return bool|WP_Error |
| 2638 |
|
*/ |
| 2639 |
|
public static function validate_custom_service_id( $value = '', $request, $param ) { |
| 2640 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/custom\-[0-1]+/i', $value ) ) ) { |
| 2641 |
|
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 ) ); |
| 2642 |
|
} |
| 2643 |
|
|
| 2644 |
|
if ( ! class_exists( 'Sharing_Service' ) && ! include_once( JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php' ) ) { |
| 2645 |
|
return new WP_Error( 'invalid_param', esc_html__( 'Failed loading required dependency Sharing_Service.', 'jetpack' ) ); |
|
@@ 2669-2671 (lines=3) @@
|
| 2666 |
|
* @return bool|WP_Error |
| 2667 |
|
*/ |
| 2668 |
|
public static function validate_twitter_username( $value = '', $request, $param ) { |
| 2669 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^@?\w{1,15}$/i', $value ) ) ) { |
| 2670 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a Twitter username.', 'jetpack' ), $param ) ); |
| 2671 |
|
} |
| 2672 |
|
return true; |
| 2673 |
|
} |
| 2674 |
|
|