-
Notifications
You must be signed in to change notification settings - Fork 368
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
Add/featured first argument #2675
Conversation
if ( ! is_null( $atts['featured_first'] ) ) { | ||
$atts['featured_first'] = ( is_bool( $atts['featured_first'] ) && $atts['featured_first'] ) || in_array( $atts['featured_first'], [ 1, '1', 'true', 'yes' ], true ); | ||
} |
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.
if ( ! is_null( $atts['featured_first'] ) ) { | |
$atts['featured_first'] = ( is_bool( $atts['featured_first'] ) && $atts['featured_first'] ) || in_array( $atts['featured_first'], [ 1, '1', 'true', 'yes' ], true ); | |
} |
$this->string_to_bool is already called on $atts['featured_first'], which does exactly that
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.
Removed in d716a58
if ( ! empty( $atts['featured_first'] ) ) { | ||
$data_attributes['featured_first'] = $atts['featured_first'] ? 'true' : 'false'; | ||
} |
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.
Is it really what you wanted to do ?
If $atts['featured_first'] is false, then it's empty, which means $data_attributes won't be populated.
If it's what you wanted to do, then it's ok :)
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.
yeah no, not what I want to do. Removed in c3b858a
@@ -180,6 +181,13 @@ function get_job_listings( $args = [] ) { | |||
]; | |||
} | |||
|
|||
if ( 'true' === $args['featured_first'] && 'featured' !== $args['orderby'] && 'rand_featured' !== $args['orderby'] ) { |
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.
Does $args['featured_first'] (and all added data_attributes) have to be a string ?
If we want to test it against a bool, it's way better to test it ... well ... against a bool, but maybe there's a reason for that ?
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'm trying to also account for people who might use featured_first="0"
or featured_first="1"
so checking the string worked for all cases. What do you think about something like this:
if ( true === filter_var( $args['featured_first'], FILTER_VALIDATE_BOOLEAN ) && 'featured' !== $args['orderby'] && 'rand_featured' !== $args['orderby'] ) {
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 thought the data here were populated by https://github.com/Automattic/WP-Job-Manager/pull/2675/files#diff-a0e82a74ed6b687d4ee6efce7bb4c78d6fa157212afa751c5c40f88306c489ddR684 , hence my question about making it boolean directly instead of string, but, if it's supposed to do more than what I thought, that's ok as-is
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.
What shortcode specifically wasn't working for you? |
Ok I think I forgot to npm run build, I know this might be tedious, but can it be included in test instructions when needed ? It helps a lot when reviewing a bunch of PRs |
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.
After code changes (and npm build :D), worked like a charm
Fixes #1487
Changes Proposed in this Pull Request
featured_first
argument to the[jobs]
shortcodeTesting Instructions
I would also make sure to try at least a few
featured_first="false"
to ensure that works as well.Release Notes