PluginProbe
Social Share Buttons / trunk
Social Share Buttons vtrunk
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 +39 -16 1.12trunk 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 {
@@ -296,8 +296,9 @@
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 +
300 301 if ( Install::isPRO() ) {
301 302 $show_mobile = (isset($data['display']['show_mobile']) && $data['display']['show_mobile'] == 0) ? false: true;
302 303 $show_desktop = (isset($data['display']['show_desktop']) && $data['display']['show_desktop'] == 0) ? false: true;
303 304
@@ -309,8 +310,9 @@
309 310 {
310 311 $this->is_showable = false;
311 312 }
312 313 }
314 +
313 315 // new method of getting data around
314 316 $w->tell('display/env/hook', $hook);
315 317 $w->tell('display/env/post_id', $this->post_id);
316 318 $w->tell('display/env/is_static', $this->is_static );
@@ -349,8 +351,24 @@
349 351 $result["title"] = __("Error : Block was not there","maxbuttons");
350 352 return $result;
351 353 }
352 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 +
353 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 */
354 372 public function save($post)
355 373 {
356 374 $data = array();
@@ -622,9 +640,8 @@
622 640 {
623 641 if (! $this->is_showable)
624 642 return;
625 643
626 -
627 644 /* 1.8 Deprecated. Not included in MB() anymore, using svg method.
628 645 if (method_exists(MB(), 'load_library'))
629 646 {
630 647 MB()->load_library('fontawesome'); // always load lib since change is about 100% this includes FA.
@@ -690,11 +707,16 @@
690 707 }
691 708
692 709 }
693 710
694 - public function getDisplayCSS() // For file output
711 + public function getDisplayCSS($doc_id = false) // For file output
695 712 {
696 - $meta = $this->get_meta('_parsed_css');
713 + $key = '_parsed_css';
714 +
715 + if ($doc_id)
716 + $key .= '_' . $doc_id;
717 +
718 + $meta = $this->get_meta($key);
697 719 if (is_array($meta))
698 720 return array_shift($meta);
699 721 else
700 722 return false;
@@ -713,13 +735,14 @@
713 735 if ($args['load_type'] == 'inline')
714 736 $args['style_tag'] =true;
715 737
716 738 $output = '';
739 + $css = apply_filters('mbsocial/displaycss/', $css);
717 740
718 741 if ($args["style_tag"])
719 742 $output .= "<style type='text/css'>";
720 743
721 - $output .= apply_filters('mbsocial/displaycss/', $css);
744 + $output .= $css;
722 745
723 746 if ($args["style_tag"])
724 747 $output .= "</style>";
725 748
@@ -730,10 +753,11 @@
730 753
731 754 $use_file = get_option('maxbuttons_usecssfile', false);
732 755 if ($use_file)
733 756 {
734 - wp_enqueue_style('maxbuttons-social-front', admin_url('admin-ajax.php').'?action=maxbuttons_social_css&id=' . $this->collection_id);
735 - $this->update_meta($this->collection_id, '_parsed_css', $css);
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);
736 760 }
737 761
738 762 if (self::$count > 1)
739 763 {
@@ -751,9 +775,9 @@
751 775 }
752 776
753 777 }
754 778
755 - public function displayJS($js, $args = array() ) // $echo = true, $style_tag = true)
779 + public function displayJS($js, $args = array() )
756 780 {
757 781 $default = array(
758 782 "echo" => true,
759 783 "js_tag" => true,
@@ -784,11 +808,9 @@
784 808 }
785 809
786 810 if ($args["js_tag"])
787 811 {
788 - $output .= " // }
789 - // }
790 - // window.onload = MBcollection" . $this->collection_id . "();
812 + $output .= "
791 813 </script> ";
792 814 }
793 815
794 816
@@ -821,9 +843,9 @@
821 843 $collectionObj = new simple_html_dom();
822 844 $collection_id = $this->collection_id;
823 845
824 846 $styleObj = $this->styleObj;
825 - $style_class = ''; //$styleObj->class;
847 + $style_class = '';
826 848 $style_class = $this->orientation;
827 849
828 850 // create container
829 851 if (self::$count > 1)
@@ -829,9 +851,9 @@
829 851 if (self::$count > 1)
830 852 {
831 853 $style_class .= ' doc-' . self::$count;
832 854 }
833 - $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) . "''>
834 856 </div>";
835 857 $node = apply_filters("maxbuttons/social/basic-container",$node);
836 858
837 859 $collectionObj->load($node);
@@ -869,9 +891,9 @@
869 891 }
870 892 $w->tell('display/parse/network', $network);
871 893
872 894 $button_args = array('link' => $network->get_url(),
873 - 'preview' => $is_preview,
895 + 'preview' => $is_preview,
874 896 'index' => $index,
875 897 'name' => $network->get('network'),
876 898 'data' => $this->data,
877 899 'collection_count' => self::$count,
@@ -976,8 +998,9 @@
976 998 $css = $this->styleObj->preParse($css);
977 999 $css = apply_filters('mbsocial/parsecss/', $css); // anybody else
978 1000
979 1001 $css = $this->getCSSParser()->parse($css);
1002 +
980 1003 maxUtils::endTime('collection-parseCSS-'. self::$count);
981 1004 return $css;
982 1005 }
983 1006