Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion app/Http/Controllers/CheckoutController.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ public function checkout( Validator $validator, WP_REST_Request $request ): arra
}

// Update the order status to paid
$repository->update( ( new DTO )->set_id( $dto->get_id() )->set_status( Status::PAID ) );
$dto->set_id( $dto->get_id() )->set_status( Status::PAID );
$repository->update( $dto );

do_action( 'directorist_before_redirect_checkout', $dto, $checkout_type, $request );

Expand Down
362 changes: 181 additions & 181 deletions assets/js/admin-builder-archive.js

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions assets/src/js/public/checkout.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@
return number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
}

function get_error_message( error ) {
function get_error_message(error) {
let message = '';

if ( error.message ) {
if (error.message) {
message = error.message;
} else if ( error.messages ) {
const messages = Object.values( error.messages );
} else if (error.messages) {
const messages = Object.values(error.messages);

if ( messages.length > 0 ) {
if (messages.length > 0) {
message = messages[0][0];
}
}
Expand Down Expand Up @@ -116,15 +116,15 @@
data: data,
});

if ( response.redirect_url ) {
if (response.redirect_url) {
window.location.href = response.redirect_url;
}
} catch (error) {
const message = get_error_message( error );
const message = get_error_message(error);

alert(message);
console.log(error);

alert( message );
console.log( error );

// Reset loading state on error
submitBtn.prop('disabled', false);
btnText.text(originalText);
Expand Down
15 changes: 11 additions & 4 deletions assets/src/js/public/components/dashboard/dashboardListing.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,20 @@
} else if (task == 'unfeature') {
swal(
{
title: directorist.listing_unfeature_title || 'Unfeature Listing',
text: directorist.listing_unfeature_text || 'Are you sure you want to unfeature this listing?',
title:
directorist.listing_unfeature_title ||
'Unfeature Listing',
text:
directorist.listing_unfeature_text ||
'Are you sure you want to unfeature this listing?',
type: 'warning',
cancelButtonText:
directorist.review_cancel_btn_text || 'Cancel',
showCancelButton: true,
confirmButtonColor: '#DD6B55',
confirmButtonText:
directorist.listing_unfeature_confirm_text || 'Yes, Unfeature',
directorist.listing_unfeature_confirm_text ||
'Yes, Unfeature',
showLoaderOnConfirm: true,
closeOnConfirm: false,
},
Expand All @@ -139,7 +144,9 @@
postid
);
swal({
title: directorist.listing_unfeatured || 'Listing Unfeatured',
title:
directorist.listing_unfeatured ||
'Listing Unfeatured',
type: 'success',
timer: 200,
showConfirmButton: false,
Expand Down
35 changes: 35 additions & 0 deletions includes/helper-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -4774,3 +4774,38 @@ function directorist_renewal_token_hash( $listing_id, $user_id ) {
$token_str = 'cB0XtpVzGb180dgPi3hADW-' . $listing_id . '::' . $user_id;
return wp_hash( $token_str, 'nonce' );
}

function directorist_submission_form_fields_raw( int $directory_type_id ): array {
return get_term_meta( $directory_type_id, 'submission_form_fields', true );
}

function directorist_submission_form_fields( int $directory_type_id, array $data = [] ): array {
$data['directory_type_id'] = $directory_type_id;
return apply_filters( 'directorist_submission_form_fields', directorist_submission_form_fields_raw( $directory_type_id ), $data );
}

function directorist_single_listing_header( int $directory_type_id, array $data = [] ): array {
$data['directory_type_id'] = $directory_type_id;
return apply_filters( 'directorist_single_listing_header', get_term_meta( $directory_type_id, 'single_listing_header', true ), $data );
}

function directorist_single_listings_contents( int $directory_type_id, array $data = [] ): array {
$data['directory_type_id'] = $directory_type_id;
return apply_filters( 'directorist_single_listings_contents', get_term_meta( $directory_type_id, 'single_listings_contents', true ), $data );
}

function directorist_listing_archive_fields( int $directory_type_id, array $data = [] ): array {
$card_fields = get_term_meta( $directory_type_id, 'listings_card_grid_view', true );
$list_fields = get_term_meta( $directory_type_id, 'listings_card_list_view', true );

$data['directory_type_id'] = $directory_type_id;

return apply_filters(
'directorist_listing_archive_fields',
[
'card_fields' => ! empty( $card_fields ) && is_array( $card_fields ) ? $card_fields : [],
'list_fields' => ! empty( $list_fields ) && is_array( $list_fields ) ? $list_fields : [],
],
$data
);
}
15 changes: 14 additions & 1 deletion includes/model/ListingForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -778,14 +778,27 @@ protected function set_directory() {
return $this->current_listing_type;
}

public function get_listing_owner_id(): int {
if ( $this->add_listing_id ) {
return (int) get_post_field( 'post_author', $this->add_listing_id );
}
return get_current_user_id();
}

public function build_form_data( $type ) {
$form_data = [];

if ( ! $type ) {
return $form_data;
}

$submission_form_fields = get_term_meta( $type, 'submission_form_fields', true );
$submission_form_fields = directorist_submission_form_fields(
(int) $type,
[
'listing_id' => $this->add_listing_id,
'listing_owner_id' => $this->get_listing_owner_id(),
]
);

if ( ! empty( $submission_form_fields['groups'] ) ) {
foreach ( $submission_form_fields['groups'] as $group ) {
Expand Down
16 changes: 8 additions & 8 deletions includes/model/Listings.php
Original file line number Diff line number Diff line change
Expand Up @@ -507,16 +507,12 @@ public function set_loop_data() {
$u_pro_pic = ! empty( $u_pro_pic ) ? wp_get_attachment_image_src( $u_pro_pic, 'thumbnail' ) : '';
$bdbh = get_post_meta( $id, '_bdbh', true );


$listing_type = $this->current_listing_type;
$card_fields = get_term_meta( $listing_type, 'listings_card_grid_view', true );
$list_fields = get_term_meta( $listing_type, 'listings_card_list_view', true );
$get_directory_type = get_term_by( 'id', $this->current_listing_type, ATBDP_TYPE );
$directory_type = ! empty( $get_directory_type ) ? $get_directory_type->slug : '';

$this->loop = [
'id' => $id,
'card_fields' => $card_fields,
'list_fields' => $list_fields,
'permalink' => get_permalink( $id ),
'title' => get_the_title(),
'cats' => get_the_terms( $id, ATBDP_CATEGORY ),
Expand All @@ -541,6 +537,10 @@ public function set_loop_data() {
'avatar_img' => get_avatar( $author_id, apply_filters( 'atbdp_avatar_size', 32 ), '', $author_display_name ),
'review' => $this->get_review_data(),
];

$archive_fields = directorist_listing_archive_fields( $listing_type, [ 'author_id' => $author_id, ] );

$this->loop = array_merge( $this->loop, $archive_fields );
}

public function get_review_data() {
Expand Down Expand Up @@ -1811,12 +1811,12 @@ function loop_get_the_thumbnail( $class = '' ) {
$listing_prv_img = directorist_get_listing_preview_image( $id );
$listing_img = directorist_get_listing_gallery_images( $id );



$thumbnail_img_id = array_filter( array_merge( (array) $listing_prv_img, (array) $listing_img ) );
$link_start = '<a href="' . esc_url( $this->loop['permalink'] ) . '"><figure>';
$link_end = '</figure></a>';

$thumbnail_img_id = apply_filters( 'directorist_listing_archive_thumbnails', $thumbnail_img_id, $id );

if ( empty( $thumbnail_img_id ) ) {
$thumbnail_img_id = $default_image_src;
$image_alt = esc_html( get_the_title( $id ) );
Expand All @@ -1832,7 +1832,7 @@ function loop_get_the_thumbnail( $class = '' ) {
return is_numeric( $value );
}
);

$image_count = count( $thumbnail_img_id );

if ( 1 === (int) $image_count ) {
Expand Down
41 changes: 23 additions & 18 deletions includes/model/SingleListing.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ class Directorist_Single_Listing {

private function __construct( $listing_id = 0 ) {
if ( $listing_id && is_int( $listing_id ) ) {
$this->id = $listing_id;
$this->id = (int) $listing_id;
} else {
$this->id = get_the_ID();
$this->id = (int) get_the_ID();
}

$this->prepare_data();
Expand All @@ -64,10 +64,10 @@ public function get_directory_type_id() {
}

public function prepare_data() {
$this->author_id = get_post_field( 'post_author', $this->id );
$this->author_id = (int) get_post_field( 'post_author', $this->id );
$this->post = get_post( $this->id );
$this->type = $this->get_directory_type_id();
$this->header_data = get_term_meta( $this->type, 'single_listing_header', true );
$this->type = (int) $this->get_directory_type_id();
$this->header_data = directorist_single_listing_header( $this->type, [ 'listing_id' => $this->id, 'listing_owner_id' => $this->author_id, 'directory_type_id' => $this->type ] );
$this->content_data = $this->build_content_data();
$this->fm_plan = get_post_meta( $this->id, '_fm_plans', true );
$this->price_range = get_post_meta( $this->id, '_price_range', true );
Expand All @@ -77,8 +77,14 @@ public function prepare_data() {

public function build_content_data() {
$content_data = [];
$single_fields = get_term_meta( $this->type, 'single_listings_contents', true );
$submission_form_fields = get_term_meta( $this->type, 'submission_form_fields', true );
$single_fields = directorist_single_listings_contents(
$this->type,
[
'listing_id' => (int) $this->id,
'listing_owner_id' => (int) $this->author_id,
]
);
$submission_form_fields = directorist_submission_form_fields_raw( $this->type );

if ( ! empty( $single_fields['fields'] ) ) {
foreach ( $single_fields['fields'] as $key => $value ) {
Expand Down Expand Up @@ -616,6 +622,8 @@ public function get_slider_data( $data = null ) {
array_unshift( $data['images'], $preview_img );
}

$data['images'] = apply_filters( 'directorist_single_listing_thumbnails', $data['images'], $listing_id );

if ( count( $data['images'] ) < 1 ) {
$data['images'][] = [
'alt' => $listing_title,
Expand All @@ -629,7 +637,6 @@ public function get_slider_data( $data = null ) {
}

public function slider_template() {

$slider = $this->listing_header( 'slider', 'slider-placeholder' );

if ( ! $slider ) {
Expand All @@ -640,7 +647,6 @@ public function slider_template() {
}

public function slider_field_template( $slider = null ) {

$args = [
'listing' => $this,
'has_slider' => true,
Expand Down Expand Up @@ -1037,23 +1043,22 @@ public function listing_header( $key = '', $group = '', $subgroup = '' ) {
}

public function header_template() {

$display_title = $this->listing_header( 'title', 'listing-title-placeholder' );
$args = [
'listing' => $this,
'use_listing_title' => true,
'section_title' => '',
'section_icon' => '',
'display_title' => $display_title,
'display_tagline' => ! empty( $display_title['enable_tagline'] ) ? $display_title['enable_tagline'] : false,
'display_content' => false,
'listing' => $this,
'use_listing_title' => true,
'section_title' => '',
'section_icon' => '',
'display_title' => $display_title,
'display_tagline' => ! empty( $display_title['enable_tagline'] ) ? $display_title['enable_tagline'] : false,
'display_content' => false,
];

return Helper::get_template( 'single/header', $args );
}

public function render_shortcode_single_listing() {

if ( ! is_singular( ATBDP_POST_TYPE ) ) {
return;
}
Expand Down
19 changes: 12 additions & 7 deletions templates/listing-form/fields/image_upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,18 @@
$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 = [
'type' => join( ', ', $accepted_mime_types ),
'max_num_of_img' => $limit,
'max_total_img_size' => $max_total_file_size_kb,
'is_required' => $required,
'max_size_per_img' => $max_file_size_kb,
];
$img_upload_data = apply_filters(
'directorist_image_upload_config',
[
'type' => join( ', ', $accepted_mime_types ),
'max_num_of_img' => $limit,
'max_total_img_size' => $max_total_file_size_kb,
'is_required' => $required,
'max_size_per_img' => $max_file_size_kb,
],
$listing_form,
$data
);

$img_upload_data = json_encode( $img_upload_data );
?>
Expand Down
Loading