|
@@ 1781-1783 (lines=3) @@
|
| 1778 |
|
* @return bool |
| 1779 |
|
*/ |
| 1780 |
|
public static function validate_alphanum( $value = '', $request, $param ) { |
| 1781 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/[a-z0-9]+/i', $value ) ) ) { |
| 1782 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string.', 'jetpack' ), $param ) ); |
| 1783 |
|
} |
| 1784 |
|
return true; |
| 1785 |
|
} |
| 1786 |
|
|
|
@@ 1923-1925 (lines=3) @@
|
| 1920 |
|
* @return bool |
| 1921 |
|
*/ |
| 1922 |
|
public static function validate_custom_service_id( $value = '', $request, $param ) { |
| 1923 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/custom\-[0-1]+/i', $value ) ) ) { |
| 1924 |
|
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 ) ); |
| 1925 |
|
} |
| 1926 |
|
|
| 1927 |
|
if ( ! class_exists( 'Sharing_Service' ) && ! @include( JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php' ) ) { |
| 1928 |
|
return new WP_Error( 'invalid_param', esc_html__( 'Failed loading required dependency Sharing_Service.', 'jetpack' ) ); |
|
@@ 1952-1954 (lines=3) @@
|
| 1949 |
|
* @return bool |
| 1950 |
|
*/ |
| 1951 |
|
public static function validate_twitter_username( $value = '', $request, $param ) { |
| 1952 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^@?\w{1,15}$/i', $value ) ) ) { |
| 1953 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a Twitter username.', 'jetpack' ), $param ) ); |
| 1954 |
|
} |
| 1955 |
|
return true; |
| 1956 |
|
} |
| 1957 |
|
|