PluginProbe
Property Hive / 2.3.0
Property Hive v2.3.0
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 1.4.62 All 260 releases
← All changes | includes/class-ph-elementor.php +81 -33 2.2.32.3.0 View file →
@@ -14,8 +14,11 @@
14 14 add_action( 'elementor/query/onmarketlettingspropertyquery', array( $this, 'elementor_query_on_market_lettings_only' ) );
15 15 add_action( 'elementor/query/onmarketcommercialpropertyquery', array( $this, 'elementor_query_on_market_commercial_only' ) );
16 16 add_action( 'elementor/query/featuredpropertyquery', array( $this, 'elementor_query_featured_only' ) );
17 17 add_filter( 'elementor/query/query_args', array( $this, 'elementor_query_args' ), 10, 2 );
18 +
19 + add_action( 'propertyhive_elementor_widget_property_image_controls', array( $this, 'elementor_widget_property_image_controls' ), 10 );
20 + add_action( 'propertyhive_elementor_widget_property_image_render_after', array( $this, 'elementor_widget_property_image_render_after' ), 10, 2 );
18 21 }
19 22
20 23 public function elementor_query_args( $query_vars, $widget )
21 24 {
@@ -29,8 +32,9 @@
29 32 $query_vars['orderby'] = $ordering['orderby'] . ' post_title';
30 33 $query_vars['order'] = $ordering['order'];
31 34 if ( isset( $ordering['meta_key'] ) )
32 35 {
36 + // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key -- Elementor integration copies the ordering meta_key produced by PH_Query, whose supported order cases map to fixed Property Hive keys. The surrounding hook applies only to named Property Hive query IDs; Elementor supplies its own paginated widget query.
33 37 $query_vars['meta_key'] = $ordering['meta_key'];
34 38 }
35 39 }
36 40
@@ -88,18 +92,10 @@
88 92 }
89 93
90 94 public function elementor_query_on_market_sales_only( $query )
91 95 {
92 - $original_department = isset($_REQUEST['department']) ? $_REQUEST['department'] : '';
93 -
94 - $_GET['department'] = 'residential-sales';
95 - $_REQUEST['department'] = 'residential-sales';
96 + $this->query_department( $query, 'residential-sales' );
96 97
97 - PH()->query->property_query( $query );
98 -
99 - $_GET['department'] = $original_department;
100 - $_REQUEST['department'] = $original_department;
101 -
102 98 // Set the custom post type
103 99 $query->set( 'post_type', [ 'property' ] );
104 100
105 101 // ensure a department is set as not set by default from property_query
@@ -114,18 +110,10 @@
114 110 }
115 111
116 112 public function elementor_query_on_market_lettings_only( $query )
117 113 {
118 - $original_department = isset($_REQUEST['department']) ? $_REQUEST['department'] : '';
119 -
120 - $_GET['department'] = 'residential-lettings';
121 - $_REQUEST['department'] = 'residential-lettings';
114 + $this->query_department( $query, 'residential-lettings' );
122 115
123 - PH()->query->property_query( $query );
124 -
125 - $_GET['department'] = $original_department;
126 - $_REQUEST['department'] = $original_department;
127 -
128 116 // Set the custom post type
129 117 $query->set( 'post_type', [ 'property' ] );
130 118
131 119 // ensure a department is set as not set by default from property_query
@@ -140,18 +128,10 @@
140 128 }
141 129
142 130 public function elementor_query_on_market_commercial_only( $query )
143 131 {
144 - $original_department = isset($_REQUEST['department']) ? $_REQUEST['department'] : '';
145 -
146 - $_GET['department'] = 'commercial';
147 - $_REQUEST['department'] = 'commercial';
132 + $this->query_department( $query, 'commercial' );
148 133
149 - PH()->query->property_query( $query );
150 -
151 - $_GET['department'] = $original_department;
152 - $_REQUEST['department'] = $original_department;
153 -
154 134 // Set the custom post type
155 135 $query->set( 'post_type', [ 'property' ] );
156 136
157 137 // ensure a department is set as not set by default from property_query
@@ -189,8 +169,32 @@
189 169 $query->set( 'orderby', $original_orderby );
190 170 $query->set( 'order', $original_order );
191 171 }
192 172
173 + /** Temporarily scope the public query while preserving the exact surrounding request. */
174 + private function query_department( $query, $department ) {
175 + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Snapshot only: this raw value is restored unchanged, never used in the scoped query. PH_Query separately validates request inputs.
176 + $original_request = array_key_exists( 'department', $_REQUEST ) ? array( $_REQUEST['department'] ) : array();
177 + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Snapshot only: preserve GET independently from REQUEST, including absence and the original slashing contract.
178 + $original_get = array_key_exists( 'department', $_GET ) ? array( $_GET['department'] ) : array();
179 + $_GET['department'] = $department;
180 + $_REQUEST['department'] = $department;
181 + try {
182 + PH()->query->property_query( $query );
183 + } finally {
184 + if ( $original_request ) {
185 + $_REQUEST['department'] = $original_request[0];
186 + } else {
187 + unset( $_REQUEST['department'] );
188 + }
189 + if ( $original_get ) {
190 + $_GET['department'] = $original_get[0];
191 + } else {
192 + unset( $_GET['department'] );
193 + }
194 + }
195 + }
196 +
193 197 private function remove_department_from_query( $query )
194 198 {
195 199 $new_meta_query = array();
196 200
@@ -220,15 +224,15 @@
220 224 wp_enqueue_style( 'propertyhive_fancybox_css' );
221 225
222 226 wp_enqueue_script( 'flexslider', $assets_path . 'js/flexslider/jquery.flexslider' . $suffix . '.js', array( 'jquery' ), '2.2.2', true );
223 227 wp_enqueue_script( 'flexslider-init', $assets_path . 'js/flexslider/jquery.flexslider.init' . $suffix . '.js', array( 'jquery','flexslider' ), PH_VERSION, true );
224 - wp_enqueue_style( 'flexslider_css', $assets_path . 'css/flexslider.css' );
228 + wp_enqueue_style( 'flexslider_css', $assets_path . 'css/flexslider.css', array(), PH_VERSION );
225 229
226 230 $api_key = get_option('propertyhive_google_maps_api_key');
227 - wp_register_script('googlemaps', '//maps.googleapis.com/maps/api/js?' . ( ( $api_key != '' && $api_key !== FALSE ) ? 'key=' . $api_key : '' ), false, '3');
231 + wp_register_script('googlemaps', '//maps.googleapis.com/maps/api/js?' . ( ( $api_key != '' && $api_key !== FALSE ) ? 'key=' . $api_key : '' ), false, '3', true );
228 232 wp_enqueue_script('googlemaps');
229 233
230 - wp_enqueue_script( 'propertyhive_elementor', $assets_path . 'js/elementor/elementor.js', array( 'jquery','flexslider' ), PH_VERSION, true );
234 + wp_enqueue_script( 'propertyhive_elementor', $assets_path . 'js/elementor/elementor.js', array( 'jquery','flexslider', 'googlemaps' ), PH_VERSION, true );
231 235 }
232 236
233 237 public function add_elementor_widget_category( $elements_manager )
234 238 {
@@ -389,12 +393,56 @@
389 393
390 394 $image_src = $images[0]['url'];
391 395
392 396 $image_class = ! empty( $settings['hover_animation'] ) ? 'elementor-animation-' . $settings['hover_animation'] : '';
393 - $image_class_html = ! empty( $image_class ) ? ' class="' . $image_class . '"' : '';
397 + $image_class_html = ! empty( $image_class ) ? ' class="' . esc_attr( $image_class ) . '"' : '';
394 398
395 - $html = sprintf( '<img src="%s" title="" alt=""%s />', esc_attr( $image_src ), $image_class_html );
399 + $html = sprintf( '<img src="%s" title="" alt=""%s />', esc_url( $image_src ), $image_class_html );
396 400 return $html;
397 401 }
402 +
403 + public function elementor_widget_property_image_controls( $widget )
404 + {
405 + $widget->add_control(
406 + 'show_flag',
407 + [
408 + 'label' => __( 'Show Availability Flag', 'propertyhive' ),
409 + 'type' => \Elementor\Controls_Manager::SWITCHER,
410 + 'label_on' => __( 'Yes', 'propertyhive' ),
411 + 'label_off' => __( 'No', 'propertyhive' ),
412 + 'return_value' => 'yes',
413 + 'default' => '',
414 + ]
415 + );
416 +
417 + $widget->add_control(
418 + 'flag_note',
419 + [
420 + 'label' => '',
421 + 'type' => \Elementor\Controls_Manager::RAW_HTML,
422 + 'raw' => /* translators: %s: Template Assistant flags settings URL. */ sprintf( __( 'The flag shown will take its colour and position settings from the <a href="%s" target="_blank">Template Assistant Flags</a> settings area', 'propertyhive' ), esc_url( admin_url( 'admin.php?page=ph-settings&tab=frontend&section=flags' ) ) ),
423 + 'condition' => [
424 + 'show_flag' => 'yes',
425 + ],
426 + ]
427 + );
428 + }
429 +
430 + public function elementor_widget_property_image_render_after( $settings, $property )
431 + {
432 + global $property;
433 +
434 + if ( isset($settings['show_flag']) && $settings['show_flag'] == 'yes' )
435 + {
436 + $flag = propertyhive_get_flag();
437 +
438 + if ( $flag != '' )
439 + {
440 + $current_settings = get_option( 'propertyhive_template_assistant', array() );
441 +
442 + echo '<div class="flag flag-' . esc_attr( sanitize_title( $flag ) ) . '" style="' . esc_attr( 'position:absolute; text-transform:uppercase; font-size:13px; box-sizing:border-box; padding:7px 20px; ' . propertyhive_get_flag_custom_style( $current_settings ) ) . '">' . esc_html( $flag ) . '</div>';
443 + }
444 + }
445 + }
398 446 }
399 447
400 -new PH_Elementor();
448 +new PH_Elementor();