counter-html.php
138 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 | if(!empty($enabled_providers[$key]['enable'])) { |
| 23 | |
| 24 | // check if provider list is provided from widget |
| 25 | if(!in_array($key, $provider)) { |
| 26 | continue; |
| 27 | } |
| 28 | |
| 29 | $p_obj = $factory->make($key); |
| 30 | //$follower_count = $p_obj->get_cached_count($cache_time); |
| 31 | |
| 32 | $label = isset($counter_provider[$key]['label']) ? $counter_provider[$key]['label'] : ''; |
| 33 | $def = isset($counter_provider[$key]['data']['value']) ? $counter_provider[$key]['data']['value'] : 0; |
| 34 | $text = isset($counter_provider[$key]['data']['text']) ? $counter_provider[$key]['data']['text'] : ''; |
| 35 | |
| 36 | /** |
| 37 | * We will give priority to the actual number, if actual number is zero then we will show the default value. |
| 38 | */ |
| 39 | $counter = !empty($counter_data[$key]) ? $counter_data[$key] : $def; |
| 40 | #$counter = ($def) > 0 ? $def : $counter; |
| 41 | |
| 42 | $id = isset($counter_provider[$key]['id']) ? $counter_provider[$key]['id'] : ''; |
| 43 | $user_name = isset($counter_provider[$key]['user_name']) ? $counter_provider[$key]['user_name'] : ''; |
| 44 | $type = isset($counter_provider[$key]['type']) ? $counter_provider[$key]['type'] : ''; |
| 45 | $getUrl = isset($core_provider[$key]['data']['url']) ? $core_provider[$key]['data']['url'] : '#'; |
| 46 | |
| 47 | if($key == 'youtube') { |
| 48 | $url = sprintf($getUrl, strtolower($type), $id); |
| 49 | |
| 50 | } elseif($key == 'linkedin') { |
| 51 | |
| 52 | if($type == 'Profile') { |
| 53 | $url = sprintf($getUrl, 'in', $id); |
| 54 | |
| 55 | } else { |
| 56 | $url = sprintf($getUrl, 'company', $id); |
| 57 | } |
| 58 | } elseif($key == 'dribbble') { |
| 59 | |
| 60 | $url = get_option('home_url_dribbble_count', 'https://dribbble.com/'); |
| 61 | |
| 62 | } elseif($key == 'instagram') { |
| 63 | |
| 64 | $url = sprintf($getUrl, $user_name); |
| 65 | |
| 66 | }else { |
| 67 | $url = sprintf($getUrl, $id); |
| 68 | } |
| 69 | |
| 70 | ?> |
| 71 | <li class="xs-counter-li <?php echo esc_attr($key); ?>" data-key="<?php echo esc_attr($key); ?>"> |
| 72 | <a href="<?php echo esc_url($url); ?>" target="_blank"> |
| 73 | <div class="xs-social-icon"> |
| 74 | <span class="met-social met-social-<?php echo esc_attr($key); ?>"></span> |
| 75 | </div> |
| 76 | |
| 77 | <?php |
| 78 | |
| 79 | if(!empty($styleArr[$cntStyleKey]['content'])) { |
| 80 | |
| 81 | if(!empty($styleArr[$cntStyleKey]['content']['number'])) { |
| 82 | |
| 83 | ?> |
| 84 | <div class="xs-social-follower"> |
| 85 | <?php echo esc_html(xs_format_num($counter)); ?> |
| 86 | </div> |
| 87 | |
| 88 | <?php |
| 89 | } |
| 90 | |
| 91 | if(!empty($styleArr[$cntStyleKey]['content']['label'])) { |
| 92 | |
| 93 | ?> |
| 94 | <div class="xs-social-follower-text"> |
| 95 | <?php echo esc_html($text); ?> |
| 96 | </div> |
| 97 | <?php |
| 98 | } |
| 99 | |
| 100 | } else { |
| 101 | |
| 102 | ?> |
| 103 | <div class="xs-social-follower"> |
| 104 | <?php echo esc_html(xs_format_num($counter)); ?> |
| 105 | </div> |
| 106 | |
| 107 | <div class="xs-social-follower-text"> |
| 108 | <?php echo esc_html($text); ?> |
| 109 | </div> |
| 110 | |
| 111 | <?php |
| 112 | } |
| 113 | ?> |
| 114 | |
| 115 | <div class="wslu-hover-content"> |
| 116 | <div class="xs-social-followers"> |
| 117 | <?php echo esc_html(xs_format_num($counter)); ?> |
| 118 | </div> |
| 119 | <div class="xs-social-follower-text"> |
| 120 | <?php echo esc_html($text); ?> |
| 121 | </div> |
| 122 | </div> |
| 123 | |
| 124 | </a> |
| 125 | </li> |
| 126 | <?php |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | ?> |
| 131 | |
| 132 | </ul> |
| 133 | </div> |
| 134 | |
| 135 | <?php |
| 136 | |
| 137 | endif; |
| 138 |