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 +128 -8 0.91.1.2 View file →
@@ -13,26 +13,42 @@
13 13 //protected $api_url; // URL of API to request information
14 14 protected $countable = false; // If network supports count of likes / shares / favs
15 15 protected $count_api = ''; // API URL for requesting counts
16 16 protected $count_check_time = 14400; // (PHP 5.3) 4 * HOUR_IN_SECONDS; // Transient time, how often to check network for new counts
17 - protected $share_url; // URL to link to when sharing something
17 + protected $share_url = null; // URL to link to when sharing something
18 18 protected $popup = true; // Open in Popup or not
19 19 protected $popup_dimensions = array(400,300); // Default popup dimensions
20 20 protected $return_var; // Count API return var ( JSON format )
21 21
22 - protected $displayMobile = true;
23 - protected $displayDesktop = true;
22 + // mobile or not settings - not yet developed
23 + protected $displayMobile = true; // network should be displayed on mobiles
24 + protected $displayDesktop = true; // network should be displayed on desktop
24 25
25 - protected $nice_name;
26 + /** Options for Share Icons */
27 + protected $profile_url = null; // URL to the network's profiles.
28 + protected $profile_placeholder; // Placeholder for profile input text field [aka 'user name' or so ]
29 + protected $profile_label;
26 30
27 - protected $label;
31 + protected $nice_name; // Nice name for display in the Editor interface
28 32
29 - protected $icon_type = 'fa';
30 - protected $icon = 'fa-circle';
33 + protected $label; // Lavel (default) Text. This will be in the button, e.g. on hover
31 34
32 - abstract public function __construct();
35 + protected $icon_type = 'fab'; // Icon library set
36 + protected $icon = 'fa-circle'; // Icon
33 37
38 + protected $color = '#fff';
34 39
40 + // extra options [internal]
41 + protected $limitedpro = false; // the network is only intended for MB PRO
42 + protected $forcesamewindow = false; // never open this in a new window
43 +
44 + public function __construct()
45 + {
46 + $this->profile_placeholder = __('User Name','mbsocial');
47 + $this->profile_label = __('Follow', 'mbsocial');
48 + }
49 +
50 +
35 51 public function get($name)
36 52 {
37 53 if (isset($this->$name))
38 54 return $this->$name;
@@ -52,11 +68,54 @@
52 68 }
53 69
54 70 public function isCountable()
55 71 {
72 + $use_profile = MBSocial()->whistle()->ask('editor/profile/use');
73 + if ($use_profile == 1)
74 + return false;
75 +
56 76 return $this->countable;
57 77 }
58 78
79 + // If network is capable of sharing profile
80 + public function is_share_icon()
81 + {
82 + if (is_null($this->profile_url))
83 + return false;
84 +
85 + return true;
86 + }
87 +
88 + /** If network is capable of sharing site page */
89 + public function is_social_share()
90 + {
91 + if (is_null($this->share_url))
92 + return false;
93 +
94 + return true;
95 + }
96 +
97 + /** Use this function to check if popup link should be used **/
98 + public function is_popup()
99 + {
100 + $use_profile = MBSocial()->whistle()->ask('editor/profile/use');
101 + if ($use_profile == 1)
102 + return false;
103 + else {
104 + return $this->popup;
105 + }
106 + }
107 +
108 + /** Return the label for this network and use **/
109 + public function get_label()
110 + {
111 + $use_profile = MBSocial()->whistle()->ask('editor/profile/use');
112 + if ($use_profile == 1 && strlen($this->profile_label) > 0)
113 + return $this->profile_label;
114 + else
115 + return $this->label;
116 + }
117 +
59 118 public function get_nice_name()
60 119 {
61 120 if (isset($this->nice_name))
62 121 return $this->nice_name;
@@ -61,9 +120,70 @@
61 120 if (isset($this->nice_name))
62 121 return $this->nice_name;
63 122 else
64 123 return ucfirst($this->network);
124 + }
65 125
126 + /** Find and get the proper URL to link to.
127 + * This can be the network link to sharing a page
128 + * or the network link to linking the profile.
129 + * Try to find out automatically or whistle ask */
130 + public function get_url()
131 + {
132 + $is_profile = $this->is_share_icon();
133 + $is_share = $this->is_social_share();
134 +
135 + if ($is_profile && ! $is_share) // profile only network
136 + {
137 + return $this->profile_url;
138 + }
139 + elseif (! $is_profile && $is_share) // share page only network
140 + {
141 + return $this->share_url;
142 + }
143 + elseif ($is_profile && $is_share)
144 + {
145 + $use_profile = MBSocial()->whistle()->ask('editor/profile/use');
146 +
147 + if ($use_profile == 1)
148 + {
149 + return $this->profile_url;
150 + }
151 + else {
152 + return $this->share_url;
153 + }
154 +
155 + }
156 +
157 +
158 + }
159 +
160 + /* Network dependent creating of a button. Called from collection class */
161 + public function createButton($args = array())
162 + {
163 + $defaults = array('link' => 'javascript:void(0)',
164 + 'preview' => false,
165 + 'index' => -1,
166 + 'name' => '',
167 + 'data' => array(),
168 + 'collection_count' => 0,
169 + );
170 +
171 + $item_index = $args['index'];
172 + if ($args['collection_count'] > 1)
173 + {
174 + $item_index = $args['collection_count'] . "_" . $item_index;
175 + }
176 +
177 + $args = wp_parse_args($args, $defaults);
178 + $html = "<span class='mb-item item-" . $item_index . "'>
179 + <a href='" . $args['link'] . "' class='mb-social '>
180 + ";
181 +
182 + $html .= "</a></span>";
183 +
184 + $button = str_get_html($html);
185 + return $button;
66 186 }
67 187
68 188 public function getRemoteShareCount($share_url)
69 189 {