After Display Page
do_action( 'vikrestaurants_after_display_{$page}', JView $view )
Fires after displaying a page of the plugin.
Description
This hook is triggered every time the plugin completes the rendering of a page.
The dynamic portion of the hook name, $page
, refers to the name of the page calling the hook. This means that, for example, the tables page will trigger an hook called vikrestaurants_after_display_tables
.
DO NOT echo any HTML in this hook to avoid sending the headers in advance.
Parameters
- $page
-
(JView) The page instance.
Example
The example below explains how to extend the toolbar with a custom button within the take-away orders list.
/**
* Fires after the controller displayed the page.
*
* @param JView $page The page instance.
*/
add_action('vikrestaurants_after_display_tkreservations', function($page)
{
// adds a button to archive the take-away orders
JToolbarHelper::archiveList('tkreservation.archive');
});
Every time the archive button is clicked, the plugin will submit the request to the following end-point.
/wp-admin/admin.php?page=vikrestaurants&task=tkreservation.archive
It is now possible to rely on the vikrestaurants_before_dispatch
hook to intercept the request and archive the selected reservations.
add_action('vikrestaurants_before_dispatch', function()
{
// get requested action
$task = isset($_REQUEST['task']) ? $_REQUEST['task'] : '';
if (is_admin() && $task == 'tkreservation.archive')
{
// get selected records
$ids = isset($_REQUEST['cid']) ? (array) $_REQUEST['cid'] : array();
if (count($ids))
{
/**
* @todo archive selected orders
*/
}
// then go back to the orders list
wp_redirect('admin.php?page=vikrestaurants&view=tkreservations');
}
});
Changelog
Version | Description |
---|---|
1.0 | Introduced. |