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
|
|
|
|
33
|
|
|
|
34
|
|
|
function jetpack_verification_options_init() { |
35
|
|
|
register_setting( 'verification_services_codes_fields', 'verification_services_codes', 'jetpack_verification_validate' ); |
36
|
|
|
} |
37
|
|
|
add_action( 'admin_init', 'jetpack_verification_options_init' ); |
38
|
|
|
|
39
|
|
|
function jetpack_verification_print_meta() { |
40
|
|
|
$verification_services_codes = Jetpack_Options::get_option_and_ensure_autoload( 'verification_services_codes', '0' ); |
41
|
|
|
if ( is_array( $verification_services_codes ) ) { |
42
|
|
|
$ver_output = "<!-- Jetpack Site Verification Tags -->\n"; |
43
|
|
|
foreach ( jetpack_verification_services() as $name => $service ) { |
44
|
|
|
if ( is_array( $service ) && !empty( $verification_services_codes["$name"] ) ) { |
45
|
|
|
$ver_tag = sprintf( '<meta name="%s" content="%s" />', esc_attr( $service["key"] ), esc_attr( $verification_services_codes["$name"] ) ); |
46
|
|
|
/** |
47
|
|
|
* Filter the meta tag template used for all verification tools. |
48
|
|
|
* |
49
|
|
|
* @module verification-tools |
50
|
|
|
* |
51
|
|
|
* @since 3.0.0 |
52
|
|
|
* |
53
|
|
|
* @param string $ver_tag Verification Tool meta tag. |
54
|
|
|
*/ |
55
|
|
|
$ver_output .= apply_filters( 'jetpack_site_verification_output', $ver_tag ); |
56
|
|
|
$ver_output .= "\n"; |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
echo $ver_output; |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
add_action( 'wp_head', 'jetpack_verification_print_meta', 1 ); |
63
|
|
|
|
64
|
|
|
function jetpack_verification_options_form() { |
65
|
|
|
$verification_services_codes = get_option( 'verification_services_codes' ); |
66
|
|
|
?> |
67
|
|
|
<form method="post" action="options.php"> |
68
|
|
|
<?php settings_fields( 'verification_services_codes_fields' ); ?> |
69
|
|
|
<div class="tools-container"> |
70
|
|
|
<?php |
71
|
|
|
foreach ( jetpack_verification_services() as $key => $service ) { |
72
|
|
|
echo "<div class='jp-verification-service'> |
73
|
|
|
<h4>" . esc_html( $service['name'] ) . "</h4> |
74
|
|
|
<input value='" . esc_attr( isset( $verification_services_codes[ $key ] ) ? $verification_services_codes[ $key ] : '' ) . "' name='verification_services_codes[" . esc_attr( $key ) . "]' type='text' /> |
75
|
|
|
<small> |
76
|
|
|
<label for='verification_services_codes[" . esc_attr( $key ) . "]'>" . esc_html( __( 'Example:' , 'jetpack' ) ) . " <span><meta name='" . esc_attr( $service['key'] ) . "' content='<strong>" . esc_attr( $service['format'] ) . "</strong>'></span></label> |
77
|
|
|
</small> |
78
|
|
|
</div>"; |
79
|
|
|
} |
80
|
|
|
?> |
81
|
|
|
</div> |
82
|
|
|
<p class="submit"> |
83
|
|
|
<input type="submit" class="button-primary" value="<?php _e( 'Save Changes' , 'jetpack' ); ?>" /> |
84
|
|
|
</p> |
85
|
|
|
</form> |
86
|
|
|
|
87
|
|
|
<style> |
88
|
|
|
/* Jetpack styles aren't loaded in the tools section of the admin, let's save on some http requests and just do an inline block */ |
89
|
|
|
|
90
|
|
|
.jp-verification-tools h3 a { |
91
|
|
|
text-decoration: none; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
.jp-verification-service { |
95
|
|
|
border-bottom: 1px #f1f1f1 solid; |
96
|
|
|
padding-bottom: 20px; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
.jp-verification-service input[type="text"] { |
100
|
|
|
width: 100%; |
101
|
|
|
margin-bottom: 10px; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
.jp-verification-service label { |
105
|
|
|
font-size: 13px; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/* mimic 'code' tag style, but this allows for better visuals + line breaks on mobile devices */ |
109
|
|
|
.jp-verification-service span { |
110
|
|
|
display: block; |
111
|
|
|
margin-top: 5px; |
112
|
|
|
font-size: 14px; |
113
|
|
|
padding: 10px; |
114
|
|
|
background: #f1f1f1; |
115
|
|
|
font-family: monospace; |
116
|
|
|
word-wrap: break-word; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
.jp-verification-service strong { |
120
|
|
|
font-weight: bold; |
121
|
|
|
} |
122
|
|
|
</style> |
123
|
|
|
|
124
|
|
|
<?php |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
function jetpack_verification_tool_box() { |
128
|
|
|
global $current_user; |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* Decide whether Site Verification tools be added to the Tools menu. |
132
|
|
|
* |
133
|
|
|
* @module verification-tools |
134
|
|
|
* |
135
|
|
|
* @since 3.0.0 |
136
|
|
|
* |
137
|
|
|
* @param bool true Should the Site Verification tools be added to the Tools menu. |
138
|
|
|
*/ |
139
|
|
|
if ( ! apply_filters( 'jetpack_enable_site_verification', true ) ) |
140
|
|
|
return; |
141
|
|
|
|
142
|
|
|
$list = array(); |
143
|
|
|
foreach ( jetpack_verification_services() as $key => $service ) { |
144
|
|
|
$list[] = '<a href="' . esc_url( $service['url'] ) . '">' . esc_html( $service['name'] ) . '</a>'; |
145
|
|
|
} |
146
|
|
|
$last = array_pop( $list ); |
147
|
|
|
|
148
|
|
|
if ( current_user_can( 'manage_options' ) ) { |
149
|
|
|
echo '<div class="jp-verification-tools card"><h3 class="title">' . __( 'Website Verification Services' , 'jetpack' ) . ' <a href="http://support.wordpress.com/webmaster-tools/" target="_blank">(?)</a></h3>'; |
150
|
|
|
echo '<p>' . sprintf( esc_html( __( 'Enter your meta key "content" value to verify your blog with %s' , 'jetpack' ) ), implode( ', ', $list ) ) . ' ' . __( 'and' , 'jetpack' ) . ' ' . $last . '.</p>'; |
151
|
|
|
jetpack_verification_options_form(); |
152
|
|
|
echo '</div>'; |
153
|
|
|
} |
154
|
|
|
} |
155
|
|
|
add_action( 'tool_box', 'jetpack_verification_tool_box', 25 ); |
156
|
|
|
|