| 1 |
<?php |
| 2 |
/** |
| 3 |
* Bricks Builder Property Images Widget. |
| 4 |
* |
| 5 |
* @since 1.0.0 |
| 6 |
*/ |
| 7 |
|
| 8 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 9 |
|
| 10 |
class Bricks_Builder_Property_Images_Widget extends \Bricks\Element { |
| 11 |
|
| 12 |
// Element properties |
| 13 |
public $category = 'propertyhive'; |
| 14 |
public $name = 'bricks-builder-property-images'; |
| 15 |
public $icon = 'fas fa-images'; |
| 16 |
public $scripts = ['ph_init_slideshow']; |
| 17 |
|
| 18 |
public function get_label() |
| 19 |
{ |
| 20 |
return esc_html__( 'Images', 'propertyhive' ); |
| 21 |
} |
| 22 |
|
| 23 |
// Enqueue element styles and scripts |
| 24 |
public function enqueue_scripts() |
| 25 |
{ |
| 26 |
$suffix = ''; |
| 27 |
$assets_path = str_replace( array( 'http:', 'https:' ), '', PH()->plugin_url() ) . '/assets/'; |
| 28 |
|
| 29 |
wp_enqueue_script( 'flexslider', $assets_path . 'js/flexslider/jquery.flexslider' . $suffix . '.js', array( 'jquery' ), '2.7.2', true ); |
| 30 |
wp_enqueue_script( 'flexslider-init', $assets_path . 'js/flexslider/jquery.flexslider.init' . $suffix . '.js', array( 'jquery','flexslider' ), PH_VERSION, true ); |
| 31 |
wp_enqueue_style( 'flexslider_css', $assets_path . 'css/flexslider.css', array(), '2.7.2' ); |
| 32 |
} |
| 33 |
|
| 34 |
public function set_control_groups() |
| 35 |
{ |
| 36 |
/*$this->control_groups['form'] = [ |
| 37 |
'title' => esc_html__( 'Form', 'propertyhive' ), |
| 38 |
'tab' => 'content', // content / style |
| 39 |
];*/ |
| 40 |
} |
| 41 |
|
| 42 |
public function set_controls() |
| 43 |
{ |
| 44 |
$this->controls['hide_thumbnails'] = [ |
| 45 |
'tab' => 'content', |
| 46 |
//'group' => 'settings', |
| 47 |
'label' => esc_html__( 'Hide Thumbnails', 'propertyhive' ), |
| 48 |
'type' => 'select', |
| 49 |
'options' => [ |
| 50 |
'' => __( 'No', 'propertyhive' ), |
| 51 |
'yes' => __( 'Yes', 'propertyhive' ), |
| 52 |
], |
| 53 |
//'inline' => true, |
| 54 |
//'clearable' => false, |
| 55 |
//'pasteStyles' => false, |
| 56 |
'default' => '', |
| 57 |
]; |
| 58 |
} |
| 59 |
|
| 60 |
public function render() |
| 61 |
{ |
| 62 |
global $property; |
| 63 |
|
| 64 |
if ( !isset($property->id) ) { |
| 65 |
return; |
| 66 |
} |
| 67 |
|
| 68 |
$root_classes[] = $this->name; |
| 69 |
|
| 70 |
// Add 'class' attribute to element root tag |
| 71 |
$this->set_attribute( '_root', 'class', $root_classes ); |
| 72 |
|
| 73 |
echo "<div {$this->render_attributes( '_root' )}>"; |
| 74 |
|
| 75 |
if ( isset($this->settings['hide_thumbnails']) && 'yes' === $this->settings['hide_thumbnails'] ) |
| 76 |
{ |
| 77 |
remove_action( 'propertyhive_product_thumbnails', 'propertyhive_show_property_thumbnails', 20 ); |
| 78 |
} |
| 79 |
|
| 80 |
propertyhive_show_property_images(); |
| 81 |
|
| 82 |
echo '</div>'; |
| 83 |
} |
| 84 |
} |