| @@ -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(); |
| @@ -757,9 +775,9 @@ | ||
| 757 | 775 | } |
| 758 | 776 | |
| 759 | 777 | } |
| 760 | 778 | |
| 761 | - public function displayJS($js, $args = array() ) // $echo = true, $style_tag = true) | |
| 779 | + public function displayJS($js, $args = array() ) | |
| 762 | 780 | { |
| 763 | 781 | $default = array( |
| 764 | 782 | "echo" => true, |
| 765 | 783 | "js_tag" => true, |
| @@ -790,11 +808,9 @@ | ||
| 790 | 808 | } |
| 791 | 809 | |
| 792 | 810 | if ($args["js_tag"]) |
| 793 | 811 | { |
| 794 | - $output .= " // } | |
| 795 | - // } | |
| 796 | - // window.onload = MBcollection" . $this->collection_id . "(); | |
| 812 | + $output .= " | |
| 797 | 813 | </script> "; |
| 798 | 814 | } |
| 799 | 815 | |
| 800 | 816 | |
| @@ -827,9 +843,9 @@ | ||
| 827 | 843 | $collectionObj = new simple_html_dom(); |
| 828 | 844 | $collection_id = $this->collection_id; |
| 829 | 845 | |
| 830 | 846 | $styleObj = $this->styleObj; |
| 831 | - $style_class = ''; //$styleObj->class; | |
| 847 | + $style_class = ''; | |
| 832 | 848 | $style_class = $this->orientation; |
| 833 | 849 | |
| 834 | 850 | // create container |
| 835 | 851 | if (self::$count > 1) |
| @@ -835,9 +851,9 @@ | ||
| 835 | 851 | if (self::$count > 1) |
| 836 | 852 | { |
| 837 | 853 | $style_class .= ' doc-' . self::$count; |
| 838 | 854 | } |
| 839 | - $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) . "''> | |
| 840 | 856 | </div>"; |
| 841 | 857 | $node = apply_filters("maxbuttons/social/basic-container",$node); |
| 842 | 858 | |
| 843 | 859 | $collectionObj->load($node); |
| @@ -875,9 +891,9 @@ | ||
| 875 | 891 | } |
| 876 | 892 | $w->tell('display/parse/network', $network); |
| 877 | 893 | |
| 878 | 894 | $button_args = array('link' => $network->get_url(), |
| 879 | - 'preview' => $is_preview, | |
| 895 | + 'preview' => $is_preview, | |
| 880 | 896 | 'index' => $index, |
| 881 | 897 | 'name' => $network->get('network'), |
| 882 | 898 | 'data' => $this->data, |
| 883 | 899 | 'collection_count' => self::$count, |