PluginProbe
MaxButtons – Create buttons / 6.23
MaxButtons – Create buttons v6.23
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 6.23, at includes/maxbuttons-settings.php

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