-
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
Change deactivation approach #2562
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.
Hey there, this is looking good!
I left a couple of comments/suggestions, and I'll test the PR in the meantime. :)
includes/promoted-jobs/class-wp-job-manager-promoted-jobs-notifications.php
Show resolved
Hide resolved
@@ -234,6 +233,7 @@ private function prepare_item_for_response( WP_Post $item ) { | |||
return [ | |||
'id' => (string) $item->ID, | |||
'status' => $item->post_status, | |||
'promoted' => WP_Job_Manager_Promoted_Jobs::is_promoted( $item->ID ), |
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.
Do you foresee any changes we need to make on WPJMCOM to use this field?
I am just thinking about the use-case 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.
Currently, I don't think so. But I added it because it can be useful in the future and make the feed more concise (we don't have promoted and not promoted jobs in the feed without a differentiation).
We could use that, in case we want to list all the promoted jobs as a type of extra promotion, for example.
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.
Sounds good, thanks!
Co-authored-by: Fernando Jorge Mota <[email protected]>
f0859e7
to
99c974b
Compare
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 and works well! I left a comment for updating a PHPDoc, but everything else seems to be working just fine. Thanks!
includes/promoted-jobs/class-wp-job-manager-promoted-jobs-notifications.php
Show resolved
Hide resolved
@@ -209,6 +209,11 @@ public function handle_promote_job() { | |||
$verify_endpoint_url = rest_url( '/wpjm-internal/v1/promoted-jobs/verify-token', 'https' ); | |||
$verify_endpoint_url = substr( $verify_endpoint_url, strlen( $site_url ) ); | |||
|
|||
// Make sure the job contains the promoted job meta to be listed in the feed. | |||
if ( ! $is_editing ) { | |||
WP_Job_Manager_Promoted_Jobs::update_promotion( $post_id, 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.
Good catch on setting the flag only if we're creating a new job
@@ -234,6 +233,7 @@ private function prepare_item_for_response( WP_Post $item ) { | |||
return [ | |||
'id' => (string) $item->ID, | |||
'status' => $item->post_status, | |||
'promoted' => WP_Job_Manager_Promoted_Jobs::is_promoted( $item->ID ), |
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.
Sounds good, thanks!
* @param bool|string $promoted `true` to promoted, `false` to not promoted, `force_delete` to delete. | ||
* The deletion is used to force a removal from the feed, deactivating the promotion while syncing. |
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 think we should probably update this PHPDoc, right?
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.
Yep! Good catch! I updated the previous commit just changing this. ;)
51ebc4b
99c974b
to
51ebc4b
Compare
Changes proposed in this Pull Request
_promoted
meta key on the feed, even if it's not promoted. To represent it in the feed, we added thepromote
attribute, which is not currently used but it's useful if we want to iterate in the future, and it makes the endpoint more concise.The previous issue:
_promoted
0
because it didn't sync with the new status yet (wpjobmanager.com -> WPJM). So in the sync WPJM -> wpjobmanager.com, it would remove the job from wpjobmanager.com, removing from the feed that JobTarget will consume, which would deactivate their promotion.Testing instructions
vip dev-env -- exec wp cron event run wpjobmanager_com_sync_promoted_job_status
.