This repository was archived by the owner on May 21, 2025. It is now read-only.
Always pass the object ID as the second param to the 'get_edit_post_link' filter #826
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #822
Description
The
wcs_get_edit_post_link()
helper function is designed to get the URL for the edit screen of an order/subscription.It's designed to take an order or subscription ID as the parameter, however there are cases where we pass the full order/subscription object.
If you're a 3rd party hooking onto the
'get_edit_post_link'
filter, this means you'd sometimes get a whole order/subscription object - not just an ID.This PR fixes that by making sure we always pass the ID as the second parameter to the
get_edit_post_link
filter in line with it's intended design.This also appears to fix warnings like this:
🗒️ I was curious where these dynamic property errors were coming from so I logged the stack trace. I've included it below for completeness.
Details
Essentially:
apply_filters( 'get_edit_post_l...', 'http://...', Object(WC_Subscription), '' )
get_post_type(Object(WC_Subscription))
which WP eventually tries to set the ID. 😨As far as I can tell this doesn't actually lead to any issues.
How to test this PR
Product impact