/** * Prepare the table with different parameters, pagination, columns and table elements */ public function prepare_items() { $cron_items = BD_Util::get_cron_schedules(); $totalitems = count($cron_items); //How many to display per page? $perpage = 50; //How many pages do we have in total? $totalpages = ceil($totalitems / $perpage); /* -- Register the pagination -- */ $this->set_pagination_args(array('total_items' => $totalitems, 'total_pages' => $totalpages, 'per_page' => $perpage)); //The pagination links are automatically built according to those parameters /* — Register the Columns — */ $columns = $this->get_columns(); $hidden = array(); $sortable = $this->get_sortable_columns(); $this->_column_headers = array($columns, $hidden, $sortable); $this->items = $cron_items; }
/** * Process delete cron job request. * This should ideally go in a separate class. But I was * lazy to create a separate class for a single function * * @since 5.0 * @static */ public static function do_delete_cron() { if (check_admin_referer('sm-bulk-delete-cron', 'sm-bulk-delete-cron-nonce')) { $cron_id = absint($_GET['cron_id']); $cron_items = BD_Util::get_cron_schedules(); wp_unschedule_event($cron_items[$cron_id]['timestamp'], $cron_items[$cron_id]['type'], $cron_items[$cron_id]['args']); $msg = __('The selected scheduled job was successfully deleted ', 'bulk-delete'); add_settings_error(Bulk_Delete::CRON_PAGE_SLUG, 'deleted-cron', $msg, 'updated'); } }