multipage link filtering
This commit is contained in:
parent
a5a72a9128
commit
50bbc6ff5a
|
@ -117,14 +117,77 @@ class GraphicalNavigationWidgetTest extends PHPUnit_Framework_TestCase {
|
||||||
* @dataProvider providerTestSetUpPostNavStoryPrev
|
* @dataProvider providerTestSetUpPostNavStoryPrev
|
||||||
*/
|
*/
|
||||||
function testComicPressSetUpPostNavFilterStoryPrev($instance, $post_nav, $expected_post_nav) {
|
function testComicPressSetUpPostNavFilterStoryPrev($instance, $post_nav, $expected_post_nav) {
|
||||||
$this->assertEquals($expected_post_nav, array_shift($this->w->_comicpress_set_up_post_nav_story_prev($post_nav, $instance)));
|
$this->assertEquals($expected_post_nav, array_shift($this->w->_comicpress_set_up_post_nav_story_prev($post_nav, null, $instance)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*function testComicPressSetUpPostNavFilterMultiPageSupport($instance, $post_nav, $_page, $_numpages, $expected_post_nav) {
|
function providerTestComicPressSetUpPostNavFilterMultiPageSupport() {
|
||||||
|
return array(
|
||||||
|
array(
|
||||||
|
array('enable_multipage_support' => 'off'),
|
||||||
|
array('previous' => 'prev-post', 'next' => 'next-post'),
|
||||||
|
1, 4,
|
||||||
|
array('previous' => 'prev-post', 'next' => 'next-post')
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array('enable_multipage_support' => 'on'),
|
||||||
|
array('previous' => 'prev-post', 'next' => 'next-post'),
|
||||||
|
1, 1,
|
||||||
|
array('previous' => 'prev-post', 'next' => 'next-post')
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array('enable_multipage_support' => 'on'),
|
||||||
|
array('previous' => 'prev-post', 'next' => 'next-post'),
|
||||||
|
1, 2,
|
||||||
|
array(
|
||||||
|
'previous' => 'prev-post',
|
||||||
|
'next' => 'current-post/2/',
|
||||||
|
'storyline-next' => 'current-post/2/',
|
||||||
|
)
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array('enable_multipage_support' => 'on'),
|
||||||
|
array('previous' => 'prev-post', 'next' => 'next-post'),
|
||||||
|
2, 2,
|
||||||
|
array(
|
||||||
|
'previous' => 'current-post/1/',
|
||||||
|
'storyline-previous' => 'current-post/1/',
|
||||||
|
'next' => 'next-post'
|
||||||
|
)
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array('enable_multipage_support' => 'on'),
|
||||||
|
array(
|
||||||
|
'previous' => 'prev-post',
|
||||||
|
'next' => 'next-post',
|
||||||
|
'storyline-previous' => 'prev-post',
|
||||||
|
'storyline-next' => 'next-post',
|
||||||
|
),
|
||||||
|
2, 3,
|
||||||
|
array(
|
||||||
|
'previous' => 'current-post/1/',
|
||||||
|
'next' => 'current-post/3/',
|
||||||
|
'storyline-previous' => 'current-post/1/',
|
||||||
|
'storyline-next' => 'current-post/3/',
|
||||||
|
)
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider providerTestComicPressSetUpPostNavFilterMultiPageSupport
|
||||||
|
* @return unknown_type
|
||||||
|
*/
|
||||||
|
function testComicPressSetUpPostNavFilterMultiPageSupport($instance, $post_nav, $_page, $_numpages, $expected_post_nav) {
|
||||||
global $post, $page, $numpages;
|
global $post, $page, $numpages;
|
||||||
|
|
||||||
$post = (object)array('ID' => 1);
|
update_option('permalink_structure', '/test/');
|
||||||
}*/
|
|
||||||
|
$post = (object)array('ID' => 1, 'guid' => 'current-post', 'post_status' => 'publish');
|
||||||
|
$page = $_page;
|
||||||
|
$numpages = $_numpages;
|
||||||
|
|
||||||
|
$this->assertEquals($expected_post_nav, array_shift($this->w->_comicpress_set_up_post_nav_multi_page_support($post_nav, $post, $instance)));
|
||||||
|
}
|
||||||
|
|
||||||
function providerTestBuildInPostPageLink() {
|
function providerTestBuildInPostPageLink() {
|
||||||
return array(
|
return array(
|
||||||
|
|
|
@ -27,7 +27,7 @@ class GraphicalNavigationWidget extends WP_Widget {
|
||||||
|
|
||||||
foreach (get_class_methods($this) as $method) {
|
foreach (get_class_methods($this) as $method) {
|
||||||
if (strpos($method, '_comicpress_set_up_post_nav') === 0) {
|
if (strpos($method, '_comicpress_set_up_post_nav') === 0) {
|
||||||
add_filter('comicpress_set_up_post_nav', array(&$this, $method), 10, 2);
|
add_filter('comicpress_set_up_post_nav', array(&$this, $method), 10, 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,7 +295,7 @@ class GraphicalNavigationWidget extends WP_Widget {
|
||||||
$navigation->init($storyline);
|
$navigation->init($storyline);
|
||||||
$post_nav = $navigation->get_post_nav($post);
|
$post_nav = $navigation->get_post_nav($post);
|
||||||
|
|
||||||
$result = apply_filters('comicpress_set_up_post_nav', $post_nav, $instance);
|
$result = apply_filters('comicpress_set_up_post_nav', $post_nav, $post, $instance);
|
||||||
if (is_array($result)) {
|
if (is_array($result)) {
|
||||||
return array_shift($result);
|
return array_shift($result);
|
||||||
} else {
|
} else {
|
||||||
|
@ -311,13 +311,28 @@ class GraphicalNavigationWidget extends WP_Widget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function _comicpress_set_up_post_nav_story_prev($post_nav, $instance) {
|
function _comicpress_set_up_post_nav_story_prev($post_nav, $post, $instance) {
|
||||||
if ($instance['story_prev_acts_as_prev_in'] == 'on') {
|
if ($instance['story_prev_acts_as_prev_in'] == 'on') {
|
||||||
if ($post_nav['storyline-previous'] !== false) {
|
if ($post_nav['storyline-previous'] !== false) {
|
||||||
$post_nav['storyline-chapter-previous'] = $post_nav['storyline-previous'];
|
$post_nav['storyline-chapter-previous'] = $post_nav['storyline-previous'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return array($post_nav, $instance);
|
return array($post_nav, $post, $instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
function _comicpress_set_up_post_nav_multi_page_support($post_nav, $post, $instance) {
|
||||||
|
global $page, $numpages;
|
||||||
|
|
||||||
|
if ($instance['enable_multipage_support'] == 'on') {
|
||||||
|
if ($page < $numpages && $numpages != 1) {
|
||||||
|
$post_nav['next'] = $post_nav['storyline-next'] = $this->_build_in_post_page_link($post, $page + 1);
|
||||||
|
}
|
||||||
|
if ($page != 1 && $numpages > 1) {
|
||||||
|
$post_nav['previous'] = $post_nav['storyline-previous'] = $this->_build_in_post_page_link($post, $page - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return array($post_nav, $post, $instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue