| 1 |
<?php // Prismatic - Reset Settings |
| 2 |
|
| 3 |
if (!defined('ABSPATH')) exit; |
| 4 |
|
| 5 |
function prismatic_admin_notice() { |
| 6 |
|
| 7 |
$screen = get_current_screen(); |
| 8 |
|
| 9 |
if ($screen->id === 'settings_page_prismatic') { |
| 10 |
|
| 11 |
if (isset($_GET['reset-options'])) { |
| 12 |
|
| 13 |
if ($_GET['reset-options'] === 'true') : ?> |
| 14 |
|
| 15 |
<div class="notice notice-success is-dismissible"><p><strong><?php esc_html_e('Default options restored.', 'prismatic'); ?></strong></p></div> |
| 16 |
|
| 17 |
<?php else : ?> |
| 18 |
|
| 19 |
<div class="notice notice-info is-dismissible"><p><strong><?php esc_html_e('No changes made to options.', 'prismatic'); ?></strong></p></div> |
| 20 |
|
| 21 |
<?php endif; |
| 22 |
|
| 23 |
} |
| 24 |
|
| 25 |
} |
| 26 |
|
| 27 |
} |
| 28 |
|
| 29 |
function prismatic_reset_options() { |
| 30 |
|
| 31 |
if (isset($_GET['reset-options-verify']) && wp_verify_nonce($_GET['reset-options-verify'], 'prismatic_reset_options')) { |
| 32 |
|
| 33 |
if (!current_user_can('manage_options')) exit; |
| 34 |
|
| 35 |
$update_general = update_option('prismatic_options_general', Prismatic::options_general()); |
| 36 |
$update_prism = update_option('prismatic_options_prism', Prismatic::options_prism()); |
| 37 |
$update_highlight = update_option('prismatic_options_highlight', Prismatic::options_highlight()); |
| 38 |
$update_plain = update_option('prismatic_options_plain', Prismatic::options_plain()); |
| 39 |
|
| 40 |
$result = 'false'; |
| 41 |
|
| 42 |
if ( |
| 43 |
$update_general || |
| 44 |
$update_prism || |
| 45 |
$update_highlight || |
| 46 |
$update_plain |
| 47 |
|
| 48 |
) $result = 'true'; |
| 49 |
|
| 50 |
$location = admin_url('options-general.php?page=prismatic&reset-options='. $result); |
| 51 |
|
| 52 |
wp_redirect($location); |
| 53 |
|
| 54 |
exit; |
| 55 |
|
| 56 |
} |
| 57 |
|
| 58 |
} |
| 59 |
|