|
@@ 1746-1748 (lines=3) @@
|
| 1743 |
|
* @return bool |
| 1744 |
|
*/ |
| 1745 |
|
public static function validate_alphanum( $value = '', $request, $param ) { |
| 1746 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/[a-z0-9]+/i', $value ) ) ) { |
| 1747 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string.', 'jetpack' ), $param ) ); |
| 1748 |
|
} |
| 1749 |
|
return true; |
| 1750 |
|
} |
| 1751 |
|
|
|
@@ 1888-1890 (lines=3) @@
|
| 1885 |
|
* @return bool |
| 1886 |
|
*/ |
| 1887 |
|
public static function validate_custom_service_id( $value = '', $request, $param ) { |
| 1888 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/custom\-[0-1]+/i', $value ) ) ) { |
| 1889 |
|
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 ) ); |
| 1890 |
|
} |
| 1891 |
|
|
| 1892 |
|
if ( ! class_exists( 'Sharing_Service' ) && ! @include( JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php' ) ) { |
| 1893 |
|
return new WP_Error( 'invalid_param', esc_html__( 'Failed loading required dependency Sharing_Service.', 'jetpack' ) ); |
|
@@ 1917-1919 (lines=3) @@
|
| 1914 |
|
* @return bool |
| 1915 |
|
*/ |
| 1916 |
|
public static function validate_twitter_username( $value = '', $request, $param ) { |
| 1917 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^@?\w{1,15}$/i', $value ) ) ) { |
| 1918 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a Twitter username.', 'jetpack' ), $param ) ); |
| 1919 |
|
} |
| 1920 |
|
return true; |
| 1921 |
|
} |
| 1922 |
|
|