make first link work with multipage
This commit is contained in:
parent
81832d0b5a
commit
d578797b7b
|
@ -28,20 +28,21 @@ class GraphicalNavigationWidgetTest extends PHPUnit_Framework_TestCase {
|
|||
|
||||
function providerTestIsNavLinkVisible() {
|
||||
return array(
|
||||
array('first', 1, 2, 1, 1, true),
|
||||
array('first', 1, 1, 1, 1, false),
|
||||
array('last', 1, 2, 1, 1, true),
|
||||
array('last', 1, 1, 1, 1, false),
|
||||
array('prev', 1, 2, 1, 1, true),
|
||||
array('first', 1, 1, 2, 2, true),
|
||||
array('first', 1, 1, 1, 2, false),
|
||||
array('first', 1, 2, 1, 1, 'on', true),
|
||||
array('first', 1, 1, 1, 1, 'on', false),
|
||||
array('last', 1, 2, 1, 1, 'on', true),
|
||||
array('last', 1, 1, 1, 1, 'on', false),
|
||||
array('prev', 1, 2, 1, 1, 'on', true),
|
||||
array('first', 1, 1, 2, 2, 'on', true),
|
||||
array('first', 1, 1, 1, 2, 'on', false),
|
||||
array('first', 1, 1, 2, 2, 'off', false),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerTestIsNavLinkVisible
|
||||
*/
|
||||
function testIsNavLinkVisible($which, $current_id, $target_id, $_page, $_numpages, $expected_result) {
|
||||
function testIsNavLinkVisible($which, $current_id, $target_id, $_page, $_numpages, $multi_page_support, $expected_result) {
|
||||
global $page, $numpages;
|
||||
$page = $_page;
|
||||
$numpages = $_numpages;
|
||||
|
@ -49,7 +50,7 @@ class GraphicalNavigationWidgetTest extends PHPUnit_Framework_TestCase {
|
|||
$current = (object)array('ID' => $current_id);
|
||||
$target = (object)array('ID' => $target_id);
|
||||
|
||||
$this->assertEquals($expected_result, $this->w->_will_display_nav_link($which, $current, $target));
|
||||
$this->assertEquals($expected_result, $this->w->_will_display_nav_link($which, $current, $target, array('enable_multipage_support' => $multi_page_support)));
|
||||
}
|
||||
|
||||
function providerTestGroupNavigationButtons() {
|
||||
|
|
|
@ -63,7 +63,7 @@ class GraphicalNavigationWidget extends WP_Widget {
|
|||
switch ($which) {
|
||||
case 'first':
|
||||
case 'last':
|
||||
$ok = $this->_will_display_nav_link($which, $current, $target);
|
||||
$ok = $this->_will_display_nav_link($which, $current, $target, $instance);
|
||||
break;
|
||||
case 'previous':
|
||||
case 'next':
|
||||
|
@ -169,17 +169,19 @@ class GraphicalNavigationWidget extends WP_Widget {
|
|||
* @param object $target The target post to comare to.
|
||||
* @return boolean True if this link should be visible.
|
||||
*/
|
||||
function _will_display_nav_link($which, $current, $target) {
|
||||
function _will_display_nav_link($which, $current, $target, $instance) {
|
||||
global $page, $numpages;
|
||||
|
||||
$return = true;
|
||||
|
||||
switch ($which) {
|
||||
case 'first':
|
||||
if ($instance['enable_multipage_support'] == 'on') {
|
||||
if ($page != 1 && $numpages > 1) {
|
||||
$return = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
case 'last':
|
||||
$return = ($target->ID != $current->ID);
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue