PluginProbe
Social Share Buttons / 1.1.2
Social Share Buttons v1.1.2
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-network.php +13 -109 1.201.1.2 View file →
@@ -2,9 +2,8 @@
2 2 namespace MBSocial;
3 3 defined('ABSPATH') or die('No direct access permitted');
4 4
5 5 use \MaxButtons\MaxUtils as MaxUtils;
6 -use \MaxButtons\simple_html_dom as simple_html_dom;
7 6
8 7 abstract class mbNetwork
9 8 {
10 9
@@ -15,11 +14,9 @@
15 14 protected $countable = false; // If network supports count of likes / shares / favs
16 15 protected $count_api = ''; // API URL for requesting counts
17 16 protected $count_check_time = 14400; // (PHP 5.3) 4 * HOUR_IN_SECONDS; // Transient time, how often to check network for new counts
18 17 protected $share_url = null; // URL to link to when sharing something
19 - protected $alternate_url = null; // if another URL needs to be
20 - protected $alternate_label = null; // Label for the other option (checkbox)
21 - protected $is_popup = true; // Open in Popup or not
18 + protected $popup = true; // Open in Popup or not
22 19 protected $popup_dimensions = array(400,300); // Default popup dimensions
23 20 protected $return_var; // Count API return var ( JSON format )
24 21
25 22 // mobile or not settings - not yet developed
@@ -28,41 +25,29 @@
28 25
29 26 /** Options for Share Icons */
30 27 protected $profile_url = null; // URL to the network's profiles.
31 28 protected $profile_placeholder; // Placeholder for profile input text field [aka 'user name' or so ]
32 - protected $profile_label; // Not in use at the moment?
29 + protected $profile_label;
33 30
34 31 protected $nice_name; // Nice name for display in the Editor interface
35 32
36 - protected $label; // Label (default) Text. This will be in the button, e.g. on hover
33 + protected $label; // Lavel (default) Text. This will be in the button, e.g. on hover
37 34
38 35 protected $icon_type = 'fab'; // Icon library set
39 36 protected $icon = 'fa-circle'; // Icon
40 - protected $icon_image_id; // for svg type icons.
41 - protected $icon_image_url;
42 - protected $icon_image_size;
43 -// protected $icon_image_alt = '';
44 37
45 38 protected $color = '#fff';
46 39
47 40 // extra options [internal]
48 - protected $is_native = true; // is this network built-in, or imported? Relevant for network settings
49 - protected $is_editable = true; // should this network be user-editable?
50 - protected $is_active = true;
51 - protected $is_limitedpro = false; // the network is only intended for MB PRO
52 - protected $forcesamewindow = false; // never open this in a new window / i.e. email / print type networks
41 + protected $limitedpro = false; // the network is only intended for MB PRO
42 + protected $forcesamewindow = false; // never open this in a new window
53 43
54 - protected $default_options = null;
55 -
56 44 public function __construct()
57 45 {
58 - if (is_null($this->profile_placeholder))
59 - $this->profile_placeholder = __('User Name','mbsocial');
60 - if (is_null($this->profile_label))
61 - $this->profile_label = __('Follow', 'mbsocial');
46 + $this->profile_placeholder = __('User Name','mbsocial');
47 + $this->profile_label = __('Follow', 'mbsocial');
48 + }
62 49
63 - $this->default_options = $this->get_all_options(); // init them as default. For save function
64 - }
65 50
66 51 public function get($name)
67 52 {
68 53 if (isset($this->$name))
@@ -68,77 +53,11 @@
68 53 if (isset($this->$name))
69 54 return $this->$name;
70 55 else
71 56 return null;
72 - }
73 57
74 - public function get_all_options()
75 - {
76 - $popup_width = isset($this->popup_dimensions[0]) ? $this->popup_dimensions[0] : 0;
77 - $popup_height = isset($this->popup_dimensions[1]) ? $this->popup_dimensions[1] : 0;
78 -
79 -
80 - // iterate on this next time perhaps.
81 - //$attrs = get_object_vars($this);
82 -
83 - $options = array(
84 - 'active' => $this->is_active, // no nw setting for this
85 - 'popup' => $this->is_popup,
86 - 'label' => $this->label,
87 - 'share_url' => $this->share_url,
88 - 'profile_url' => $this->profile_url,
89 - 'popup_width' => $popup_width,
90 - 'popup_height' => $popup_height,
91 - 'icon_type' => $this->icon_type,
92 - 'icon' => $this->icon,
93 - 'icon_image_id' => $this->icon_image_id,
94 - 'icon_image_url' => $this->icon_image_url,
95 - // 'icon_image_alt' => $this->icon_image_alt,
96 - 'icon_image_size' => $this->icon_image_size,
97 - 'color' => $this->color,
98 - 'displayMobile' => $this->displayMobile,
99 - 'displayDesktop' => $this->displayDesktop,
100 - );
101 -
102 - return $options;
103 58 }
104 59
105 - public function get_all_defaults()
106 - {
107 - return $this->default_options;
108 - }
109 -
110 - public function load_settings($settings)
111 - {
112 - if (! $settings)
113 - return;
114 - foreach($settings as $setting => $value)
115 - {
116 - if (is_null($value) || strlen($value) == 0)
117 - continue;
118 -
119 - switch($setting)
120 - {
121 - case 'active':
122 - $this->is_active = ($value == 1) ? true : false;
123 - break;
124 - case 'popup':
125 - $this->is_popup = ($value == 1) ? true : false;
126 - break;
127 - case 'popup_width':
128 - $this->popup_dimensions[0] = $value;
129 - break;
130 - case 'popup_height':
131 - $this->popup_dimensions[1] = $value;
132 - break;
133 - default:
134 - $this->{$setting} = $value;
135 - break;
136 - }
137 - }
138 - }
139 -
140 -
141 60 public function forMobile()
142 61 {
143 62 return $this->displayMobile;
144 63 }
@@ -147,13 +66,8 @@
147 66 {
148 67 return $this->displayDesktop;
149 68 }
150 69
151 - /** If current running setting of network should display count
152 - *
153 - * Even if network supports displaying a counter, this should not be the case when showing the 'profile'
154 - * @return boolean
155 - */
156 70 public function isCountable()
157 71 {
158 72 $use_profile = MBSocial()->whistle()->ask('editor/profile/use');
159 73 if ($use_profile == 1)
@@ -179,16 +93,8 @@
179 93
180 94 return true;
181 95 }
182 96
183 - public function has_alternate()
184 - {
185 - if (is_null($this->alternate_url))
186 - return false;
187 -
188 - return true;
189 - }
190 -
191 97 /** Use this function to check if popup link should be used **/
192 98 public function is_popup()
193 99 {
194 100 $use_profile = MBSocial()->whistle()->ask('editor/profile/use');
@@ -194,9 +100,9 @@
194 100 $use_profile = MBSocial()->whistle()->ask('editor/profile/use');
195 101 if ($use_profile == 1)
196 102 return false;
197 103 else {
198 - return $this->is_popup;
104 + return $this->popup;
199 105 }
200 106 }
201 107
202 108 /** Return the label for this network and use **/
@@ -236,16 +142,12 @@
236 142 }
237 143 elseif ($is_profile && $is_share)
238 144 {
239 145 $use_profile = MBSocial()->whistle()->ask('editor/profile/use');
240 - $use_alternate = MBSocial()->whistle()->ask('editor/profile/alternate');
241 146
242 147 if ($use_profile == 1)
243 148 {
244 - if ($use_alternate == 1)
245 - return $this->alternate_url;
246 - else
247 - return $this->profile_url;
149 + return $this->profile_url;
248 150 }
249 151 else {
250 152 return $this->share_url;
251 153 }
@@ -250,8 +152,10 @@
250 152 return $this->share_url;
251 153 }
252 154
253 155 }
156 +
157 +
254 158 }
255 159
256 160 /* Network dependent creating of a button. Called from collection class */
257 161 public function createButton($args = array())
@@ -276,9 +180,9 @@
276 180 ";
277 181
278 182 $html .= "</a></span>";
279 183
280 - $button = \MaxButtons\str_get_html($html);
184 + $button = str_get_html($html);
281 185 return $button;
282 186 }
283 187
284 188 public function getRemoteShareCount($share_url)