| 1 |
<?php |
| 2 |
defined('ABSPATH') or die('No direct access permitted'); |
| 3 |
|
| 4 |
|
| 5 |
if(isset($_POST['alter_charset'])) { |
| 6 |
|
| 7 |
global $maxbuttons_installed_version; |
| 8 |
global $wpdb; |
| 9 |
$table_name = maxUtils::get_table_name(); |
| 10 |
|
| 11 |
$sql = "ALTER TABLE " . $table_name . " CONVERT TO CHARACTER SET utf8"; |
| 12 |
require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
| 13 |
$wpdb->query($sql); |
| 14 |
$response = 'CHARSET now utf_8 COLLATE utf8_general_ci'; |
| 15 |
|
| 16 |
} else { |
| 17 |
$response = ''; |
| 18 |
} |
| 19 |
|
| 20 |
if (isset($_POST["reset_cache"])) |
| 21 |
{ |
| 22 |
$button = new maxButton(); |
| 23 |
$button->reset_cache(); |
| 24 |
|
| 25 |
} |
| 26 |
|
| 27 |
if (isset($_POST["remigrate"])) |
| 28 |
{ |
| 29 |
$install = MB()->getClass("install"); |
| 30 |
$install::create_database_table(); |
| 31 |
$install::migrate(); |
| 32 |
} |
| 33 |
|
| 34 |
if (isset($_POST["replace"]) && check_admin_referer('mb_bulk_edit', 'bulk_edit')) |
| 35 |
{ |
| 36 |
$search = $_POST["search"]; |
| 37 |
$replace = $_POST["replace"]; |
| 38 |
$field = $_POST["replace_field"]; |
| 39 |
|
| 40 |
$button = new maxButton(); |
| 41 |
|
| 42 |
if ($field == '') |
| 43 |
exit("FATAL"); |
| 44 |
|
| 45 |
$admin = MB()->getClass('admin'); |
| 46 |
$buttonsIDS = $admin->getButtons(array('limit' => -1)); |
| 47 |
|
| 48 |
$data_found = false; |
| 49 |
|
| 50 |
foreach($buttonsIDS as $row) |
| 51 |
{ |
| 52 |
$button_id = $row["id"]; |
| 53 |
$button->set($button_id); |
| 54 |
$data = $button->get(); |
| 55 |
foreach($data as $block => $fields) |
| 56 |
{ |
| 57 |
if (isset($fields[$field])) |
| 58 |
{ |
| 59 |
$value = $fields[$field]; |
| 60 |
$data[$block][$field] = str_replace($search, $replace, $value); |
| 61 |
$button->update($data); |
| 62 |
//echo "UPDATE $field of $block with ($search) - $replace - ($value) <br>"; |
| 63 |
|
| 64 |
$data_found = true; |
| 65 |
continue; |
| 66 |
} |
| 67 |
|
| 68 |
if ($data_found) |
| 69 |
{ |
| 70 |
$data_found = false; |
| 71 |
continue; |
| 72 |
} |
| 73 |
} |
| 74 |
|
| 75 |
|
| 76 |
} |
| 77 |
|
| 78 |
} |
| 79 |
|
| 80 |
?> |
| 81 |
<?php |
| 82 |
$admin = MB()->getClass('admin'); |
| 83 |
$page_title = __("Settings","maxbuttons"); |
| 84 |
$admin->get_header(array("tabs_active" => true, "title" => $page_title) ); |
| 85 |
?> |
| 86 |
|
| 87 |
<div class="mb_tab"> <!-- first tab ---> |
| 88 |
<div class="title"> |
| 89 |
<span class="dashicons dashicons-list-view"></span> |
| 90 |
<span class='title'><?php _e('Settings', 'maxbuttons') ?></span> |
| 91 |
</div> |
| 92 |
<div class="option-container"> |
| 93 |
<div class="title"><?php _e('Settings','maxbuttons'); ?></div> |
| 94 |
<div class="inside"> |
| 95 |
|
| 96 |
<form method="post" action="options.php"> |
| 97 |
<div class="option-design"> |
| 98 |
|
| 99 |
<?php settings_fields( 'maxbuttons_settings' ); ?> |
| 100 |
<label><?php _e('MaxButtons User Level', 'maxbuttons') ?></label> |
| 101 |
<div class="input"> |
| 102 |
<select name="maxbuttons_user_level"> |
| 103 |
<?php $maxbuttons_user_level = get_option('maxbuttons_user_level'); ?> |
| 104 |
<option value="edit_posts" <?php if($maxbuttons_user_level === 'edit_posts') { echo 'selected="selected"'; } ?>>Contributor</option> |
| 105 |
<option value="edit_published_posts" <?php if($maxbuttons_user_level === 'edit_published_posts') { echo 'selected="selected"'; } ?>>Author</option> |
| 106 |
<option value="manage_categories" <?php if($maxbuttons_user_level === 'manage_categories') { echo 'selected="selected"'; } ?>>Editor</option> |
| 107 |
<option value="manage_options" <?php if($maxbuttons_user_level === 'manage_options') { echo 'selected="selected"'; } ?>>Administrator</option> |
| 108 |
</select> |
| 109 |
<br /> |
| 110 |
<?php printf( __('For more details on user roles and permissions, click %s here%s.','maxbuttons'), |
| 111 |
'<a target="_blank" href="https://codex.wordpress.org/Roles_and_Capabilities">', |
| 112 |
"</a>"); |
| 113 |
?> |
| 114 |
|
| 115 |
</div> |
| 116 |
|
| 117 |
<div class="clear"></div> |
| 118 |
</div><!-- option-design --> |
| 119 |
<?php |
| 120 |
$noshow = get_option('maxbuttons_noshowtinymce'); |
| 121 |
//$noshow = $max["noshow_tinymce"]; |
| 122 |
?> |
| 123 |
<div class="option-design"> |
| 124 |
<label for='maxbuttons_noshowtinymce'><?php _e("Don't show add button in post editor", 'maxbuttons'); ?></label> |
| 125 |
<div class="input checkbox"><input type="checkbox" id='maxbuttons_noshowtinymce' name="maxbuttons_noshowtinymce" value="1" <?php checked($noshow,1); ?> /></div> |
| 126 |
</div> |
| 127 |
|
| 128 |
<?php |
| 129 |
$minify = get_option("maxbuttons_minify", 1); |
| 130 |
$description_hide = get_option('maxbuttons_hidedescription',0); |
| 131 |
|
| 132 |
?> |
| 133 |
<div class="option-design"> |
| 134 |
<label for="maxbuttons_minify"><?php _e("Minify CSS output of buttons","maxbuttons"); ?></label> |
| 135 |
<div class="input checkbox"> |
| 136 |
<input type="checkbox" id='maxbuttons_minify' name="maxbuttons_minify" value="1" <?php checked($minify,1); ?>> |
| 137 |
<span class='note'><?php _e("You will have to clear your cache after changing this setting","maxbuttons"); ?></span> |
| 138 |
</div> |
| 139 |
</div> |
| 140 |
|
| 141 |
<div class="option-design"> |
| 142 |
<label for='maxbuttons_hidedescription'><?php _e("Hide description field","maxbuttons"); ?></label> |
| 143 |
<div class='input checkbox'><input type='checkbox' id='maxbuttons_hidedescription' name='maxbuttons_hidedescription' value='1' <?php checked($description_hide, 1); ?> > |
| 144 |
</div> |
| 145 |
|
| 146 |
</div> |
| 147 |
|
| 148 |
|
| 149 |
<?php do_action("maxbuttons_settings_end"); ?> |
| 150 |
<?php submit_button(); ?> |
| 151 |
</form> |
| 152 |
</div> |
| 153 |
</div> |
| 154 |
|
| 155 |
|
| 156 |
<form method="POST"> |
| 157 |
<input type="hidden" name="reset_cache" value="true" /> |
| 158 |
<div class="option-container"> |
| 159 |
<div class="title"><?php _e("Clear button cache","maxbuttons"); ?></div> |
| 160 |
<div class="inside"> |
| 161 |
<p><?php _e("Maxbuttons caches the style output allowing for lightning fast display of your buttons. In the event |
| 162 |
this cache needs to be flushed and rebuilt you can reset the cache here.","maxbuttons"); ?></p> |
| 163 |
<?php submit_button(__("Reset Cache", "maxbuttons") ); ?> |
| 164 |
</div> |
| 165 |
</div> |
| 166 |
</form> |
| 167 |
|
| 168 |
</div> <!-- /first tab ---> |
| 169 |
<div class="mb_tab"><!-- advanced tab --> |
| 170 |
<div class="title"> |
| 171 |
<span class="dashicons dashicons-list-view"></span> |
| 172 |
<span class='title'><?php _e('Advanced', 'maxbuttons') ?></span> |
| 173 |
</div> |
| 174 |
|
| 175 |
<form method="POST"> |
| 176 |
<div class="option-container"> |
| 177 |
|
| 178 |
<input type="hidden" name="remigrate" value="true" /> |
| 179 |
<div class="title"><?php _e("Retry Database migration","maxbuttons"); ?></div> |
| 180 |
<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> |
| 181 |
<?php submit_button(__("Remigrate", "maxbuttons") ); ?> |
| 182 |
</div> |
| 183 |
|
| 184 |
|
| 185 |
</div> |
| 186 |
</form> |
| 187 |
|
| 188 |
<div class="option-container"> |
| 189 |
<div class="title"><?php _e('UTF8 Table Fix', 'maxbuttons') ?></div> |
| 190 |
<div class="inside"> |
| 191 |
<div class="option-design" > |
| 192 |
<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> |
| 193 |
|
| 194 |
<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> |
| 195 |
|
| 196 |
<form action="" method="POST"> |
| 197 |
<input type="submit" name="alter_charset" class="button-primary" value="<?php _e('Change MaxButtons Table To UTF8', 'maxbuttons') ?>" /> <?php echo $response; ?> |
| 198 |
</form> |
| 199 |
|
| 200 |
|
| 201 |
<div class="clear"></div> |
| 202 |
</div> |
| 203 |
</div> |
| 204 |
</div> |
| 205 |
|
| 206 |
<?php if (isset($_GET["show_replace"])): ?> |
| 207 |
<form method="POST"> |
| 208 |
<div class="option-container"> |
| 209 |
<?php |
| 210 |
$button = MB()->getClass('button'); |
| 211 |
$button->set(0); |
| 212 |
$data = $button->get(); |
| 213 |
|
| 214 |
$allfields = array(); |
| 215 |
foreach($data as $block => $fields) |
| 216 |
{ |
| 217 |
$allfields = array_merge($allfields, array_keys($fields)); |
| 218 |
|
| 219 |
} |
| 220 |
$allfields = array_combine($allfields, $allfields); |
| 221 |
|
| 222 |
wp_nonce_field( 'mb_bulk_edit','bulk_edit' ); |
| 223 |
?> |
| 224 |
|
| 225 |
<input type="hidden" name="replace" value="true" /> |
| 226 |
<div class="title"> <?php _e("Bulk edit","maxbuttons"); ?></div> |
| 227 |
|
| 228 |
<div class="inside" > |
| 229 |
<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> |
| 230 |
|
| 231 |
<div class="option"><label><?php _e("Field", "maxbuttons"); ?> </label> <?php echo maxUtils::selectify("replace_field", $allfields, 'url'); ?></div> |
| 232 |
|
| 233 |
<div class="option"><label><?php _e("Search","maxbuttons"); ?> </label> <input type="text" name="search" value=""></div> |
| 234 |
<div class="option"><label><?php _e("Replace","maxbuttons"); ?> </label> <input type="text" name="replace" value=""></div> |
| 235 |
|
| 236 |
|
| 237 |
<p style="color: #ff0000"> <?php _e("I understand that this may destroy all my buttons", "maxbuttons"); ?></p> |
| 238 |
|
| 239 |
<p><?php _e("", "maxbuttons"); ?></p> |
| 240 |
<?php submit_button(__("Replace", "maxbuttons") ); ?> |
| 241 |
</div> |
| 242 |
</div> |
| 243 |
</form> |
| 244 |
|
| 245 |
<?php else: ?> |
| 246 |
<a href="<?php echo add_query_arg('show_replace',true); ?>"><?php _e("I need to bulk edit something","maxbuttons"); ?></a> |
| 247 |
<?php endif; ?> |
| 248 |
|
| 249 |
</div> |
| 250 |
</div> <!-- advanced tab --> |
| 251 |
<div class="ad-wrap"> |
| 252 |
<?php do_action("mb-display-ads"); ?> |
| 253 |
</div> |
| 254 |
|
| 255 |
<?php $admin->get_footer(); ?> |
| 256 |
|