public function display() { require_once 'AddActionsAndFilters_AdminViewUrlBuilder.php'; $urlBuilder = new AddActionsAndFilters_AdminViewUrlBuilder(); $cleanUrl = $urlBuilder->buildUrl(); // no action value in it echo '<div class="wrap">'; // Header $adminUrl = get_admin_url() . 'admin.php?page='; printf('<table width="%s"><tbody><tr><td><a href="%s"><img src="%s"/></a></td><td align="right"><span style="white-space: nowrap;"><a href="%s"><img src="%s"/></a><a href="%s"><img src="%s"/></a></span></td></tr></tbody></table>', '100%', $cleanUrl, $this->plugin->getPluginFileUrl('img/admin-banner.png'), $adminUrl . $this->plugin->getImportExportSlug(), $this->plugin->getPluginFileUrl('img/import-export.png'), $adminUrl . $this->plugin->getSettingsSlug(), $this->plugin->getPluginFileUrl('img/settings.png')); printf('<table><tbody><tr><td></td></tr></tbody></table>'); $actions = new AddActionsAndFilters_AdminPageActions(); printf('<a href="%s%s%s%s%s" class="page-title-action">%s</a>', get_admin_url(), 'admin.php?page=', $this->plugin->getAdminPageSlug(), '&action=', $actions->getEditKey(), __('Add New')); // Table Styles echo '<style type="text/css">'; echo '.wp-list-table .column-id { width: 7%; }'; echo '.wp-list-table .column-enabled { width: 10%; }'; echo '.wp-list-table .column-shortcode { width: 7%; }'; echo '.wp-list-table .column-name { width: 25%; }'; echo '.wp-list-table .column-capability { width: 20%; }'; echo '.wp-list-table .column-description { width: 31%; }'; echo '.wp-list-table .item-inactive { font-style: italic; opacity: 0.6; filter: alpha(opacity = 60); /* MSIE */ }'; echo '</style>'; // Form for bulk actions printf('<form action="%s" method="post">', $cleanUrl); // Search box $this->table->search_box('search', 'search_id'); // Code table $this->table->display(); // Closing Tags echo '</form>'; echo '</div>'; }
/** * Handle the URL request for the WP dashboard admin page. * Handle any actions indicated in the URL GET parameters */ function handleAdminPageUrl() { $this->plugin->securityCheck(); // set-screen-option callback - does not work // this is the work-around if (isset($_REQUEST['wp_screen_options']) && is_array($_REQUEST['wp_screen_options'])) { AddActionsAndFilters_ViewAdminPage::setScreenOptionCallback($_REQUEST['wp_screen_options']['option'], $_REQUEST['wp_screen_options']['value']); } require_once 'AddActionsAndFilters_DataModelConfig.php'; require_once 'AddActionsAndFilters_DataModel.php'; // Look for Sorting, ordering and searching $config = new AddActionsAndFilters_DataModelConfig(); if (isset($_REQUEST['orderby'])) { $config->setOrderby($_REQUEST['orderby']); } if (isset($_REQUEST['order'])) { $config->setAsc($_REQUEST['order'] != 'desc'); } if (isset($_REQUEST['s'])) { $config->setSearch($_REQUEST['s']); } // Init DataModel and Table $dataModel = new AddActionsAndFilters_DataModel($this->plugin, $config); require_once 'AddActionsAndFilters_CodeListTable.php'; $table = new AddActionsAndFilters_CodeListTable($dataModel); // May be changed if a different page is to be displayed $showAdminPage = true; // Look for actions to be performed $action = $table->current_action(); if ($action && $action != -1) { require_once 'AddActionsAndFilters_AdminPageActions.php'; $actions = new AddActionsAndFilters_AdminPageActions(); $ids = null; if (isset($_REQUEST['cb']) && is_array($_REQUEST['cb'])) { // check nonce which is on the bulk action form only if ($table->verifyBulkNonce($_REQUEST['_wpnonce'])) { $ids = $_REQUEST['cb']; } } else { if (isset($_REQUEST['id'])) { $ids = array($_REQUEST['id']); } else { if (isset($_REQUEST['ids'])) { $ids = explode(',', $_REQUEST['ids']); } } } // Perform Actions if ($action == $actions->getEditKey()) { $item = isset($_REQUEST['id']) ? $dataModel->getDataItem($_REQUEST['id']) : array(); $showAdminPage = false; // show edit page instead $this->plugin->displayEditPage($item); } else { if ($ids) { switch ($action) { case $actions->getActivateKey(): $dataModel->activate($ids, true); break; case $actions->getDeactivateKey(): $dataModel->activate($ids, false); break; case $actions->getDeleteKey(): $dataModel->delete($ids); break; case $actions->getExportKey(): if (!empty($ids)) { require_once 'AddActionsAndFilters_ViewImportExport.php'; $view = new AddActionsAndFilters_ViewImportExport($this->plugin); $view->outputBulkExport($ids); } break; default: break; } } } } // Display Admin Page if ($showAdminPage) { $table->prepare_items(); $this->displayAdminTable($table); } }