diff --git a/assets/css/admin-main.css b/assets/css/admin-main.css index 555d4e9410..05d885d066 100644 --- a/assets/css/admin-main.css +++ b/assets/css/admin-main.css @@ -7599,27 +7599,15 @@ body.stop-scrolling { .directorist-form-image-upload-field .ezmu__info-list-item:empty { display: none; } -.directorist-form-image-upload-field .ezmu__thumbnail-list-item { - width: auto; -} .directorist-add-listing-wrapper { max-width: 750px !important; margin: 0 auto; } -.directorist-add-listing-wrapper .ezmu__thumbnail-list-item { - max-width: 300px; - -webkit-flex-basis: 300px; - -ms-flex-preferred-size: 300px; - flex-basis: 300px; -} .directorist-add-listing-wrapper .ezmu__thumbnail-list-item_back { height: 200px; width: 100%; } -.directorist-add-listing-wrapper .ezmu__media-picker-buttons { - margin-top: 10px; -} .directorist-add-listing-wrapper .ezmu__titles-area .ezmu__title-1 { font-size: 30px; } diff --git a/assets/css/admin-main.rtl.css b/assets/css/admin-main.rtl.css index 9ccfec7752..01517bfb59 100644 --- a/assets/css/admin-main.rtl.css +++ b/assets/css/admin-main.rtl.css @@ -7599,27 +7599,15 @@ body.stop-scrolling { .directorist-form-image-upload-field .ezmu__info-list-item:empty { display: none; } -.directorist-form-image-upload-field .ezmu__thumbnail-list-item { - width: auto; -} .directorist-add-listing-wrapper { max-width: 750px !important; margin: 0 auto; } -.directorist-add-listing-wrapper .ezmu__thumbnail-list-item { - max-width: 300px; - -webkit-flex-basis: 300px; - -ms-flex-preferred-size: 300px; - flex-basis: 300px; -} .directorist-add-listing-wrapper .ezmu__thumbnail-list-item_back { height: 200px; width: 100%; } -.directorist-add-listing-wrapper .ezmu__media-picker-buttons { - margin-top: 10px; -} .directorist-add-listing-wrapper .ezmu__titles-area .ezmu__title-1 { font-size: 30px; } diff --git a/assets/css/all-listings.css b/assets/css/all-listings.css index 892954cb33..b6e9dcf1c5 100644 --- a/assets/css/all-listings.css +++ b/assets/css/all-listings.css @@ -3042,27 +3042,15 @@ body.stop-scrolling { .directorist-form-image-upload-field .ezmu__info-list-item:empty { display: none; } -.directorist-form-image-upload-field .ezmu__thumbnail-list-item { - width: auto; -} .directorist-add-listing-wrapper { max-width: 750px !important; margin: 0 auto; } -.directorist-add-listing-wrapper .ezmu__thumbnail-list-item { - max-width: 300px; - -webkit-flex-basis: 300px; - -ms-flex-preferred-size: 300px; - flex-basis: 300px; -} .directorist-add-listing-wrapper .ezmu__thumbnail-list-item_back { height: 200px; width: 100%; } -.directorist-add-listing-wrapper .ezmu__media-picker-buttons { - margin-top: 10px; -} .directorist-add-listing-wrapper .ezmu__titles-area .ezmu__title-1 { font-size: 30px; } diff --git a/assets/css/all-listings.rtl.css b/assets/css/all-listings.rtl.css index 2107a31b4b..f356910c1a 100644 --- a/assets/css/all-listings.rtl.css +++ b/assets/css/all-listings.rtl.css @@ -3042,27 +3042,15 @@ body.stop-scrolling { .directorist-form-image-upload-field .ezmu__info-list-item:empty { display: none; } -.directorist-form-image-upload-field .ezmu__thumbnail-list-item { - width: auto; -} .directorist-add-listing-wrapper { max-width: 750px !important; margin: 0 auto; } -.directorist-add-listing-wrapper .ezmu__thumbnail-list-item { - max-width: 300px; - -webkit-flex-basis: 300px; - -ms-flex-preferred-size: 300px; - flex-basis: 300px; -} .directorist-add-listing-wrapper .ezmu__thumbnail-list-item_back { height: 200px; width: 100%; } -.directorist-add-listing-wrapper .ezmu__media-picker-buttons { - margin-top: 10px; -} .directorist-add-listing-wrapper .ezmu__titles-area .ezmu__title-1 { font-size: 30px; } diff --git a/assets/css/public-main.css b/assets/css/public-main.css index 1029699eab..a8c11873fc 100644 --- a/assets/css/public-main.css +++ b/assets/css/public-main.css @@ -3042,27 +3042,15 @@ body.stop-scrolling { .directorist-form-image-upload-field .ezmu__info-list-item:empty { display: none; } -.directorist-form-image-upload-field .ezmu__thumbnail-list-item { - width: auto; -} .directorist-add-listing-wrapper { max-width: 750px !important; margin: 0 auto; } -.directorist-add-listing-wrapper .ezmu__thumbnail-list-item { - max-width: 300px; - -webkit-flex-basis: 300px; - -ms-flex-preferred-size: 300px; - flex-basis: 300px; -} .directorist-add-listing-wrapper .ezmu__thumbnail-list-item_back { height: 200px; width: 100%; } -.directorist-add-listing-wrapper .ezmu__media-picker-buttons { - margin-top: 10px; -} .directorist-add-listing-wrapper .ezmu__titles-area .ezmu__title-1 { font-size: 30px; } diff --git a/assets/css/public-main.rtl.css b/assets/css/public-main.rtl.css index 2107a31b4b..f356910c1a 100644 --- a/assets/css/public-main.rtl.css +++ b/assets/css/public-main.rtl.css @@ -3042,27 +3042,15 @@ body.stop-scrolling { .directorist-form-image-upload-field .ezmu__info-list-item:empty { display: none; } -.directorist-form-image-upload-field .ezmu__thumbnail-list-item { - width: auto; -} .directorist-add-listing-wrapper { max-width: 750px !important; margin: 0 auto; } -.directorist-add-listing-wrapper .ezmu__thumbnail-list-item { - max-width: 300px; - -webkit-flex-basis: 300px; - -ms-flex-preferred-size: 300px; - flex-basis: 300px; -} .directorist-add-listing-wrapper .ezmu__thumbnail-list-item_back { height: 200px; width: 100%; } -.directorist-add-listing-wrapper .ezmu__media-picker-buttons { - margin-top: 10px; -} .directorist-add-listing-wrapper .ezmu__titles-area .ezmu__title-1 { font-size: 30px; } diff --git a/assets/js/add-listing.js b/assets/js/add-listing.js index 636fb15564..c7b2e525b6 100644 --- a/assets/js/add-listing.js +++ b/assets/js/add-listing.js @@ -128,6 +128,13 @@ var localized_data = directorist.add_listing_data; function joinQueryString(url, queryString) { return url.match(/[?]/) ? "".concat(url, "&").concat(queryString) : "".concat(url, "?").concat(queryString); } +function scrollTo(selector) { + var _document$querySelect; + (_document$querySelect = document.querySelector(selector)) === null || _document$querySelect === void 0 || _document$querySelect.scrollIntoView({ + block: 'start', + behavior: 'smooth' + }); +} /* Show and hide manual coordinate input field */ $(window).on('load', function () { @@ -465,12 +472,6 @@ $(document).ready(function () { render_category_based_fields(); storeCustomFieldsData(); }); - function scrollToEl(selector) { - document.querySelector(selector).scrollIntoView({ - block: 'start', - behavior: 'smooth' - }); - } function atbdp_element_value(element) { var field = $(element); if (field.length) { @@ -478,25 +479,23 @@ $(document).ready(function () { } return ''; } - var uploaders = localized_data.media_uploader; var mediaUploaders = []; - if (uploaders) { - var i = 0; - var _iterator = _createForOfIteratorHelper(uploaders), + if (localized_data.media_uploader) { + var _iterator = _createForOfIteratorHelper(localized_data.media_uploader), _step; try { for (_iterator.s(); !(_step = _iterator.n()).done;) { var uploader = _step.value; - if ($('.' + uploader['element_id']).length) { - var media_uploader = new EzMediaUploader({ - containerClass: uploader['element_id'] + if ($('.' + uploader.element_id).length) { + var EzUploader = new EzMediaUploader({ + containerClass: uploader.element_id }); mediaUploaders.push({ - media_uploader: media_uploader, + media_uploader: EzUploader, uploaders_data: uploader }); - mediaUploaders[i].media_uploader.init(); - i++; + EzUploader.init(); + // mediaUploaders[i].media_uploader.init(); } } } catch (err) { @@ -508,190 +507,254 @@ $(document).ready(function () { var on_processing = false; var has_media = true; var quick_login_modal__success_callback = null; + var $notification = $('#listing_notifier'); // ----------------------------- // Submit The Form // ----------------------------- + var uploadedImages = []; $('body').on('submit', '#directorist-add-listing-form', function (e) { e.preventDefault(); - if (localized_data.is_admin) { - return; - } var $form = $(e.target); - var $submitButton = $form.find('.directorist-form-submit__btn'); - var err_log = {}; var error_count = 0; + var err_log = {}; + var $submitButton = $('.directorist-form-submit__btn'); if (on_processing) { - $submitButton.attr('disabled', true); return; } - var form_data = new FormData(); - form_data.append('action', 'add_listing_action'); - form_data.append('directorist_nonce', directorist.directorist_nonce); - $submitButton.addClass('atbd_loading'); - var fieldValuePairs = $form.serializeArray(); - - // Append Form Fields Values - var _iterator2 = _createForOfIteratorHelper(fieldValuePairs), - _step2; - try { - for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { - var field = _step2.value; - form_data.append(field.name, field.value); - } - - // images - } catch (err) { - _iterator2.e(err); - } finally { - _iterator2.f(); + function disableSubmitButton() { + on_processing = true; + $submitButton.addClass('atbd_loading').attr('disabled', true); } + function enableSubmitButton() { + on_processing = false; + $submitButton.removeClass('atbd_loading').attr('disabled', false); + } + + // images + var selectedImages = []; if (mediaUploaders.length) { for (var _i = 0, _mediaUploaders = mediaUploaders; _i < _mediaUploaders.length; _i++) { var uploader = _mediaUploaders[_i]; - if (has_media && uploader.media_uploader) { - if (uploader.media_uploader.hasValidFiles()) { - // files - var files = uploader.media_uploader.getTheFiles(); - if (files) { - for (var i = 0; i < files.length; i++) { - form_data.append(uploader.uploaders_data['meta_name'] + '[]', files[i]); - } + if (!uploader.media_uploader || $(uploader.media_uploader.container).parents('form').get(0) !== $form.get(0)) { + continue; + } + if (!uploader.media_uploader.hasValidFiles()) { + $submitButton.removeClass('atbd_loading'); + err_log.listing_gallery = { + msg: uploader.uploaders_data['error_msg'] + }; + error_count++; + scrollTo('.' + uploader.uploaders_data.element_id); + break; + } + selectedImages = uploader.media_uploader.getTheFiles(); + } + } + if (selectedImages.length) { + var counter = 0; + function uploadImage() { + var formData = new FormData(); + formData.append('action', 'directorist_upload_listing_image'); + formData.append('directorist_nonce', directorist.directorist_nonce); + formData.append('image', selectedImages[counter]); + $.ajax({ + method: 'POST', + processData: false, + contentType: false, + url: localized_data.ajaxurl, + data: formData, + beforeSend: function beforeSend() { + disableSubmitButton(); + var totalImages = selectedImages.length; + if (totalImages === 1) { + $notification.show().html("".concat(localized_data.i18n_text.image_uploading_msg, "")); + } else { + var completedPercent = Math.ceil((counter === 0 ? 1 : counter) * 100 / totalImages); + $notification.show().html("".concat(localized_data.i18n_text.image_uploading_msg, " (").concat(completedPercent, "%)")); + } + }, + success: function success(response) { + if (!response.success) { + enableSubmitButton(); + $notification.show().html("".concat(response.data, "")); + return; } + uploadedImages.push(response.data); + counter++; + if (counter < selectedImages.length) { + uploadImage(); + } else { + submitForm($form, uploadedImages); + } + }, + error: function error(response) { + enableSubmitButton(); + $notification.html("".concat(response.responseJSON.data, "")); + } + }); + } + if (uploadedImages.length === selectedImages.length) { + submitForm($form, uploadedImages); + } else { + uploadImage(); + } + } else { + submitForm($form); + } + function submitForm($form) { + var uploadedImages = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; + var error_count = 0; + var err_log = {}; + var form_data = new FormData(); + form_data.append('action', 'add_listing_action'); + form_data.append('directorist_nonce', directorist.directorist_nonce); + form_data.append('listing_img', uploadedImages); + disableSubmitButton(); + var fieldValuePairs = $form.serializeArray(); + + // Append Form Fields Values + var _iterator2 = _createForOfIteratorHelper(fieldValuePairs), + _step2; + try { + for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { + var field = _step2.value; + form_data.append(field.name, field.value); + } + + //images + } catch (err) { + _iterator2.e(err); + } finally { + _iterator2.f(); + } + if (mediaUploaders.length) { + for (var _i2 = 0, _mediaUploaders2 = mediaUploaders; _i2 < _mediaUploaders2.length; _i2++) { + var uploader = _mediaUploaders2[_i2]; + if (!uploader.media_uploader || $(uploader.media_uploader.container).parents('form').get(0) !== $form.get(0)) { + continue; + } + if (uploader.media_uploader.hasValidFiles()) { var files_meta = uploader.media_uploader.getFilesMeta(); if (files_meta) { for (var i = 0; i < files_meta.length; i++) { - var elm = files_meta[i]; - for (var key in elm) { - form_data.append("".concat(uploader.uploaders_data['files_meta_name'], "[").concat(i, "][").concat(key, "]"), elm[key]); - } + form_data.append("listing_img_old[".concat(i, "]"), files_meta[i].attachmentID); } } } else { - $submitButton.removeClass('atbd_loading'); err_log.listing_gallery = { msg: uploader.uploaders_data['error_msg'] }; error_count++; - if ($('#' + uploader.uploaders_data['element_id']).length) { - scrollToEl('#' + uploader.uploaders_data['element_id']); - } - if ($('.' + uploader.uploaders_data['element_id']).length) { - scrollToEl('.' + uploader.uploaders_data['element_id']); + if ($('.' + uploader.uploaders_data.element_id).length) { + scrollTo('.' + uploader.uploaders_data.element_id); } } } } - } - // categories - var categories = $form.find('#at_biz_dir-categories').val(); - if (Array.isArray(categories) && categories.length) { - for (var key in categories) { - var value = categories[key]; - form_data.append('tax_input[at_biz_dir-category][]', value); + // categories + var categories = $form.find('#at_biz_dir-categories').val(); + if (Array.isArray(categories) && categories.length) { + for (var key in categories) { + form_data.append('tax_input[at_biz_dir-category][]', categories[key]); + } } - } - if (typeof categories === 'string') { - form_data.append('tax_input[at_biz_dir-category][]', categories); - } - if (form_data.has('admin_category_select[]')) { - form_data.delete('admin_category_select[]'); - } - if (form_data.has('directory_type')) { - form_data.delete('directory_type'); - } - var form_directory_type = $form.find("input[name='directory_type']"); - var form_directory_type_value = form_directory_type !== undefined ? form_directory_type.val() : ''; - var directory_type = qs.directory_type ? qs.directory_type : form_directory_type_value; - form_data.append('directory_type', directory_type); - if (qs.plan) { - form_data.append('plan_id', qs.plan); - } - if (error_count) { - on_processing = false; - $submitButton.attr('disabled', false); - console.log('Form has invalid data'); - console.log(error_count, err_log); - return; - } - on_processing = true; - $.ajax({ - method: 'POST', - processData: false, - contentType: false, - url: localized_data.ajaxurl, - data: form_data, - success: function success(response) { - //console.log(response); - // return; - // show the error notice - $submitButton.attr('disabled', false); - var redirect_url = response && response.redirect_url ? response.redirect_url : ''; - redirect_url = redirect_url && typeof redirect_url === 'string' ? response.redirect_url.replace(/:\/\//g, '%3A%2F%2F') : ''; - if (response.error === true) { - $('#listing_notifier').show().html("".concat(response.error_msg, "")); - $submitButton.removeClass('atbd_loading'); - on_processing = false; - if (response.quick_login_required) { - var modal = $('#directorist-quick-login'); - var email = response.email; - - // Prepare fields - modal.find('input[name="email"]').val(email); - modal.find('input[name="email"]').prop('disabled', true); - - // Show alert - var alert = '
p+n)&&(a.scrollLeft=h)}}}}}(); \ No newline at end of file diff --git a/directorist-base.php b/directorist-base.php index f1249386df..6cbb70bbb2 100644 --- a/directorist-base.php +++ b/directorist-base.php @@ -162,6 +162,8 @@ final class Directorist_Base public $announcement; public $review; + public $background_image_process = null; + /** * Main Directorist_Base Instance. * @@ -226,6 +228,8 @@ public static function instance() self::$instance->tools = new ATBDP_Tools(); self::$instance->announcement = new ATBDP_Announcement(); + self::$instance->background_image_process = new \Directorist\Background_Image_Process(); + // Load widgets Directorist\Widgets\Init::instance(); diff --git a/includes/asset-loader/localized_data.php b/includes/asset-loader/localized_data.php index e8c1e6d85c..117fca5e95 100644 --- a/includes/asset-loader/localized_data.php +++ b/includes/asset-loader/localized_data.php @@ -150,6 +150,8 @@ public static function get_add_listings_data() { 'deleted' => __( 'Deleted!', 'directorist' ), 'max_location_creation' => esc_attr( $max_loc_creation ), 'max_location_msg' => sprintf( __('You can only use %s', 'directorist'), $max_loc_creation ), + 'submission_wait_msg' => esc_html__( 'Please wait, your submission is being processed.', 'directorist' ), + 'image_uploading_msg' => esc_html__( 'Please wait, your selected images being uploaded.', 'directorist' ) ); //get listing is if the screen in edit listing diff --git a/includes/classes/class-add-listing.php b/includes/classes/class-add-listing.php index e2eea6a49a..c0742a2f8a 100644 --- a/includes/classes/class-add-listing.php +++ b/includes/classes/class-add-listing.php @@ -48,6 +48,63 @@ public function __construct() { add_action( 'parse_query', array( $this, 'parse_query' ) ); // do stuff likes adding, editing, renewing, favorite etc in this hook. add_action( 'wp_ajax_add_listing_action', array( $this, 'atbdp_submit_listing' ) ); add_action( 'wp_ajax_nopriv_add_listing_action', array( $this, 'atbdp_submit_listing' ) ); + + add_action( 'wp_ajax_directorist_upload_listing_image', array( __CLASS__, 'upload_listing_image' ) ); + add_action( 'wp_ajax_nopriv_directorist_upload_listing_image', array( __CLASS__, 'upload_listing_image' ) ); + } + + public static function upload_listing_image() { + try { + if ( ! directorist_verify_nonce() ) { + throw new Exception( __( 'Invalid request.', 'directorist' ), 400 ); + } + + $image = ! empty( $_FILES['image'] ) ? directorist_clean( $_FILES['image'] ) : array(); + + if ( empty( $image ) ) { + return; + } + + // Set temporary upload directory. + add_filter( 'upload_dir', array( __CLASS__, 'set_temporary_upload_dir' ) ); + + // handle file upload + $status = wp_handle_upload( + $image, + array( + 'test_form' => true, + 'test_type' => true, + 'action' => 'directorist_upload_listing_image', + 'mimes' => directorist_get_mime_types( 'image' ), + ) + ); + + // Restore to default upload directory. + remove_filter( 'upload_dir', array( __CLASS__, 'set_temporary_upload_dir' ) ); + + if ( ! empty( $status['error'] ) ) { + throw new Exception( sprintf( '%s - (%s)', $status['error'], $image['name'] ), 500 ); + } + + if ( empty( $status['url'] ) ) { + throw new Exception( sprintf( __( 'Could not upload (%s), please try again.', 'directorist' ), $image['name'] ), 500 ); + } + + wp_send_json_success( explode( 'directorist_temp_uploads/', $status['url'] )[1] ); + + } catch ( Exception $e ) { + + wp_send_json_error( $e->getMessage(), $e->getCode() ); + + } + } + + public static function set_temporary_upload_dir( $upload ) { + $upload['subdir'] = '/directorist_temp_uploads'; + $upload['path'] = $upload['basedir'] . $upload['subdir']; + $upload['url'] = $upload['baseurl'] . $upload['subdir']; + + return $upload; } /** @@ -212,6 +269,9 @@ public function atbdp_submit_listing() { case 'map': self::process_map( $field, $posted_data, $meta_data, $error ); break; + + case 'image_upload': + break; default: $meta_data[ '_' . $field->get_key() ] = $field->sanitize( $posted_data ); @@ -395,7 +455,7 @@ public function atbdp_submit_listing() { } wp_send_json( apply_filters( 'atbdp_listing_form_submission_info', $data ) ); - } catch ( Exception $e ) { + } catch (Exception $e ) { return wp_send_json( array( 'error' => true, 'error_msg' => $e->getMessage(), @@ -449,91 +509,104 @@ public static function is_admin_only_field( $field ) { } public static function upload_images( $listing_id, $posted_data ) { - $listing_images = atbdp_get_listing_attachment_ids( $listing_id ); - $files = ! empty( $_FILES['listing_img'] ) ? directorist_clean( wp_unslash( $_FILES['listing_img'] ) ) : array(); - $files_meta = directorist_get_var( $posted_data['files_meta'], array() ); - - if ( ! empty( $listing_images ) ) { - foreach ( $listing_images as $__old_id ) { - $match_found = false; - - if ( ! empty( $files_meta ) ) { - foreach ( $files_meta as $__new_id ) { - $new_id = isset( $__new_id['attachmentID'] ) ? (int) $__new_id['attachmentID'] : ''; - if ( $new_id === (int) $__old_id ) { - $match_found = true; - break; - } - } - } + $image_upload_field = directorist_get_listing_form_field( $posted_data['directory_id'], 'image_upload' ); - if ( ! $match_found ) { - wp_delete_attachment( (int) $__old_id, true ); - } - } + if ( empty( $image_upload_field ) ) { + return; } - $attach_data = array(); + $selected_images = Fields::create( $image_upload_field )->get_value( $posted_data ); + $old_images = $selected_images['old']; + $new_images = $selected_images['new']; - if ( $files ) { - foreach ( $files['name'] as $key => $value ) { + self::clean_unselected_images( $listing_id, $old_images ); - $filetype = wp_check_filetype( $files['name'][ $key ] ); + if ( empty( $old_images ) && empty( $new_images ) ) { + return; + } - if ( empty( $filetype['ext'] ) ) { + try { + $upload_dir = wp_get_upload_dir(); + $temp_dir = $upload_dir['basedir'] . '/directorist_temp_uploads/'; + $target_dir = trailingslashit( $upload_dir['path'] ); + $uploaded_images = $old_images; + $background_processable_images = array(); + + foreach ( $new_images as $image ) { + if ( empty( $image ) ) { continue; } - if ( $files['name'][ $key ] ) { - $file = array( - 'name' => $files['name'][ $key ], - 'type' => $files['type'][ $key ], - 'tmp_name' => $files['tmp_name'][ $key ], - 'error' => $files['error'][ $key ], - 'size' => $files['size'][ $key ], - ); - - $_FILES['my_file_upload'] = $file; - $meta_data = array(); - $meta_data['name'] = $files['name'][ $key ]; - $meta_data['id'] = atbdp_handle_attachment( 'my_file_upload', $listing_id ); + $filepath = $temp_dir . $image; + + if ( is_dir( $filepath ) || ! file_exists( $filepath ) ) { + continue; + } - array_push( $attach_data, $meta_data ); + if ( file_exists( $target_dir . $image ) ) { + $image = wp_unique_filename( $target_dir, $image ); } - } - } + + rename( $filepath, $target_dir . $image ); - $new_files_meta = array(); + $mime = wp_check_filetype( $image ); + $name = wp_basename( $image, ".{$mime['ext']}" ); - foreach ( $files_meta as $key => $value ) { - if ( $key === 0 && $value['oldFile'] === 'true' ) { - update_post_meta( $listing_id, '_listing_prv_img', $value['attachmentID'] ); - set_post_thumbnail( $listing_id, $value['attachmentID'] ); - } + // Construct the attachment array. + $attachment = array( + 'post_mime_type' => $mime['type'], + 'guid' => trailingslashit( $upload_dir['url'] ) . $image, + 'post_parent' => $listing_id, + 'post_title' => sanitize_text_field( $name ), + ); - if ( $key === 0 && $value['oldFile'] !== 'true' ) { - foreach ( $attach_data as $item ) { - if ( $item['name'] === $value['name'] ) { - update_post_meta( $listing_id, '_listing_prv_img', $item['id'] ); - set_post_thumbnail( $listing_id, $item['id'] ); - } + $attachment_id = wp_insert_attachment( $attachment, $target_dir . $image, $listing_id, false ); + + if ( is_wp_error( $attachment_id ) ) { + throw new Exception( $attachment_id->get_error_message() ); + + continue; } - } - if ( $key !== 0 && $value['oldFile'] === 'true' ) { - $new_files_meta[] = $value['attachmentID']; + $background_processable_images[ $attachment_id ] = $target_dir . $image; + + $uploaded_images[] = $attachment_id; } - if ( $key !== 0 && $value['oldFile'] !== 'true' ) { - foreach ( $attach_data as $item ) { - if ( $item['name'] === $value['name'] ) { - $new_files_meta[] = $item['id']; - } + if ( ! empty( $uploaded_images ) ) { + update_post_meta( $listing_id, '_listing_prv_img', $uploaded_images[0] ); + set_post_thumbnail( $listing_id, $uploaded_images[0] ); + + unset( $uploaded_images[0] ); + + if ( count( $uploaded_images ) ) { + update_post_meta( $listing_id, '_listing_img', $uploaded_images ); } + + directorist_background_image_process( $background_processable_images ); } + + } catch ( Exception $e ) { + + error_log( $e->getMessage() ); + } + } - update_post_meta( $listing_id, '_listing_img', $new_files_meta ); + protected static function clean_unselected_images( $listing_id, $selected_images ) { + $saved_images = atbdp_get_listing_attachment_ids( $listing_id ); + if ( empty( $saved_images ) ) { + return; + } + + $unselected_images = array_diff( $saved_images, $selected_images ); + if ( empty( $unselected_images ) ) { + return; + } + + foreach ( $unselected_images as $unselected_image ) { + wp_delete_attachment( $unselected_image, true ); + } } public static function process_map( $field, $posted_data, &$data, $error ) { diff --git a/includes/classes/class-background-image-process.php b/includes/classes/class-background-image-process.php new file mode 100644 index 0000000000..68a4685bdc --- /dev/null +++ b/includes/classes/class-background-image-process.php @@ -0,0 +1,94 @@ +prefix = 'wp_' . get_current_blog_id(); + $this->action = 'directorist_background_image_process'; + + parent::__construct(); + } + + /** + * Handle cron healthcheck + * + * Restart the background process if not already running + * and data exists in the queue. + */ + public function handle_cron_healthcheck() { + if ( $this->is_process_running() ) { + // Background process already running. + return; + } + + if ( $this->is_queue_empty() ) { + // No data to process. + $this->clear_scheduled_event(); + return; + } + + $this->handle(); + } + + /** + * Schedule fallback event. + */ + protected function schedule_event() { + if ( ! wp_next_scheduled( $this->cron_hook_identifier ) ) { + wp_schedule_event( time() + 10, $this->cron_interval_identifier, $this->cron_hook_identifier ); + } + } + + + /** + * Task + * + * Override this method to perform any actions required on each + * queue item. Return the modified item for further processing + * in the next pass through. Or, return false to remove the + * item from the queue. + * + * @param array $attachments { attachment_id => attachment_path } + * @return string|bool + */ + protected function task( $image ) { + $image_id = key( $image ); + + if ( ! headers_sent() ) { + header( 'X-WP-Upload-Attachment-ID: ' . $image_id ); + } + + \wp_update_attachment_metadata( $image_id, \wp_generate_attachment_metadata( $image_id, $image[ $image_id ] ) ); + } + + /** + * See if the batch limit has been exceeded. + * + * @return bool + */ + public function is_memory_exceeded() { + return $this->memory_exceeded(); + } +} diff --git a/includes/fields/class-directorist-image-upload-field.php b/includes/fields/class-directorist-image-upload-field.php index a596245cac..fb06e43bf9 100644 --- a/includes/fields/class-directorist-image-upload-field.php +++ b/includes/fields/class-directorist-image-upload-field.php @@ -13,17 +13,27 @@ class Image_Upload_Field extends Base_Field { public $type = 'image_upload'; public function get_value( $posted_data ) { - if ( empty( $_FILES[ $this->get_key() ] ) ) { - return array(); - } + $new_images = $posted_data[ $this->get_key() ]; + $old_images = (array) $posted_data[ $this->get_key() . '_old' ]; - return directorist_clean( wp_unslash( $_FILES[ $this->get_key() ] ) ); + return array( + 'new' => array_filter( explode( ',', $new_images ) ), + 'old' => array_filter( wp_parse_id_list( $old_images ) ), + ); } public function validate( $posted_data ) { - $files = $this->get_value( $posted_data ); + $files = $this->get_value( $posted_data ); + $old_images = $files['old']; + $new_images = $files['new']; + + if ( $this->is_required() && empty( $old_images ) && empty( $new_images ) ) { + $this->add_error( __( 'This field is required.', 'directorist' ) ); + + return false; + } - if ( count( $files['name'] ) > $this->get_total_upload_limit() ) { + if ( ( count( $old_images ) + count( $new_images ) ) > $this->get_total_upload_limit() ) { $this->add_error( sprintf( _n( '%s image allowed only.', '%s images allowed only.', $this->get_total_upload_limit(), 'directorist' ), $this->get_total_upload_limit() @@ -32,27 +42,41 @@ public function validate( $posted_data ) { return false; } + // TODO: use get_attached_file to calculate the old images file size. + + $upload_dir = wp_get_upload_dir(); + $temp_dir = $upload_dir['basedir'] . '/directorist_temp_uploads/'; $total_size = 0; - foreach ( $files['name'] as $key => $value ) { - if ( strpos( $files['type'][ $key ], 'image' ) === false ) { + foreach ( $new_images as $file ) { + $filepath = realpath( $temp_dir . $file ); + + if ( empty( $file ) || ! $filepath ) { + continue; + } + + $filesize = filesize( $filepath ); + $real_mime = wp_get_image_mime( $filepath ); + + if ( ! $real_mime || strpos( $real_mime, 'image' ) === false ) { + $this->add_error( sprintf( - __( '[%1$s] Only image allowed.', 'directorist' ), - $files['name'][ $key ] + __( '[%1$s] invalid file type, only image allowed.', 'directorist' ), + $file ) ); continue; } - if ( $files['size'][ $key ] > $this->get_per_image_upload_size() ) { + if ( $filesize > $this->get_per_image_upload_size() ) { $this->add_error( sprintf( - __( '[%1$s] Size exceeded, %2$s is allowed only.', 'directorist' ), - $files['name'][ $key ], + __( '[%1$s] size exceeded, %2$s is allowed only.', 'directorist' ), + $file, size_format( $this->get_per_image_upload_size() ) ) ); } - $total_size += $files['size'][ $key ]; + $total_size += $filesize; if ( $total_size > $this->get_total_upload_size() ) { $this->add_error( sprintf( diff --git a/includes/helper-functions.php b/includes/helper-functions.php index c236130e36..2a5eb9a5b0 100644 --- a/includes/helper-functions.php +++ b/includes/helper-functions.php @@ -2447,13 +2447,30 @@ function atbdp_guest_submission($guest_email) } } -function atbdp_get_listing_attachment_ids($post_id){ +function atbdp_get_listing_attachment_ids( $listing_id ) { + $featured_image = (int) get_post_meta( $listing_id, '_listing_prv_img', true ); + $attachment_ids = array(); - $listing_img = get_post_meta($post_id, '_listing_img', true); - $listing_img = !empty($listing_img) ? $listing_img : array(); - $listing_prv_img = get_post_meta($post_id, '_listing_prv_img', true); - array_unshift($listing_img, $listing_prv_img); - return $listing_img; + if ( $featured_image ) { + $attachment_ids[] = $featured_image; + } + + $gallery_images = (array) get_post_meta( $listing_id, '_listing_img', true ); + + if ( empty( $gallery_images ) ) { + return $attachment_ids; + } + + $gallery_images = wp_parse_id_list( $gallery_images ); + $gallery_images = array_filter( $gallery_images ); + + if ( empty( $gallery_images ) ) { + return $attachment_ids; + } + + $attachment_ids = array_merge( $attachment_ids, $gallery_images ); + + return $attachment_ids; } @@ -4028,44 +4045,36 @@ function directorist_password_reset_url( $user, $password_reset = true, $confirm return apply_filters( 'directorist_password_reset_url', $reset_password_url ); } -function directorist_get_mime_types( $filter_type = '', $return_type = '' ) { - $supported_mime_types = wp_get_mime_types(); - - // Filter - if ( ! empty( $filter_type ) ) { - $filtered_supported_mime_types = []; - - foreach ($supported_mime_types as $key => $value) { - $_type = preg_replace( "/\/\w+$/", '', $value ); - - if ( $_type !== $filter_type ) { - continue; - } - - $filtered_supported_mime_types[ $key ] = $value; - } +/** + * Get allowed mime types. + * + * @param string $filterby Filter allowed mime types by group. eg. image, audio, video, document etc. + * @param string $return_type Get the full mime types map or only extensions. Valid args are extension and .extension. + * + * @return array + */ +function directorist_get_mime_types( $filterby = '', $return_type = '' ) { + $allowed_mime_types = get_allowed_mime_types(); - $supported_mime_types = $filtered_supported_mime_types; + if ( ! empty( $filterby ) ) { + $allowed_mime_types = array_filter( $allowed_mime_types, static function( $mime_type, $extensions ) use ( $filterby ) { + return stripos( $mime_type, $filterby ) !== false; + }, ARRAY_FILTER_USE_BOTH ); } - // Convert to extension if ( $return_type === 'extension' || $return_type === '.extension' ) { - $extensions = array_keys( $supported_mime_types ); - - $extended_extensions = []; - - foreach ( $extensions as $extension ) { - $_sub_extensions = explode( '|', $extension ); - - foreach ( $_sub_extensions as $sub_extension ) { - $extended_extensions[] = ( $return_type === '.extension' ) ? '.' . $sub_extension : $sub_extension; - } + $allowed_mime_types = array_reduce( array_keys( $allowed_mime_types ), static function( $carry, $extension ) { + return array_merge( $carry, explode( '|', $extension ) ); + }, array() ); + + if ( $return_type === '.extension' ) { + $allowed_mime_types = array_map( static function( $extension ) { + return '.' . $extension; + }, $allowed_mime_types ); } - - $supported_mime_types = array_values( $extended_extensions ); } - return $supported_mime_types; + return $allowed_mime_types; } /** @@ -4198,3 +4207,25 @@ function directorist_validate_youtube_vimeo_url( $url ) { function directorist_is_listing_post_type( $listing_id ) { return ( get_post_type( absint( $listing_id ) ) === ATBDP_POST_TYPE ); } + +function directorist_background_image_process( $images ) { + if ( empty( $images ) || ! is_array( $images ) ) { + return; + } + + $should_dispatch = false; + + foreach ( $images as $image_id => $image_path ) { + if ( empty( $image_id ) || empty( $image_path ) ) { + continue; + } + + $should_dispatch = true; + + ATBDP()->background_image_process->push_to_queue( array( $image_id => $image_path ) ); + } + + if ( $should_dispatch ) { + ATBDP()->background_image_process->save()->dispatch(); + } +} diff --git a/includes/model/SingleListing.php b/includes/model/SingleListing.php index 5a311a9b31..e44f3c8eaa 100644 --- a/includes/model/SingleListing.php +++ b/includes/model/SingleListing.php @@ -493,7 +493,7 @@ public function get_slider_data() { // Get the preview images $preview_img_id = get_post_meta( $listing_id, '_listing_prv_img', true); - $preview_img_link = ! empty($preview_img_id) ? atbdp_get_image_source($preview_img_id, 'large') : ''; + $preview_img_link = ! empty($preview_img_id) ? atbdp_get_image_source( $preview_img_id, 'large' ) : ''; $preview_img_alt = get_post_meta($preview_img_id, '_wp_attachment_image_alt', true); $preview_img_alt = ( ! empty( $preview_img_alt ) ) ? $preview_img_alt : get_the_title( $preview_img_id ); diff --git a/languages/directorist.pot b/languages/directorist.pot index b5f2feea3a..b3b6fbc42b 100644 --- a/languages/directorist.pot +++ b/languages/directorist.pot @@ -6,7 +6,11 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" +<<<<<<< HEAD +"POT-Creation-Date: 2022-11-03 08:18+0000\n" +======= "POT-Creation-Date: 2023-11-16 11:06+0000\n" +>>>>>>> 21829f182e5820dd7e33a3b8c362611f0b3a9517 "X-Poedit-Basepath: ..\n" "X-Poedit-KeywordsList: __;_e;_ex:1,2c;_n:1,2;_n_noop:1,2;_nx:1,2,4c;_nx_noop:1,2,3c;_x:1,2c;esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c\n" "X-Poedit-SearchPath-0: .\n" @@ -158,6 +162,273 @@ msgstr "" msgid "You need to be logged in to view the content of this page" msgstr "" +<<<<<<< HEAD +#: ../includes/helper-functions.php:972 +msgid "You need to be logged in to view the content of this page. You can login %s. Don't have an account? %s" +msgstr "" + +#: ../includes/helper-functions.php:972, ../includes/classes/class-helper.php:538, ../includes/classes/class-settings-panel.php:4003, ../templates/account/registration.php:33, ../templates/account/registration.php:25 +msgid "Here" +msgstr "" + +#: ../includes/helper-functions.php:972 +msgid "Sign up" +msgstr "" + +#: ../includes/helper-functions.php:1001 +msgid "Jan" +msgstr "" + +#: ../includes/helper-functions.php:1002 +msgid "Feb" +msgstr "" + +#: ../includes/helper-functions.php:1003 +msgid "Mar" +msgstr "" + +#: ../includes/helper-functions.php:1004 +msgid "Apr" +msgstr "" + +#: ../includes/helper-functions.php:1005 +msgid "May" +msgstr "" + +#: ../includes/helper-functions.php:1006 +msgid "Jun" +msgstr "" + +#: ../includes/helper-functions.php:1007 +msgid "Jul" +msgstr "" + +#: ../includes/helper-functions.php:1008 +msgid "Aug" +msgstr "" + +#: ../includes/helper-functions.php:1009 +msgid "Sep" +msgstr "" + +#: ../includes/helper-functions.php:1010 +msgid "Oct" +msgstr "" + +#: ../includes/helper-functions.php:1011 +msgid "Nov" +msgstr "" + +#: ../includes/helper-functions.php:1012 +msgid "Dec" +msgstr "" + +#: ../includes/helper-functions.php:1567, ../includes/classes/class-settings-panel.php:1690, ../includes/classes/class-settings-panel.php:3132 +msgid "A to Z (title)" +msgstr "" + +#: ../includes/helper-functions.php:1568, ../includes/classes/class-settings-panel.php:1694, ../includes/classes/class-settings-panel.php:3136 +msgid "Z to A (title)" +msgstr "" + +#: ../includes/helper-functions.php:1569, ../includes/classes/class-settings-panel.php:1698, ../includes/classes/class-settings-panel.php:3140 +msgid "Latest listings" +msgstr "" + +#: ../includes/helper-functions.php:1570, ../includes/classes/class-settings-panel.php:1702, ../includes/classes/class-settings-panel.php:3144 +msgid "Oldest listings" +msgstr "" + +#: ../includes/helper-functions.php:1571, ../includes/classes/class-settings-panel.php:1706, ../includes/classes/class-settings-panel.php:3148 +msgid "Popular listings" +msgstr "" + +#: ../includes/helper-functions.php:1572, ../includes/classes/class-settings-panel.php:1710, ../includes/classes/class-settings-panel.php:3152 +msgid "Price (low to high)" +msgstr "" + +#: ../includes/helper-functions.php:1573, ../includes/classes/class-settings-panel.php:1714, ../includes/classes/class-settings-panel.php:3156 +msgid "Price (high to low)" +msgstr "" + +#: ../includes/helper-functions.php:1574, ../includes/classes/class-settings-panel.php:1718, ../includes/classes/class-settings-panel.php:3160 +msgid "Random listings" +msgstr "" + +#: ../includes/helper-functions.php:1719, ../includes/classes/class-settings-panel.php:1759, ../includes/classes/class-settings-panel.php:1778, ../includes/classes/class-settings-panel.php:3079, ../includes/classes/class-settings-panel.php:3605, ../includes/classes/class-settings-panel.php:3693, ../includes/widgets/all-categories.php:49, ../includes/widgets/all-locations.php:49, ../includes/widgets/all-tags.php:48 +msgid "List" +msgstr "" + +#: ../includes/helper-functions.php:1722, ../includes/classes/class-settings-panel.php:1755, ../includes/classes/class-settings-panel.php:1774, ../includes/classes/class-settings-panel.php:3075, ../includes/classes/class-settings-panel.php:3601, ../includes/classes/class-settings-panel.php:3689 +msgid "Grid" +msgstr "" + +#: ../includes/helper-functions.php:1725, ../includes/classes/class-settings-panel.php:1763, ../includes/classes/class-settings-panel.php:1782, ../includes/classes/class-settings-panel.php:3083, ../includes/classes/class-settings-panel.php:4651, ../includes/classes/class-settings-panel.php:4655, ../includes/widgets/single-map.php:27 +msgid "Map" +msgstr "" + +#: ../includes/helper-functions.php:2500 +msgid "Email already registered. Please login first" +msgstr "" + +#: ../includes/helper-functions.php:2539, ../includes/classes/class-settings-panel.php:4559 +msgid "Remove Data on Uninstall?" +msgstr "" + +#: ../includes/helper-functions.php:2540, ../includes/classes/class-settings-panel.php:4560 +msgid "Checked it if you would like Directorist to completely remove all of its data when the plugin is deleted." +msgstr "" + +#: ../includes/helper-functions.php:2551 +msgid "CSV" +msgstr "" + +#: ../includes/helper-functions.php:2652 +msgid "Search Home" +msgstr "" + +#: ../includes/helper-functions.php:2656, ../includes/classes/class-settings-panel.php:4712, ../includes/classes/class-setup-wizard.php:425, ../includes/elementor/search-result.php:15 +msgid "Search Result" +msgstr "" + +#: ../includes/helper-functions.php:2660, ../includes/classes/class-setup-wizard.php:345 +msgid "Add Listing" +msgstr "" + +#: ../includes/helper-functions.php:2664, ../includes/classes/class-settings-panel.php:4584, ../includes/classes/class-setup-wizard.php:353, ../includes/elementor/all-listing.php:16, ../templates/dashboard/tab-my-listings.php:28 +msgid "All Listings" +msgstr "" + +#: ../includes/helper-functions.php:2672, ../includes/classes/class-setup-wizard.php:361, ../includes/elementor/category.php:15 +msgid "Single Category" +msgstr "" + +#: ../includes/helper-functions.php:2680, ../includes/classes/class-setup-wizard.php:369, ../includes/elementor/location.php:15 +msgid "Single Location" +msgstr "" + +#: ../includes/helper-functions.php:2684, ../includes/classes/class-setup-wizard.php:377, ../includes/elementor/tag.php:15 +msgid "Single Tag" +msgstr "" + +#: ../includes/helper-functions.php:2688, ../includes/classes/class-setup-wizard.php:385 +msgid "Author Profile" +msgstr "" + +#: ../includes/helper-functions.php:2692, ../includes/classes/class-settings-panel.php:4892, ../includes/classes/class-setup-wizard.php:393, ../includes/elementor/user-dashboard.php:15 +msgid "Dashboard" +msgstr "" + +#: ../includes/helper-functions.php:2696, ../includes/classes/class-setup-wizard.php:409, ../includes/elementor/custom-registration.php:15 +msgid "Registration" +msgstr "" + +#: ../includes/helper-functions.php:2700, ../includes/classes/class-setup-wizard.php:401, ../includes/elementor/user-login.php:15, ../includes/model/SingleListing.php:1169, ../templates/listing-form/quick-login.php:41 +msgid "Login" +msgstr "" + +#: ../includes/helper-functions.php:3152 +msgid "Add listing page not selected" +msgstr "" + +#: ../includes/helper-functions.php:3153, ../includes/helper-functions.php:3161, ../includes/helper-functions.php:3169, ../includes/helper-functions.php:3177, ../includes/helper-functions.php:3185, ../includes/helper-functions.php:3193, ../includes/helper-functions.php:3201, ../includes/helper-functions.php:3209, ../includes/helper-functions.php:3217, ../includes/helper-functions.php:3225, ../includes/helper-functions.php:3233, ../includes/helper-functions.php:3241, ../includes/helper-functions.php:3249 +msgid "Contains a collection of relevant data that will help you debug your website accurately and more efficiently." +msgstr "" + +#: ../includes/helper-functions.php:3155, ../includes/helper-functions.php:3163, ../includes/helper-functions.php:3171, ../includes/helper-functions.php:3179, ../includes/helper-functions.php:3187, ../includes/helper-functions.php:3195, ../includes/helper-functions.php:3203, ../includes/helper-functions.php:3211, ../includes/helper-functions.php:3219, ../includes/helper-functions.php:3227, ../includes/helper-functions.php:3235, ../includes/helper-functions.php:3243 +msgid "Select Page" +msgstr "" + +#: ../includes/helper-functions.php:3160 +msgid "Dashboard page not selected" +msgstr "" + +#: ../includes/helper-functions.php:3168 +msgid "User Profile page not selected" +msgstr "" + +#: ../includes/helper-functions.php:3176 +msgid "Single Category page not selected" +msgstr "" + +#: ../includes/helper-functions.php:3184, ../includes/helper-functions.php:3192 +msgid "Single Location page not selected" +msgstr "" + +#: ../includes/helper-functions.php:3200 +msgid "Registration page not selected" +msgstr "" + +#: ../includes/helper-functions.php:3208 +msgid "Login page not selected" +msgstr "" + +#: ../includes/helper-functions.php:3216 +msgid "Search Result page not selected" +msgstr "" + +#: ../includes/helper-functions.php:3224 +msgid "Checkout page not selected" +msgstr "" + +#: ../includes/helper-functions.php:3232 +msgid "Payment Receipt page not selected" +msgstr "" + +#: ../includes/helper-functions.php:3240 +msgid "Transaction Failure page not selected" +msgstr "" + +#: ../includes/helper-functions.php:3248 +msgid "Map Api Key is missing" +msgstr "" + +#: ../includes/helper-functions.php:3251 +msgid "Give the Api" +msgstr "" + +#: ../includes/helper-functions.php:3256 +msgid "SMTP not configured" +msgstr "" + +#: ../includes/helper-functions.php:3257 +msgid "SMTP is a TCP/IP protocol responsible for email deliveries. You must configure SMTP to send or receive emails." +msgstr "" + +#: ../includes/helper-functions.php:3344 +msgid "Something went wrong!" +msgstr "" + +#: ../includes/helper-functions.php:3345 +msgid "Registration failed. Please make sure you filed up all the necessary fields marked with *" +msgstr "" + +#: ../includes/helper-functions.php:3346 +msgid "Sorry, that email already exists!" +msgstr "" + +#: ../includes/helper-functions.php:3347, ../includes/classes/class-user.php:227 +msgid "Username too short. At least 4 characters is required" +msgstr "" + +#: ../includes/helper-functions.php:3348, ../includes/classes/class-user.php:231 +msgid "Sorry, that username already exists!" +msgstr "" + +#: ../includes/helper-functions.php:3349, ../includes/classes/class-user.php:241 +msgid "Password length must be greater than 5" +msgstr "" + +#: ../includes/helper-functions.php:3350, ../includes/classes/class-user.php:256 +msgid "Email is not valid" +msgstr "" + +#: ../includes/helper-functions.php:3351 +msgid "Space is not allowed in username" +msgstr "" + +#: ../includes/helper-functions.php:3352 +======= #: ../includes/helper-functions.php:939 msgid "You need to be logged in to view the content of this page. You can login %s. Don't have an account? %s" msgstr "" @@ -427,6 +698,7 @@ msgid "Space is not allowed in username" msgstr "" #: ../includes/helper-functions.php:3276 +>>>>>>> 21829f182e5820dd7e33a3b8c362611f0b3a9517 msgid "Please make sure you filed up the user type" msgstr "" @@ -666,7 +938,11 @@ msgstr "" msgid "Sorry, Something went wrong. Listing ID is missing. Please try again." msgstr "" +<<<<<<< HEAD +#: ../includes/checkout/class-checkout.php:86, ../includes/checkout/class-checkout.php:182, ../includes/classes/class-custom-post.php:259, ../includes/classes/class-custom-post.php:267, ../includes/classes/class-settings-panel.php:511, ../includes/classes/class-settings-panel.php:2246, ../includes/model/Listings.php:183, ../includes/model/Listings.php:2037, ../includes/modules/multi-directory-setup/class-multi-directory-manager.php:3317, ../views/admin-templates/listing-form/expiration-featured-fields.php:57 +======= #: ../includes/checkout/class-checkout.php:86, ../includes/checkout/class-checkout.php:182, ../includes/classes/class-custom-post.php:314, ../includes/classes/class-custom-post.php:322, ../includes/classes/class-settings-panel.php:519, ../includes/classes/class-settings-panel.php:2238, ../includes/model/Listings.php:211, ../includes/model/Listings.php:2042, ../includes/modules/multi-directory-setup/class-builder-data.php:1173, ../views/admin-templates/listing-form/expiration-featured-fields.php:57 +>>>>>>> 21829f182e5820dd7e33a3b8c362611f0b3a9517 msgid "Featured" msgstr "" @@ -687,6 +963,31 @@ msgstr "" msgid "Every %d minutes" msgstr "" +<<<<<<< HEAD +#: ../includes/classes/class-add-listing.php:55, ../includes/classes/class-add-listing.php:115, ../includes/classes/class-ajax-handler.php:222, ../includes/classes/class-ajax-handler.php:1153, ../includes/classes/class-ajax-handler.php:1366, ../includes/classes/class-settings-panel.php:373, ../includes/modules/multi-directory-setup/class-multi-directory-manager.php:235, ../includes/modules/multi-directory-setup/class-multi-directory-manager.php:315, ../includes/modules/multi-directory-setup/class-multi-directory-manager.php:437 +msgid "Something is wrong! Please refresh and retry." +msgstr "" + +#: ../includes/classes/class-add-listing.php:178, ../includes/classes/class-add-listing.php:183, ../includes/classes/class-add-listing.php:188, ../includes/classes/class-add-listing.php:193, ../includes/classes/class-add-listing.php:198, ../includes/classes/class-add-listing.php:204 +msgid " field is required!" +msgstr "" + +#: ../includes/classes/class-add-listing.php:479, ../includes/classes/class-add-listing.php:326 +msgctxt "tag delimiter" +msgid "," +msgstr "" + +#: ../includes/classes/class-add-listing.php:742 +msgid "Your Submission is Completed! redirecting.." +msgstr "" + +#: ../includes/classes/class-add-listing.php:746 +msgid "Sorry! Something Wrong with Your Submission" +msgstr "" + +#: ../includes/classes/class-add-listing.php:752 +msgid "Payment Required! redirecting to checkout.." +======= #: ../includes/classes/class-add-listing.php:82, ../includes/classes/class-setup-wizard.php:115, ../includes/classes/class-tools.php:70 msgid "Invalid request!" msgstr "" @@ -709,6 +1010,7 @@ msgstr "" #: ../includes/classes/class-add-listing.php:121 msgid "Invalid guest email." +>>>>>>> 21829f182e5820dd7e33a3b8c362611f0b3a9517 msgstr "" #: ../includes/classes/class-add-listing.php:218 @@ -2664,7 +2966,11 @@ msgstr "" msgid "Popular Badge Text" msgstr "" +<<<<<<< HEAD +#: ../includes/classes/class-settings-panel.php:2251, ../includes/model/Listings.php:182, ../includes/model/Listings.php:2049, ../includes/modules/multi-directory-setup/class-multi-directory-manager.php:3331, ../includes/modules/multi-directory-setup/class-multi-directory-migration.php:1604 +======= #: ../includes/classes/class-settings-panel.php:2243, ../includes/model/Listings.php:210, ../includes/model/Listings.php:2054, ../includes/modules/multi-directory-setup/class-builder-data.php:1187, ../includes/modules/multi-directory-setup/class-multi-directory-migration.php:1605 +>>>>>>> 21829f182e5820dd7e33a3b8c362611f0b3a9517 msgid "Popular" msgstr "" @@ -5086,6 +5392,17 @@ msgid_plural "Reviews" msgstr[0] "" msgstr[1] "" +<<<<<<< HEAD +#: ../includes/model/Listings.php:1119 +msgid "No listing found." +msgstr "" + +#: ../includes/model/Listings.php:1537 +msgid "Posted %s ago" +msgstr "" + +#: ../includes/model/Listings.php:1603 +======= #: ../includes/model/Listings.php:1142 msgid "No listing found." msgstr "" @@ -5095,27 +5412,40 @@ msgid "Posted %s ago" msgstr "" #: ../includes/model/Listings.php:1630 +>>>>>>> 21829f182e5820dd7e33a3b8c362611f0b3a9517 msgctxt "search result header" msgid "%s result" msgid_plural "%s results" msgstr[0] "" msgstr[1] "" +<<<<<<< HEAD +#: ../includes/model/Listings.php:1600 +======= #: ../includes/model/Listings.php:1627 +>>>>>>> 21829f182e5820dd7e33a3b8c362611f0b3a9517 msgctxt "search result header" msgid "%s result in %s" msgid_plural "%s results in %s" msgstr[0] "" msgstr[1] "" +<<<<<<< HEAD +#: ../includes/model/Listings.php:1597 +======= #: ../includes/model/Listings.php:1624 +>>>>>>> 21829f182e5820dd7e33a3b8c362611f0b3a9517 msgctxt "search result header" msgid "%s result for %s" msgid_plural "%s results for %s" msgstr[0] "" msgstr[1] "" +<<<<<<< HEAD +#: ../includes/model/Listings.php:1594 +======= #: ../includes/model/Listings.php:1621 +>>>>>>> 21829f182e5820dd7e33a3b8c362611f0b3a9517 msgctxt "search result header" msgid "%s result for %s in %s" msgid_plural "%s results for %s in %s" diff --git a/templates/listing-form/fields/image_upload.php b/templates/listing-form/fields/image_upload.php index 6565eab961..9f0b0c4753 100644 --- a/templates/listing-form/fields/image_upload.php +++ b/templates/listing-form/fields/image_upload.php @@ -7,19 +7,18 @@ if ( ! defined( 'ABSPATH' ) ) exit; -$p_id = $listing_form->get_add_listing_id(); -$listing_img = atbdp_get_listing_attachment_ids( $p_id ); -$maximum = !empty( $data['max'] ) ? $data['max'] : $data['max_image_limit']; -$unlimited = !empty( $data['unlimited'] ) ? $data['unlimited'] : ''; +$listing_img = atbdp_get_listing_attachment_ids( $listing_form->get_add_listing_id() ); +$maximum = ! empty( $data['max'] ) ? $data['max'] : $data['max_image_limit']; +$unlimited = ! empty( $data['unlimited'] ) ? $data['unlimited'] : ''; $limit = $unlimited ? '0' : $maximum; -$max_file_size = $data['max_per_image_limit']; -$max_total_file_size = $data['max_total_image_limit']; -$max_file_size_kb = (float) $max_file_size * 1024;// -$max_total_file_size_kb = (float) $max_total_file_size * 1024;// -$required = $data['required'] ? '1' : 0; +$max_file_size = (float) $data['max_per_image_limit']; +$max_total_file_size = (float) $data['max_total_image_limit']; +$max_file_size_kb = $max_file_size * 1024; +$max_total_file_size_kb = $max_total_file_size * 1024; +$required = (bool) $data['required']; $accepted_mime_types = directorist_get_mime_types( 'image', 'extension' ); -$accepted_mime_types_upper = array_map( function( $ext ) { return strtoupper( $ext ); }, $accepted_mime_types ) ; +$accepted_mime_types_upper = array_map( 'strtoupper', $accepted_mime_types ) ; $accepted_mime_types = array_merge( $accepted_mime_types, $accepted_mime_types_upper ); $img_upload_data = [ @@ -29,33 +28,28 @@ 'is_required' => $required, 'max_size_per_img' => $max_file_size_kb, ]; + $img_upload_data = json_encode( $img_upload_data ); ?>