| @@ -46,9 +46,9 @@ | ||
| 46 | 46 | |
| 47 | 47 | $url = $itemObj->href; |
| 48 | 48 | |
| 49 | 49 | // replace all {} variables with data |
| 50 | - $url = $admin->applyVars($url); | |
| 50 | + $url = $this->applyVars($url, $args); | |
| 51 | 51 | |
| 52 | 52 | // remove empty query parts from the URL |
| 53 | 53 | $parts = parse_url($url); |
| 54 | 54 | if(isset($parts['query']) > 0) |
| @@ -72,8 +72,9 @@ | ||
| 72 | 72 | } |
| 73 | 73 | else { |
| 74 | 74 | if (! $network->get('forcesamewindow')) |
| 75 | 75 | $itemObj->target = "_blank"; |
| 76 | + | |
| 76 | 77 | } |
| 77 | 78 | |
| 78 | 79 | $itemObj->rel = 'noopener nofollow'; |
| 79 | 80 | |
| @@ -112,22 +113,14 @@ | ||
| 112 | 113 | { |
| 113 | 114 | $layoutBlock = $this->collection->getBlock('layoutBlock'); |
| 114 | 115 | $icon_size = $layoutBlock->getValue('font_icon_size'); |
| 115 | 116 | } |
| 116 | - | |
| 117 | +// | |
| 117 | 118 | $args = array('icon' => $icon, |
| 118 | 119 | 'icon_type' => $icon_type, |
| 119 | 120 | 'title' => $network_name, |
| 120 | 121 | 'icon_size' => $icon_size |
| 121 | 122 | ); |
| 122 | - | |
| 123 | - if ($icon_type == 'image') | |
| 124 | - { | |
| 125 | - $args['image_id'] = $network->get('icon_image_id'); | |
| 126 | - $args['image_size'] = $network->get('icon_image_size'); | |
| 127 | - $args['image_url'] = $network->get('icon_image_url'); | |
| 128 | - } | |
| 129 | - | |
| 130 | 123 | return MBSocial()->admin()->renderIcon($args); |
| 131 | 124 | |
| 132 | 125 | } |
| 133 | 126 | |
| @@ -286,10 +279,56 @@ | ||
| 286 | 279 | else |
| 287 | 280 | return ''; |
| 288 | 281 | } |
| 289 | 282 | |
| 283 | + public function applyVars($string) | |
| 284 | + { | |
| 285 | + //$vars = $this->getShareData(); | |
| 286 | + $w = MBSocial()->whistle(); | |
| 290 | 287 | |
| 288 | + preg_match_all('/\{(.*?)\}/im', $string, $matches); | |
| 289 | + //$vars = (isset($vars[0]) && count($vars[0]) > 0) ? $vars[0] : array(); | |
| 291 | 290 | |
| 291 | + if (count($matches) == 0) | |
| 292 | + return $string; | |
| 293 | + | |
| 294 | + $vars = $matches[0]; // i.e. {url} | |
| 295 | + $clean_vars = $matches[1]; // i.e. url | |
| 296 | + | |
| 297 | + for($i = 0; $i < count($vars); $i++) | |
| 298 | + { | |
| 299 | + $var = $vars[$i]; | |
| 300 | + $clean_var = $clean_vars[$i]; | |
| 301 | + | |
| 302 | + if (strpos($string, $var) !== false) | |
| 303 | + { | |
| 304 | + $val = $w->ask('display/vars/' . $clean_var); | |
| 305 | + $string = str_replace($var, $val, $string); | |
| 306 | + } | |
| 307 | + | |
| 308 | + } | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + /*if (isset($vars["url"])) | |
| 313 | + $string = str_replace("{url}", urlencode(esc_url($vars["url"])), $string); | |
| 314 | + if (isset($vars["count"])) | |
| 315 | + { | |
| 316 | + $count = $this->formatCount($vars["count"]); | |
| 317 | + $string = str_replace("{count}", "<span class='share_count'>" . $count . "</span>", $string); | |
| 318 | + $string = str_replace("{c}", "<span class='share_count'>" . $count . "</span>", $string); | |
| 319 | + } | |
| 320 | + if (isset($vars["title"])) | |
| 321 | + $string = str_replace("{title}", $vars["title"], $string); | |
| 322 | + if (isset($vars["network_name"])) | |
| 323 | + $string = str_replace("{network_name}", $vars["network_name"], $string); | |
| 324 | + | |
| 325 | + if (isset($vars["img"])) | |
| 326 | + $string = str_replace("{img}", $vars["img"], $string); | |
| 327 | +*/ | |
| 328 | + return $string; | |
| 329 | + } | |
| 330 | + | |
| 292 | 331 | function save_fields($data, $post) |
| 293 | 332 | { |
| 294 | 333 | $data = parent::save_fields($data, $post); |
| 295 | 334 | |
| @@ -375,9 +414,8 @@ | ||
| 375 | 414 | |
| 376 | 415 | $active_networks = isset($blockdata['network_active']) ? $blockdata['network_active'] : array(); |
| 377 | 416 | $networks = $admin->get_networks($active_networks); |
| 378 | 417 | $styleObj = $this->collection->getStyle(); |
| 379 | - | |
| 380 | 418 | ?> |
| 381 | 419 | <div class='help-side'> |
| 382 | 420 | <h3><?php _e('Social Networks','mbsocial'); ?></h3> |
| 383 | 421 | <p>Drag and drop the networks you want to use into the 'active' box. You can find additional networks under the 'more networks' tab.</p> |
| @@ -453,9 +491,8 @@ | ||
| 453 | 491 | |
| 454 | 492 | <?php |
| 455 | 493 | // find caps of Networks |
| 456 | 494 | $networks = mbSocial()->networks()->get(); |
| 457 | - | |
| 458 | 495 | $nw_share = array(); |
| 459 | 496 | $nw_profile = array(); |
| 460 | 497 | foreach($networks as $nw) |
| 461 | 498 | { |
| @@ -529,15 +566,8 @@ | ||
| 529 | 566 | $icon_type = $network->get('icon_type'); |
| 530 | 567 | $color = $network->get('color'); |
| 531 | 568 | |
| 532 | 569 | $icon_args = array('icon' => $icon, 'icon_type' => $icon_type); |
| 533 | - | |
| 534 | - if ($icon_type == 'image') | |
| 535 | - { | |
| 536 | - $icon_args['image_id'] = $network->get('icon_image_id'); | |
| 537 | - $icon_args['image_size'] = $network->get('icon_image_size'); | |
| 538 | - $icon_args['image_url'] = $network->get('icon_image_url'); | |
| 539 | - } | |
| 540 | 570 | |
| 541 | 571 | $icon_output = MBSocial()->admin()->renderIcon($icon_args); |
| 542 | 572 | $is_share_icon = $network->is_share_icon(); |
| 543 | 573 | $is_social_share = $network->is_social_share(); |