|
@@ 2088-2090 (lines=3) @@
|
| 2085 |
|
* @return bool |
| 2086 |
|
*/ |
| 2087 |
|
public static function validate_custom_service_id( $value = '', $request, $param ) { |
| 2088 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/custom\-[0-1]+/i', $value ) ) ) { |
| 2089 |
|
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 ) ); |
| 2090 |
|
} |
| 2091 |
|
|
| 2092 |
|
if ( ! class_exists( 'Sharing_Service' ) && ! include_once( JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php' ) ) { |
| 2093 |
|
return new WP_Error( 'invalid_param', esc_html__( 'Failed loading required dependency Sharing_Service.', 'jetpack' ) ); |
|
@@ 2117-2119 (lines=3) @@
|
| 2114 |
|
* @return bool |
| 2115 |
|
*/ |
| 2116 |
|
public static function validate_twitter_username( $value = '', $request, $param ) { |
| 2117 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^@?\w{1,15}$/i', $value ) ) ) { |
| 2118 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a Twitter username.', 'jetpack' ), $param ) ); |
| 2119 |
|
} |
| 2120 |
|
return true; |
| 2121 |
|
} |
| 2122 |
|
|
|
@@ 1928-1930 (lines=3) @@
|
| 1925 |
|
* @return bool |
| 1926 |
|
*/ |
| 1927 |
|
public static function validate_alphanum( $value = '', $request, $param ) { |
| 1928 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^[a-z0-9]+$/i', $value ) ) ) { |
| 1929 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string.', 'jetpack' ), $param ) ); |
| 1930 |
|
} |
| 1931 |
|
return true; |
| 1932 |
|
} |
| 1933 |
|
|
|
@@ 1946-1948 (lines=3) @@
|
| 1943 |
|
* @return bool |
| 1944 |
|
*/ |
| 1945 |
|
public static function validate_verification_service( $value = '', $request, $param ) { |
| 1946 |
|
if ( ! empty( $value ) && ! ( is_string( $value ) && ( preg_match( '/^[a-z0-9_-]+$/i', $value ) || preg_match( '#^<meta name="([a-z0-9_\-.:]+)?" content="([a-z0-9_-]+)?" />$#i', $value ) ) ) ) { |
| 1947 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string or a verification tag.', 'jetpack' ), $param ) ); |
| 1948 |
|
} |
| 1949 |
|
return true; |
| 1950 |
|
} |
| 1951 |
|
|