add new storyline-based archive dropdown option
This commit is contained in:
parent
dbdfcf055c
commit
01e2073aee
|
@ -19,7 +19,8 @@ class ArchiveDropdownWidget extends WP_Widget {
|
||||||
$this->modes = array(
|
$this->modes = array(
|
||||||
'monthly_archive' => __('Monthly archive', 'comicpress'),
|
'monthly_archive' => __('Monthly archive', 'comicpress'),
|
||||||
'comic_archive' => __('Comic archive', 'comicpress'),
|
'comic_archive' => __('Comic archive', 'comicpress'),
|
||||||
'storyline_order' => __('Storyline order', 'comicpress'),
|
'storyline_order' => __('Storyline archive pages', 'comicpress'),
|
||||||
|
'storyline_order_post_link' => __('Storyline posts', 'comicpress'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,6 +131,31 @@ class ArchiveDropdownWidget extends WP_Widget {
|
||||||
return $this->build_dropdown($results);
|
return $this->build_dropdown($results);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build dropdown based on storyline order, linking to the first post in each category.
|
||||||
|
*/
|
||||||
|
function build_storyline_order_post_link_dropdown() {
|
||||||
|
$storyline = $this->_new_comicpressstoryline();
|
||||||
|
$storyline->read_from_options();
|
||||||
|
|
||||||
|
$dbi = $this->_new_comicpressdbinterface();
|
||||||
|
|
||||||
|
$results = array();
|
||||||
|
if (!empty($storyline->_structure)) {
|
||||||
|
foreach ($storyline->_structure as $id => $info) {
|
||||||
|
$category = get_category($id);
|
||||||
|
if (!empty($category)) {
|
||||||
|
$post = $dbi->get_first_post($id);
|
||||||
|
if (!empty($post)) {
|
||||||
|
$results[get_permalink($post)] = str_repeat(' ', ($info['level'] - 1) * 3) . $category->name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->build_dropdown($results);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render the widget.
|
* Render the widget.
|
||||||
*/
|
*/
|
||||||
|
@ -202,4 +228,4 @@ class ArchiveDropdownWidget extends WP_Widget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
add_action('template_redirect', array('ArchiveDropdownWidget', 'template_redirect'));
|
add_action('template_redirect', array('ArchiveDropdownWidget', 'template_redirect'));
|
||||||
|
|
Loading…
Reference in New Issue