jjgrainger / PostTypes

Simple WordPress custom post types.
https://posttypes.jjgrainger.co.uk/
MIT License
372 stars 48 forks source link

Allow setting false to sort by alphabetical #74

Closed mav2287 closed 2 years ago

mav2287 commented 3 years ago

This fixes a bug that does not allow you to pass in a boolean false to have columns sorted alphabetically. This fix ensures that the docs at https://posttypes.jjgrainger.co.uk/post-types/columns#sortable-columns reflect how the actual params works, where as right now if you pass a boolean false as per the docs you will still have a numeric sort. See below examples

// This is currently the only way to make it sort alphabetically
$books->columns()->sortable( [
    'price'  =>  'name'
] );

// This pull-request will now sort alphabetically with this as well
$books->columns()->sortable( [
    'price'  => [ 'name', false]
] );
jjgrainger commented 2 years ago

Thanks @mav2287

This is an nice enhancement and also fixes #77