PluginProbe
Social Share Buttons / 1.5
Social Share Buttons v1.5
trunk 0.9 1.0 1.1 1.1.1 1.1.2 1.10 1.11 1.12 1.15 1.16 1.17 1.18 1.19 1.2 1.20 1.3 1.30 1.4 1.5 1.6 1.7 1.8 1.9
← All changes | classes/blocks/network-block.php +58 -71 trunk1.5 View file →
@@ -4,9 +4,9 @@
4 4
5 5 $collectionBlock["network"] = array('order' => 10,
6 6 'class' => "networkBlock");
7 7
8 -use \MaxButtons\simple_html_dom as simple_html_dom;
8 +use \simple_html_dom as simple_html_dom;
9 9 use \MaxButtons\maxField as maxField;
10 10 use \MaxButtons\maxBlocks as maxBlocks;
11 11 use \MaxButtons\maxInstall as maxInstall;
12 12
@@ -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
@@ -297,14 +336,8 @@
297 336
298 337 $button = MB()->getClass("button");
299 338 $network_active = isset($post['network_item_active']) ? $post['network_item_active'] : array();
300 339
301 - // Dummy is to ensure conditionals work on network_active.
302 - $index = array_search('dummy', $network_active);
303 - if ($index !== false)
304 - unset($network_active[$index]);
305 -
306 -
307 340 //mbcustom
308 341 $mbcustom = isset($post['mbcustom_id']) ? $post['mbcustom_id'] : array();
309 342 $data[$this->blockname]['mbcustom'] = array();
310 343
@@ -335,15 +368,11 @@
335 368 }
336 369
337 370 // new user, give default networks
338 371 $collection_id = $this->collection->getID();
339 -
340 -
341 372 if (count($network_active) == 0 && $collection_id == 0)
342 373 $network_active = array('facebook', 'twitter'); // default options
343 374
344 -
345 -
346 375 $data[$this->blockname]["network_active"] = $network_active;
347 376 return $data;
348 377 }
349 378
@@ -385,33 +414,13 @@
385 414
386 415 $active_networks = isset($blockdata['network_active']) ? $blockdata['network_active'] : array();
387 416 $networks = $admin->get_networks($active_networks);
388 417 $styleObj = $this->collection->getStyle();
389 -
390 -/*
391 - No clue what this is doing here.
392 -foreach ($networks as $type => $data)
393 - {
394 - echo $type; var_dump($data);
395 - foreach ($data as $network_id => $network)
396 - {
397 - $label = $network->get_nice_name();
398 - $icon = $network->get('icon');
399 - $icon_type = $network->get('icon_type');
400 - $color = $network->get('color');
401 -
402 - $field = new maxField('switch');
403 - $field->id = $network->get('name');
404 - $field->label = $label;
405 -
406 - $admin->addField($field, 'start', 'end');
407 - }
408 - } */
409 418 ?>
410 419 <div class='help-side'>
411 420 <h3><?php _e('Social Networks','mbsocial'); ?></h3>
412 - <p><?php printf(__('%s Drag and drop %s the networks you want to use into the \'active\' box. You can find additional networks under the \'more networks\' tab.', 'mbsocial'), '<strong>', '</strong>'); ?></p>
413 - <p><?php __('Hold the mouse pointer over the network icon to see the network\'s name', 'mbsocial'); ?></p>
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>
422 + <p>Hold the mouse pointer over the network icon to see the network's name</p>
414 423 <p>The <strong>Share Page</strong> networks will share your website's URL to other networks. </p>
415 424 <p>The <strong>Share Profile</strong> networks will link from the website to your social accounts</p>
416 425 </div>
417 426 <div class='options networks option-container' id='networkBlock' data-refresh='previewBlock'>
@@ -425,9 +434,8 @@
425 434 $admin->addField($field_obj);
426 435 $admin->addUpdate($field_obj);
427 436 $admin->display_fields();
428 437
429 -
430 438 ?>
431 439 <div class='title'><?php _e('Social Networks','mbsocial') ?> </div>
432 440 <div class='inside'>
433 441 <div class='option active_network'>
@@ -434,10 +442,8 @@
434 442 <label><?php _e('Active','mbsocial'); ?></label>
435 443 <div class='drag-area input' data-area='active'>
436 444 <span class="updatables hidden">input[name="network_active"], input[name="network_item_active"]</span>
437 445
438 - <input type="hidden" name="network_item_active[]" value="dummy">
439 -
440 446 <?php if (isset($networks['selected'])): foreach($networks['selected'] as $index => $network): ?>
441 447
442 448 <?php
443 449 $args = array();
@@ -446,12 +452,9 @@
446 452
447 453 $this->printNetwork($index, $network, $args );
448 454
449 455 ?>
450 - <?php endforeach;
451 - else: ?>
452 - <?php
453 - endif; ?>
456 + <?php endforeach; endif; ?>
454 457 </div>
455 458 </div>
456 459
457 460
@@ -478,20 +481,10 @@
478 481
479 482 <?php endforeach; endif; ?>
480 483 </div>
481 484
482 - <?php if (Install::IsPro()): ?>
483 - <p><?php printf(__("Need another network? Check out the %s Network settings %s","mbsocial"),
484 - '<a href="' . admin_url('admin.php') . '?page=maxbuttons-social-settings" target="_blank">', '</a>');
485 - ?>
486 -
487 - </p>
488 - <?php else : ?>
489 - <p>
490 - <?php printf(__("More Networks or Customization needed? %s Check out our PRO offer %s ", 'mbsocial'),
491 - '<a href="https://maxbuttons.com/wordpress-share-buttons/#compare" target="_blank">', '</a>'); ?>
492 - </p>
493 - <?php endif; ?>
485 + <p><?php _e("Need another network?","mbsocial"); ?>
486 + <a href='mailto:support@maxfoundry.com'><?php _e('Email us','mbsocial'); ?> </a></p>
494 487 </span>
495 488
496 489 </div>
497 490 </div> <!-- option -->
@@ -498,9 +491,8 @@
498 491
499 492 <?php
500 493 // find caps of Networks
501 494 $networks = mbSocial()->networks()->get();
502 -
503 495 $nw_share = array();
504 496 $nw_profile = array();
505 497 foreach($networks as $nw)
506 498 {
@@ -535,9 +527,9 @@
535 527 </p>
536 528
537 529
538 530 <?php if (Install::isPro()): ?>
539 - <p><?php _e('The MaxButtons option lets you add a MaxButton and configure it.','mbsocial') ?></p>
531 + <p><?php _e('The MaxButtons option lets you a MaxButton and configure it.','mbsocial') ?></p>
540 532 <?php endif; ?>
541 533 </div>
542 534
543 535 <div class='hidden mbcustom-helper'>
@@ -575,15 +567,8 @@
575 567 $color = $network->get('color');
576 568
577 569 $icon_args = array('icon' => $icon, 'icon_type' => $icon_type);
578 570
579 - if ($icon_type == 'image')
580 - {
581 - $icon_args['image_id'] = $network->get('icon_image_id');
582 - $icon_args['image_size'] = $network->get('icon_image_size');
583 - $icon_args['image_url'] = $network->get('icon_image_url');
584 - }
585 -
586 571 $icon_output = MBSocial()->admin()->renderIcon($icon_args);
587 572 $is_share_icon = $network->is_share_icon();
588 573 $is_social_share = $network->is_social_share();
589 574
@@ -732,4 +717,6 @@
732 717 <?php
733 718 }
734 719
735 720 }
721 +
722 +?>