function prepare_items() { $per_page = $this->get_items_per_page(static::PER_PAGE_OPTION, static::PER_PAGE_DEFAULT); $current_page = $this->get_pagenum(); $orderby = isset($_REQUEST['orderby']) ? $_REQUEST['orderby'] : 'date'; $order = isset($_REQUEST['order']) ? $_REQUEST['order'] : 'desc'; $offset = ($current_page - 1) * $per_page; $limit = $per_page; $game_filter = \WP_Clanwars\ACL::user_can('which_games'); $args = array('id' => 'all', 'game_id' => $game_filter, 'sum_tickets' => true, 'orderby' => $orderby, 'order' => $order, 'limit' => $limit, 'offset' => $limit * ($current_page - 1)); $matches = \WP_Clanwars\Matches::get_match($args); $pagination = $matches->get_pagination(); $this->set_pagination_args(array('total_pages' => $pagination->get_num_pages(), 'total_items' => $pagination->get_num_rows(), 'per_page' => $per_page)); $this->items = $matches->getArrayCopy(); }
function on_settings() { $table_columns = array('cb' => '<input type="checkbox" />', 'user_login' => __('User Login', WP_CLANWARS_TEXTDOMAIN), 'user_permissions' => __('Permissions', WP_CLANWARS_TEXTDOMAIN)); $categories_dropdown = wp_dropdown_categories(array('name' => 'category', 'hierarchical' => true, 'show_option_none' => __('None'), 'hide_empty' => 0, 'hide_if_empty' => 0, 'selected' => get_option(WP_CLANWARS_CATEGORY, -1), 'echo' => false)); $enable_default_styles = get_option(WP_CLANWARS_DEFAULTCSS); // hide default styles checkbox on jumpstarter $hide_default_styles = $this->is_jumpstarter(); $games = \WP_Clanwars\Games::get_game('id=all'); $acl = \WP_Clanwars\ACL::get(); $acl_keys = \WP_Clanwars\ACL::all_caps(); $obj = new stdClass(); $obj->id = 0; $obj->title = __('All', WP_CLANWARS_TEXTDOMAIN); $obj->abbr = __('All'); $obj->icon = 0; array_unshift($games, $obj); $user_acl_info = array(); foreach ($acl as $user_id => $user_acl) { $user = get_userdata($user_id); $allowed_games = \WP_Clanwars\ACL::user_can('which_games', false, $user_id); $user_games = \WP_Clanwars\Games::get_game(array('id' => $allowed_games, 'orderby' => 'title', 'order' => 'asc')); // populate games with urls for icons foreach ($user_games as $game) { $game->icon_url = wp_get_attachment_url($game->icon); } $item = new stdClass(); $item->user = $user; $item->user_acl = $user_acl; $item->user_games = $user_games; $item->allowed_games = $allowed_games; array_push($user_acl_info, $item); } $view = new View('settings'); $view->add_helper('print_table_header', array($this, 'print_table_header')); $context = compact('table_columns', 'games', 'acl_keys', 'user_acl_info', 'categories_dropdown', 'enable_default_styles', 'hide_default_styles'); $view->render($context); }