Changing default warning message for resetting all options
  • I didn't like the default warning message for resetting all options. I didn't think it captured the attention of users enough and thought it was too easy to ignore.

    So this is how I changed it.

    Add some custom css:
    #pw_warning_screen { 
    width: 450px;
    padding: 15px;
    border-radius: 12px;
    -moz-border-radius: 12px;
    -webkit-border-radius: 12px;
    position: fixed;
    top: 50%;
    left: 50%;
    margin: 0 0 0 -250px;
    box-shadow: 0 0 5px rgba(0,0,0,0.5);
    -moz-box-shadow: 0 0 5px rgba(0,0,0,0.5);
    -webkit-box-shadow: 0 0 5px rgba(0,0,0,0.5);
    background: #f0f0f0;
    z-index: 1100;
    font-family: Quattrocento, Georgia;
    color: #444444;
    text-shadow: none;
    #pw_warning_screen p{
    font-size: 1.25em;
    line-height: 1.25em
    #pw_warning_screen span{
    background: -moz-linear-gradient(center top , #4FB859, #2B904E) repeat scroll 0 0 transparent;
    border: 1px solid #016526;
    border-radius: 6px 6px 6px 6px;
    box-shadow: 0 1px 0 #88FF91 inset;
    color: #FFFFFF;
    display: block;
    float: left;
    font: 14px/26px bold;
    height: 27px;
    margin: 3px;
    padding: 0 10px;
    text-align: center;
    text-shadow: 0 1px 0 #004017;

    Next let's get a script in there. In your custom actions or child theme add:
    function extra_footer_scripts() { 
    <script type="text/javascript">
    (function($) {
    $('body').append('<div id="pw_warning_screen"><h3>Whoa there cowboy!</h3><p id="warning-message">Resetting all options will revert the theme to its default state. Any changes made to the colour, layout and other options via the PressWork menu will be lost. Are you sure you want to reset the theme options?</p><span id="warning-confrim">I know what I\'m doing!</span> <span id="warning-cancel">Oops get me out of here!</span></div>');
    $('#pw_reset_options').click(function() {
    var loader = $("#ajaxloader");;
    var data = {
    action: 'reset_theme_options'
    $.post('<?php echo admin_url('admin-ajax.php'); ?>', data,
    setTimeout(function() { location.reload(); }, 1000);
    if(current_user_can('edit_theme_options') && pw_theme_option('toolbox')=="on") {
    add_action('wp_footer', 'extra_footer_scripts');

    Notice we're changing the id of the reset options button. This stops the default event from triggering and allows us to add our own.

    Change the css and message to suit.
    Post edited by Mike at 2012-01-10 22:09:00