PluginProbe
Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder / 1.0.2
Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder v1.0.2
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.2, at classes/admin/General.php

279 lines 14.5 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 $bHasProFeature = false ;
31 public function __construct( $aFontAwesome )
32 {
33 $this->aFontAwesome = $aFontAwesome;
34 $this->loadData();
35 $this->registerStylingSettings();
36 $this->registerAdvancedSettings();
37 $this->registerSocialSettings();
38 $this->registerOther();
39 $this->generatePage();
40 }
41
42 private function loadData()
43 {
44 $this->aSavedData = (array) get_option( 'buttonizer_general_settings' );
45 }
46
47 private function generatePage()
48 {
49 $sTabs = '';
50 $sTabsContent = '';
51 $bFirstTab = true;
52 // Get tabs
53 foreach ( $this->aSubCatagories as $sKey => $sTitle ) {
54 $sTabs .= '<a href="#tab_' . $sKey . '" onclick="javascript:buttonizer.tabNavigate(\'' . $sKey . '\')" id="tab_container_' . $sKey . '" class="nav-tab ' . (( $bFirstTab ? 'first nav-tab-active' : '' )) . '">' . $sTitle . '</a>';
55 $sTabsContent .= '<div id="tab_container_' . $sKey . '" ' . (( !$bFirstTab ? 'style="display: none;"' : '' )) . ' class="tab-container">' . $this->aSubPages[$sKey] . '</div>';
56 $bFirstTab = false;
57 }
58 echo '<table class="vertical-tabs">
59 <tr>
60 <td class="tabs">' . $sTabs . '</td>
61 <td class="tabsholder">' . $sTabsContent . '</td>
62 </tr>
63 </table>' ;
64 }
65
66 /*
67 * Register settings
68 */
69 public function registerStylingSettings()
70 {
71 $this->aSubCatagories['styling'] = 'Styling settings';
72 $this->aSubPages['styling'] = '<table class="form-table"><tbody>';
73 $this->aSubPages['styling'] .= $this->createFormField( 'Right', array( &$this, 'field_position_right' ) );
74 $this->aSubPages['styling'] .= $this->createFormField( 'Bottom', array( &$this, 'field_position_bottom' ) );
75 $this->aSubPages['styling'] .= $this->createFormField( 'Color button unpushed', array( &$this, 'field_button_unpushed' ) );
76 $this->aSubPages['styling'] .= $this->createFormField( 'Color button pushed', array( &$this, 'field_button_pushed' ) );
77 $this->aSubPages['styling'] .= $this->createFormField( 'Icon color', array( &$this, 'field_icon_color' ) );
78 $this->aSubPages['styling'] .= $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' ) );
79 $this->aSubPages['styling'] .= '</tbody></table>';
80 }
81
82 public function registerAdvancedSettings()
83 {
84 $this->aSubCatagories['advanced'] = 'Advanced settings';
85 $this->aSubPages['advanced'] = '<table class="form-table"><tbody>';
86 $this->aSubPages['advanced'] .= $this->createFormField( '
87 <span class="info-class">
88 <i class="fa fa-info-circle"></i>
89 <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)
90 </span>
91 </span>
92 Google Analytics', array( &$this, 'field_analytics_code' ) );
93 // Show on scroll
94 $this->aSubPages['advanced'] .= $this->createFormField( '
95 <span class="info-class">
96 <i class="fa fa-info-circle"></i>
97 <span>
98 When selected, the buttons will be shown after the user has scrolled a percentage of the page.
99 </span>
100 </span>
101 Show on scroll?', array( &$this, 'field_show_on_scroll' ) );
102 $this->aSubPages['advanced'] .= $this->createFormField( '
103 <span class="info-class">
104 <i class="fa fa-info-circle"></i>
105 <span>
106 Enter a percentage, starting from 0, up to 100.
107 </span>
108 </span>
109 % from top to show:', array( &$this, 'field_procent_to_scroll' ) );
110 // Show after timeout
111 $this->aSubPages['advanced'] .= $this->createFormField( '
112 <span class="info-class">
113 <i class="fa fa-info-circle"></i>
114 <span>
115 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.
116 </span>
117 </span>
118 Show after timeout?', array( &$this, 'field_show_on_timeout' ) );
119 $this->aSubPages['advanced'] .= $this->createFormField( '
120 <span class="info-class">
121 <i class="fa fa-info-circle"></i>
122 <span>
123 Enter the miliseconds from when the buttons must get shown to the user.<br />
124 <br />
125 1 second = 1000 miliseconds<br />
126 10 seconds = 10000 miliseconds<br />
127 1 minute = 60000 miliseconds<br />
128 </span>
129 </span>
130 Milliseconds: ', array( &$this, 'field_time_to_timeout' ) );
131 $this->aSubPages['advanced'] .= '</tbody></table>';
132 if ( !ButtonizerLicense()->is_not_paying() ) {
133 $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>';
134 }
135 }
136
137 public function registerSocialSettings()
138 {
139 $this->aSubCatagories['social'] = 'Social share settings';
140 $this->aSubPages['social'] = '<table class="form-table"><tbody>';
141 // Facebook share button
142 $this->aSubPages['social'] .= $this->createFormField( 'Share on Facebook', array( &$this, 'field_share_facebook' ) );
143 // Twitter share button
144 $this->aSubPages['social'] .= $this->createFormField( 'Share on Twitter', array( &$this, 'field_share_twitter' ) );
145 // LinkedIn share button
146 $this->aSubPages['social'] .= $this->createFormField( 'Share on LinkedIn', array( &$this, 'field_share_linkedin' ) );
147 $this->aSubPages['social'] .= '</tbody></table>';
148 }
149
150 public function registerOther()
151 {
152 $this->aSubCatagories['other'] = 'Other';
153 $this->aSubPages['other'] = '<table class="form-table"><tbody>';
154 $this->aSubPages['other'] .= '<tr><th scope="row">Reset Buttonizer</th><td><a href="?page=Buttonizer&tab=buttonizer_page_reset">More info</a></td></tr>';
155 $this->aSubPages['other'] .= '</tbody></table>';
156 }
157
158 private function createFormField( $sLabel, $aFunction )
159 {
160 return '<tr><th scope="row">' . $sLabel . '</th><td>' . $aFunction() . '</td></tr>';
161 }
162
163 /*
164 * Form
165 */
166 public function field_button_unpushed()
167 {
168 $button_unpushed = ( isset( $this->aSavedData['button_unpushed'] ) ? $this->aSavedData['button_unpushed'] : '#48A4DC' );
169 return '<input type="text" name="buttonizer_general_settings[button_unpushed]" value="' . $button_unpushed . '" id="button_unpushed" data-default-color="#fffff" />';
170 }
171
172 public function field_button_pushed()
173 {
174 $button_pushed = ( isset( $this->aSavedData['button_pushed'] ) ? $this->aSavedData['button_pushed'] : '#1D9BDB' );
175 return '<input type="text" name="buttonizer_general_settings[button_pushed]" value="' . $button_pushed . '" id="button_pushed" data-default-color="#fffff" />';
176 }
177
178 public function field_icon_color()
179 {
180 $icon_color = ( isset( $this->aSavedData['icon_color'] ) ? $this->aSavedData['icon_color'] : '#fffff' );
181 return '<input type="text" name="buttonizer_general_settings[icon_color]" value="' . $icon_color . '" id="icon_color" data-default-color="#fffff" />';
182 }
183
184 public function field_icon_icon()
185 {
186 $fieldName = 'icon_icon';
187 $icon_image = ( isset( $this->aSavedData[$fieldName] ) ? $this->aSavedData[$fieldName] : '' );
188 $sValueImage = ( isset( $this->aSavedData['custom_icon'] ) ? $this->aSavedData['custom_icon'] : '' );
189 if ( $sValueImage != '' ) {
190 $this->bHasProFeature = true;
191 }
192 $p = '<div class="icon-or-image" data-type="' . (( $sValueImage != '' ? 'image' : 'icon' )) . '">
193 <div class="icon-placeholder" ' . (( $sValueImage != '' ? 'style="display: none;"' : '' )) . '>
194 <div class="placeholder-choose">
195 or <a href="javascript:void(0)">upload image</a>
196 </div>';
197 $p .= '<select name="buttonizer_general_settings[' . $fieldName . ']" id="' . $fieldName . '" style="font-family: \'FontAwesome\', \'Helvetica\';" class="fa-chooser">';
198 $p .= '<option value="+">+</option>';
199 foreach ( $this->aFontAwesome as $key => $row ) {
200 $p .= '<option value="' . $key . '" ' . (( $icon_image == $key ? 'selected="selected"' : '' )) . '>' . $row . ' ' . $key . '</option>';
201 }
202 $p .= '</select>';
203 $p .= '</div><div class="image-placeholder" ' . (( $sValueImage == '' ? 'style="display: none;"' : '' )) . '>';
204 $p .= '
205 <div class="placeholder-choose">
206 or <a href="javascript:void(0)">use an icon</a>
207 </div>
208
209 <div class="form-group smartcat-uploader" data-image="' . $sValueImage . '">
210 <input type="hidden" name="buttonizer_general_settings[custom_icon]" value="' . $sValueImage . '">
211 </div>
212 </div>';
213 return $p;
214 }
215
216 public function field_position_right()
217 {
218 $position_right = ( isset( $this->aSavedData['position_right'] ) ? $this->aSavedData['position_right'] : '95' );
219 return '<input type="text" name="buttonizer_general_settings[position_right]" value="' . $position_right . '"/><small><i>%</i></small>';
220 }
221
222 public function field_position_bottom()
223 {
224 $position_bottom = ( isset( $this->aSavedData['position_bottom'] ) ? $this->aSavedData['position_bottom'] : '95' );
225 return '<input type="text" name="buttonizer_general_settings[position_bottom]" value="' . $position_bottom . '"/><small><i>%</i></small>';
226 }
227
228 /*
229 * Advanced
230 */
231 public function field_analytics_code()
232 {
233 $google_analytics = ( isset( $this->aSavedData['google_analytics'] ) ? $this->aSavedData['google_analytics'] : '' );
234 return '<input type="text" name="buttonizer_general_settings[google_analytics]" value="' . $google_analytics . '" placeholder="Only when not inserted yet" style="width: 250px;"/>';
235 }
236
237 public function field_show_on_scroll()
238 {
239 return '<input type="checkbox" class="buttonizer-click-to-pro" readonly /> <span class="buttonizer-pro-feature">PRO</span>';
240 }
241
242 public function field_procent_to_scroll()
243 {
244 return '<input type="text" value="0" class="buttonizer-click-to-pro" readonly /><small><i>%</i></small> <span class="buttonizer-pro-feature">PRO</span>';
245 }
246
247 public function field_show_on_timeout()
248 {
249 return '<input type="checkbox" class="buttonizer-click-to-pro" readonly /> <span class="buttonizer-pro-feature">PRO</span>';
250 }
251
252 public function field_time_to_timeout()
253 {
254 return '<input type="text" class="buttonizer-click-to-pro" readonly value="0" /><span class="buttonizer-pro-feature">PRO</span>';
255 }
256
257 // Share page
258 public function field_share_facebook()
259 {
260 $share_facebook = ( isset( $this->aSavedData['share_facebook'] ) ? $this->aSavedData['share_facebook'] : '' );
261 $share_facebook_text = ( isset( $this->aSavedData['share_facebook_text'] ) ? $this->aSavedData['share_facebook_text'] : 'Share this on Facebook' );
262 return '<input type="checkbox" name="buttonizer_general_settings[share_facebook]" value="1" ' . (( $share_facebook == '1' ? 'checked="checked"' : '' )) . ' /> <input type="text" name="buttonizer_general_settings[share_facebook_text]" value="' . $share_facebook_text . '" placeholder="Share this on Facebook" style="vertical-align: middle; margin-left: 10px;" />';
263 }
264
265 public function field_share_linkedin()
266 {
267 $share_linkedin = ( isset( $this->aSavedData['share_linkedin'] ) ? $this->aSavedData['share_linkedin'] : '' );
268 $share_linkedin_text = ( isset( $this->aSavedData['share_linkedin_text'] ) ? $this->aSavedData['share_linkedin_text'] : 'Share this on LinkedIn' );
269 return '<input type="checkbox" name="buttonizer_general_settings[share_linkedin]" value="1" ' . (( $share_linkedin == '1' ? 'checked="checked"' : '' )) . ' /> <input type="text" name="buttonizer_general_settings[share_linkedin_text]" value="' . $share_linkedin_text . '" placeholder="Share this on LinkedIn" style="vertical-align: middle; margin-left: 10px;" />';
270 }
271
272 public function field_share_twitter()
273 {
274 $share_twitter = ( isset( $this->aSavedData['share_twitter'] ) ? $this->aSavedData['share_twitter'] : '' );
275 $share_twitter_text = ( isset( $this->aSavedData['share_twitter_text'] ) ? $this->aSavedData['share_twitter_text'] : 'Share this on Twitter' );
276 return '<input type="checkbox" name="buttonizer_general_settings[share_twitter]" value="1" ' . (( $share_twitter == '1' ? 'checked="checked"' : '' )) . ' /> <input type="text" name="buttonizer_general_settings[share_twitter_text]" value="' . $share_twitter_text . '" placeholder="Share this on Twitter" style="vertical-align: middle; margin-left: 10px;" />';
277 }
278
279 }