|
@@ 2065-2067 (lines=3) @@
|
| 2062 |
|
* @return bool |
| 2063 |
|
*/ |
| 2064 |
|
public static function validate_alphanum( $value = '', $request, $param ) { |
| 2065 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/[a-z0-9]+/i', $value ) ) ) { |
| 2066 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string.', 'jetpack' ), $param ) ); |
| 2067 |
|
} |
| 2068 |
|
return true; |
| 2069 |
|
} |
| 2070 |
|
|
|
@@ 2190-2192 (lines=3) @@
|
| 2187 |
|
* @return bool |
| 2188 |
|
*/ |
| 2189 |
|
public static function validate_custom_service_id( $value = '', $request, $param ) { |
| 2190 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/custom\-[0-1]+/i', $value ) ) ) { |
| 2191 |
|
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 ) ); |
| 2192 |
|
} |
| 2193 |
|
|
| 2194 |
|
if ( ! class_exists( 'Sharing_Service' ) && ! @include( JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php' ) ) { |
| 2195 |
|
return new WP_Error( 'invalid_param', esc_html__( 'Failed loading required dependency Sharing_Service.', 'jetpack' ) ); |
|
@@ 2219-2221 (lines=3) @@
|
| 2216 |
|
* @return bool |
| 2217 |
|
*/ |
| 2218 |
|
public static function validate_twitter_username( $value = '', $request, $param ) { |
| 2219 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^@?\w{1,15}$/i', $value ) ) ) { |
| 2220 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a Twitter username.', 'jetpack' ), $param ) ); |
| 2221 |
|
} |
| 2222 |
|
return true; |
| 2223 |
|
} |
| 2224 |
|
|