What is the right way to issue commands in wp-admin? My plugin imports data from a set of RSS feeds via a cron job. Thats all working good. I've set up a custom settings page to change parameters, and wanted to add an "Update Now" button so the user could force a manual refresh. I need a few other commands as well.
What is the "wordpress way" to add and handle these commands?
I tried adding a url http://example.com/wp-admin/options-general.php?page=myplugin&action=update to the options page, then
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'update') { doUpdate(); }
but i get an error showing $wp has not been initialised. I tried including the wp-load.php and the wp-settings.php but it didn't help.
Error message is Fatal error: Call to a member function add_rewrite_tag() on a non-object in /wordpress/wp-includes/rewrite.php on line 51
The lines causing the problem in doUpdate() are
if (taxonomy_exists($name)) {
return;
}
$slug = str_replace(' ', '_', $title);
register_taxonomy(
$name,
'',
array(
'labels' => array( 'name' => __(ucwords($title)) ),
'public' => true,
'show_ui' => self::SHOW_UI,
'show_in_nav_menus' => true,
'show_admin_column' => true,
'hierarchical' => false,
'query_var' => $slug,
'rewrite' => array( 'slug' => __($slug) ),
)
);
What am I doing wrong? How can I allow the user to perform an action from an admin settings pane?