Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.

[Feature request] Ask for confirmation in Admin Panel

+6 votes
265 views
asked Nov 18, 2014 in Q2A Core by Allard
I just accidentally hit the button "Reset to defaults" in the Posting tab of my admin panel. Now I lost a lot of custom html and settings. Wouldn't it be better to pop up a confirmation window?
Q2A version: 1.6.3
commented Nov 18, 2014 by vdamanafshan
+1 for your good idea.

1 Answer

+3 votes
answered Nov 18, 2014 by sama55
selected Nov 19, 2014 by Allard
 
Best answer

I think so too. My almost addons have that feature. This is a issue that Q2A core should improve.

Plugin example:

  1. Add "reset-confirm" folder under qa-plugin
  2. Add php files (qa-plugin.php and qa-reset-confirm.php)

qa-plugin.php:

<?php
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
  header('Location: ../../');
  exit;
}
qa_register_plugin_layer('qa-reset-confirm.php', 'Reset confirm');

qa-reset-confirm.php:

<?php
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
  header('Location: ../../');
  exit;
}
class qa_html_theme_layer extends qa_html_theme_base {
  function form_button_data($button, $key, $style) {
    if($this->template === 'admin' && $key === 'reset') 
      $button['tags'] .= ' onclick="javascript:return confirm(\'Settings reset to default. Are you OK?\');"';
    qa_html_theme_base::form_button_data($button, $key, $style);
  }
}

Update:

if($this->template === 'admin' && $key === 'reset')  // <<< Updated !

...