PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 14.8
Jetpack – WP Security, Backup, Speed, & Growth v14.8
16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 13.9.2 14.0.1 14.1.1 14.2.2 14.3.1 All 501 releases
jetpack / modules / verification-tools / verification-tools-utils.php
verification-tools-utils.php
61 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Helper functions that are called from API even when module is inactive should be added here.
4 * This file will be included in module-extras.php.
5 *
6 * @package jetpack
7 */
8
9 if ( ! function_exists( 'jetpack_verification_validate' ) ) {
10 /**
11 * Validate jetpack verification codes.
12 *
13 * @param array $verification_services_codes - array of verification codes.
14 */
15 function jetpack_verification_validate( $verification_services_codes ) {
16 foreach ( $verification_services_codes as $key => $code ) {
17 // Parse html meta tag if it does not look like a valid code.
18 if ( ! preg_match( '/^[a-z0-9_-]+$/i', $code ) ) {
19 $code = jetpack_verification_get_code( $code );
20 }
21
22 $code = esc_attr( trim( $code ) );
23
24 // limit length to 100 chars.
25 $code = substr( $code, 0, 100 );
26
27 /**
28 * Fire after each Verification code was validated.
29 *
30 * @module verification-tools
31 *
32 * @since 3.0.0
33 *
34 * @param string $key Verification service name.
35 * @param string $code Verification service code provided in field in the Tools menu.
36 */
37 do_action( 'jetpack_site_verification_validate', $key, $code );
38
39 $verification_services_codes[ $key ] = $code;
40 }
41 return $verification_services_codes;
42 }
43 }
44
45 if ( ! function_exists( 'jetpack_verification_get_code' ) ) {
46 /**
47 * Return the code we're trying to verify after decoding.
48 *
49 * @param string $code - the code we need to parse.
50 */
51 function jetpack_verification_get_code( $code ) {
52 $pattern = '/content=["\']?([^"\' ]*)["\' ]/is';
53 preg_match( $pattern, $code, $match );
54 if ( $match ) {
55 return urldecode( $match[1] );
56 } else {
57 return false;
58 }
59 }
60 }
61