counter-html.php
156 lines
| 1 | <?php |
| 2 | |
| 3 | defined('ABSPATH') || exit; |
| 4 | |
| 5 | $enabled_providers = \WP_Social\App\Settings::get_enabled_provider_conf_counter(); |
| 6 | |
| 7 | $show_core_provider = \WP_Social\App\Providers::get_core_providers_count(); |
| 8 | $show_core_provider = array_keys($show_core_provider); |
| 9 | |
| 10 | if(!empty($enabled_providers)) : ?> |
| 11 | |
| 12 | <div class="xs_social_counter_widget <?php echo esc_attr($className); ?>"> |
| 13 | <ul class="xs_counter_url <?php echo esc_attr($widget_style); ?>"> |
| 14 | |
| 15 | <?php |
| 16 | |
| 17 | $factory = new \WP_Social\Lib\Provider\Counter_Factory(); |
| 18 | $cache_time = \WP_Social\App\Settings::get_counter_cache_time(); |
| 19 | |
| 20 | foreach($show_core_provider as $key) { |
| 21 | |
| 22 | |
| 23 | if(!empty($enabled_providers[$key]['enable'])) { |
| 24 | |
| 25 | // check if provider list is provided from widget |
| 26 | if(!in_array($key, $provider)) { |
| 27 | continue; |
| 28 | } |
| 29 | |
| 30 | // TikTok requires wp-social-pro plugin to be active |
| 31 | if($key === 'tiktok' && !\WP_Social::is_pro_active()) { |
| 32 | continue; |
| 33 | } |
| 34 | |
| 35 | $p_obj = $factory->make($key); |
| 36 | //$follower_count = $p_obj->get_cached_count($cache_time); |
| 37 | |
| 38 | $label = isset($counter_provider[$key]['label']) ? $counter_provider[$key]['label'] : ''; |
| 39 | $def = isset($counter_provider[$key]['data']['value']) ? $counter_provider[$key]['data']['value'] : 0; |
| 40 | $text = isset($counter_provider[$key]['data']['text']) ? $counter_provider[$key]['data']['text'] : ''; |
| 41 | |
| 42 | /** |
| 43 | * We will give priority to the actual number, if actual number is zero then we will show the default value. |
| 44 | */ |
| 45 | $counter = !empty($counter_data[$key]) ? $counter_data[$key] : $def; |
| 46 | #$counter = ($def) > 0 ? $def : $counter; |
| 47 | |
| 48 | $id = isset($counter_provider[$key]['id']) ? $counter_provider[$key]['id'] : ''; |
| 49 | $user_name = isset($counter_provider[$key]['user_name']) ? $counter_provider[$key]['user_name'] : ''; |
| 50 | $pinterest_user_name = isset($counter_provider[$key]['username']) ? $counter_provider[$key]['username'] : ''; |
| 51 | $type = isset($counter_provider[$key]['type']) ? $counter_provider[$key]['type'] : ''; |
| 52 | $getUrl = isset($core_provider[$key]['data']['url']) ? $core_provider[$key]['data']['url'] : '#'; |
| 53 | |
| 54 | if($key == 'youtube') { |
| 55 | if ($type === 'Channel') { |
| 56 | $getUrl = 'http://youtube.com/%s/%s'; |
| 57 | $url = sprintf($getUrl, strtolower($type), $id); |
| 58 | } else { |
| 59 | |
| 60 | $url = sprintf($getUrl, $id); |
| 61 | } |
| 62 | |
| 63 | } elseif($key == 'linkedin') { |
| 64 | |
| 65 | if($type == 'Profile') { |
| 66 | $url = sprintf($getUrl, 'in', $id); |
| 67 | |
| 68 | } else { |
| 69 | $url = sprintf($getUrl, 'company', $id); |
| 70 | } |
| 71 | } elseif($key == 'dribbble') { |
| 72 | |
| 73 | $url = get_option('home_url_dribbble_count', 'https://dribbble.com/'); |
| 74 | |
| 75 | } elseif($key == 'instagram') { |
| 76 | |
| 77 | $url = sprintf($getUrl, $user_name); |
| 78 | |
| 79 | } elseif($key == 'pinterest') { |
| 80 | |
| 81 | $url = sprintf($getUrl, $pinterest_user_name); |
| 82 | |
| 83 | |
| 84 | } else { |
| 85 | $url = sprintf($getUrl, $id); |
| 86 | } |
| 87 | |
| 88 | ?> |
| 89 | <li class="xs-counter-li <?php echo esc_attr($key); ?>" data-key="<?php echo esc_attr($key); ?>"> |
| 90 | <a href="<?php echo esc_url($url); ?>" target="_blank"> |
| 91 | <div class="xs-social-icon"> |
| 92 | <span class="met-social met-social-<?php echo esc_attr($key); ?>"></span> |
| 93 | </div> |
| 94 | |
| 95 | <?php |
| 96 | |
| 97 | if(!empty($styleArr[$cntStyleKey]['content'])) { |
| 98 | |
| 99 | if(!empty($styleArr[$cntStyleKey]['content']['number'])) { |
| 100 | |
| 101 | ?> |
| 102 | <div class="xs-social-follower"> |
| 103 | <?php echo esc_html(xs_format_num($counter)); ?> |
| 104 | </div> |
| 105 | |
| 106 | <?php |
| 107 | } |
| 108 | |
| 109 | if(!empty($styleArr[$cntStyleKey]['content']['label'])) { |
| 110 | |
| 111 | ?> |
| 112 | <div class="xs-social-follower-text"> |
| 113 | <?php echo esc_html($text); ?> |
| 114 | </div> |
| 115 | <?php |
| 116 | } |
| 117 | |
| 118 | } else { |
| 119 | |
| 120 | ?> |
| 121 | <div class="xs-social-follower"> |
| 122 | <?php echo esc_html(xs_format_num($counter)); ?> |
| 123 | </div> |
| 124 | |
| 125 | <div class="xs-social-follower-text"> |
| 126 | <?php echo esc_html($text); ?> |
| 127 | </div> |
| 128 | |
| 129 | <?php |
| 130 | } |
| 131 | ?> |
| 132 | |
| 133 | <div class="wslu-hover-content"> |
| 134 | <div class="xs-social-followers"> |
| 135 | <?php echo esc_html(xs_format_num($counter)); ?> |
| 136 | </div> |
| 137 | <div class="xs-social-follower-text"> |
| 138 | <?php echo esc_html($text); ?> |
| 139 | </div> |
| 140 | </div> |
| 141 | |
| 142 | </a> |
| 143 | </li> |
| 144 | <?php |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | ?> |
| 149 | |
| 150 | </ul> |
| 151 | </div> |
| 152 | |
| 153 | <?php |
| 154 | |
| 155 | endif; |
| 156 |