PluginProbe
MaxButtons – Create buttons / 7.1.2
MaxButtons – Create buttons v7.1.2
6.23 6.24 6.25 6.26 6.26.1 6.27 6.28 6.3 6.4 6.5 6.6 6.7 6.8 6.9 7.0 7.1 7.1.1 7.1.2 7.1.3 7.10 7.11 7.13 7.13.1 7.13.2 7.13.3 All 100 releases
maxbuttons / includes / maxbuttons-settings.php

maxbuttons-settings.php in MaxButtons – Create buttons 7.1.2, at includes/maxbuttons-settings.php

317 lines 12.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace MaxButtons;
3 defined('ABSPATH') or die('No direct access permitted');
4
5 // settings for this page are registered in register_setting ( main class )
6
7 $button = MB()->getClass('button'); // To load maxfield templates
8
9 if(isset($_POST['alter_charset'])) {
10
11 global $maxbuttons_installed_version;
12 global $wpdb;
13 $table_name = maxUtils::get_table_name();
14
15 $sql = "ALTER TABLE " . $table_name . " CONVERT TO CHARACTER SET utf8";
16 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
17 $wpdb->query($sql);
18 $response = 'CHARSET now utf_8 COLLATE utf8_general_ci';
19
20 } else {
21 $response = '';
22 }
23
24 if (isset($_POST["reset_cache"]))
25 {
26 $button = MB()->getClass('button');
27 $button->reset_cache();
28
29 }
30
31 if (isset($_POST["remigrate"]))
32 {
33 $install = MB()->getClass("install");
34 $install::create_database_table();
35 $install::migrate();
36 }
37
38 if (isset($_POST["replace"]) && check_admin_referer('mb_bulk_edit', 'bulk_edit'))
39 {
40 $search = sanitize_text_field($_POST["search"]);
41 $replace = sanitize_text_field($_POST["replace"]);
42 $field = sanitize_text_field($_POST["replace_field"]);
43
44 $button = MB()->getClass('button');
45
46 if ($field == '')
47 exit("FATAL");
48
49 $admin = MB()->getClass('admin');
50 $buttonsIDS = $admin->getButtons(array('limit' => -1));
51
52 $data_found = false;
53
54 foreach($buttonsIDS as $row)
55 {
56 $button_id = $row["id"];
57 $button->set($button_id);
58 $data = $button->get();
59 foreach($data as $block => $fields)
60 {
61 if (isset($fields[$field]))
62 {
63 $value = $fields[$field];
64 $data[$block][$field] = str_replace($search, $replace, $value);
65 $button->update($data);
66
67 $data_found = true;
68 continue;
69 }
70
71 if ($data_found)
72 {
73 $data_found = false;
74 continue;
75 }
76 }
77
78
79 }
80
81 }
82
83 ?>
84 <?php
85 $admin = MB()->getClass('admin');
86 $page_title = __("Settings","maxbuttons");
87 $admin->get_header(array("tabs_active" => true, "title" => $page_title) );
88 ?>
89
90 <div class="mb_tab"> <!-- first tab --->
91 <div class="title">
92 <span class="dashicons dashicons-list-view"></span>
93 <span class='title'><?php _e('Settings', 'maxbuttons') ?></span>
94 </div>
95 <div class="option-container">
96 <div class="title"><?php _e('Settings','maxbuttons'); ?></div>
97 <div class="inside">
98
99 <form method="post" action="options.php">
100 <div class="option-design">
101
102 <?php settings_fields( 'maxbuttons_settings' ); ?>
103 <label><?php _e('MaxButtons User Level', 'maxbuttons') ?></label>
104 <div class="input">
105 <select name="maxbuttons_user_level">
106 <?php $maxbuttons_user_level = get_option('maxbuttons_user_level'); ?>
107 <option value="edit_posts" <?php if($maxbuttons_user_level === 'edit_posts') { echo 'selected="selected"'; } ?>>Contributor</option>
108 <option value="edit_published_posts" <?php if($maxbuttons_user_level === 'edit_published_posts') { echo 'selected="selected"'; } ?>>Author</option>
109 <option value="manage_categories" <?php if($maxbuttons_user_level === 'manage_categories') { echo 'selected="selected"'; } ?>>Editor</option>
110 <option value="manage_options" <?php if($maxbuttons_user_level === 'manage_options') { echo 'selected="selected"'; } ?>>Administrator</option>
111 </select>
112 <br />
113 <?php printf( __('For more details on user roles and permissions, click %s here%s.','maxbuttons'),
114 '<a target="_blank" href="https://codex.wordpress.org/Roles_and_Capabilities">',
115 "</a>");
116 ?>
117
118 </div>
119
120 <div class="clear"></div>
121 </div><!-- option-design -->
122
123 <div class="option-design">
124 <?php
125 $option_noshow = get_option('maxbuttons_noshowtinymce');
126
127 $nomce = new maxField('switch');
128 $nomce->label = __('Hide "add button" in post editor toolbar', 'maxbuttons');
129 $nomce->name = 'maxbuttons_noshowtinymce';
130 $nomce->id = $nomce->name;
131 $nomce->value = '1';
132 $nomce->checked = checked($option_noshow, 1, false);
133 $nomce->output ('start','end');
134 ?>
135
136 </div>
137
138 <?php
139 $option_minify = get_option("maxbuttons_minify", 1);
140 $option_description_hide = get_option('maxbuttons_hidedescription',0);
141 $option_borderbox = get_option('maxbuttons_borderbox', 0);
142
143 ?>
144 <div class="option-design">
145 <?php
146 $minify = new maxField('switch');
147 $minify->note = __('Recommended, only turn off in case of issues. You will have to clear your cache after changing this setting', 'maxbuttons') ;
148 $minify->label = __('Minify Button CSS', 'maxbuttons');
149 $minify->name = 'maxbuttons_minify';
150 $minify->id = $minify->name;
151 $minify->value = '1';
152 $minify->checked = checked($option_minify, 1, false);
153 $minify->output ('start','end');
154 ?>
155 </div>
156
157 <div class="option-design">
158 <?php
159 $desc = new maxField('switch');
160 $desc->label = __('Hide description field', 'maxbuttons');
161 $desc->name = 'maxbuttons_hidedescription';
162 $desc->id = $desc->name;
163 $desc->value = '1';
164 $desc->checked = checked($option_description_hide, 1, false);
165 $desc->output ('start','end');
166 ?>
167 </div>
168
169 <div class='option-design'>
170 <?php
171 $bbox = new maxField('switch');
172 $bbox->label = __('Preview in Border Box mode','maxbuttons');
173 $bbox->note = __('A lot of modern themes render their templates as "border box". If you notice that padding
174 and borders looks differently on the site compared to preview, try to turn this option on', 'maxbuttons');
175 $bbox->name = 'maxbuttons_borderbox';
176 $bbox->id = $bbox->name;
177 $bbox->value = '1';
178 $bbox->checked = checked($option_borderbox, 1, false);
179 $bbox->output('start','end');
180 ?>
181 </div>
182
183 <div class='option-design'>
184 <?php
185 /* $option_forcefa = get_option('maxbuttons_forcefa');
186
187 $fa = new maxField('switch');
188 $fa->label = __('FontAwesome conflict mode', 'maxbuttons');
189 $fa->note = __('If other plugins are conflicting with FontAwesome, tries to force plugin version.');
190 $fa->name = 'maxbuttons_forcefa';
191 $fa->id = $fa->name;
192 $fa->value = '1';
193 $fa->checked = checked($option_forcefa, 1, false);
194 $fa->output('start','end'); */
195
196 $prot = new maxField('text');
197 $prot->id = 'maxbuttons_protocol';
198 $prot->name = $prot->id;
199 $prot->value = get_option('maxbuttons_protocol');
200 $prot->label = __('Additional allowed link protocols', 'maxbuttons');
201 $prot->note = __('Separate multiple protocols with comma', 'maxbuttons');
202
203 $prot->output('start', 'end');
204 ?>
205 </div>
206
207
208 <?php do_action("maxbuttons_settings_end"); ?>
209 <?php submit_button(); ?>
210 </form>
211 </div>
212 </div>
213
214
215 <form method="POST">
216 <input type="hidden" name="reset_cache" value="true" />
217 <div class="option-container">
218 <div class="title"><?php _e("Clear button cache","maxbuttons"); ?></div>
219 <div class="inside">
220 <p><?php _e("Maxbuttons caches the style output allowing for lightning fast display of your buttons. In the event
221 this cache needs to be flushed and rebuilt you can reset the cache here.","maxbuttons"); ?></p>
222 <?php submit_button(__("Reset Cache", "maxbuttons") ); ?>
223 </div>
224 </div>
225 </form>
226
227 </div> <!-- /first tab --->
228 <div class="mb_tab"><!-- advanced tab -->
229 <div class="title">
230 <span class="dashicons dashicons-list-view"></span>
231 <span class='title'><?php _e('Advanced', 'maxbuttons') ?></span>
232 </div>
233
234 <form method="POST">
235 <div class="option-container">
236
237 <input type="hidden" name="remigrate" value="true" />
238 <div class="title"><?php _e("Retry Database migration","maxbuttons"); ?></div>
239 <div class="inside"><p><?php _e("In case the upgrade functionality failed to move your old buttons from MaxButtons before version 3, you can do so here manually. <strong>Attention</strong> The new database table (maxbuttonsv3) *must* be empty, and the old database table *must* contain buttons otherwise this will not run. Run this <strong>at your own risk</strong> - it is strongly advised to make a backup before doing so.", "maxbuttons"); ?></p>
240 <?php submit_button(__("Remigrate", "maxbuttons") ); ?>
241 </div>
242
243
244 </div>
245 </form>
246
247 <div class="option-container">
248 <div class="title"><?php _e('UTF8 Table Fix', 'maxbuttons') ?></div>
249 <div class="inside">
250 <div class="option-design" >
251 <h3 class="alert"><?php _e('WARNING: We strongly recommend backing up your database before altering the charset of the MaxButtons table in your WordPress database.', 'maxbuttons') ?></h3>
252
253 <h3><?php _e('The button below should help fix the "foreign character issue" some people experience when using MaxButtons. If you use foreign characters in your buttons and after saving see ????, use this button.', 'maxbuttons') ?></h3>
254
255 <form action="" method="POST">
256 <input type="submit" name="alter_charset" class="button-primary" value="<?php _e('Change MaxButtons Table To UTF8', 'maxbuttons') ?>" /> <?php echo $response; ?>
257 </form>
258
259
260 <div class="clear"></div>
261 </div>
262 </div>
263 </div>
264
265 <?php if (isset($_GET["show_replace"])): ?>
266 <form method="POST">
267 <div class="option-container">
268 <?php
269 $button = MB()->getClass('button');
270 $button->set(0);
271 $data = $button->get();
272
273 $allfields = array();
274
275 foreach($data as $block => $fields)
276 {
277 if ( is_array($fields) )
278 $allfields = array_merge($allfields, array_keys($fields));
279
280 }
281 $allfields = array_combine($allfields, $allfields);
282
283 wp_nonce_field( 'mb_bulk_edit','bulk_edit' );
284 ?>
285
286 <input type="hidden" name="replace" value="true" />
287 <div class="title"> <?php _e("Bulk edit","maxbuttons"); ?></div>
288
289 <div class="inside" >
290 <p><strong><?php _e("Using Bulk editor MAY and probably WILL destroy your buttons. In case you wish to prevent this - please BACKUP all your buttons before proceeding!","maxbuttons"); ?></strong></p>
291
292 <div class="option"><label><?php _e("Field", "maxbuttons"); ?> </label> <?php echo maxUtils::selectify("replace_field", $allfields, 'url'); ?></div>
293
294 <div class="option"><label><?php _e("Search","maxbuttons"); ?> </label> <input type="text" name="search" value=""></div>
295 <div class="option"><label><?php _e("Replace","maxbuttons"); ?> </label> <input type="text" name="replace" value=""></div>
296
297
298 <p style="color: #ff0000"> <?php _e("I understand that this may destroy all my buttons", "maxbuttons"); ?></p>
299
300 <p><?php _e("", "maxbuttons"); ?></p>
301 <?php submit_button(__("Replace", "maxbuttons") ); ?>
302 </div>
303 </div>
304 </form>
305
306 <?php else: ?>
307 <a href="<?php echo add_query_arg('show_replace',true); ?>"><?php _e("I need to bulk edit something","maxbuttons"); ?></a>
308 <?php endif; ?>
309
310 </div>
311 </div> <!-- advanced tab -->
312 <div class="ad-wrap">
313 <?php do_action("mb-display-ads"); ?>
314 </div>
315
316 <?php $admin->get_footer(); ?>
317