PluginProbe
MaxButtons – Create buttons / 7.11
MaxButtons – Create buttons v7.11
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.11, at includes/maxbuttons-settings.php

318 lines 12.6 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 for editing buttons', '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 $prot->help = __('You can add link formats not regarded as "safe" by WordPress. Use this if links are removed or lose their protocol ( xx:// ). For instance: "file,sms,skype" .', 'maxbuttons');
203
204 $prot->output('start', 'end');
205 ?>
206 </div>
207
208
209 <?php do_action("maxbuttons_settings_end"); ?>
210 <?php submit_button(); ?>
211 </form>
212 </div>
213 </div>
214
215
216 <form method="POST">
217 <input type="hidden" name="reset_cache" value="true" />
218 <div class="option-container">
219 <div class="title"><?php _e("Clear button cache","maxbuttons"); ?></div>
220 <div class="inside">
221 <p><?php _e("Maxbuttons caches the style output allowing for lightning fast display of your buttons. In the event
222 this cache needs to be flushed and rebuilt you can reset the cache here.","maxbuttons"); ?></p>
223 <?php submit_button(__("Reset Cache", "maxbuttons") ); ?>
224 </div>
225 </div>
226 </form>
227
228 </div> <!-- /first tab --->
229 <div class="mb_tab"><!-- advanced tab -->
230 <div class="title">
231 <span class="dashicons dashicons-list-view"></span>
232 <span class='title'><?php _e('Advanced', 'maxbuttons') ?></span>
233 </div>
234
235 <form method="POST">
236 <div class="option-container">
237
238 <input type="hidden" name="remigrate" value="true" />
239 <div class="title"><?php _e("Retry Database migration","maxbuttons"); ?></div>
240 <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>
241 <?php submit_button(__("Remigrate", "maxbuttons") ); ?>
242 </div>
243
244
245 </div>
246 </form>
247
248 <div class="option-container">
249 <div class="title"><?php _e('UTF8 Table Fix', 'maxbuttons') ?></div>
250 <div class="inside">
251 <div class="option-design" >
252 <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>
253
254 <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>
255
256 <form action="" method="POST">
257 <input type="submit" name="alter_charset" class="button-primary" value="<?php _e('Change MaxButtons Table To UTF8', 'maxbuttons') ?>" /> <?php echo $response; ?>
258 </form>
259
260
261 <div class="clear"></div>
262 </div>
263 </div>
264 </div>
265
266 <?php if (isset($_GET["show_replace"])): ?>
267 <form method="POST">
268 <div class="option-container">
269 <?php
270 $button = MB()->getClass('button');
271 $button->set(0);
272 $data = $button->get();
273
274 $allfields = array();
275
276 foreach($data as $block => $fields)
277 {
278 if ( is_array($fields) )
279 $allfields = array_merge($allfields, array_keys($fields));
280
281 }
282 $allfields = array_combine($allfields, $allfields);
283
284 wp_nonce_field( 'mb_bulk_edit','bulk_edit' );
285 ?>
286
287 <input type="hidden" name="replace" value="true" />
288 <div class="title"> <?php _e("Bulk edit","maxbuttons"); ?></div>
289
290 <div class="inside" >
291 <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>
292
293 <div class="option"><label><?php _e("Field", "maxbuttons"); ?> </label> <?php echo maxUtils::selectify("replace_field", $allfields, 'url'); ?></div>
294
295 <div class="option"><label><?php _e("Search","maxbuttons"); ?> </label> <input type="text" name="search" value=""></div>
296 <div class="option"><label><?php _e("Replace","maxbuttons"); ?> </label> <input type="text" name="replace" value=""></div>
297
298
299 <p style="color: #ff0000"> <?php _e("I understand that this may destroy all my buttons", "maxbuttons"); ?></p>
300
301 <p><?php _e("", "maxbuttons"); ?></p>
302 <?php submit_button(__("Replace", "maxbuttons") ); ?>
303 </div>
304 </div>
305 </form>
306
307 <?php else: ?>
308 <a href="<?php echo add_query_arg('show_replace',true); ?>"><?php _e("I need to bulk edit something","maxbuttons"); ?></a>
309 <?php endif; ?>
310
311 </div>
312 </div> <!-- advanced tab -->
313 <div class="ad-wrap">
314 <?php do_action("mb-display-ads"); ?>
315 </div>
316
317 <?php $admin->get_footer(); ?>
318