PluginProbe
Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder / 1.0.8
Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder v1.0.8
3.6.0 3.5.0 trunk 1.0.10 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.6.1 1.0.7 1.0.8 1.0.9 1.1 1.1.1 1.2 1.3 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.5 1.5.1 All 110 releases
buttonizer-multifunctional-button / classes / admin / General.php

General.php in Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder 1.0.8, at classes/admin/General.php

388 lines 21.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
18 Copyright 2017 Buttonizer
19 */
20 namespace Buttonizer\Admin;
21
22 # No script kiddies
23 defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
24 class General
25 {
26 private $aSavedData = array() ;
27 private $aSubCatagories = array() ;
28 private $aSubPages = array() ;
29 private $aFontAwesome = array() ;
30 private $oIconManager = array() ;
31 private $bHasProFeature = false ;
32 public function __construct( $aFontAwesome, $oIconManager )
33 {
34 $this->aFontAwesome = $aFontAwesome;
35 $this->oIconManager = $oIconManager;
36 $this->loadData();
37 $this->registerPlacingSettings();
38 $this->registerDesignSettings();
39 $this->registerAdvancedSettings();
40 $this->registerSocialSettings();
41 $this->registerOther();
42 $this->generatePage();
43 }
44
45 private function loadData()
46 {
47 $this->aSavedData = (array) get_option( 'buttonizer_general_settings' );
48 }
49
50 private function generatePage()
51 {
52 $sTabs = '';
53 $sTabsContent = '';
54 $bFirstTab = true;
55 // Get tabs
56 foreach ( $this->aSubCatagories as $sKey => $sTitle ) {
57 $sTabs .= '<a href="#tab_' . $sKey . '" onclick="javascript:buttonizer.tabNavigate(\'' . $sKey . '\')" id="tab_container_' . $sKey . '" class="nav-tab ' . (( $bFirstTab ? 'first nav-tab-active' : '' )) . '">' . $sTitle . '</a>';
58 $sTabsContent .= '<div id="tab_container_' . $sKey . '" ' . (( !$bFirstTab ? 'style="display: none;"' : '' )) . ' class="tab-container">' . $this->aSubPages[$sKey] . '</div>';
59 $bFirstTab = false;
60 }
61 echo '<table class="vertical-tabs">
62 <tr>
63 <td class="tabs">' . $sTabs . '</td>
64 <td class="tabsholder">' . $sTabsContent . '</td>
65 </tr>
66 </table>' ;
67 }
68
69 /*
70 * Register settings
71 */
72 public function registerPlacingSettings()
73 {
74 $this->aSubCatagories['placing'] = __( 'Placing &amp; animations', BUTTONIZER_SLUG );
75 $this->aSubPages['placing'] = '<table class="form-table"><tbody>';
76 $this->aSubPages['placing'] .= '<tr>
77 <td colspan="2">
78 <h2>Placing &amp; animations</h2>
79 <p>You can change here the button position and the button animation.</p>
80 </td></tr>';
81 $this->aSubPages['placing'] .= $this->createFormField( 'Right', array( &$this, 'field_position_right' ) );
82 $this->aSubPages['placing'] .= $this->createFormField( 'Bottom', array( &$this, 'field_position_bottom' ) );
83 $this->aSubPages['placing'] .= $this->createFormField( 'Button animation', array( &$this, 'field_button_animation' ) );
84 $this->aSubPages['placing'] .= $this->createFormField( 'Attention animation', array( &$this, 'field_attention_animation' ) );
85 $this->aSubPages['placing'] .= '</tbody></table>';
86 }
87
88 /*
89 * Register settings
90 */
91 public function registerDesignSettings()
92 {
93 $this->aSubCatagories['design'] = __( 'Design', BUTTONIZER_SLUG );
94 $this->aSubPages['design'] = '<table class="form-table"><tbody>';
95 $this->aSubPages['design'] .= '<tr>
96 <td colspan="2">
97 <h2>Design</h2>
98 <p>Style your button, make it blinky as you wish. You can change here the main color, main label and set the label hover types.</p>
99 </td></tr>';
100 $this->aSubPages['design'] .= $this->createFormField( 'Color button unpushed', array( &$this, 'field_button_unpushed' ) );
101 $this->aSubPages['design'] .= $this->createFormField( 'Color button pushed', array( &$this, 'field_button_pushed' ) );
102 $this->aSubPages['design'] .= $this->createFormField( 'Icon color', array( &$this, 'field_icon_color' ) );
103 $this->aSubPages['design'] .= $this->createFormField( 'Main icon<br /><br /><small>Used only when more then one button and there is a menu.</small>', array( &$this, 'field_icon_icon' ) );
104 $this->aSubPages['design'] .= $this->createFormField( 'Main label<br /><br /><small>Used only when more then one button and there is a menu.</small>', array( &$this, 'field_icon_label' ) );
105 $this->aSubPages['design'] .= $this->createFormField( 'Only show labels on hover<br /><br /><small>Only show the label when you hover the button.</small>', array( &$this, 'field_label_show_on_hover' ) );
106 $this->aSubPages['design'] .= '</tbody></table>';
107 }
108
109 public function registerAdvancedSettings()
110 {
111 $this->aSubCatagories['advanced'] = __( 'Advanced settings', BUTTONIZER_SLUG );
112 $this->aSubPages['advanced'] = '<table class="form-table"><tbody>';
113 $this->aSubPages['advanced'] .= '<tr>
114 <td colspan="2">
115 <h2>Advanced settings</h2>
116 <p></p>
117 </td></tr>';
118 $this->aSubPages['advanced'] .= $this->createFormField( '
119 <span class="info-class">
120 <i class="fa fa-info-circle"></i>
121 <span>If you have your Google Analytics tracking code already installed you can ignore this setting. If you want to be sure that your buttons are tracked in your Google Analytics account? Then go to your Google Analytics account > Click on Real Time > Events and open your website in another tab. Click on a Buttonizer button and check if you see that the click gets tracked in Google Analytics. If this doesn\'t happen than go to your google Analytics settings page > Click on tracking code and copy your tracking-ID. It should look like this (UA-00000000-0)
122 </span>
123 </span>
124 Google Analytics', array( &$this, 'field_analytics_code' ) );
125 $this->aSubPages['advanced'] .= $this->createFieldset( 'Show on scroll' );
126 // Show on scroll
127 $this->aSubPages['advanced'] .= $this->createFormField( '
128 <span class="info-class">
129 <i class="fa fa-info-circle"></i>
130 <span>
131 When selected, the buttons will be shown after the user has scrolled a percentage of the page.
132 </span>
133 </span>
134 Show on scroll?', array( &$this, 'field_show_on_scroll' ) );
135 $this->aSubPages['advanced'] .= $this->createFormField( '
136 <span class="info-class">
137 <i class="fa fa-info-circle"></i>
138 <span>
139 Enter a percentage, starting from 0, up to 100.
140 </span>
141 </span>
142 % from top to show:', array( &$this, 'field_procent_to_scroll' ) );
143 $this->aSubPages['advanced'] .= $this->closeFieldset();
144 // Show after timeout
145 $this->aSubPages['advanced'] .= $this->createFieldset( 'Show after timeout' );
146 $this->aSubPages['advanced'] .= $this->createFormField( '
147 <span class="info-class">
148 <i class="fa fa-info-circle"></i>
149 <span>
150 When selected, the buttons will be shown when the user browsers more than the given seconds. So when you say: Show after 20<i>000</i>ms, the button shows after the user browsed on the website for 20 seconds.
151 </span>
152 </span>
153 Show after timeout?', array( &$this, 'field_show_on_timeout' ) );
154 $this->aSubPages['advanced'] .= $this->createFormField( '
155 <span class="info-class">
156 <i class="fa fa-info-circle"></i>
157 <span>
158 Enter the miliseconds from when the buttons must get shown to the user.<br />
159 <br />
160 1 second = 1000 miliseconds<br />
161 10 seconds = 10000 miliseconds<br />
162 1 minute = 60000 miliseconds<br />
163 </span>
164 </span>
165 Milliseconds: ', array( &$this, 'field_time_to_timeout' ) );
166 $this->aSubPages['advanced'] .= $this->closeFieldset();
167 // Exit intent
168 $this->aSubPages['advanced'] .= $this->createFieldset( 'Exit intent' );
169 $this->aSubPages['advanced'] .= $this->createFormField( '
170 <span class="info-class">
171 <i class="fa fa-info-circle"></i>
172 <span>
173 When selected, the buttons will open with a effect when your guest/user tries to escape from your website. The user gets attracted from your buttons.
174 </span>
175 </span>
176 Exit intent', array( &$this, 'field_exit_intent' ) );
177 $this->aSubPages['advanced'] .= $this->createFormField( '
178 <span class="info-class">
179 <i class="fa fa-info-circle"></i>
180 <span>
181 When the exit intent activates, there will be shown some text next to the head-button. You can edit that here.<br />
182 <br />
183 When empty, no message will be shown.
184 </span>
185 </span>
186 Exit intent text', array( &$this, 'field_exit_intent_text' ) );
187 $this->aSubPages['advanced'] .= $this->closeFieldset();
188 $this->aSubPages['advanced'] .= '</tbody></table>';
189 if ( !ButtonizerLicense()->is_not_paying() && !ButtonizerLicense()->is_plan( 'premium' ) ) {
190 $this->aSubPages['advanced'] .= '<div class="buttonizer-pro-text"><i class="fa fa-lock"></i> You are missing the fun! When upgrading to <a href="admin.php?page=Buttonizer-pricing">Buttonizer Pro</a> you will get these features.</div>';
191 }
192 }
193
194 public function registerSocialSettings()
195 {
196 $this->aSubCatagories['social'] = __( 'Social share settings', BUTTONIZER_SLUG );
197 $this->aSubPages['social'] = '<table class="form-table"><tbody>';
198 $this->aSubPages['social'] .= '<tr>
199 <td colspan="2">
200 <h2>Social sharing buttons</h2>
201 <p>This are separated pre-configured buttons to share a page. The buttons will be visible at every page, you can let the user share a page on Twitter, Facebook or LinkedIn.<p>
202 <p>You can enable them to check the checkbox at the end of the input. Don\'t forget that :)</p>
203 </td></tr>';
204 // Facebook share button
205 $this->aSubPages['social'] .= $this->createFormField( 'Share on Facebook', array( &$this, 'field_share_facebook' ) );
206 // Twitter share button
207 $this->aSubPages['social'] .= $this->createFormField( 'Share on Twitter', array( &$this, 'field_share_twitter' ) );
208 // LinkedIn share button
209 $this->aSubPages['social'] .= $this->createFormField( 'Share on LinkedIn', array( &$this, 'field_share_linkedin' ) );
210 $this->aSubPages['social'] .= '<tr>
211 <td colspan="2" style="text-align: right;">
212 <p>Do you want us to add more social media options? <a href="admin.php?page=Buttonizer-contact">Contact us</a></p>
213 </td></tr>';
214 $this->aSubPages['social'] .= '</tbody></table>';
215 }
216
217 public function registerOther()
218 {
219 $this->aSubCatagories['other'] = __( 'Other', BUTTONIZER_SLUG );
220 $this->aSubPages['other'] = '<table class="form-table"><tbody>';
221 $this->aSubPages['other'] .= '<tr>
222 <td colspan="2">
223 <h2>Other</h2>
224 <p>Nothing really specials here, just a way to reset the buttonizer to the default settings.</p>
225 <p>Click the button below to get some more information.</p>
226 </td></tr>';
227 $this->aSubPages['other'] .= '<tr><th scope="row">Reset Buttonizer</th><td><a href="?page=Buttonizer&tab=buttonizer_page_reset" class="button ">More info</a></td></tr>';
228 $this->aSubPages['other'] .= '</tbody></table>';
229 }
230
231 private function createFormField( $sLabel, $aFunction )
232 {
233 return '<tr><th scope="row">' . $sLabel . '</th><td class="r-sit">' . $aFunction() . '</td></tr>';
234 }
235
236 private function createFieldset( $sLabel )
237 {
238 return '<tr><td colspan="2"><fieldset><legend>' . $sLabel . '</legend><table class="form-table">';
239 }
240
241 private function closeFieldset()
242 {
243 return '</table></fieldset></td></tr>';
244 }
245
246 /*
247 * Form
248 */
249 function field_button_unpushed()
250 {
251 $button_unpushed = ( isset( $this->aSavedData['button_unpushed'] ) ? $this->aSavedData['button_unpushed'] : '#48A4DC' );
252 return '<input type="text" name="buttonizer_general_settings[button_unpushed]" value="' . $button_unpushed . '" id="button_unpushed" data-default-color="#fffff" />';
253 }
254
255 function field_button_pushed()
256 {
257 $button_pushed = ( isset( $this->aSavedData['button_pushed'] ) ? $this->aSavedData['button_pushed'] : '#1D9BDB' );
258 return '<input type="text" name="buttonizer_general_settings[button_pushed]" value="' . $button_pushed . '" id="button_pushed" data-default-color="#fffff" />';
259 }
260
261 function field_icon_color()
262 {
263 $icon_color = ( isset( $this->aSavedData['icon_color'] ) ? $this->aSavedData['icon_color'] : '#fffff' );
264 return '<input type="text" name="buttonizer_general_settings[icon_color]" value="' . $icon_color . '" id="icon_color" data-default-color="#fffff" />';
265 }
266
267 function field_icon_icon()
268 {
269 $p = $this->oIconManager->generator( [
270 'icon' => ( isset( $this->aSavedData['icon_icon'] ) ? $this->aSavedData['icon_icon'] : '' ),
271 'icon_fieldname' => 'buttonizer_general_settings[icon_icon]',
272 'image' => ( isset( $this->aSavedData['custom_icon'] ) ? $this->aSavedData['custom_icon'] : '' ),
273 'image_fieldname' => 'buttonizer_general_settings[custom_icon]',
274 ] );
275 return $p;
276 }
277
278 function field_icon_label()
279 {
280 $icon_label = ( isset( $this->aSavedData['icon_label'] ) ? $this->aSavedData['icon_label'] : '' );
281 return '<input type="text" name="buttonizer_general_settings[icon_label]" value="' . $icon_label . '" placeholder="Fill in some text" />';
282 }
283
284 function field_position_right()
285 {
286 $position_right = ( isset( $this->aSavedData['position_right'] ) ? $this->aSavedData['position_right'] : '5' );
287 return '<input type="text" name="buttonizer_general_settings[position_right]" value="' . $position_right . '" placeholder="Fill in a number from 0 to 100"/><small><i class="after-input">%</i><br />Recommended 5% then it will position itself on the right corner</small>';
288 }
289
290 function field_position_bottom()
291 {
292 $position_bottom = ( isset( $this->aSavedData['position_bottom'] ) ? $this->aSavedData['position_bottom'] : '5' );
293 return '<input type="text" name="buttonizer_general_settings[position_bottom]" value="' . $position_bottom . '" placeholder="Fill in a number from 0 to 100"/><small><i class="after-input">%</i><br>Recommended 5% then it will position itself on the bottom corner</small>';
294 }
295
296 function field_button_animation()
297 {
298 $button_animation = ( isset( $this->aSavedData['buttons_animation'] ) ? $this->aSavedData['buttons_animation'] : 'default' );
299 return '
300 <select name="buttonizer_general_settings[buttons_animation]" style="width: 100%; padding: 0 10px; height: 40px;">
301 <option value="default" ' . (( $button_animation == 'default' ? 'selected' : '' )) . '>Default button animation (fade up)</option>
302 <option value="circle" ' . (( $button_animation == 'circle' ? 'selected' : '' )) . '>Circle animation (arround button, right bottom corner)</option>
303 <option value="fade-left-to-right" ' . (( $button_animation == 'fade-left-to-right' ? 'selected' : '' )) . '>Fade animation left to right</option>
304 </select>';
305 }
306
307 function field_attention_animation()
308 {
309 $attention_animation = ( isset( $this->aSavedData['attention_animation'] ) ? $this->aSavedData['attention_animation'] : 'none' );
310 return '
311 <select name="buttonizer_general_settings[attention_animation]" style="width: 100%; padding: 0 10px; height: 40px;">
312 <option value="none" ' . (( $attention_animation == 'none' ? 'selected' : '' )) . '>No attention animation</option>
313 <option value="hello" ' . (( $attention_animation == 'hello' ? 'selected' : '' )) . '>Buttonizer Hello</option>
314 <option value="bounce" ' . (( $attention_animation == 'bounce' ? 'selected' : '' )) . '>Bouncing</option>
315 </select>
316 <small>This will get the button jumping out of the background. So it gets your attention. All animations will be played every 10 seconds. Average animation duration is 1.75 seconds.</small>
317 ';
318 }
319
320 public function field_label_show_on_hover()
321 {
322 $is_selected = ( isset( $this->aSavedData['buttons_label_show_on_hover'] ) ? $this->aSavedData['buttons_label_show_on_hover'] : '' );
323 return '<input type="checkbox" name="buttonizer_general_settings[buttons_label_show_on_hover]" id="buttons_label_show_on_hover" value="1" ' . (( $is_selected == '1' ? 'checked="checked"' : '' )) . ' /> <small><label for="buttons_label_show_on_hover">Only show on hover</label></small>';
324 }
325
326 /*
327 * Advanced
328 */
329 function field_analytics_code()
330 {
331 $google_analytics = ( isset( $this->aSavedData['google_analytics'] ) ? $this->aSavedData['google_analytics'] : '' );
332 return '<input type="text" name="buttonizer_general_settings[google_analytics]" value="' . $google_analytics . '" placeholder="Only when not inserted yet" /><small>Insert here the Google Analytics tracking code. Like UA-000000-2</small>';
333 }
334
335 public function field_show_on_scroll()
336 {
337 return '<input type="checkbox" class="buttonizer-click-to-pro" readonly /> <div class="after-input"><span class="buttonizer-pro-feature">PRO</span></div>';
338 }
339
340 public function field_procent_to_scroll()
341 {
342 return '<input type="text" value="0" class="buttonizer-click-to-pro" readonly /> <div class="after-input"><small><i>%</i></small> <span class="buttonizer-pro-feature">PRO</span></div>';
343 }
344
345 public function field_show_on_timeout()
346 {
347 return '<input type="checkbox" class="buttonizer-click-to-pro" readonly /> <span class="buttonizer-pro-feature">PRO</span>';
348 }
349
350 public function field_time_to_timeout()
351 {
352 return '<input type="text" class="buttonizer-click-to-pro" readonly value="0" /><div class="after-input"><span class="buttonizer-pro-feature">PRO</span></div>';
353 }
354
355 // Exit intent
356 public function field_exit_intent()
357 {
358 return '<input type="checkbox" class="buttonizer-click-to-pro" readonly /> <span class="buttonizer-pro-feature">PRO</span>';
359 }
360
361 public function field_exit_intent_text()
362 {
363 return '<input type="text" class="buttonizer-click-to-pro" readonly value="" /><div class="after-input"><span class="buttonizer-pro-feature">PRO</span></div>';
364 }
365
366 // Share page
367 function field_share_facebook()
368 {
369 $share_facebook = ( isset( $this->aSavedData['share_facebook'] ) ? $this->aSavedData['share_facebook'] : '' );
370 $share_facebook_text = ( isset( $this->aSavedData['share_facebook_text'] ) ? $this->aSavedData['share_facebook_text'] : 'Share this on Facebook' );
371 return '<span class="after-input"><input type="checkbox" name="buttonizer_general_settings[share_facebook]" value="1" ' . (( $share_facebook == '1' ? 'checked="checked"' : '' )) . ' /></span> <input type="text" name="buttonizer_general_settings[share_facebook_text]" value="' . $share_facebook_text . '" placeholder="Share this on Facebook" />';
372 }
373
374 function field_share_linkedin()
375 {
376 $share_linkedin = ( isset( $this->aSavedData['share_linkedin'] ) ? $this->aSavedData['share_linkedin'] : '' );
377 $share_linkedin_text = ( isset( $this->aSavedData['share_linkedin_text'] ) ? $this->aSavedData['share_linkedin_text'] : 'Share this on LinkedIn' );
378 return '<span class="after-input"><input type="checkbox" name="buttonizer_general_settings[share_linkedin]" value="1" ' . (( $share_linkedin == '1' ? 'checked="checked"' : '' )) . ' /></span> <input type="text" name="buttonizer_general_settings[share_linkedin_text]" value="' . $share_linkedin_text . '" placeholder="Share this on LinkedIn" />';
379 }
380
381 function field_share_twitter()
382 {
383 $share_twitter = ( isset( $this->aSavedData['share_twitter'] ) ? $this->aSavedData['share_twitter'] : '' );
384 $share_twitter_text = ( isset( $this->aSavedData['share_twitter_text'] ) ? $this->aSavedData['share_twitter_text'] : 'Share this on Twitter' );
385 return '<span class="after-input"><input type="checkbox" name="buttonizer_general_settings[share_twitter]" value="1" ' . (( $share_twitter == '1' ? 'checked="checked"' : '' )) . ' /></span> <input type="text" name="buttonizer_general_settings[share_twitter_text]" value="' . $share_twitter_text . '" placeholder="Share this on Twitter" />';
386 }
387
388 }