/var/www/html/wp-content/plugins/dreamteam-shortcodes/class-shortcodes.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
defined
('ABSPATH') || exit;

class 
DRT_Shortcodes
{
  public static function 
init()
  {
    
$shortcodes = array(
      
'kd_admin_brand' => __CLASS__ '::getBrand',
      
'kd_admin_email' => __CLASS__ '::getEmail',
      
'kd_admin_phone' => __CLASS__ '::getPhone',
      
'kd_admin_address' => __CLASS__ '::getAddress',
      
'kd_admin_domain' => __CLASS__ '::getDomainName'
    
);
    foreach (
$shortcodes as $shortcode => $function) {
      
add_shortcode($shortcode$function);
    }
  }

  public static function 
getDomain()
  {
    
$domain $_SERVER['HTTP_HOST'];
    
$domain str_replace(array('https://''http://''www.'), ''$domain);
    return 
$domain;
  }

  public static function 
getData()
  {
    global 
$dreamteam_business_data;
    if (empty(
$dreamteam_business_data)) {
      
$dreamteam_business_data get_option('dreamteam_business_data', array());
    }

    if (empty(
$dreamteam_business_data))
      return [];

    
$domain self::getDomain();
    
$item_res array_filter($dreamteam_business_data, function ($item) use ($domain) {
      return 
strtolower(trim($item['domain'])) === trim($domain);
    });

    
$item_res array_values($item_res);
    
$item_res sizeof($item_res) > $item_res[0] : false;
    if (
$item_res) {
      
$item_res['brand'] = str_replace("\'""'"$item_res['brand']);
    }
    return 
$item_res;
  }

  public static function 
getBrand($atts)
  {
    
$business self::getData();
    if (!
$business)
      return;
    return 
$business['brand'];
  }

  public static function 
getEmail($atts)
  {
    
$business self::getData();
    if (!
$business)
      return;
    return 
$business['contact'];
  }

  public static function 
getPhone($atts)
  {
    
$business self::getData();
    if (!
$business)
      return;
    return 
$business['phone'];
  }


  public static function 
getAddress($atts)
  {
    
$business self::getData();
    if (!
$business)
      return;
    return 
$business['address'];
  }

  public static function 
getDomainName($atts$content$tag)
  {
    
$atts shortcode_atts(array(
      
'type' => '0'
    
), $atts$tag);
    
$domain self::getDomain();
    if (
$atts['type'] === '1') {
      
$domain ucfirst($domain);
    }
    return 
$domain;
  }
}