| @@ -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 \MaxButtons\simple_html_dom as simple_html_dom; | |
| 5 | +use \maxbuttons\maxUtils as maxUtils; | |
| 6 | +use \maxbuttons\maxCSSParser as maxCSSParser; | |
| 7 | +use \simple_html_dom as simple_html_dom; | |
| 8 | 8 | |
| 9 | 9 | |
| 10 | 10 | class collection |
| 11 | 11 | { |
| @@ -31,10 +31,8 @@ | ||
| 31 | 31 | public $is_static = false; |
| 32 | 32 | public $is_post = false; // embedded in a post situation |
| 33 | 33 | public $is_mobile = false; |
| 34 | 34 | public $is_tablet = false; |
| 35 | - public $is_desktop = false; | |
| 36 | - | |
| 37 | 35 | public $orientation = 'horizontal'; |
| 38 | 36 | public $display_mode = 'hidden'; |
| 39 | 37 | public $post_id; |
| 40 | 38 | |
| @@ -59,9 +57,9 @@ | ||
| 59 | 57 | $block = collections::getBlock($block_name); |
| 60 | 58 | if ($block) |
| 61 | 59 | { |
| 62 | 60 | $block->setCollection($this); |
| 63 | - $default_data = $block->save_fields($default_data, array() ); // force the fields to set a default pos. | |
| 61 | + $default_data = $block->save_fields($default_data, null ); // force the fields to set a default pos. | |
| 64 | 62 | |
| 65 | 63 | $this->blocks[$block_name] = $block; |
| 66 | 64 | |
| 67 | 65 | } |
| @@ -80,9 +78,9 @@ | ||
| 80 | 78 | } |
| 81 | 79 | |
| 82 | 80 | if ($collection_id > 0) |
| 83 | 81 | { |
| 84 | - $this->set($collection_id); // set function loads the block values | |
| 82 | + $this->set($collection_id); | |
| 85 | 83 | } |
| 86 | 84 | } |
| 87 | 85 | /* Get all buttons that are currently loaded */ |
| 88 | 86 | /*public function getLoadedButtons() |
| @@ -244,9 +242,8 @@ | ||
| 244 | 242 | // check if on some mobile |
| 245 | 243 | $mobileDetect = new Mobile_Detect; |
| 246 | 244 | $this->is_mobile = $mobileDetect->isMobile(); |
| 247 | 245 | $this->is_tablet = $mobileDetect->isTablet(); |
| 248 | - $this->is_desktop = ($this->is_mobile) ? false : true; | |
| 249 | 246 | |
| 250 | 247 | $options = isset($data['display'][$hook . '_options']) ? $data['display'][$hook . '_options'] : array(); |
| 251 | 248 | |
| 252 | 249 | $orientation = isset($options['orientation']) ? $options['orientation'] : 'auto'; |
| @@ -296,23 +293,8 @@ | ||
| 296 | 293 | elseif (isset($meta['general']['active']) && $is_old_active === 0) // backward for 0.9.5 . Can go at some point |
| 297 | 294 | $this->is_showable = false; |
| 298 | 295 | } |
| 299 | 296 | |
| 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 | - | |
| 315 | 297 | // new method of getting data around |
| 316 | 298 | $w->tell('display/env/hook', $hook); |
| 317 | 299 | $w->tell('display/env/post_id', $this->post_id); |
| 318 | 300 | $w->tell('display/env/is_static', $this->is_static ); |
| @@ -351,24 +333,8 @@ | ||
| 351 | 333 | $result["title"] = __("Error : Block was not there","maxbuttons"); |
| 352 | 334 | return $result; |
| 353 | 335 | } |
| 354 | 336 | |
| 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 | - | |
| 371 | 337 | /** Save the collection post data to the database. This will invoke the save functions of the blocks itself to gather, verify and manipulate data */ |
| 372 | 338 | public function save($post) |
| 373 | 339 | { |
| 374 | 340 | $data = array(); |
| @@ -640,14 +606,14 @@ | ||
| 640 | 606 | { |
| 641 | 607 | if (! $this->is_showable) |
| 642 | 608 | return; |
| 643 | 609 | |
| 644 | - /* 1.8 Deprecated. Not included in MB() anymore, using svg method. | |
| 645 | - if (method_exists(MB(), 'load_library')) | |
| 610 | + | |
| 611 | + /*if (method_exists(MB(), 'load_library')) | |
| 646 | 612 | { |
| 647 | 613 | MB()->load_library('fontawesome'); // always load lib since change is about 100% this includes FA. |
| 648 | - } | |
| 649 | - */ | |
| 614 | + } */ | |
| 615 | + | |
| 650 | 616 | maxUtils::startTime('collection-display-' . self::$count); |
| 651 | 617 | |
| 652 | 618 | $w = MBSocial()->whistle(); |
| 653 | 619 | |
| @@ -707,23 +673,8 @@ | ||
| 707 | 673 | } |
| 708 | 674 | |
| 709 | 675 | } |
| 710 | 676 | |
| 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 | - | |
| 726 | 677 | public function displayCSS($css, $args = array() ) // $echo = true, $style_tag = true) |
| 727 | 678 | { |
| 728 | 679 | |
| 729 | 680 | $default = array( |
| @@ -735,9 +686,8 @@ | ||
| 735 | 686 | if ($args['load_type'] == 'inline') |
| 736 | 687 | $args['style_tag'] =true; |
| 737 | 688 | |
| 738 | 689 | $output = ''; |
| 739 | - $css = apply_filters('mbsocial/displaycss/', $css); | |
| 740 | 690 | |
| 741 | 691 | if ($args["style_tag"]) |
| 742 | 692 | $output .= "<style type='text/css'>"; |
| 743 | 693 | |
| @@ -750,22 +700,13 @@ | ||
| 750 | 700 | if ($args["load_type"] == 'footer') |
| 751 | 701 | { |
| 752 | 702 | $load_id = 'collection-' . $this->collection_id; // must be unique for unique items, otherwise css won't be output |
| 753 | 703 | |
| 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 | - | |
| 762 | 704 | if (self::$count > 1) |
| 763 | 705 | { |
| 764 | 706 | $load_id .= "-" . self::$count; |
| 765 | 707 | } |
| 766 | 708 | |
| 767 | - | |
| 768 | 709 | do_action('mb-footer',$load_id, $output); |
| 769 | 710 | } |
| 770 | 711 | elseif ($args["load_type"] == 'inline') |
| 771 | 712 | { |
| @@ -775,9 +716,9 @@ | ||
| 775 | 716 | } |
| 776 | 717 | |
| 777 | 718 | } |
| 778 | 719 | |
| 779 | - public function displayJS($js, $args = array() ) | |
| 720 | + public function displayJS($js, $args = array() ) // $echo = true, $style_tag = true) | |
| 780 | 721 | { |
| 781 | 722 | $default = array( |
| 782 | 723 | "echo" => true, |
| 783 | 724 | "js_tag" => true, |
| @@ -798,9 +739,12 @@ | ||
| 798 | 739 | |
| 799 | 740 | if ($args["js_tag"]) |
| 800 | 741 | { |
| 801 | 742 | $output .= "<script type='text/javascript'> "; |
| 743 | +// $output .= " if (typeof MBcollection" . $this->collection_id . " == 'undefined') { "; | |
| 744 | +// $output .= " function MBcollection" . $this->collection_id . "() { "; | |
| 802 | 745 | |
| 746 | + | |
| 803 | 747 | } |
| 804 | 748 | |
| 805 | 749 | foreach($js as $index => $code) |
| 806 | 750 | { |
| @@ -808,9 +752,11 @@ | ||
| 808 | 752 | } |
| 809 | 753 | |
| 810 | 754 | if ($args["js_tag"]) |
| 811 | 755 | { |
| 812 | - $output .= " | |
| 756 | + $output .= " // } | |
| 757 | + // } | |
| 758 | + // window.onload = MBcollection" . $this->collection_id . "(); | |
| 813 | 759 | </script> "; |
| 814 | 760 | } |
| 815 | 761 | |
| 816 | 762 | |
| @@ -843,9 +789,9 @@ | ||
| 843 | 789 | $collectionObj = new simple_html_dom(); |
| 844 | 790 | $collection_id = $this->collection_id; |
| 845 | 791 | |
| 846 | 792 | $styleObj = $this->styleObj; |
| 847 | - $style_class = ''; | |
| 793 | + $style_class = ''; //$styleObj->class; | |
| 848 | 794 | $style_class = $this->orientation; |
| 849 | 795 | |
| 850 | 796 | // create container |
| 851 | 797 | if (self::$count > 1) |
| @@ -851,9 +797,9 @@ | ||
| 851 | 797 | if (self::$count > 1) |
| 852 | 798 | { |
| 853 | 799 | $style_class .= ' doc-' . self::$count; |
| 854 | 800 | } |
| 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) . "''> | |
| 801 | + $node = "<div class='maxsocial maxsocial-" . $collection_id . " $style_class ' data-collection='" . $collection_id . "'> | |
| 856 | 802 | </div>"; |
| 857 | 803 | $node = apply_filters("maxbuttons/social/basic-container",$node); |
| 858 | 804 | |
| 859 | 805 | $collectionObj->load($node); |
| @@ -858,9 +804,8 @@ | ||
| 858 | 804 | |
| 859 | 805 | $collectionObj->load($node); |
| 860 | 806 | |
| 861 | 807 | $active = ( isset($this->data['network']['network_active']) && is_array($this->data['network']['network_active']) ) ? $this->data['network']['network_active'] : array(); |
| 862 | - | |
| 863 | 808 | if (count($active) == 0 && $args['preview'] == true) |
| 864 | 809 | { |
| 865 | 810 | $networks = $admin->get_default_networks(); |
| 866 | 811 | $use_networks = $networks['unselected']; |
| @@ -881,19 +826,12 @@ | ||
| 881 | 826 | if (! is_object($network)) |
| 882 | 827 | { |
| 883 | 828 | continue; |
| 884 | 829 | } |
| 885 | - if (! $is_preview) | |
| 886 | - { | |
| 887 | - if ( ($this->is_mobile && ! $network->forMobile() ) || $this->is_desktop && ! $network->forDesktop() ) | |
| 888 | - { | |
| 889 | - continue; | |
| 890 | - } | |
| 891 | - } | |
| 892 | 830 | $w->tell('display/parse/network', $network); |
| 893 | 831 | |
| 894 | 832 | $button_args = array('link' => $network->get_url(), |
| 895 | - 'preview' => $is_preview, | |
| 833 | + 'preview' => $is_preview, | |
| 896 | 834 | 'index' => $index, |
| 897 | 835 | 'name' => $network->get('network'), |
| 898 | 836 | 'data' => $this->data, |
| 899 | 837 | 'collection_count' => self::$count, |
| @@ -998,9 +936,8 @@ | ||
| 998 | 936 | $css = $this->styleObj->preParse($css); |
| 999 | 937 | $css = apply_filters('mbsocial/parsecss/', $css); // anybody else |
| 1000 | 938 | |
| 1001 | 939 | $css = $this->getCSSParser()->parse($css); |
| 1002 | - | |
| 1003 | 940 | maxUtils::endTime('collection-parseCSS-'. self::$count); |
| 1004 | 941 | return $css; |
| 1005 | 942 | } |
| 1006 | 943 | |