share-html.php
144 lines
| 1 | <?php |
| 2 | |
| 3 | use WP_Social\App\Settings; |
| 4 | |
| 5 | defined('ABSPATH') || exit; |
| 6 | |
| 7 | $share_settings = Settings::instance()->get_providers_settings_share(); |
| 8 | $share_settings = isset( $share_settings['social'] ) ? $share_settings['social'] : $share_settings ; |
| 9 | $wanted_providers = $provider; |
| 10 | $selected_share_style = $shareStyleKey; |
| 11 | |
| 12 | $uri_hash = md5($currentUrl); |
| 13 | |
| 14 | |
| 15 | if(!empty($wanted_providers) && is_array($wanted_providers)) : |
| 16 | |
| 17 | if(!empty($styles[$selected_share_style]['package']) && $styles[$selected_share_style]['package'] == 'pro' && !WP_Social::is_pro_active()) { |
| 18 | |
| 19 | ?> |
| 20 | <div class="xs_social_share_widget xs_share_url"> |
| 21 | <ul> |
| 22 | <li class="xs-share-li wslu-no-extra-data">Pro plugin deactivated or invalid</li> |
| 23 | </ul> |
| 24 | </div> |
| 25 | <?php |
| 26 | |
| 27 | return; |
| 28 | } ?> |
| 29 | |
| 30 | <div class="xs_social_share_widget xs_share_url <?php echo esc_attr($customClass) . ' '; ?> |
| 31 | <?php echo esc_attr($fixed_display) . ' '; ?> <?php echo esc_attr($widget_style); ?>"> |
| 32 | |
| 33 | <?php if($showCountMarkup): ?> |
| 34 | |
| 35 | <div class="wslu-share-count"> |
| 36 | <span class="wslu-share-count--total"><?php echo esc_html(xs_format_num($totalSCount)); ?></span> |
| 37 | <span class="wslu-share-count--text"><?php esc_html_e('Shares', 'wp-social') ?></span> |
| 38 | </div> |
| 39 | |
| 40 | <?php endif; ?> |
| 41 | |
| 42 | <ul> |
| 43 | <?php |
| 44 | $content = isset($styles[$selected_share_style]['content']) ? $styles[$selected_share_style]['content'] : ''; |
| 45 | |
| 46 | foreach($wanted_providers as $key) { |
| 47 | |
| 48 | if(!empty($enabled_providers[$key]['enable'])) { |
| 49 | |
| 50 | $counter = empty($share_counting[$key]['count']) ? 0 : $share_counting[$key]['count']; |
| 51 | |
| 52 | $label = isset($share_settings[$key]['data']['label']) ? $share_settings[$key]['data']['label'] : ucfirst($key); |
| 53 | $def = isset($share_settings[$key]['data']['value']) ? intval($share_settings[$key]['data']['value']) : 0; |
| 54 | $text = isset($share_settings[$key]['data']['text']) ? $share_settings[$key]['data']['text'] : ''; |
| 55 | |
| 56 | $getUrl = isset($core_provider[$key]['url']) ? $core_provider[$key]['url'] : ''; |
| 57 | $pData = isset($core_provider[$key]['params']) ? $core_provider[$key]['params'] : []; |
| 58 | |
| 59 | $urlCon = empty($core_provider[$key]['params']) ? [] : $core_provider[$key]['params']; |
| 60 | |
| 61 | $old_count = Settings::get_old_count($key); |
| 62 | $counter = ( $counter + $old_count > 0 ) ? $counter + $old_count : $def; |
| 63 | |
| 64 | foreach($urlCon as $k => $v) { |
| 65 | |
| 66 | $urlCon[$k] = str_replace( |
| 67 | ['[%url%]', '[%title%]', '[%author%]', '[%details%]', '[%source%]', '[%media%]', '[%app_id%]'], |
| 68 | [$currentUrl, $title, $author, $details, $source, $media, $app_id], |
| 69 | $v |
| 70 | ); |
| 71 | } |
| 72 | |
| 73 | $params = http_build_query($urlCon, '&'); |
| 74 | |
| 75 | ?> |
| 76 | <li class="xs-share-li <?php echo esc_attr($key); ?> |
| 77 | <?php echo esc_attr(Settings::get_extra_data_class($selected_share_style, $styles)) ?>"> |
| 78 | <a href="javascript:void();" |
| 79 | id="xs_feed_<?php echo esc_attr($key) ?>" |
| 80 | onclick="xs_social_sharer(this);" |
| 81 | data-pid="<?php echo esc_attr($postId) ?>" |
| 82 | data-uri_hash="<?php echo esc_attr($uri_hash) ?>" |
| 83 | data-key="<?php echo esc_attr($key); ?>" |
| 84 | data-xs-href="<?php echo esc_attr($getUrl . '?' . $params); ?>"> |
| 85 | |
| 86 | <div class="xs-social-icon"> |
| 87 | <span class="met-social met-social-<?php echo esc_attr($key); ?>"></span> |
| 88 | </div> |
| 89 | |
| 90 | <?php if(!empty($styles[$selected_share_style]['content']) != '') : ?> |
| 91 | <div class="wslu-both-counter-text "> |
| 92 | |
| 93 | <?php if(Settings::has_number_content_in_selected_style($selected_share_style, $styles)) : ?> |
| 94 | <div class="xs-social-follower"> |
| 95 | <?php echo esc_html(xs_format_num($counter)); ?> |
| 96 | </div> |
| 97 | <?php endif; ?> |
| 98 | |
| 99 | <?php if(Settings::has_text_content_in_selected_style($selected_share_style, $styles)) : ?> |
| 100 | <div class="xs-social-follower-text"> |
| 101 | <?php echo esc_html($text); ?> |
| 102 | </div> |
| 103 | <?php endif; ?> |
| 104 | |
| 105 | <?php if(Settings::has_label_content_in_selected_style($selected_share_style, $styles)) : ?> |
| 106 | <div class="xs-social-follower-label"> |
| 107 | <?php echo esc_html($label); ?> |
| 108 | </div> |
| 109 | <?php endif; ?> |
| 110 | </div> |
| 111 | <?php endif; ?> |
| 112 | |
| 113 | <div class="wslu-hover-content"> |
| 114 | <div class="xs-social-followers"> |
| 115 | <?php echo esc_html(xs_format_num($counter)); ?> |
| 116 | </div> |
| 117 | <div class="xs-social-follower-text"> |
| 118 | <?php echo esc_html($text); ?> |
| 119 | </div> |
| 120 | <div class="xs-social-follower-label"> |
| 121 | <?php echo esc_html($label); ?> |
| 122 | </div> |
| 123 | </div> |
| 124 | </a> |
| 125 | </li> |
| 126 | <?php |
| 127 | } |
| 128 | } ?> |
| 129 | </ul> |
| 130 | </div> <?php |
| 131 | |
| 132 | elseif(!empty($styles[$selected_share_style]['package']) && $styles[$selected_share_style]['package'] == 'pro'): ?> |
| 133 | |
| 134 | <div class="xs_social_share_widget xs_share_url"> |
| 135 | <ul> |
| 136 | <li class="xs-share-li wslu-no-extra-data">Pro plugin deactivated</li> |
| 137 | </ul> |
| 138 | </div> |
| 139 | |
| 140 | <?php |
| 141 | |
| 142 | endif; ?> |
| 143 | |
| 144 |