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
Remove query args from paginate_links urls #2037
Remove query args from paginate_links urls #2037
Conversation
public function filter_paginate_links( $link ) { | ||
return remove_query_arg( [ 'action', 'job_id', '_wpnonce' ], $link ); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find myself concerned with this again. I had imagined before that this would only be called if a WPJM-related shortcode existed on the page, but looking again I think this would be called on any page that calls the paginate_links
function. This seems dangerous to me.
Do you think it would make sense to add a condition here to ensure that it only happens on the page(s) we want? E.g. see the shortcode_action_handler
method. Maybe something like:
public function filter_paginate_links( $link ) { | |
return remove_query_arg( [ 'action', 'job_id', '_wpnonce' ], $link ); | |
} | |
public function filter_paginate_links( $link ) { | |
global $post; | |
if ( is_page() && has_shortcode( $post->post_content, 'job_dashboard' ) ) { | |
return remove_query_arg( [ 'action', 'job_id', '_wpnonce' ], $link ); | |
} | |
return $link; | |
} |
If so, maybe we could also extract that conditional logic to a private method (assuming we use the same logic as in shortcode_action_handler
). Maybe private function is_job_dashboard_page() { ... }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey Alex!
You're totally right! It's a bit too aggressive... Your suggestion works perfectly! I just implemented it...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, works well! Thanks for the PR 🚀
Fixes #1912
Changes proposed in this Pull Request:
Testing instructions:
Proposed changelog entry for your changes: