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
88 changes: 0 additions & 88 deletions includes/classes/class-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,94 +19,6 @@ public function __construct()
add_action('init', [$this, 'check_req_php_version'], 100);
}

// get_plasma_slider
public static function get_plasma_slider($args)
{
$data = [];
$default_image = get_directorist_option(
'default_preview_image',
DIRECTORIST_ASSETS . 'images/grid.jpg'
);
$background_type = get_directorist_option('single_slider_background_type', 'custom-color');

// Default
$data['show-slider'] = get_directorist_option('dsiplay_slider_single_page', true);
$is_enabled = (true == $data['show-slider'] || '1' === $data['show-slider']) ? true : false;

if (!$is_enabled) {
return '';
}

$default_image = get_directorist_option('default_preview_image', DIRECTORIST_ASSETS . 'images/grid.jpg');
$data['images'] = [];
$data['alt'] = '';
$data['background-size'] = get_directorist_option('single_slider_image_size', 'cover');
$data['blur-background'] = ('blur' === $background_type) ? true : false;
$data['width'] = get_directorist_option('gallery_crop_width', 670);
$data['height'] = get_directorist_option('gallery_crop_height', 750);
$data['background-color'] = get_directorist_option('single_slider_background_color', 'gainsboro');
$data['thumbnail-background-color'] = '#fff';
$data['show-thumbnails'] = get_directorist_option('dsiplay_thumbnail_img', true);
$data['gallery'] = true;
$data['rtl'] = is_rtl();

// Extend Default
if (isset($args['plan_slider'])) {
$data['gallery'] = $args['plan_slider'];
}

if (isset($args['listing_prv_imgurl']) && !empty($args['listing_prv_imgurl'])) {
array_push($data['images'], $args['listing_prv_imgurl']);
}
if ($data['gallery'] && isset($args['image_links']) && is_array($args['image_links'])) {
foreach ($args['image_links'] as $image) {
array_push($data['images'], $image);
}
}

if (count($data['images']) < 1) {
array_push($data['images'], $default_image);
}

if (count($data['images']) < 1) {
array_push($data['images'], $default_image);
}

if (isset($args['p_title'])) {
$data['alt'] = $args['p_title'];
}
if (isset($args['thumbnail-background-color'])) {
$data['thumbnail-background-color'] = $args['thumbnail-background-color'];
}
if (isset($args['background-color'])) {
$data['background-color'] = $args['background-color'];
}

$padding_top = $data['height'] / $data['width'] * 100;
$data['padding-top'] = $padding_top;

return self::get_view('plasma-slider', $data);
}

public static function view($file_path, $data = null)
{
$path = ATBDP_VIEW_DIR . $file_path . '.php';
if (file_exists($path)) {
require_once $path;
}
}

public static function get_view($file_path, $data = null)
{
$view = '';
ob_start();
self::view($file_path, $data);
$view = ob_get_contents();
ob_end_clean();

return $view;
}

// get_default_slider
public static function get_default_slider($args)
{
Expand Down
110 changes: 0 additions & 110 deletions includes/helper-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -8014,121 +8014,11 @@ function the_thumbnail_card($img_src = '', $_args = array()) {
return atbdp_thumbnail_card($img_src,$_args);
}


// get_plasma_slider
function get_plasma_slider()
{
$show_slider = get_directorist_option( 'dsiplay_slider_single_page', 1 );
$slider_is_enabled = ( $show_slider === 1 || $show_slider === '1' ) ? true : false;

if ( ! $slider_is_enabled ) { return ''; }

global $post;
$listing_id = $post->ID;
$listing_title = get_the_title( $post->ID );
$data = array();

// Check if gallery is allowed or not
$fm_plan = get_post_meta($listing_id, '_fm_plans', true);
$show_gallery = true;

if ( is_fee_manager_active() ) {
$show_gallery = is_plan_allowed_slider($fm_plan);
}

// Get the default image
$default_image = get_directorist_option(
'default_preview_image', DIRECTORIST_ASSETS . 'images/grid.jpg'
);

// 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_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 );

// Get the gallery images
$listing_img = get_post_meta( $listing_id, '_listing_img', true );
$listing_imgs = ( ! empty( $listing_img ) ) ? $listing_img : array();
$image_links = array(); // define a link placeholder variable

foreach ( $listing_imgs as $img_id ) {
$alt = get_post_meta( $img_id, '_wp_attachment_image_alt', true );
$alt = ( ! empty( $alt ) ) ? $alt : get_the_title( $img_id );

$image_links[] = [
'alt' => ( ! empty( $alt ) ) ? $alt : $listing_title,
'src' => atbdp_get_image_source( $img_id, 'large' ),
];
}

// Get the options
$background_type = get_directorist_option('single_slider_background_type', 'custom-color');

// Set the options
$data['images'] = [];
$data['alt'] = $listing_title;
$data['background-size'] = get_directorist_option('single_slider_image_size', 'cover');
$data['blur-background'] = ( 'blur' === $background_type ) ? true : false;
$data['width'] = get_directorist_option('gallery_crop_width', 670);
$data['height'] = get_directorist_option('gallery_crop_height', 750);
$data['background-color'] = get_directorist_option('single_slider_background_color', 'gainsboro');
$data['thumbnail-bg-color'] = '#fff';
$data['show-thumbnails'] = get_directorist_option('dsiplay_thumbnail_img', true);
$data['gallery'] = true;
$data['rtl'] = is_rtl();

if ( $show_gallery && ! empty( $image_links ) ) {
$data['images'] = $image_links;
}

if ( ! empty( $preview_img_link ) ) {
$preview_img = [
'alt' => $preview_img_alt,
'src' => $preview_img_link,
];

array_unshift( $data['images'], $preview_img );
}

if ( count( $data['images'] ) < 1 ) {
$data['images'][] = [
'alt' => $listing_title,
'src' => $default_image,
];
}

$padding_top = $data['height'] / $data['width'] * 100;
$data['padding-top'] = $padding_top;

return get_view('plasma-slider', $data);
}


function atbdp_style_example_image ($src) {
$img = sprintf("<img src='%s'>", $src );
echo $img;
}

function view( $file_path, $data = null )
{
$path = ATBDP_VIEW_DIR . $file_path . '.php';
if ( file_exists($path) ) {
include($path);
}
}

function get_view( $file_path, $data = null )
{
$view = '';
ob_start();
view( $file_path, $data );
$view = ob_get_contents();
ob_end_clean();

return $view;
}

if(!function_exists('csv_get_data')){
function csv_get_data($default_file = null, $multiple = null, $delimiter = ',')
{
Expand Down
31 changes: 0 additions & 31 deletions includes/view/plasma-slider.php

This file was deleted.

8 changes: 4 additions & 4 deletions templates/single/slider.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
$img_size_class = ( 'contain' === $data['background-size'] ) ? '' : ' plasmaSlider__cover';
?>
<div id="directorist-single-listing-slider" class="plasmaSlider"
data-width="<?php echo esc_attr( $data['width'] ); ?>"
data-height="<?php echo esc_attr( $data['height'] ); ?>"
data-width="<?php echo esc_attr( $data['width'] ); ?>"
data-height="<?php echo esc_attr( $data['height'] ); ?>"
data-rtl="<?php echo esc_attr( $data['rtl'] ); ?>"
data-show-thumbnails="<?php echo esc_attr( $data['show-thumbnails'] ); ?>"
data-background-size="<?php echo esc_attr( $data['background-size'] ); ?>"
Expand All @@ -23,7 +23,7 @@
data-thumbnail-background-color="<?php echo esc_attr( $data['thumbnail-bg-color'] ); ?>">

<div class="plasmaSliderTempImage" style="padding-top: <?php echo $data['padding-top'] ."%;" ?>">
<?php
<?php
if ( ! empty( $data['images'] ) ) :
$img_src = $data['images'][0]['src'];
$img_alt = $data['images'][0]['alt'];
Expand All @@ -34,7 +34,7 @@
echo "<img class='plasmaSliderTempImg {$img_size_class}' src='{$img_src}' alt='{$img_alt}'/>";
endif; ?>
</div>

<div class="plasmaSliderImages">
<?php
if ( ! empty( $data['images'] ) ):
Expand Down