|
@@ 1700-1702 (lines=3) @@
|
| 1697 |
|
* @return bool |
| 1698 |
|
*/ |
| 1699 |
|
public static function validate_alphanum( $value = '', $request, $param ) { |
| 1700 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/[a-z0-9]+/i', $value ) ) ) { |
| 1701 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string.', 'jetpack' ), $param ) ); |
| 1702 |
|
} |
| 1703 |
|
return true; |
| 1704 |
|
} |
| 1705 |
|
|
|
@@ 1839-1841 (lines=3) @@
|
| 1836 |
|
* @return bool |
| 1837 |
|
*/ |
| 1838 |
|
public static function validate_custom_service_id( $value = '', $request, $param ) { |
| 1839 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/custom\-[0-1]+/i', $value ) ) ) { |
| 1840 |
|
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 ) ); |
| 1841 |
|
} |
| 1842 |
|
|
| 1843 |
|
if ( ! class_exists( 'Sharing_Service' ) && ! @include( JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php' ) ) { |
| 1844 |
|
return new WP_Error( 'invalid_param', esc_html__( 'Failed loading required dependency Sharing_Service.', 'jetpack' ) ); |
|
@@ 1868-1870 (lines=3) @@
|
| 1865 |
|
* @return bool |
| 1866 |
|
*/ |
| 1867 |
|
public static function validate_twitter_username( $value = '', $request, $param ) { |
| 1868 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^@?\w{1,15}$/i', $value ) ) ) { |
| 1869 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a Twitter username.', 'jetpack' ), $param ) ); |
| 1870 |
|
} |
| 1871 |
|
return true; |
| 1872 |
|
} |
| 1873 |
|
|