PluginProbe
Social Share Buttons / 1.30
Social Share Buttons v1.30
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/class-collection.php +69 -17 1.31.30 View file →
@@ -1,11 +1,11 @@
1 1 <?php
2 2 namespace MBSocial;
3 3 defined('ABSPATH') or die('No direct access permitted');
4 4
5 -use \maxbuttons\maxUtils as maxUtils;
6 -use \maxbuttons\maxCSSParser as maxCSSParser;
7 -use \simple_html_dom as simple_html_dom;
5 +use \MaxButtons\maxUtils as maxUtils;
6 +use \MaxButtons\maxCSSParser as maxCSSParser;
7 +use \MaxButtons\simple_html_dom as simple_html_dom;
8 8
9 9
10 10 class collection
11 11 {
@@ -59,9 +59,9 @@
59 59 $block = collections::getBlock($block_name);
60 60 if ($block)
61 61 {
62 62 $block->setCollection($this);
63 - $default_data = $block->save_fields($default_data, null ); // force the fields to set a default pos.
63 + $default_data = $block->save_fields($default_data, array() ); // force the fields to set a default pos.
64 64
65 65 $this->blocks[$block_name] = $block;
66 66
67 67 }
@@ -296,8 +296,23 @@
296 296 elseif (isset($meta['general']['active']) && $is_old_active === 0) // backward for 0.9.5 . Can go at some point
297 297 $this->is_showable = false;
298 298 }
299 299
300 +
301 + if ( Install::isPRO() ) {
302 + $show_mobile = (isset($data['display']['show_mobile']) && $data['display']['show_mobile'] == 0) ? false: true;
303 + $show_desktop = (isset($data['display']['show_desktop']) && $data['display']['show_desktop'] == 0) ? false: true;
304 +
305 + if ($this->is_mobile && ! $show_mobile)
306 + {
307 + $this->is_showable = false;
308 + }
309 + if ($this->is_desktop && ! $show_desktop)
310 + {
311 + $this->is_showable = false;
312 + }
313 + }
314 +
300 315 // new method of getting data around
301 316 $w->tell('display/env/hook', $hook);
302 317 $w->tell('display/env/post_id', $this->post_id);
303 318 $w->tell('display/env/is_static', $this->is_static );
@@ -336,8 +351,24 @@
336 351 $result["title"] = __("Error : Block was not there","maxbuttons");
337 352 return $result;
338 353 }
339 354
355 + public function endAjaxRequest($args = array())
356 + {
357 + $defaults = array(
358 + "error" => true, // can have errors and still result true on success
359 + "result" => true,
360 + "body" => "",
361 + "title" => "",
362 + "data" => array(),
363 + );
364 +
365 + $args = wp_parse_args($args, $defaults);
366 +
367 + echo json_encode($args);
368 + die();
369 + }
370 +
340 371 /** Save the collection post data to the database. This will invoke the save functions of the blocks itself to gather, verify and manipulate data */
341 372 public function save($post)
342 373 {
343 374 $data = array();
@@ -609,14 +640,14 @@
609 640 {
610 641 if (! $this->is_showable)
611 642 return;
612 643
613 -
644 + /* 1.8 Deprecated. Not included in MB() anymore, using svg method.
614 645 if (method_exists(MB(), 'load_library'))
615 646 {
616 647 MB()->load_library('fontawesome'); // always load lib since change is about 100% this includes FA.
617 648 }
618 -
649 + */
619 650 maxUtils::startTime('collection-display-' . self::$count);
620 651
621 652 $w = MBSocial()->whistle();
622 653
@@ -676,8 +707,23 @@
676 707 }
677 708
678 709 }
679 710
711 + public function getDisplayCSS($doc_id = false) // For file output
712 + {
713 + $key = '_parsed_css';
714 +
715 + if ($doc_id)
716 + $key .= '_' . $doc_id;
717 +
718 + $meta = $this->get_meta($key);
719 + if (is_array($meta))
720 + return array_shift($meta);
721 + else
722 + return false;
723 +
724 + }
725 +
680 726 public function displayCSS($css, $args = array() ) // $echo = true, $style_tag = true)
681 727 {
682 728
683 729 $default = array(
@@ -689,8 +735,9 @@
689 735 if ($args['load_type'] == 'inline')
690 736 $args['style_tag'] =true;
691 737
692 738 $output = '';
739 + $css = apply_filters('mbsocial/displaycss/', $css);
693 740
694 741 if ($args["style_tag"])
695 742 $output .= "<style type='text/css'>";
696 743
@@ -703,13 +750,22 @@
703 750 if ($args["load_type"] == 'footer')
704 751 {
705 752 $load_id = 'collection-' . $this->collection_id; // must be unique for unique items, otherwise css won't be output
706 753
754 + $use_file = get_option('maxbuttons_usecssfile', false);
755 + if ($use_file)
756 + {
757 +
758 + wp_enqueue_style('maxbuttons-social-front-' . self::$count, admin_url('admin-ajax.php').'?action=maxbuttons_social_css&id=' . $this->collection_id . '&doc=' . self::$count) ;
759 + $this->update_meta($this->collection_id, '_parsed_css_' . self::$count, $css);
760 + }
761 +
707 762 if (self::$count > 1)
708 763 {
709 764 $load_id .= "-" . self::$count;
710 765 }
711 766
767 +
712 768 do_action('mb-footer',$load_id, $output);
713 769 }
714 770 elseif ($args["load_type"] == 'inline')
715 771 {
@@ -719,9 +775,9 @@
719 775 }
720 776
721 777 }
722 778
723 - public function displayJS($js, $args = array() ) // $echo = true, $style_tag = true)
779 + public function displayJS($js, $args = array() )
724 780 {
725 781 $default = array(
726 782 "echo" => true,
727 783 "js_tag" => true,
@@ -742,12 +798,9 @@
742 798
743 799 if ($args["js_tag"])
744 800 {
745 801 $output .= "<script type='text/javascript'> ";
746 -// $output .= " if (typeof MBcollection" . $this->collection_id . " == 'undefined') { ";
747 -// $output .= " function MBcollection" . $this->collection_id . "() { ";
748 802
749 -
750 803 }
751 804
752 805 foreach($js as $index => $code)
753 806 {
@@ -755,11 +808,9 @@
755 808 }
756 809
757 810 if ($args["js_tag"])
758 811 {
759 - $output .= " // }
760 - // }
761 - // window.onload = MBcollection" . $this->collection_id . "();
812 + $output .= "
762 813 </script> ";
763 814 }
764 815
765 816
@@ -792,9 +843,9 @@
792 843 $collectionObj = new simple_html_dom();
793 844 $collection_id = $this->collection_id;
794 845
795 846 $styleObj = $this->styleObj;
796 - $style_class = ''; //$styleObj->class;
847 + $style_class = '';
797 848 $style_class = $this->orientation;
798 849
799 850 // create container
800 851 if (self::$count > 1)
@@ -800,9 +851,9 @@
800 851 if (self::$count > 1)
801 852 {
802 853 $style_class .= ' doc-' . self::$count;
803 854 }
804 - $node = "<div class='maxsocial maxsocial-" . $collection_id . " $style_class ' data-collection='" . $collection_id . "'>
855 + $node = "<div class='maxsocial maxsocial-" . esc_attr($collection_id) . " $style_class ' data-collection='" . $collection_id . "' data-nonce='" . wp_create_nonce('maxsocial_ajax_action-' . $collection_id) . "''>
805 856 </div>";
806 857 $node = apply_filters("maxbuttons/social/basic-container",$node);
807 858
808 859 $collectionObj->load($node);
@@ -834,15 +885,15 @@
834 885 if (! $is_preview)
835 886 {
836 887 if ( ($this->is_mobile && ! $network->forMobile() ) || $this->is_desktop && ! $network->forDesktop() )
837 888 {
838 - continue;
889 + continue;
839 890 }
840 891 }
841 892 $w->tell('display/parse/network', $network);
842 893
843 894 $button_args = array('link' => $network->get_url(),
844 - 'preview' => $is_preview,
895 + 'preview' => $is_preview,
845 896 'index' => $index,
846 897 'name' => $network->get('network'),
847 898 'data' => $this->data,
848 899 'collection_count' => self::$count,
@@ -947,8 +998,9 @@
947 998 $css = $this->styleObj->preParse($css);
948 999 $css = apply_filters('mbsocial/parsecss/', $css); // anybody else
949 1000
950 1001 $css = $this->getCSSParser()->parse($css);
1002 +
951 1003 maxUtils::endTime('collection-parseCSS-'. self::$count);
952 1004 return $css;
953 1005 }
954 1006