johnbillion / extended-cpts

A library which provides extended functionality to WordPress custom post types and taxonomies.
GNU General Public License v2.0
979 stars 96 forks source link

Add $post_id parameter to column custom callback #135

Closed nlemoine closed 3 years ago

nlemoine commented 4 years ago

$post_id parameter is available in the original hook. This PR passes it to the custom column callback (function) and avoids to call global $post to access current post data.

johnbillion commented 4 years ago

For a bit of context, the original design decision here was that the column callback function could be shared with one that's used within the loop on the front end, for example for outputting a meta value, and would therefore use the global post. At the time it made sense but I don't think there's a huge amount of value in that and it's easy enough to work around.

Happy to merge this in, but this is technically a breaking change so I'll leave it for version 5.0.

johnbillion commented 3 years ago

Note: In d0b86d4116ec513690c5f525d887e197d9f9f2fb I changed this to passing the full WP_Post object.

nlemoine commented 3 years ago

Nice! This is even better 👍