Skip to content

Commit

Permalink
New settings (#1819)
Browse files Browse the repository at this point in the history
  • Loading branch information
Armanul46 authored Aug 29, 2024
1 parent ea09e6b commit 5918807
Show file tree
Hide file tree
Showing 22 changed files with 713 additions and 878 deletions.
2 changes: 1 addition & 1 deletion assets/js/admin-multi-directory-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -31414,7 +31414,7 @@ var render = function render() {
_c = _vm._self._c;
return _c("div", {
staticClass: "directorist-type-icon-select"
}, [_c("label", [_vm._v("Icon")]), _vm._v(" "), _c("div", {
}, [_c("div", {
ref: "iconPickerElm",
staticClass: "icon-picker-wrap"
})]);
Expand Down
6 changes: 5 additions & 1 deletion assets/js/admin-multi-directory-builder.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/js/admin-settings-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -31472,7 +31472,7 @@ var render = function render() {
_c = _vm._self._c;
return _c("div", {
staticClass: "directorist-type-icon-select"
}, [_c("label", [_vm._v("Icon")]), _vm._v(" "), _c("div", {
}, [_c("div", {
ref: "iconPickerElm",
staticClass: "icon-picker-wrap"
})]);
Expand Down
6 changes: 5 additions & 1 deletion assets/js/admin-settings-manager.min.js

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion assets/js/all-listings.min.js

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion assets/js/single-listing.min.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion assets/sample-data/directory/directory-settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@
"display_listings_header": true,
"all_listing_title": "Items Found",
"listing_filters_button": true,
"listing_filters_icon": true,
"listings_filter_button_text": "Filters",
"listings_display_filter": "sliding",
"listing_filters_fields": "[\"search_text\",\"search_category\",\"search_location\",\"search_price\",\"search_price_range\",\"search_rating\",\"search_tag\",\"search_custom_fields\",\"radius_search\"]",
Expand Down
1 change: 0 additions & 1 deletion assets/src/js/admin/vue/modules/form-fields/Icon_Field.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<template>
<div class="directorist-type-icon-select">
<label>Icon</label>
<div class="icon-picker-wrap" ref="iconPickerElm"></div>
</div>
</template>
Expand Down
13 changes: 4 additions & 9 deletions includes/class-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -491,15 +491,10 @@ public static function multi_directory_enabled() {
}

public static function default_preview_image_src( $directory_id ) {
if ( directorist_is_multi_directory_enabled() ) {
$settings = directorist_get_directory_general_settings( $directory_id );

if ( ! empty( $settings['preview_image'] ) ) {
$default_preview = $settings['preview_image'];
} else {
$default_img = get_directorist_option( 'default_preview_image' );
$default_preview = $default_img ? $default_img : DIRECTORIST_ASSETS . 'images/grid.jpg';
}
$settings = directorist_get_directory_general_settings( $directory_id );

if ( ! empty( $settings['preview_image'] ) ) {
$default_preview = $settings['preview_image'];
} else {
$default_img = get_directorist_option( 'default_preview_image' );
$default_preview = $default_img ? $default_img : DIRECTORIST_ASSETS . 'images/grid.jpg';
Expand Down
3 changes: 0 additions & 3 deletions includes/classes/class-add-listing.php
Original file line number Diff line number Diff line change
Expand Up @@ -931,9 +931,6 @@ public function parse_query( $query ) {
* @since 3.1.0
*/
private function renew_listing( $listing_id ) {
if ( ! directorist_can_user_renew_listings() ) {
return false;// vail if renewal option is turned off on the site.
}

// Hook for developers
do_action( 'atbdp_before_renewal', $listing_id );
Expand Down
50 changes: 20 additions & 30 deletions includes/classes/class-cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,8 @@ private function get_order_by_listing( $listing_id ) {
* @access private
*/
private function update_renewal_status() {
$renew_email_threshold = (int) get_directorist_option( 'email_to_expire_day' ); // before how many days of expiration, a renewal message should be sent

if ( directorist_can_user_renew_listings() && $renew_email_threshold > 0 ) {
$renew_email_threshold = get_directorist_option( 'email_to_expire_day' ); // before how many days of expiration, a renewal message should be sent
if ( $renew_email_threshold > 0 ) {
$renew_email_threshold_date = date( 'Y-m-d H:i:s', strtotime( "+{$renew_email_threshold} days" ) );

// Define the query
Expand Down Expand Up @@ -261,28 +260,23 @@ private function update_expired_status() {
'_featured' => 0,
'_renewal_reminder_sent' => 0,
);

// delete expired listings?
if ( $del_exp_l ) {
// if deletion threshold is set then add deletion date
if ( $delete_threshold > 0 ) {
$meta_input['_deletion_date'] = date( 'Y-m-d H:i:s', strtotime( '+' . $delete_threshold . ' days' ) );
} else {
$meta_input['_deletion_date'] = date( 'Y-m-d H:i:s', current_time( 'timestamp' ) );
}
}

$expired_listing_id = wp_update_post( array(
'ID' => $listing->ID,
'post_status' => 'expired',
'meta_input' => $meta_input,
) );

if ( is_wp_error( $expired_listing_id ) ) {
continue;

// if deletion threshold is set then add deletion date
if ( $delete_threshold > 0 ) {
$metas['_deletion_date'] = date( 'Y-m-d H:i:s', strtotime( '+' . $delete_threshold . ' days' ) );
} else {
$metas['_deletion_date'] = date( 'Y-m-d H:i:s', current_time( 'timestamp' ) );
}

do_action( 'atbdp_listing_expired', $expired_listing_id );
wp_update_post(
array(
'ID' => $listing->ID,
'post_status' => 'private', // update the status to private so that we do not run this func a second time
'meta_input' => $metas, // insert all meta data once to reduce update meta query
)
);
// Hook for developers
do_action( 'atbdp_listing_expired', $listing->ID );
}
}
}
Expand Down Expand Up @@ -386,7 +380,7 @@ private function update_expired_listing_status() {
private function send_renewal_reminders() {
$email_renewal_day = (int) get_directorist_option( 'email_renewal_day' );

if ( directorist_can_user_renew_listings() && $email_renewal_day > 0 ) {
if ( $email_renewal_day > 0 ) {
// Define the query
$args = array(
'post_type' => ATBDP_POST_TYPE,
Expand Down Expand Up @@ -440,12 +434,8 @@ private function send_renewal_reminders() {
*/
private function delete_expired_listings() {

$del_exp_l = get_directorist_option( 'delete_expired_listing' );
if ( ! $del_exp_l ) {
return; // vail if admin does not want to delete expired listing
}
$del_mode = get_directorist_option( 'deletion_mode', 'trash' ); // force_delete | trash
$force = 'force_delete' == $del_mode ? true : false; // for now we are just focusing on Force Delete or Not. later we may consider more
$del_mode = get_directorist_option( 'delete_expired_listing_permanently', false ); // force_delete | trash
$force = ! empty( $del_mode ) ? true : false; // for now we are just focusing on Force Delete or Not. later we may consider more
// Define the query
$args = array(
'post_type' => ATBDP_POST_TYPE,
Expand Down
Loading

0 comments on commit 5918807

Please sign in to comment.