|
@@ 2082-2084 (lines=3) @@
|
| 2079 |
|
* @return bool |
| 2080 |
|
*/ |
| 2081 |
|
public static function validate_alphanum( $value = '', $request, $param ) { |
| 2082 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/[a-z0-9]+/i', $value ) ) ) { |
| 2083 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string.', 'jetpack' ), $param ) ); |
| 2084 |
|
} |
| 2085 |
|
return true; |
| 2086 |
|
} |
| 2087 |
|
|
|
@@ 2207-2209 (lines=3) @@
|
| 2204 |
|
* @return bool |
| 2205 |
|
*/ |
| 2206 |
|
public static function validate_custom_service_id( $value = '', $request, $param ) { |
| 2207 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/custom\-[0-1]+/i', $value ) ) ) { |
| 2208 |
|
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 ) ); |
| 2209 |
|
} |
| 2210 |
|
|
| 2211 |
|
if ( ! class_exists( 'Sharing_Service' ) && ! @include( JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php' ) ) { |
| 2212 |
|
return new WP_Error( 'invalid_param', esc_html__( 'Failed loading required dependency Sharing_Service.', 'jetpack' ) ); |
|
@@ 2236-2238 (lines=3) @@
|
| 2233 |
|
* @return bool |
| 2234 |
|
*/ |
| 2235 |
|
public static function validate_twitter_username( $value = '', $request, $param ) { |
| 2236 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^@?\w{1,15}$/i', $value ) ) ) { |
| 2237 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a Twitter username.', 'jetpack' ), $param ) ); |
| 2238 |
|
} |
| 2239 |
|
return true; |
| 2240 |
|
} |
| 2241 |
|
|