Skip to content
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

Allow plugins to override renewal values #2566

Merged
merged 1 commit into from
Aug 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion includes/helper/class-wp-job-manager-helper-renewals.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,15 @@ public static function is_spl_renew_compatible() {
public static function renew_job_listing( $job ) {
$old_expiry = date_create_immutable_from_format( 'Y-m-d', get_post_meta( $job->ID, '_job_expires', true ) );
$new_expiry = calculate_job_expiry( $job->ID, false, $old_expiry );

/**
* Filters the expiry date after a renewal.
*
* @param string $new_expiry The new expiry date (Y-m-d).
* @param WP_Post $job The job that is being renewed.
*/
$new_expiry = apply_filters( 'job_manager_renewal_expiry_date', $new_expiry, $job );

update_post_meta( $job->ID, '_job_expires', $new_expiry );

/**
Expand Down Expand Up @@ -216,6 +225,14 @@ public static function job_can_be_renewed( $job ) {
$current_time_stamp = current_datetime()->getTimestamp();
$status = get_post_status( $job );

return 'publish' === $status && $expiry - $current_time_stamp < $expiring_soon_days * DAY_IN_SECONDS;
$can_be_renewed = 'publish' === $status && $expiry - $current_time_stamp < $expiring_soon_days * DAY_IN_SECONDS;

/**
* Filters whether a job can be renewed.
*
* @param boolean $can_be_renewed Whether the job can be renewed.
* @param WP_Post $job The job.
*/
return apply_filters( 'job_manager_job_can_be_renewed', $can_be_renewed, $job );
}
}
Loading