PluginProbe
Property Hive / 2.2.5
Property Hive v2.2.5
2.3.1 2.3.0 2.2.6 2.2.5 2.2.4 2.2.3 2.2.2 1.4.46 1.4.47 1.4.48 1.4.49 1.4.5 1.4.50 1.4.51 1.4.52 1.4.53 1.4.54 1.4.55 1.4.56 1.4.57 1.4.58 1.4.59 1.4.6 1.4.60 1.4.61 All 261 releases
propertyhive / includes / divi-widgets / property-bedrooms.php

property-bedrooms.php in Property Hive 2.2.5, at includes/divi-widgets/property-bedrooms.php

160 lines 5.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if (!defined('ABSPATH')) {
3 exit;
4 }
5
6 class Divi_Property_Bedrooms_Widget extends ET_Builder_Module
7 {
8 public $slug = 'et_pb_property_bedrooms_widget';
9 public $vb_support = 'partial';
10 public $icon = '';
11
12 public function init() {
13 $this->name = esc_html__( 'Property Bedrooms', 'propertyhive' );
14 $this->icon = '3';
15 $this->icon_element_selector = '%%order_class%% .et-pb-icon';
16 $this->icon_element_classname = 'et-pb-icon';
17 $this->main_css_element = '%%order_class%%';
18 }
19
20 public function get_fields()
21 {
22 $fields = array(
23 'before' => array(
24 'label' => __( 'Before', 'propertyhive' ),
25 'type' => 'text',
26 'toggle_slug' => 'main_content',
27 ),
28 'after' => array(
29 'label' => __( 'After', 'propertyhive' ),
30 'type' => 'text',
31 'toggle_slug' => 'main_content',
32 ),
33 'font_icon' => array(
34 'label' => __( 'Icon', 'propertyhive' ),
35 'type' => 'select_icon',
36 'option_category' => 'basic_option',
37 'class' => array( 'et-pb-font-icon' ),
38 'toggle_slug' => 'icon',
39 ),
40 'icon_width' => array(
41 'label' => esc_html__( 'Icon Size', 'et_builder' ),
42 'default' => '24px',
43 'range_settings' => array(
44 'min' => '1',
45 'max' => '200',
46 'step' => '1',
47 ),
48 'toggle_slug' => 'icon_settings',
49 'description' => esc_html__( 'Here you can choose icon width.', 'et_builder' ),
50 'type' => 'range',
51 'option_category' => 'layout',
52 'tab_slug' => 'advanced',
53 'mobile_options' => true,
54 'validate_unit' => true,
55 'allowed_units' => array( '%', 'em', 'rem', 'px', 'cm', 'mm', 'in', 'pt', 'pc', 'ex', 'vh', 'vw' ),
56 'responsive' => true,
57 'mobile_options' => true,
58 'sticky' => true,
59 'hover' => 'tabs',
60 ),
61 'icon_color' => array(
62 'default' => et_builder_accent_color(),
63 'label' => esc_html__( 'Icon Colour', 'et_builder' ),
64 'type' => 'color-alpha',
65 'description' => esc_html__( 'Here you can define a custom color for your icon.', 'et_builder' ),
66 'tab_slug' => 'advanced',
67 'toggle_slug' => 'icon_settings',
68 'hover' => 'tabs',
69 'mobile_options' => true,
70 'sticky' => true,
71 ),
72 );
73
74 return $fields;
75 }
76
77 public function render( $attrs, $content, $render_slug )
78 {
79 $post_id = get_the_ID();
80
81 $property = new PH_Property($post_id);
82
83 if ( !isset($property->id) ) {
84 return;
85 }
86
87 if ( $property->bedrooms == '' || $property->bedrooms == 0 )
88 {
89 return;
90 }
91
92 $icon_hover_selector = str_replace( $this->icon_element_classname, $this->icon_element_classname . ':hover', $this->icon_element_selector );
93
94 // Font Icon Style.
95 $this->generate_styles(
96 array(
97 'utility_arg' => 'icon_font_family',
98 'render_slug' => $render_slug,
99 'base_attr_name' => 'font_icon',
100 'important' => true,
101 'selector' => $this->icon_element_selector,
102 'hover_selector' => $icon_hover_selector,
103 'processor' => array(
104 'ET_Builder_Module_Helper_Style_Processor',
105 'process_extended_icon',
106 ),
107 )
108 );
109
110 // Font Icon Color Style.
111 $this->generate_styles(
112 array(
113 'base_attr_name' => 'icon_color',
114 'selector' => $this->icon_element_selector,
115 'css_property' => 'color',
116 'render_slug' => $render_slug,
117 'type' => 'color',
118 'hover_selector' => $icon_hover_selector,
119 )
120 );
121
122 // Font Icon Size Style.
123 $this->generate_styles(
124 array(
125 'base_attr_name' => 'icon_width',
126 'selector' => $this->icon_element_selector,
127 'css_property' => 'font-size',
128 'render_slug' => $render_slug,
129 'type' => 'range',
130 'hover_selector' => $icon_hover_selector,
131 )
132 );
133
134 $return = '';
135
136 $font_icon = $this->props['font_icon'];
137
138 $image = ( '' !== $font_icon ) ? sprintf(
139 '<span class="et-pb-icon%2$s%3$s" style="%4$s">%1$s</span>',
140 esc_attr( et_pb_process_font_icon( $font_icon ) ),
141 '',
142 '',
143 'vertical-align:middle; margin-right:7px;'
144 ) : '';
145
146 $return .= '<div class="divi-widget-bedrooms">';
147
148 $return .= $image;
149
150 if ( isset($this->props['before']) && $this->props['before'] != '' ) { $return .= $this->props['before'] . ' '; }
151
152 $return .= esc_html($property->bedrooms);
153
154 if ( isset($this->props['after']) && $this->props['after'] != '' ) { $return .= ' ' . $this->props['after']; }
155
156 $return .= '</div>';
157
158 return $this->_render_module_wrapper( $return, $render_slug );
159 }
160 }