Skip to content

Commit

Permalink
Listing status migration (#1606)
Browse files Browse the repository at this point in the history
  • Loading branch information
obiPlabon authored May 14, 2024
1 parent e19b502 commit d246bea
Show file tree
Hide file tree
Showing 18 changed files with 441 additions and 261 deletions.
16 changes: 7 additions & 9 deletions includes/classes/class-add-listing.php
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ public function atbdp_submit_listing() {
}

update_post_meta( $listing_id, '_featured', 0 );
// TODO: Status has been migrated, remove related code.
update_post_meta( $listing_id, '_listing_status', 'post_status' );

/*
Expand Down Expand Up @@ -931,9 +932,7 @@ public function parse_query( $query ) {
* @since 3.1.0
*/
private function renew_listing( $listing_id ) {
$can_renew = get_directorist_option( 'can_renew_listing' );

if ( ! $can_renew ) {
if ( ! directorist_can_user_renew_listings() ) {
return false;// vail if renewal option is turned off on the site.
}

Expand Down Expand Up @@ -963,8 +962,10 @@ private function renew_listing( $listing_id ) {

$directory_type = get_post_meta( $listing_id, '_directory_type', true );
// Update the post_meta into the database
$old_status = get_post_meta( $listing_id, '_listing_status', true );
if ( 'expired' == $old_status ) {
// TODO: Status has been migrated, remove related code.
// $old_status = get_post_meta( $listing_id, '_listing_status', true );
$old_status = get_post_status( $listing_id );
if ( 'expired' === $old_status ) {
$expiry_date = calc_listing_expiry_date();
} else {
$old_expiry_date = get_post_meta( $listing_id, '_expiry_date', true );
Expand All @@ -973,16 +974,13 @@ private function renew_listing( $listing_id ) {

// update related post meta_data
update_post_meta( $listing_id, '_expiry_date', $expiry_date );
// 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 ) {
update_post_meta( $listing_id, '_never_expire', 1 );
}
// TODO: Delete (refactored '_never_expire' for the sake of key comparison only).
// else {
// update_post_meta( $listing_id, '_never_expire', 0 );
// }

do_action( 'atbdp_after_renewal', $listing_id );
$r_url = add_query_arg( 'renew', 'success', ATBDP_Permalink::get_dashboard_page_link() );
Expand Down
Loading

0 comments on commit d246bea

Please sign in to comment.