|
@@ 1636-1638 (lines=3) @@
|
| 1633 |
|
* @return bool |
| 1634 |
|
*/ |
| 1635 |
|
public static function validate_alphanum( $value = '', $request, $param ) { |
| 1636 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/[a-z0-9]+/i', $value ) ) ) { |
| 1637 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string.', 'jetpack' ), $param ) ); |
| 1638 |
|
} |
| 1639 |
|
return true; |
| 1640 |
|
} |
| 1641 |
|
|
|
@@ 1775-1777 (lines=3) @@
|
| 1772 |
|
* @return bool |
| 1773 |
|
*/ |
| 1774 |
|
public static function validate_custom_service_id( $value = '', $request, $param ) { |
| 1775 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/custom\-[0-1]+/i', $value ) ) ) { |
| 1776 |
|
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 ) ); |
| 1777 |
|
} |
| 1778 |
|
|
| 1779 |
|
if ( ! class_exists( 'Sharing_Service' ) && ! @include( JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php' ) ) { |
| 1780 |
|
return new WP_Error( 'invalid_param', esc_html__( 'Failed loading required dependency Sharing_Service.', 'jetpack' ) ); |
|
@@ 1804-1806 (lines=3) @@
|
| 1801 |
|
* @return bool |
| 1802 |
|
*/ |
| 1803 |
|
public static function validate_twitter_username( $value = '', $request, $param ) { |
| 1804 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^@?\w{1,15}$/i', $value ) ) ) { |
| 1805 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a Twitter username.', 'jetpack' ), $param ) ); |
| 1806 |
|
} |
| 1807 |
|
return true; |
| 1808 |
|
} |
| 1809 |
|
|