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() {
|
function providerTestIsNavLinkVisible() {
|
||||||
return array(
|
return array(
|
||||||
array('first', 1, 2, 1, 1, true),
|
array('first', 1, 2, 1, 1, 'on', true),
|
||||||
array('first', 1, 1, 1, 1, false),
|
array('first', 1, 1, 1, 1, 'on', false),
|
||||||
array('last', 1, 2, 1, 1, true),
|
array('last', 1, 2, 1, 1, 'on', true),
|
||||||
array('last', 1, 1, 1, 1, false),
|
array('last', 1, 1, 1, 1, 'on', false),
|
||||||
array('prev', 1, 2, 1, 1, true),
|
array('prev', 1, 2, 1, 1, 'on', true),
|
||||||
array('first', 1, 1, 2, 2, true),
|
array('first', 1, 1, 2, 2, 'on', true),
|
||||||
array('first', 1, 1, 1, 2, false),
|
array('first', 1, 1, 1, 2, 'on', false),
|
||||||
|
array('first', 1, 1, 2, 2, 'off', false),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider providerTestIsNavLinkVisible
|
* @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;
|
global $page, $numpages;
|
||||||
$page = $_page;
|
$page = $_page;
|
||||||
$numpages = $_numpages;
|
$numpages = $_numpages;
|
||||||
|
@ -49,7 +50,7 @@ class GraphicalNavigationWidgetTest extends PHPUnit_Framework_TestCase {
|
||||||
$current = (object)array('ID' => $current_id);
|
$current = (object)array('ID' => $current_id);
|
||||||
$target = (object)array('ID' => $target_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() {
|
function providerTestGroupNavigationButtons() {
|
||||||
|
|
|
@ -63,7 +63,7 @@ class GraphicalNavigationWidget extends WP_Widget {
|
||||||
switch ($which) {
|
switch ($which) {
|
||||||
case 'first':
|
case 'first':
|
||||||
case 'last':
|
case 'last':
|
||||||
$ok = $this->_will_display_nav_link($which, $current, $target);
|
$ok = $this->_will_display_nav_link($which, $current, $target, $instance);
|
||||||
break;
|
break;
|
||||||
case 'previous':
|
case 'previous':
|
||||||
case 'next':
|
case 'next':
|
||||||
|
@ -169,16 +169,18 @@ class GraphicalNavigationWidget extends WP_Widget {
|
||||||
* @param object $target The target post to comare to.
|
* @param object $target The target post to comare to.
|
||||||
* @return boolean True if this link should be visible.
|
* @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;
|
global $page, $numpages;
|
||||||
|
|
||||||
$return = true;
|
$return = true;
|
||||||
|
|
||||||
switch ($which) {
|
switch ($which) {
|
||||||
case 'first':
|
case 'first':
|
||||||
if ($page != 1 && $numpages > 1) {
|
if ($instance['enable_multipage_support'] == 'on') {
|
||||||
$return = true;
|
if ($page != 1 && $numpages > 1) {
|
||||||
break;
|
$return = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case 'last':
|
case 'last':
|
||||||
$return = ($target->ID != $current->ID);
|
$return = ($target->ID != $current->ID);
|
||||||
|
|
Loading…
Reference in New Issue