You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.5KB

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