| @@ -4,8 +4,9 @@ | ||
| 4 | 4 | |
| 5 | 5 | class Install |
| 6 | 6 | { |
| 7 | 7 | protected static $issue; |
| 8 | + protected static $ispro; | |
| 8 | 9 | |
| 9 | 10 | public static function getIssue() |
| 10 | 11 | { |
| 11 | 12 | if (! is_null(self::$issue)) |
| @@ -14,8 +15,11 @@ | ||
| 14 | 15 | return false; |
| 15 | 16 | |
| 16 | 17 | } |
| 17 | 18 | |
| 19 | + /** Check if all needed conditions are met. Sets issue variable if not. | |
| 20 | + * @return Boolean | |
| 21 | + */ | |
| 18 | 22 | public static function verifyPlugin() |
| 19 | 23 | { |
| 20 | 24 | $not_fatal = true; |
| 21 | 25 | |
| @@ -32,8 +36,35 @@ | ||
| 32 | 36 | |
| 33 | 37 | return true; |
| 34 | 38 | } |
| 35 | 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 */ | |
| 36 | 67 | protected static function checkMaxButtons() |
| 37 | 68 | { |
| 38 | 69 | if (! class_exists('MaxButtons\maxButtonsPlugin')) |
| 39 | 70 | { |
| @@ -53,8 +84,104 @@ | ||
| 53 | 84 | return false; |
| 54 | 85 | |
| 55 | 86 | } |
| 56 | 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 | + | |
| 57 | 184 | public static function noMaxButtons() |
| 58 | 185 | { |
| 59 | 186 | |
| 60 | 187 | $action = 'install-plugin'; |
| @@ -70,9 +197,9 @@ | ||
| 70 | 197 | $action.'_'.$slug |
| 71 | 198 | ); |
| 72 | 199 | |
| 73 | 200 | |
| 74 | - $message = sprintf( __("MaxButtons Social Share requires MaxButtons, which doesn't seem to be active or installed","maxbuttons"), PHP_VERSION); | |
| 201 | + $message = sprintf( __("Wordpress Social Buttons requires MaxButtons plugin, which doesn't seem to be active or installed","maxbuttons"), PHP_VERSION); | |
| 75 | 202 | echo"<div class='error'> <h4>$message</h4> |
| 76 | 203 | <p><a href='$url'>" . __('Install MaxButtons Now','mbsocial') . "</a></p> |
| 77 | 204 | </div>"; |
| 78 | 205 | return; |