Skip to content
53 changes: 43 additions & 10 deletions includes/model/Listings.php
Original file line number Diff line number Diff line change
Expand Up @@ -1282,11 +1282,20 @@ public function render_list_view( $post_ids ) {
}

foreach ( $post_ids as $listing_id ) {
?>
<div class="directorist-col-12">
<?php $this->loop_template( 'list', $listing_id ); ?>
</div>
<?php

$is_slider = apply_filters(
'directorist_listings_list_items_view_before',
false,
$this
);

if ( $is_slider ) : ?>
<div class="listing-slider-style">
<?php $this->loop_template( 'list', $listing_id ); ?>
</div>
<?php else :
$this->loop_template( 'list', $listing_id );
endif;
}
}

Expand All @@ -1297,11 +1306,35 @@ public function render_grid_view( $post_ids ) {
}

foreach ( $post_ids as $listing_id ) {
?>
<div class="<?php Helper::directorist_column( $this->columns ); ?>">

$is_slider = apply_filters(
'directorist_listings_grid_items_view_before',
false,
$this
);

$default_wrapper_class = '';
ob_start();
Helper::directorist_column( $this->columns );
$default_wrapper_class = trim( ob_get_clean() );

$grid_item_wrapper_class = apply_filters(
'directorist_listings_grid_item_wrapper_class',
$default_wrapper_class,
$this
);

$has_grid_item_wrapper = ( ! $is_slider && '' !== trim( (string) $grid_item_wrapper_class ) );

if ( $has_grid_item_wrapper ) : ?>
<div class="<?php echo esc_attr( $grid_item_wrapper_class ); ?>">
<?php endif; ?>

<?php $this->loop_template( 'grid', $listing_id ); ?>
</div>
<?php

<?php if ( $has_grid_item_wrapper ) : ?>
</div>
<?php endif;
}
}

Expand Down Expand Up @@ -1339,7 +1372,7 @@ public function loop_template( $loop = 'grid', $id = NULL ) {
$template = ( $active_template == 'list_view_with_thumbnail' && $this->display_preview_image ) ? 'loop-list' : 'loop-list-nothumb';
Helper::get_template( 'archive/' . $template, [ 'listings' => $this ] );
}

wp_reset_postdata();
}

Expand Down
18 changes: 12 additions & 6 deletions templates/archive/grid-view.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,19 @@
<?php do_action( 'directorist_before_grid_listings_loop' ); ?>

<?php if ( $listings->have_posts() ) : ?>

<div class="<?php echo $listings->has_masonry() ? 'directorist-masonry' : ''; ?> <?php Helper::directorist_row(); ?>">

<?php $listings->render_grid_view( $listings->post_ids() ) ?>

<?php
ob_start();
Helper::directorist_row();
$row_class = trim( ob_get_clean() );
$default_class = ( $listings->has_masonry() ? 'directorist-masonry' : '' ) . ' ' . $row_class;
?>
<div class="<?php echo esc_attr( apply_filters(
'directorist_grid_view_wrapper_class',
$default_class,
$listings
) ); ?>">
<?php $listings->render_grid_view( $listings->post_ids() ) ?>
</div>

<?php
if ( $listings->show_pagination && 'numbered' === $listings->options['pagination_type'] ) {

Expand Down
32 changes: 14 additions & 18 deletions templates/archive/list-view.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,20 @@
<?php do_action( 'directorist_before_list_listings_loop' ); ?>

<?php if ( $listings->have_posts() ) : ?>

<div class="<?php Helper::directorist_row(); ?>">
<?php $listings->render_list_view( $listings->post_ids() ) ?>
</div>
<div/>

<?php
if ( $listings->show_pagination && 'numbered' === $listings->options['pagination_type'] ) {

do_action( 'directorist_before_listings_pagination' );

$listings->pagination();

do_action( 'directorist_after_listings_pagination' );
}
?>

<?php do_action( 'directorist_after_grid_listings_loop' ); ?>
<?php
ob_start();
Helper::directorist_row();
$row_class = trim( ob_get_clean() );
?>
<div class="<?php echo esc_attr(
apply_filters(
'directorist_list_view_wrapper_class',
$row_class,
$listings
)
); ?>">
<?php $listings->render_list_view( $listings->post_ids() ) ?>
</div>

<?php else : ?>

Expand Down
1 change: 0 additions & 1 deletion templates/archive/loop-grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

if ( ! defined( 'ABSPATH' ) ) exit;

$loop_fields = $listings->loop['card_fields']['template_data']['grid_view_with_thumbnail'];
?>

Expand Down
Loading