|
@@ 1774-1776 (lines=3) @@
|
| 1771 |
|
* @return bool |
| 1772 |
|
*/ |
| 1773 |
|
public static function validate_alphanum( $value = '', $request, $param ) { |
| 1774 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/[a-z0-9]+/i', $value ) ) ) { |
| 1775 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string.', 'jetpack' ), $param ) ); |
| 1776 |
|
} |
| 1777 |
|
return true; |
| 1778 |
|
} |
| 1779 |
|
|
|
@@ 1916-1918 (lines=3) @@
|
| 1913 |
|
* @return bool |
| 1914 |
|
*/ |
| 1915 |
|
public static function validate_custom_service_id( $value = '', $request, $param ) { |
| 1916 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/custom\-[0-1]+/i', $value ) ) ) { |
| 1917 |
|
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 ) ); |
| 1918 |
|
} |
| 1919 |
|
|
| 1920 |
|
if ( ! class_exists( 'Sharing_Service' ) && ! @include( JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php' ) ) { |
| 1921 |
|
return new WP_Error( 'invalid_param', esc_html__( 'Failed loading required dependency Sharing_Service.', 'jetpack' ) ); |
|
@@ 1945-1947 (lines=3) @@
|
| 1942 |
|
* @return bool |
| 1943 |
|
*/ |
| 1944 |
|
public static function validate_twitter_username( $value = '', $request, $param ) { |
| 1945 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^@?\w{1,15}$/i', $value ) ) ) { |
| 1946 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a Twitter username.', 'jetpack' ), $param ) ); |
| 1947 |
|
} |
| 1948 |
|
return true; |
| 1949 |
|
} |
| 1950 |
|
|