|
@@ 1914-1916 (lines=3) @@
|
| 1911 |
|
* @return bool |
| 1912 |
|
*/ |
| 1913 |
|
public static function validate_alphanum( $value = '', $request, $param ) { |
| 1914 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/[a-z0-9]+/i', $value ) ) ) { |
| 1915 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string.', 'jetpack' ), $param ) ); |
| 1916 |
|
} |
| 1917 |
|
return true; |
| 1918 |
|
} |
| 1919 |
|
|
|
@@ 2021-2023 (lines=3) @@
|
| 2018 |
|
* @return bool |
| 2019 |
|
*/ |
| 2020 |
|
public static function validate_custom_service_id( $value = '', $request, $param ) { |
| 2021 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/custom\-[0-1]+/i', $value ) ) ) { |
| 2022 |
|
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 ) ); |
| 2023 |
|
} |
| 2024 |
|
|
| 2025 |
|
if ( ! class_exists( 'Sharing_Service' ) && ! @include( JETPACK__PLUGIN_DIR . 'modules/sharing/sharing-service.php' ) ) { |
| 2026 |
|
return new WP_Error( 'invalid_param', esc_html__( 'Failed loading required dependency Sharing_Service.', 'jetpack' ) ); |
|
@@ 2050-2052 (lines=3) @@
|
| 2047 |
|
* @return bool |
| 2048 |
|
*/ |
| 2049 |
|
public static function validate_twitter_username( $value = '', $request, $param ) { |
| 2050 |
|
if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^@?\w{1,15}$/i', $value ) ) ) { |
| 2051 |
|
return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a Twitter username.', 'jetpack' ), $param ) ); |
| 2052 |
|
} |
| 2053 |
|
return true; |
| 2054 |
|
} |
| 2055 |
|
|