Skip to content

Commit

Permalink
Fixed never expire meta not deleting issue (#1762)
Browse files Browse the repository at this point in the history
  • Loading branch information
obiPlabon authored Jun 9, 2024
1 parent c4bba19 commit 52d4bbc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions includes/classes/class-add-listing.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ public function atbdp_submit_listing() {

$listing_create_status = directorist_get_listing_create_status( $directory_id );
$listing_edit_status = directorist_get_listing_edit_status( $directory_id );
$default_expiration = get_term_meta( $directory_id, 'default_expiration', true );
$default_expiration = directorist_get_default_expiration( $directory_id );
$preview_enable = atbdp_is_truthy( get_term_meta( $directory_id, 'preview_mode', true ) );

/**
Expand Down Expand Up @@ -369,7 +369,7 @@ public function atbdp_submit_listing() {

// Every post with the published status should contain all the post meta keys so that we can include them in query.
if ( 'publish' === $listing_create_status || 'pending' === $listing_create_status ) {
if ( ! $default_expiration ) {
if ( $default_expiration <= 0 ) {
update_post_meta( $listing_id, '_never_expire', 1 );
} else {
$expiration_date = calc_listing_expiry_date( '', $default_expiration );
Expand Down Expand Up @@ -977,9 +977,10 @@ private function renew_listing( $listing_id ) {
// TODO: Status has been migrated, remove related code.
update_post_meta( $listing_id, '_listing_status', 'post_status' );

$exp_days = get_term_meta( $directory_type, 'default_expiration', true );
if ( $exp_days <= 0 ) {
if ( directorist_get_default_expiration( $directory_type ) <= 0 ) {
update_post_meta( $listing_id, '_never_expire', 1 );
} else {
delete_post_meta( $listing_id, '_never_expire' );
}

do_action( 'atbdp_after_renewal', $listing_id );
Expand Down
2 changes: 1 addition & 1 deletion includes/directorist-directory-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ function directorist_get_listing_edit_status( $directory_id ) {
}

function directorist_get_default_expiration( $directory_id ) {
return directorist_get_directory_meta( $directory_id, 'default_expiration' );
return (int) directorist_get_directory_meta( $directory_id, 'default_expiration' );
}

function directorist_is_directory( $directory_id ) {
Expand Down

0 comments on commit 52d4bbc

Please sign in to comment.