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-floor-area.php

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

162 lines 6.0 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_Floor_Area_Widget extends ET_Builder_Module
7 {
8 public $slug = 'et_pb_property_floor_area_widget';
9 public $vb_support = 'partial';
10 public $icon = '';
11
12 public function init() {
13 $this->name = esc_html__( 'Property Floor Area', 'propertyhive' );
14 $this->icon = '&';
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->department == 'commercial' && ( ( $property->floor_area_to_sqft != '' && $property->floor_area_to_sqft != 0 ) || ( $property->floor_area_from_sqft != '' && $property->floor_area_from_sqft != 0 ) ) )
88 {
89 $icon_hover_selector = str_replace( $this->icon_element_classname, $this->icon_element_classname . ':hover', $this->icon_element_selector );
90
91 // Font Icon Style.
92 $this->generate_styles(
93 array(
94 'utility_arg' => 'icon_font_family',
95 'render_slug' => $render_slug,
96 'base_attr_name' => 'font_icon',
97 'important' => true,
98 'selector' => $this->icon_element_selector,
99 'hover_selector' => $icon_hover_selector,
100 'processor' => array(
101 'ET_Builder_Module_Helper_Style_Processor',
102 'process_extended_icon',
103 ),
104 )
105 );
106
107 // Font Icon Color Style.
108 $this->generate_styles(
109 array(
110 'base_attr_name' => 'icon_color',
111 'selector' => $this->icon_element_selector,
112 'css_property' => 'color',
113 'render_slug' => $render_slug,
114 'type' => 'color',
115 'hover_selector' => $icon_hover_selector,
116 )
117 );
118
119 // Font Icon Size Style.
120 $this->generate_styles(
121 array(
122 'base_attr_name' => 'icon_width',
123 'selector' => $this->icon_element_selector,
124 'css_property' => 'font-size',
125 'render_slug' => $render_slug,
126 'type' => 'range',
127 'hover_selector' => $icon_hover_selector,
128 )
129 );
130
131 $return = '';
132
133 $font_icon = $this->props['font_icon'];
134
135 $image = ( '' !== $font_icon ) ? sprintf(
136 '<span class="et-pb-icon%2$s%3$s" style="%4$s">%1$s</span>',
137 esc_attr( et_pb_process_font_icon( $font_icon ) ),
138 '',
139 '',
140 'vertical-align:middle; margin-right:7px;'
141 ) : '';
142
143 $return .= '<div class="divi-widget-floor-area">';
144
145 $return .= $image;
146
147 if ( isset($this->props['before']) && $this->props['before'] != '' ) { $return .= $this->props['before'] . ' '; }
148
149 $return = $property->get_formatted_floor_area();
150
151 if ( isset($this->props['after']) && $this->props['after'] != '' ) { $return .= ' ' . $this->props['after']; }
152
153 $return .= '</div>';
154 }
155 else
156 {
157 return;
158 }
159
160 return $this->_render_module_wrapper( $return, $render_slug );
161 }
162 }