Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow pagination object to be generated using $prefs only #2863

Merged

Conversation

phasdev
Copy link
Contributor

@phasdev phasdev commented Dec 6, 2023

Related:

#2635

Issue

Allow pagination object to be generated using $prefs only. Currently there's a dependency on wp_query via the $paged wp_query param when checking if the previous pagination link should be rendered.

Solution

Use $current instead of $paged when checking if previous pagination link should be generated. $current is initialized using $paged but then overridden with the corresponding value in $prefs. Now we can use $prefs to wholly configure a pagination object.

Impact

No impact. Backwards compatible.

Usage Changes

None.

Considerations

None.

Testing

No tests needed.

@Levdbas Levdbas added the 2.0 label Jan 26, 2024
@Levdbas Levdbas added this to the 2.0.1 milestone Jan 26, 2024
Levdbas
Levdbas previously approved these changes Jan 26, 2024
Copy link
Member

@Levdbas Levdbas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @phasdev , looks good to me!

@Levdbas Levdbas modified the milestones: 2.0.1, 2.1.0 Feb 1, 2024
@Levdbas
Copy link
Member

Levdbas commented Feb 24, 2024

Just merged 2.0 back into this branch and there is a static analysis error @phasdev . @nlemoine , thoughts?

@nlemoine
Copy link
Member

nlemoine commented Feb 24, 2024

PHPStan is right, the $curentvariable might not be defined. @phasdev can you fix this?

$current is a 0-based array index whereas $this->current is the page number. Using $current introduces a bug, since it clears $this->prev on page 2.
@phasdev
Copy link
Contributor Author

phasdev commented Feb 26, 2024

@nlemoine OK fixed.

@Levdbas Levdbas linked an issue Feb 27, 2024 that may be closed by this pull request
@coveralls
Copy link

Coverage Status

coverage: 87.947%. remained the same
when pulling 7f261c7 on phasdev:feat-2635-generate-pagination-from-prefs-only
into 9c6e0e3 on timber:2.x.

@gchtr gchtr merged commit 99219a9 into timber:2.x Feb 27, 2024
26 of 28 checks passed
@phasdev phasdev deleted the feat-2635-generate-pagination-from-prefs-only branch April 24, 2024 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow pagination object to be generated using $prefs only
5 participants