PluginProbe ʕ •ᴥ•ʔ
Meta Tag Manager / 3.2
Meta Tag Manager v3.2
trunk 0.2 0.3 0.4 0.5 1.0 1.1 1.2 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.3 3.0 3.0.2 3.1 3.2 3.3
meta-tag-manager / classes / verify-sites.php
meta-tag-manager / classes Last commit date
open-graph-admin.php 4 years ago open-graph.php 4 years ago schema-admin.php 4 years ago schema.php 4 years ago verify-sites-admin.php 4 years ago verify-sites.php 4 years ago
verify-sites.php
52 lines
1 <?php
2 namespace Meta_Tag_Manager;
3 use Meta_Tag_Manager, MTM_Tag;
4
5 class Verify_Sites {
6 public static function init(){
7 if( is_admin() ){
8 include_once('verify-sites-admin.php');
9 }
10 add_filter('mtm_head_meta_tags', 'Meta_Tag_Manager\Verify_Sites::add_tags', 10);
11 }
12
13 public static function add_tags( $mtm_tags ){
14 $verify = static::get_options();
15 if( empty($verify) ) return $mtm_tags;
16 if( is_front_page() ){
17 $sites = static::get_sites();
18 foreach( $verify as $site => $site_key ){
19 if( !empty($sites[$site]) ) {
20 $mtm_tags[] = new MTM_Tag(array('type' => 'name', 'value' => $sites[$site], 'content' => $site_key, 'context' => 'home'));
21 }
22 }
23 }
24 return $mtm_tags;
25 }
26
27 public static function get_sites(){
28 return array(
29 'google' => 'google-site-verification',
30 'bing' => 'msvalidate.01', // https://www.bing.com/webmasters/help/add-and-verify-site-12184f8b
31 'facebook' => 'facebook-domain-verification',
32 'pintrest' => 'p:domain_verify', // https://help.pinterest.com/en/business/article/claim-your-website#section-12101
33 'sitelock' => 'sitelock-site-verification',
34 'yandex' => 'yandex-verification', // https://yandex.com/support/webmaster/service/rights.html
35 );
36 }
37
38 public static function get_options( $defaults = null ){
39 $mtm_custom = get_option('mtm_custom');
40 if( $defaults === null ) {
41 return !empty($mtm_custom['verify']) ? $mtm_custom['verify'] : false;
42 }else{
43 $verify = static::get_sites();
44 foreach( $verify as $k => $v ) $verify[$k] = ''; // empty string it
45 if( !$defaults ){
46 $verify = empty($mtm_custom['verify']) ? $verify : Meta_Tag_Manager::array_merge($verify, $mtm_custom['verify']);
47 }
48 }
49 return $verify;
50 }
51 }
52 Verify_Sites::init();