|
@@ 2257-2259 (lines=3) @@
|
| 2254 |
|
* @return bool|WP_Error |
| 2255 |
|
*/ |
| 2256 |
|
public static function validate_alphanum( $value = '', $request, $param ) { |
| 2257 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^[a-z0-9]+$/i', $value ) ) ) { |
| 2258 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string.', 'jetpack' ), $param ) ); |
| 2259 |
|
} |
| 2260 |
|
return true; |
| 2261 |
|
} |
| 2262 |
|
|
|
@@ 2417-2419 (lines=3) @@
|
| 2414 |
|
* @return bool|WP_Error |
| 2415 |
|
*/ |
| 2416 |
|
public static function validate_custom_service_id( $value = '', $request, $param ) { |
| 2417 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/custom\-[0-1]+/i', $value ) ) ) { |
| 2418 |
|
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 ) ); |
| 2419 |
|
} |
| 2420 |
|
|
| 2421 |
|
if ( ! class_exists( 'Sharing_Service' ) && ! include_once( JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php' ) ) { |
| 2422 |
|
return new WP_Error( 'invalid_param', esc_html__( 'Failed loading required dependency Sharing_Service.', 'jetpack' ) ); |
|
@@ 2446-2448 (lines=3) @@
|
| 2443 |
|
* @return bool|WP_Error |
| 2444 |
|
*/ |
| 2445 |
|
public static function validate_twitter_username( $value = '', $request, $param ) { |
| 2446 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^@?\w{1,15}$/i', $value ) ) ) { |
| 2447 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a Twitter username.', 'jetpack' ), $param ) ); |
| 2448 |
|
} |
| 2449 |
|
return true; |
| 2450 |
|
} |
| 2451 |
|
|