Skip to content

Commit

Permalink
Improved custom single listing page (sovware#1187)
Browse files Browse the repository at this point in the history
  • Loading branch information
kowsar89 authored Sep 11, 2022
1 parent 32f9047 commit 875c5f3
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 13 deletions.
12 changes: 12 additions & 0 deletions assets/css/all-listings.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions assets/css/all-listings.rtl.css
Original file line number Diff line number Diff line change
Expand Up @@ -11723,6 +11723,18 @@ input.directorist-toggle-input:checked + .directorist-toggle-input-label span.di
color: #fff;
}

.directorist-single-dummy-shortcode {
width: 100%;
background-color: #556166;
color: #fff;
margin: 10px 0;
text-align: center;
padding: 40px 10px;
font-weight: 700;
font-size: 16px;
line-height: 1.2;
}

.directorist-signle-listing-top {
margin-bottom: 15px;
}
Expand Down
12 changes: 12 additions & 0 deletions assets/css/public-main.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions assets/css/public-main.rtl.css
Original file line number Diff line number Diff line change
Expand Up @@ -11723,6 +11723,18 @@ input.directorist-toggle-input:checked + .directorist-toggle-input-label span.di
color: #fff;
}

.directorist-single-dummy-shortcode {
width: 100%;
background-color: #556166;
color: #fff;
margin: 10px 0;
text-align: center;
padding: 40px 10px;
font-weight: 700;
font-size: 16px;
line-height: 1.2;
}

.directorist-signle-listing-top {
margin-bottom: 15px;
}
Expand Down
8 changes: 4 additions & 4 deletions assets/js/admin-main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion assets/src/scss/component/listing-details/_general.scss
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,16 @@
}
}
}
}
}

.directorist-single-dummy-shortcode {
width: 100%;
background-color: #556166;
color: #fff;
margin: 10px 0;
text-align: center;
padding: 40px 10px;
font-weight: 700;
font-size: 16px;
line-height: 1.2;
}
14 changes: 14 additions & 0 deletions includes/class-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -537,9 +537,23 @@ public static function featured_badge_text() {
return get_directorist_option('feature_badge_text', 'Featured');
}

public static function single_listing_dummy_shortcode( $shortcode, $atts = [] ) {
$atts_string = '';

if ( $atts ) {
foreach ( $atts as $key => $value ) {
$atts_string .= sprintf( ' %s="%s"', $key, $value );
}
}

return sprintf( '<div class="directorist-single-dummy-shortcode">%s%s</div>', $shortcode, $atts_string );
}

/**
* Get a list of directories that has custom single listing page enabled and set.
*
* @todo remove this unused method
*
* @param int|null $page_id Optional page id.
*
* @return array
Expand Down
10 changes: 8 additions & 2 deletions includes/classes/class-shortcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ public function __construct() {
return self::$instance;
}

// single_listings_header
public function single_listings_header( $atts ) {

// Render dummy shortcode content when user isn't in single listing page
if ( !is_singular( ATBDP_POST_TYPE ) ) {
return '';
return Helper::single_listing_dummy_shortcode( 'directorist_single_listings_header', $atts );
}

$listing_id = ( isset( $atts['post_id'] ) && is_numeric( $atts['post_id'] ) ) ? ( int ) esc_attr( $atts['post_id'] ) : 0;
Expand Down Expand Up @@ -107,6 +107,12 @@ public function single_listings_header( $atts ) {
}

public function single_listing_section( $atts = array() ) {

// Render dummy shortcode content when user isn't in single listing page
if ( !is_singular( ATBDP_POST_TYPE ) ) {
return Helper::single_listing_dummy_shortcode( 'directorist_single_listing_section', $atts );
}

$listing_id = ( isset( $atts['post_id'] ) && is_numeric( $atts['post_id'] ) ) ? ( int ) esc_attr( $atts['post_id'] ) : 0;

if ( ! $listing_id ) {
Expand Down
6 changes: 0 additions & 6 deletions includes/classes/class-template-hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,6 @@ public static function single_content( $content ) {
return Helper::get_template_contents( 'single-contents' );
}

$directory_types = Helper::get_directory_types_with_custom_single_page( get_the_ID() );
if ( get_post_type() === 'page' && ! empty( $directory_types ) ) {
$directory_names = wp_list_pluck( $directory_types, 'name' );
return sprintf( __( '<p style="text-align:center" class="directorist-alert directorist-alert-info">This page is currently selected as single Listing details page for %s directory.</p>', 'directorist' ) , implode( ', ', $directory_names ) );
}

return $content;
}

Expand Down

0 comments on commit 875c5f3

Please sign in to comment.