Action
rpress_{$action}
On this page
Fires on admin_init for a request that carries an rpress-action value in POST or GET.
Runs from rpress_process_actions() on the admin_init hook. The action name is built from the sanitized rpress-action request value, so a request containing rpress-action=my_task fires rpress_my_task. The callback receives the whole sanitized request array. This is the mechanism RestroPress uses to route admin form posts and links such as the customer edit and discount actions.
Parameters#
| Parameter | Type | Description |
|---|---|---|
$request | array | The request data (the full $_POST or $_GET array, depending on which one carried the action) after rpress_sanitize_array(). |
Example#
function my_handle_clear_cache( $request ) {
if ( ! current_user_can( 'manage_shop_settings' ) ) {
return;
}
if ( empty( $request['my_nonce'] ) || ! wp_verify_nonce( $request['my_nonce'], 'my_clear_cache' ) ) {
return;
}
delete_transient( 'my_menu_cache' );
}
add_action( 'rpress_my_clear_cache', 'my_handle_clear_cache', 10, 1 );
Notes#
Fires once for POST data and, if the request also has a GET rpress-action, a second time with the GET array. The dispatcher performs no capability or nonce check, so every callback must do its own. Only runs in the admin.
Source#
Fired from:
includes/admin/admin-actions.php(line 28), inrpress_process_actions()includes/admin/admin-actions.php(line 34), inrpress_process_actions()
See also#
Was this page helpful?
