PluginProbe
Social Share Buttons / 1.8
Social Share Buttons v1.8
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
share-button / classes / class-install.php

class-install.php in Social Share Buttons 1.8, at classes/class-install.php

212 lines 4.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace MBSocial;
3 defined('ABSPATH') or die('No direct access permitted');
4
5 class Install
6 {
7 protected static $issue;
8 protected static $ispro;
9
10 public static function getIssue()
11 {
12 if (! is_null(self::$issue))
13 return self::$issue;
14
15 return false;
16
17 }
18
19 /** Check if all needed conditions are met. Sets issue variable if not.
20 * @return Boolean
21 */
22 public static function verifyPlugin()
23 {
24 $not_fatal = true;
25
26 $status = static::checkMaxButtons();
27 if (! $status)
28 {
29 self::$issue = 'no-maxclass';
30 return false; // prevent loading
31 }
32
33 $version = self::check_mb_version();
34 if ( ! $version )
35 self::$issue = 'mb-wrong-version';
36
37 return true;
38 }
39
40 /** Check if current MaxButtons loaded is a PRO version or not */
41 public static function isPro()
42 {
43 if (isset(static::$ispro))
44 return static::$ispro;
45
46 static::$ispro = false;
47 if (defined('MAXBUTTONS_PRO_ROOT_FILE'))
48 {
49 $license = MB()->getClass('license');
50 $license_activated = $license->is_activated();
51 if ( ! $license_activated)
52 {
53 return false;
54 }
55 else {
56 static::$ispro = true;
57 return true;
58 }
59 }
60 else {
61 return false;
62 }
63
64 }
65
66 /** Checks if maxbuttons plugin exists */
67 protected static function checkMaxButtons()
68 {
69 if (! class_exists('MaxButtons\maxButtonsPlugin'))
70 {
71 add_action('admin_notices', array(__NAMESPACE__ . '\Install', 'noMaxButtons'));
72 return false;
73 }
74 return true;
75 }
76
77 protected static function check_mb_version()
78 {
79 $result = version_compare( MAXBUTTONS_VERSION_NUM, MBSOCIAL_REQUIRED_MB );
80
81 if ($result >= 0)
82 return true;
83 else
84 return false;
85
86 }
87
88 public static function convertToOne($collection)
89 {
90 $collection_id = $collection->getID();
91
92 $keys = array('style', 'layout');
93
94 $styleData = $collection->get_meta('style');
95 $styleData = $styleData['style'];
96 $layoutData = $collection->get_meta('layout');
97 $layoutData = $layoutData['layout'];
98
99 $countData = $collection->get_meta('count');
100 $countData = $countData['count'];
101
102 if (! isset($styleData['style']))
103 return; // escape
104
105 $style = $styleData['style'];
106 switch($style)
107 {
108 case 'round':
109 case 'roundflip':
110 $width = 55;
111 $height = 55;
112 $label = 16;
113 $count = 16;
114 $icon = 20;
115 if ($style == 'roundflip')
116 $effect = 'flip';
117 else {
118 $effect = 'transform';
119 }
120 $style = 'round';
121
122 break;
123 case 'square':
124 case 'horizontal':
125 $width = 45;
126 $height = 45;
127 //
128 $label = 15;
129 $icon = 20;
130 if ($style == 'square')
131 {
132 $effect = 'transform';
133 $count = 20;
134 }
135 else {
136 $effect = 'stretch';
137 $count = 16;
138 }
139 $style = 'square';
140 break;
141
142 case 'dropsquare':
143 case 'liftsquare':
144 case 'shiftsquare':
145 $width = 60;
146 $height = 65;
147 $label = 10;
148 $icon = 20;
149 $count = 10;
150 if ($style == 'dropsquare')
151 { $effect = 'drop' ; }
152 if ($style == 'liftsquare')
153 { $effect = 'lift'; }
154 if ($style == 'shiftsquare')
155 { $effect = 'shift'; }
156
157 $style = 'square';
158
159 break;
160
161 }
162
163 $styleData['mbs-width'] = $width;
164 $styleData['mbs-height'] = $height;
165 $styleData['mbs-style'] = $style;
166
167 $layoutData['font_label_size'] = $label;
168 $layoutData['font_icon_size'] = $icon;
169
170 $effectData = array(); // new!
171 $effectData['effect_type'] = $effect;
172
173 $countData['font_count_size'] = $count;
174
175 unset($styleData['style']);
176
177 $collection->update_meta($collection_id, 'style', $styleData);
178 $collection->update_meta($collection_id, 'layout', $layoutData);
179 $collection->update_meta($collection_id, 'effect', $effectData);
180 $collection->update_meta($collection_id, 'count', $countData);
181
182 }
183
184 public static function noMaxButtons()
185 {
186
187 $action = 'install-plugin';
188 $slug = 'maxbuttons';
189 $url = wp_nonce_url(
190 add_query_arg(
191 array(
192 'action' => $action,
193 'plugin' => $slug
194 ),
195 admin_url( 'update.php' )
196 ),
197 $action.'_'.$slug
198 );
199
200
201 $message = sprintf( __("Wordpress Social Buttons requires MaxButtons plugin, which doesn't seem to be active or installed","maxbuttons"), PHP_VERSION);
202 echo"<div class='error'> <h4>$message</h4>
203 <p><a href='$url'>" . __('Install MaxButtons Now','mbsocial') . "</a></p>
204 </div>";
205 return;
206
207 }
208
209
210
211 }
212