-
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 check for job listing limit being 0 #2362
Conversation
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 like this option is also used here where the same change should happen.
WP-Job-Manager/includes/class-wp-job-manager-shortcodes.php
Lines 110 to 114 in 7411e91
if ( | |
$submit_job_form_page_id | |
&& $submission_limit | |
&& $job_count >= $submission_limit | |
) { |
And is there a similar check on the actual job submission page and endpoint?
@yscik - I tried the logic you are suggesting but it won't work if the Listing Limit is The logic I have now is:
Use CasesNo Limit
0 Limit
So in both cases we have both false, however they need to work in the opposite way. I thought about adding this
But, it seemed cleaner to just have a |
@@ -23,7 +23,7 @@ | |||
exit; // Exit if accessed directly. | |||
} | |||
|
|||
$submission_limit = get_option( 'job_manager_submission_limit' ); | |||
$submission_limit = ! empty( get_option( 'job_manager_submission_limit' ) ) ? absint( get_option( 'job_manager_submission_limit' ) ) : 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.
empty(0)
and empty('0')
is also true
. I think we need '' !== get_option( 'job_manager_submission_limit', '' )
to test if it doesn't have any value set.
The if
below checks for 'false'
(string) instead of the false
(bool) set here.
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.
Fixed in a8d3b34
@@ -87,7 +87,7 @@ | |||
<?php endforeach; ?> | |||
<?php endif; ?> | |||
</tbody> | |||
<?php if ( $submit_job_form_page_id && ( job_manager_count_user_job_listings() < $submission_limit || ! $submission_limit ) ) : ?> | |||
<?php if ( $submit_job_form_page_id && ( job_manager_count_user_job_listings() < $submission_limit || 'false' === $submission_limit ) ) : ?> | |||
<tfoot> |
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.
There are other places in the plugin where this check needs to be updated. Might make sense to add a new job_manager_can_user_submit_job()
to handle it consistently everywhere.
WP-Job-Manager/includes/class-wp-job-manager-shortcodes.php
Lines 110 to 114 in 7411e91
if ( | |
$submit_job_form_page_id | |
&& $submission_limit | |
&& $job_count >= $submission_limit | |
) { |
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.
Suggested a small improvement. Other than that it looks good!
wp-job-manager-functions.php
Outdated
$submission_limit = get_option( 'job_manager_submission_limit', '' ); | ||
$job_count = job_manager_count_user_job_listings(); | ||
|
||
if ( '' !== $submission_limit && |
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.
You can set the $can_submit variable only once with:
$can_submit = '' === $submission_limit || $submission_limit > $job_count;
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.
Thanks @gkaragia ! Done in cc64267
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!
Fixes #2333
Changes proposed in this Pull Request
0
. Currently if it's set to0
it works the same as it being unlimited, which I don't think is intended.Testing instructions