Skip to content

Commit

Permalink
Merge pull request #3 from Armanul46/improve/v8-beta
Browse files Browse the repository at this point in the history
Improve/v8 beta
  • Loading branch information
iamibrahimriaz authored Dec 20, 2023
2 parents 80bf62a + 142f607 commit 4a01df8
Show file tree
Hide file tree
Showing 11 changed files with 75 additions and 64 deletions.
16 changes: 9 additions & 7 deletions includes/model/ListingAuthor.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,16 +238,18 @@ public function author_listings_query() {
}

public function avatar_html() {
$html = '';
$author_id = $this->id;
$u_pro_pic = get_user_meta( $author_id, 'pro_pic', true );

if ( !empty( $u_pro_pic ) ) {
$html = '';
$author_id = $this->id;
$u_pro_pic = get_user_meta( $author_id, 'pro_pic', true );
$author_data = get_userdata( $author_id );
$display_name = ! empty( $author_data->display_name ) ? $author_data->display_name : '';

if ( ! empty( $u_pro_pic ) ) {
$html = wp_get_attachment_image( $u_pro_pic );
}

if ( !$html ) {
$html = get_avatar( $author_id );
if ( ! $html ) {
$html = get_avatar( $author_id, 96, '', $display_name );
}

return $html;
Expand Down
80 changes: 48 additions & 32 deletions includes/model/Listings.php
Original file line number Diff line number Diff line change
Expand Up @@ -396,12 +396,13 @@ public function set_loop_data() {
$author_id = get_the_author_meta( 'ID' );
$author_data = get_userdata( $author_id );

$author_first_name = ! empty( $author_data ) ? $author_data->first_name : '';
$author_last_name = ! empty( $author_data ) ? $author_data->last_name : '';
$author_first_name = ! empty( $author_data ) ? $author_data->first_name : '';
$author_last_name = ! empty( $author_data ) ? $author_data->last_name : '';
$author_display_name = ! empty( $author_data->display_name ) ? $author_data->display_name : '';

$u_pro_pic = get_user_meta( $author_id, 'pro_pic', true );
$u_pro_pic = ! empty( $u_pro_pic ) ? wp_get_attachment_image_src( $u_pro_pic, 'thumbnail' ) : '';
$bdbh = get_post_meta( $id, '_bdbh', true );
$u_pro_pic = get_user_meta( $author_id, 'pro_pic', true );
$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;
Expand Down Expand Up @@ -434,7 +435,7 @@ public function set_loop_data() {
'author_link' => ATBDP_Permalink::get_user_profile_page_link( $author_id, $directory_type ),
'author_link_class' => ! empty( $author_first_name && $author_last_name ) ? 'atbd_tooltip' : '',
'u_pro_pic' => $u_pro_pic,
'avatar_img' => get_avatar( $author_id, apply_filters( 'atbdp_avatar_size', 32 ) ),
'avatar_img' => get_avatar( $author_id, apply_filters( 'atbdp_avatar_size', 32 ), '', $author_display_name ),
'review' => $this->get_review_data(),
);
}
Expand Down Expand Up @@ -1634,43 +1635,58 @@ function loop_get_the_thumbnail( $class = '' ) {
$listing_prv_img = get_post_meta($id, '_listing_prv_img', true);
$listing_img = get_post_meta($id, '_listing_img', true);
$thumbnail_img_id = array_filter( array_merge( (array) $listing_prv_img, (array) $listing_img ) );
$link_start = '<a href="'. esc_url( $this->loop['permalink'] ) .'">';
$link_end = '</a>';

if ( empty( $thumbnail_img_id ) ) {
$thumbnail_img_id = $default_image_src;
$image_alt = esc_html( get_the_title( $id ) );
return "<img src='$default_image_src' alt='$image_alt' class='$class' />";
$image_alt = esc_html( get_the_title( $id ) );
$image = "<img src='$default_image_src' alt='$image_alt' class='$class' />";
if ( ! $this->disable_single_listing ) {
$image = $link_start . $image . $link_end;
}
return $image;
}

$image_count = count( $thumbnail_img_id );

if ( 1 === (int) $image_count ) {
$image_src = atbdp_get_image_source( reset( $thumbnail_img_id ), $image_quality );
$image_alt = get_post_meta( reset( $thumbnail_img_id ), '_wp_attachment_image_alt', true );
$image_alt = ( ! empty( $image_alt ) ) ? esc_attr( $image_alt ) : esc_html( get_the_title( reset( $thumbnail_img_id ) ) );

return "<img src='$image_src' alt='$image_alt' class='$class' />";

$image_src = atbdp_get_image_source( reset( $thumbnail_img_id ), $image_quality );
$image_alt = get_post_meta( reset( $thumbnail_img_id ), '_wp_attachment_image_alt', true );
$image_alt = ( ! empty( $image_alt ) ) ? esc_attr( $image_alt ) : esc_html( get_the_title( reset( $thumbnail_img_id ) ) );
$image = "<img src='$image_src' alt='$image_alt' class='$class' />";
if ( ! $this->disable_single_listing ) {
$image = $link_start . $image . $link_end;
}
return $image;
} else {
ob_start();
echo "<div class='directorist-swiper directorist-swiper-listing' data-sw-items='1' data-sw-margin='2' data-sw-loop='true' data-sw-perslide='1' data-sw-speed='300' data-sw-autoplay='false' data-sw-responsive='{}' >
<div class='swiper-wrapper'>";
foreach ( $thumbnail_img_id as $img_id ) {
$output = "<div class='directorist-swiper directorist-swiper-listing' data-sw-items='1' data-sw-margin='2' data-sw-loop='true' data-sw-perslide='1' data-sw-speed='300' data-sw-autoplay='false' data-sw-responsive='{}'>
<div class='swiper-wrapper'>";

foreach ( $thumbnail_img_id as $img_id ) {
$image_src = atbdp_get_image_source( $img_id, $image_quality );
$image_alt = get_post_meta($img_id, '_wp_attachment_image_alt', true);
$image_alt = ( ! empty( $image_alt ) ) ? esc_attr( $image_alt ) : esc_html( get_the_title( $img_id ) );
echo "<div class='swiper-slide'>
<img src='$image_src' alt='$image_alt' class='$class' />
</div>";
$image_alt = get_post_meta( $img_id, '_wp_attachment_image_alt', true );
$image_alt = ! empty( $image_alt ) ? esc_attr( $image_alt ) : esc_html( get_the_title( $img_id ) );
$image = "<img src='$image_src' alt='$image_alt' class='$class' />";

if ( ! $this->disable_single_listing ) {
$image = $link_start . $image . $link_end;
}

$output .= "<div class='swiper-slide'>$image</div>";
}
echo "</div>
<div class='directorist-swiper__navigation'>
<div class='directorist-swiper__nav directorist-swiper__nav--prev directorist-swiper__nav--prev-listing'>".directorist_icon('las la-angle-left', false)."</div>
<div class='directorist-swiper__nav directorist-swiper__nav--next directorist-swiper__nav--next-listing'>".directorist_icon('las la-angle-right', false)."</div>
</div>
<div class='directorist-swiper__pagination directorist-swiper__pagination--listing'></div>
</div>";
return ob_get_clean();

$output .= "</div>
<div class='directorist-swiper__navigation'>
<div class='directorist-swiper__nav directorist-swiper__nav--prev directorist-swiper__nav--prev-listing'>" . directorist_icon( 'las la-angle-left', false ) . "</div>
<div class='directorist-swiper__nav directorist-swiper__nav--next directorist-swiper__nav--next-listing'>" . directorist_icon( 'las la-angle-right', false ) . "</div>
</div>
<div class='directorist-swiper__pagination directorist-swiper__pagination--listing'></div>
</div>";

return $output;

}
}

Expand Down
5 changes: 3 additions & 2 deletions templates/archive/fields/posted_date.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
*/

if ( ! defined( 'ABSPATH' ) ) exit;
$container_element = $listings->view === 'list' ? 'div' : 'li';
?>

<li class="directorist-listing-card-posted-on">
<<?php echo esc_html( $container_element ); ?> class="directorist-listing-card-posted-on">
<?php directorist_icon( $icon );?>
<span>
<?php echo esc_html( $listings->loop_get_published_date( $data ) );?>
</span>
</li>
</<?php echo esc_html( $container_element ); ?>>
10 changes: 1 addition & 9 deletions templates/archive/fields/thumb-card.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* @author wpWax
* @since 6.6
* @version 7.7.0
* @version 8.0
*/

if ( ! defined( 'ABSPATH' ) ) exit;
Expand Down Expand Up @@ -74,12 +74,4 @@
$link_start = '<a href="'.esc_url( $listings->loop['permalink'] ).'">';
$link_end = '</a>';

if (!$listings->disable_single_listing) {
echo wp_kses_post( $link_start );
}

echo wp_kses_post( $the_html );

if (!$listings->disable_single_listing) {
echo wp_kses_post( $link_end );
}
4 changes: 2 additions & 2 deletions templates/search-form/fields/email.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
<div class="directorist-search-field directorist-form-group">

<?php if ( ! empty( $data['label'] ) ) : ?>
<label class="directorist-search-field__label"><?php echo esc_attr( $data['label'] ); ?></label>
<label class="directorist-search-field__label" for="<?php echo esc_attr( $data['field_key'] ?? '' ); ?>"><?php echo esc_attr( $data['label'] ); ?></label>
<?php endif; ?>

<input class="directorist-form-element directorist-search-field__input" type="text" name="<?php echo esc_attr( $data['field_key'] ); ?>" value="<?php echo esc_attr( $value ); ?>" placeholder="<?php echo esc_attr( $data['placeholder'] ?? '' ); ?>" <?php echo ! empty( $data['required'] ) ? 'required="required"' : ''; ?>>
<input class="directorist-form-element directorist-search-field__input" id="<?php echo esc_attr( $data['field_key'] ?? '' ); ?>" type="text" name="<?php echo esc_attr( $data['field_key'] ); ?>" value="<?php echo esc_attr( $value ); ?>" placeholder="<?php echo esc_attr( $data['placeholder'] ?? '' ); ?>" <?php echo ! empty( $data['required'] ) ? 'required="required"' : ''; ?>>

<div class="directorist-search-field__btn directorist-search-field__btn--clear">
<?php directorist_icon( 'fas fa-times-circle' ); ?>
Expand Down
4 changes: 2 additions & 2 deletions templates/search-form/fields/fax.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
<div class="directorist-search-field directorist-form-group">

<?php if ( ! empty( $data['label'] ) ) : ?>
<label class="directorist-search-field__label"><?php echo esc_attr( $data['label'] ); ?></label>
<label class="directorist-search-field__label" for="<?php echo esc_attr( $data['field_key'] ?? '' ); ?>"><?php echo esc_attr( $data['label'] ); ?></label>
<?php endif; ?>

<input class="directorist-form-element directorist-search-field__input" type="text" name="<?php echo esc_attr( $data['field_key'] ); ?>" value="<?php echo esc_attr( $value ); ?>" placeholder="<?php echo esc_attr( $data['placeholder'] ?? '' ); ?>" <?php echo ! empty( $data['required'] ) ? 'required="required"' : ''; ?>>
<input class="directorist-form-element directorist-search-field__input" id="<?php echo esc_attr( $data['field_key'] ?? '' ); ?>" type="text" name="<?php echo esc_attr( $data['field_key'] ); ?>" value="<?php echo esc_attr( $value ); ?>" placeholder="<?php echo esc_attr( $data['placeholder'] ?? '' ); ?>" <?php echo ! empty( $data['required'] ) ? 'required="required"' : ''; ?>>
<div class="directorist-search-field__btn directorist-search-field__btn--clear">
<?php directorist_icon( 'fas fa-times-circle' ); ?>
</div>
Expand Down
4 changes: 2 additions & 2 deletions templates/search-form/fields/phone.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
<div class="directorist-search-field directorist-form-group">

<?php if ( ! empty( $data['label'] ) ) : ?>
<label class="directorist-search-field__label"><?php echo esc_attr( $data['label'] ); ?></label>
<label class="directorist-search-field__label" for="<?php echo esc_attr( $data['field_key'] ?? '' ); ?>"><?php echo esc_attr( $data['label'] ); ?></label>
<?php endif; ?>

<input class="directorist-form-element directorist-search-field__input" type="text" name="<?php echo esc_attr( $data['field_key'] ); ?>" value="<?php echo esc_attr( $value ); ?>" placeholder="<?php echo esc_attr( $data['placeholder'] ?? '' ); ?>" <?php echo ! empty( $data['required'] ) ? 'required="required"' : ''; ?>>
<input class="directorist-form-element directorist-search-field__input" id="<?php echo esc_attr( $data['field_key'] ?? '' ); ?>" type="text" name="<?php echo esc_attr( $data['field_key'] ); ?>" value="<?php echo esc_attr( $value ); ?>" placeholder="<?php echo esc_attr( $data['placeholder'] ?? '' ); ?>" <?php echo ! empty( $data['required'] ) ? 'required="required"' : ''; ?>>

<div class="directorist-search-field__btn directorist-search-field__btn--clear">
<?php directorist_icon( 'fas fa-times-circle' ); ?>
Expand Down
4 changes: 2 additions & 2 deletions templates/search-form/fields/phone2.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
<div class="directorist-search-field directorist-form-group">

<?php if ( ! empty( $data['label'] ) ) : ?>
<label class="directorist-search-field__label"><?php echo esc_attr( $data['label'] ); ?></label>
<label class="directorist-search-field__label" for="<?php echo esc_attr( $data['field_key'] ?? '' ); ?>"><?php echo esc_attr( $data['label'] ); ?></label>
<?php endif; ?>

<input class="directorist-form-element directorist-search-field__input" type="text" name="<?php echo esc_attr( $data['field_key'] ); ?>" value="<?php echo esc_attr( $value ); ?>" placeholder="<?php echo esc_attr( $data['placeholder'] ?? '' ); ?>" <?php echo ! empty( $data['required'] ) ? 'required="required"' : ''; ?>>
<input class="directorist-form-element directorist-search-field__input" id="<?php echo esc_attr( $data['field_key'] ?? '' ); ?>" type="text" name="<?php echo esc_attr( $data['field_key'] ); ?>" value="<?php echo esc_attr( $value ); ?>" placeholder="<?php echo esc_attr( $data['placeholder'] ?? '' ); ?>" <?php echo ! empty( $data['required'] ) ? 'required="required"' : ''; ?>>

<div class="directorist-search-field__btn directorist-search-field__btn--clear">
<?php directorist_icon( 'fas fa-times-circle' ); ?>
Expand Down
4 changes: 2 additions & 2 deletions templates/search-form/fields/title.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
<div class="directorist-search-field directorist-form-group directorist-search-query">

<?php if ( ! empty( $data['label'] ) ) : ?>
<label class="directorist-search-field__label"><?php echo esc_attr( $data['label'] ); ?></label>
<label class="directorist-search-field__label" for="<?php echo esc_attr( $data['field_key'] ?? '' ); ?>"><?php echo esc_attr( $data['label'] ); ?></label>
<?php endif; ?>

<input class="directorist-form-element directorist-search-field__input" type="text" name="q" value="<?php echo esc_attr( $value ); ?>" placeholder="<?php echo esc_attr( $data['placeholder'] ?? '' ); ?>" <?php echo ! empty( $data['required'] ) ? 'required="required"' : ''; ?>>
<input class="directorist-form-element directorist-search-field__input" id="<?php echo esc_attr( $data['field_key'] ?? '' ); ?>" type="text" name="q" value="<?php echo esc_attr( $value ); ?>" placeholder="<?php echo esc_attr( $data['placeholder'] ?? '' ); ?>" <?php echo ! empty( $data['required'] ) ? 'required="required"' : ''; ?>>

<div class="directorist-search-field__btn directorist-search-field__btn--clear">
<?php directorist_icon( 'fas fa-times-circle' ); ?>
Expand Down
4 changes: 2 additions & 2 deletions templates/search-form/fields/website.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
<div class="directorist-search-field directorist-form-group">

<?php if ( ! empty( $data['label'] ) ) : ?>
<label class="directorist-search-field__label"><?php echo esc_attr( $data['label'] ); ?></label>
<label class="directorist-search-field__label" for="<?php echo esc_attr( $data['field_key'] ?? '' ); ?>"><?php echo esc_attr( $data['label'] ); ?></label>
<?php endif; ?>

<input class="directorist-form-element directorist-search-field__input" type="text" name="<?php echo esc_attr( $data['field_key'] ); ?>" value="<?php echo esc_attr( $value ); ?>" placeholder="<?php echo esc_attr( $data['placeholder'] ?? '' ); ?>" <?php echo ! empty( $data['required'] ) ? 'required="required"' : ''; ?>>
<input class="directorist-form-element directorist-search-field__input" id="<?php echo esc_attr( $data['field_key'] ?? '' ); ?>" type="text" name="<?php echo esc_attr( $data['field_key'] ); ?>" value="<?php echo esc_attr( $value ); ?>" placeholder="<?php echo esc_attr( $data['placeholder'] ?? '' ); ?>" <?php echo ! empty( $data['required'] ) ? 'required="required"' : ''; ?>>

<div class="directorist-search-field__btn directorist-search-field__btn--clear">
<?php directorist_icon( 'fas fa-times-circle' ); ?>
Expand Down
4 changes: 2 additions & 2 deletions templates/search-form/fields/zip.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
<div class="directorist-search-field directorist-form-group directorist-zipcode-search">

<?php if ( ! empty( $data['label'] ) ) : ?>
<label class="directorist-search-field__label"><?php echo esc_attr( $data['label'] ); ?></label>
<label class="directorist-search-field__label" for="<?php echo esc_attr( $data['field_key'] ?? '' ); ?>"><?php echo esc_attr( $data['label'] ); ?></label>
<?php endif; ?>

<input class="<?php echo esc_attr( $searchform->zip_code_class() ); ?> directorist-search-field__input" type="text" name="<?php echo esc_attr( $data['field_key'] ); ?>" value="<?php echo esc_attr( $value ); ?>" autocomplete="off" placeholder="<?php echo esc_attr( $data['placeholder'] ?? '' ); ?>" <?php echo ! empty( $data['required'] ) ? 'required="required"' : ''; ?>>
<input class="<?php echo esc_attr( $searchform->zip_code_class() ); ?> directorist-search-field__input" id="<?php echo esc_attr( $data['field_key'] ?? '' ); ?>" type="text" name="<?php echo esc_attr( $data['field_key'] ); ?>" value="<?php echo esc_attr( $value ); ?>" autocomplete="off" placeholder="<?php echo esc_attr( $data['placeholder'] ?? '' ); ?>" <?php echo ! empty( $data['required'] ) ? 'required="required"' : ''; ?>>

<div class="directorist-country directorist-search-country" style="display: none"></div>
<input type="hidden" class="zip-cityLat" name="zip_cityLat" value="<?php echo esc_attr( $lat ) ?>" />
Expand Down

0 comments on commit 4a01df8

Please sign in to comment.