Completed
Push — remove/site-verification-in-to... ( 983ed1...a0e3ae )
by
unknown
10:26
created

blog-verification-tools.php ➔ jetpack_verification_print_meta()   B

Complexity

Conditions 6
Paths 5

Size

Total Lines 28

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 6
nc 5
nop 0
dl 0
loc 28
rs 8.8497
c 0
b 0
f 0
1
<?php
2
3
// Edit here to add new services
4
function jetpack_verification_services() {
5
	return array(
6
			'google' => array(
7
			'name'   =>'Google Search Console',
8
			'key'    =>'google-site-verification',
9
			'format' =>'dBw5CvburAxi537Rp9qi5uG2174Vb6JwHwIRwPSLIK8',
10
			'url'    => 'https://www.google.com/webmasters/tools/',
11
		),
12
		'bing' => array(
13
			'name'   =>'Bing Webmaster Center',
14
			'key'    =>'msvalidate.01',
15
			'format' =>'12C1203B5086AECE94EB3A3D9830B2E',
16
			'url'    => 'http://www.bing.com/webmaster/',
17
		 ),
18
		'pinterest' => array(
19
			'name'   => 'Pinterest Site Verification',
20
			'key'    => 'p:domain_verify',
21
			'format' => 'f100679e6048d45e4a0b0b92dce1efce',
22
			'url'    => 'https://pinterest.com/website/verify/',
23
		),
24
		'yandex'     => array(
25
			'name'   => 'Yandex.Webmaster',
26
			'key'    => 'yandex-verification',
27
			'format' => '44d68e1216009f40',
28
			'url'    => 'https://webmaster.yandex.com/sites/',
29
		),
30
	);
31
}
32
function jetpack_verification_print_meta() {
33
	$verification_services_codes =  Jetpack_Options::get_option_and_ensure_autoload( 'verification_services_codes', '0' );
34
	if ( is_array( $verification_services_codes ) ) {
35
		$ver_output = "<!-- Jetpack Site Verification Tags -->\n";
36
		foreach ( jetpack_verification_services() as $name => $service ) {
37
			if ( is_array( $service ) && !empty( $verification_services_codes["$name"] ) ) {
38
				if ( preg_match( '#^<meta name="([a-z0-9_\-.:]+)?" content="([a-z0-9_-]+)?" />$#i', $verification_services_codes["$name"], $matches ) ) {
39
					$verification_code = $matches[2];
40
				} else {
41
					$verification_code = $verification_services_codes["$name"];
42
				}
43
				$ver_tag = sprintf( '<meta name="%s" content="%s" />', esc_attr( $service["key"] ), esc_attr( $verification_code ) );
44
				/**
45
				 * Filter the meta tag template used for all verification tools.
46
				 *
47
				 * @module verification-tools
48
				 *
49
				 * @since 3.0.0
50
				 *
51
				 * @param string $ver_tag Verification Tool meta tag.
52
				 */
53
				$ver_output .= apply_filters( 'jetpack_site_verification_output', $ver_tag );
54
				$ver_output .= "\n";
55
			}
56
		}
57
	echo $ver_output;
58
	}
59
}
60
add_action( 'wp_head', 'jetpack_verification_print_meta', 1 );
61
62
function jetpack_verification_options_init() {
63
	register_setting( 'verification_services_codes_fields', 'verification_services_codes', 'jetpack_verification_validate' );
64
}
65
add_action( 'admin_init', 'jetpack_verification_options_init' );
66