wp-admin – save options without refreshing?

I have my own plugin options page, but when users hit “Save” button the whole page refreshes.

Is there a way of changing my script below to something that will for example popup yellow box saying “settings saved” WITHOUT page refresh? So the data will be passed trough ajax call or something like that.

Read More

I’ve seen something like that before, but can’t recall for what plugin.

add_action('admin_menu', 'my_plugin_menu');

function my_plugin_menu() {

    add_menu_page('My Plugin Options', 'Plugin Options', 'manage_options', 'my-unique-identifier', 'my_plugin_options'); 

}

function my_plugin_options() {

  if (!current_user_can('manage_options'))  {
    wp_die( __('You do not have sufficient permissions to access this page.') );
  } ?>

<form method="post" action="options.php">
<?php wp_nonce_field('update-options'); ?>
(...)
<input type="hidden" name="action" value="update" />
<input type="hidden" name="page_options" value="option1,option2,option3,etc." />
<input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
</form>

Related posts

Leave a Reply

1 comment