public function prepare_items() { $items = \Modularity\Options\Archives::getArchives(); // Columns $columns = $this->get_columns(); $hidden = array(); $sortable = array(); $this->_column_headers = array($columns, $hidden, $sortable); // Pagination $this->set_pagination_args(array('total_items' => count($items), 'per_page' => 10, 'total_pages' => ceil(count($items) / 10))); // Items $this->items = $items; }
/** * Get active areas for template. * If nothing found on the specific template (eg. archive-cars), fallback to the default template (eg. archive) * @param string $template Template * @return array Active sidebars */ public function getActiveAreas($template) { $originalTemplate = $template; $options = get_option('modularity-options'); $active = isset($options['enabled-areas'][$template]) ? $options['enabled-areas'][$template] : array(); self::$isEditing['template'] = $template; // Fallback if (count($active) === 0 && !is_numeric($template) && strpos($template, 'archive-') !== false && !in_array($template, \Modularity\Options\Archives::getArchiveTemplateSlugs())) { $template = explode('-', $template, 2)[0]; self::$isEditing['template'] = $template; $active = isset($options['enabled-areas'][$template]) ? $options['enabled-areas'][$template] : array(); } if (self::$isEditing['title'] == 'archive-post') { $home = \Modularity\Helper\Wp::findCoreTemplates(array('home')); if ($home) { $active = isset($options['enabled-areas']['home']) ? $options['enabled-areas']['home'] : array(); self::$isEditing['template'] = 'home'; } } return $active; }