diff --git a/test/widgets/GraphicalNavigationWidgetTest.php b/test/widgets/GraphicalNavigationWidgetTest.php index 84819ca..cab99c2 100644 --- a/test/widgets/GraphicalNavigationWidgetTest.php +++ b/test/widgets/GraphicalNavigationWidgetTest.php @@ -116,7 +116,11 @@ class GraphicalNavigationWidgetTest extends PHPUnit_Framework_TestCase { /** * @dataProvider providerTestSetUpPostNav */ - function testSetUpPostNav($instance, $post_nav, $expected_post_nav) { + function testComicPressSetUpPostNavFilter($instance, $post_nav, $expected_post_nav) { + $this->assertEquals($expected_post_nav, array_shift($this->w->comicpress_set_up_post_nav($post_nav, $instance))); + } + + function testSetUpPostNav() { global $post; $post = 'post'; @@ -132,11 +136,11 @@ class GraphicalNavigationWidgetTest extends PHPUnit_Framework_TestCase { $navigation = $this->getMock('ComicPressNavigation', array('init', 'get_post_nav')); $navigation->expects($this->once())->method('init'); - $navigation->expects($this->once())->method('get_post_nav')->with($post)->will($this->returnValue($post_nav)); + $navigation->expects($this->once())->method('get_post_nav')->with($post)->will($this->returnValue('true')); $css->expects($this->once())->method('_new_comicpress_navigation')->will($this->returnValue($navigation)); - $this->assertEquals($expected_post_nav, $css->set_up_post_nav($instance)); + $css->set_up_post_nav(array()); } } diff --git a/widgets/GraphicalNavigationWidget.inc b/widgets/GraphicalNavigationWidget.inc index ab69462..e707063 100644 --- a/widgets/GraphicalNavigationWidget.inc +++ b/widgets/GraphicalNavigationWidget.inc @@ -25,6 +25,8 @@ class GraphicalNavigationWidget extends WP_Widget { add_filter('comicpress_wrap_navigation_buttons', array(&$this, 'comicpress_wrap_navigation_buttons'), 10, 2); add_filter('comicpress_navigation_grouping_details', array(&$this, 'comicpress_navigation_grouping_details')); + add_filter('comicpress_set_up_post_nav', array(&$this, 'comicpress_set_up_post_nav'), 10, 2); + // these two need to be moved one level up add_filter('comicpress_get_random_link_url', array(&$this, 'comicpress_get_random_link_url')); add_filter('comicpress_get_buy_print_url', array(&$this, 'comicpress_get_buy_print_url')); @@ -276,13 +278,21 @@ class GraphicalNavigationWidget extends WP_Widget { $navigation->init($storyline); $post_nav = $navigation->get_post_nav($post); + $result = apply_filters('comicpress_set_up_post_nav', $post_nav, $instance); + if (is_array($result)) { + return array_shift($result); + } else { + return $post_nav; + } + } + + function comicpress_set_up_post_nav($post_nav, $instance) { if ($instance['story_prev_acts_as_prev_in'] == 'on') { if ($post_nav['storyline-previous'] !== false) { $post_nav['storyline-chapter-previous'] = $post_nav['storyline-previous']; } } - - return $post_nav; + return array($post_nav, $instance); } /**