PluginProbe
Property Hive / 2.4.0
Property Hive v2.4.0
2.4.0 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 All 262 releases
← All changes | includes/admin/reports/class-ph-report-incomplete-properties.php +177 -37 1.4.6 → 2.4.0 View file →
@@ -1,6 +1,9 @@
1 1 <?php
2 +// phpcs:set WordPress.Security.ValidatedSanitizedInput customSanitizingFunctions[] ph_clean
3 +// ph_clean() recursively sanitizes text; presence, shape and unslashing checks remain separate.
2 4
5 +
3 6 if ( ! defined( 'ABSPATH' ) ) {
4 7 exit; // Exit if accessed directly
5 8 }
6 9
@@ -11,8 +14,9 @@
11 14 * @category Admin
12 15 * @package PropertyHive/Admin/Reports
13 16 * @version 1.0.0
14 17 */
18 +// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound -- Legacy public global class PH_Report_Incomplete_Properties; preserving the existing PH_* class name is required for plugin and extension compatibility.
15 19 class PH_Report_Incomplete_Properties extends PH_Admin_Report {
16 20
17 21 /**
18 22 * Output the report.
@@ -38,15 +42,29 @@
38 42
39 43 <label for="missing">Show Properties Missing:</label>
40 44 <select name="missing" id="missing" style="width:100%;">
41 45 <option value="">One or more items</option>
42 - <option value="_photos"<?php if ( isset($_POST['missing']) && $_POST['missing'] == '_photos' ) { echo ' selected'; } ?>>Photos</option>
43 - <option value="_floorplans"<?php if ( isset($_POST['missing']) && $_POST['missing'] == '_floorplans' ) { echo ' selected'; } ?>>Floorplans</option>
44 - <option value="_epcs"<?php if ( isset($_POST['missing']) && $_POST['missing'] == '_epcs' ) { echo ' selected'; } ?>>EPCS</option>
45 - <option value="_brochures"<?php if ( isset($_POST['missing']) && $_POST['missing'] == '_brochures' ) { echo ' selected'; } ?>>Brochures</option>
46 - <option value="_virtual_tours"<?php if ( isset($_POST['missing']) && $_POST['missing'] == '_virtual_tours' ) { echo ' selected'; } ?>>Virtual Tours</option>
47 - <option value="summary"<?php if ( isset($_POST['missing']) && $_POST['missing'] == 'summary' ) { echo ' selected'; } ?>>Summary Description</option>
48 - <option value="_latitude"<?php if ( isset($_POST['missing']) && $_POST['missing'] == '_latitude' ) { echo ' selected'; } ?>>Map Co-ordinates</option>
46 + <option value="_photos"<?php
47 +// phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
48 + if ( isset($_POST['missing']) && $_POST['missing'] == '_photos' ) { echo ' selected'; } ?>>Photos</option>
49 + <option value="_floorplans"<?php
50 +// phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
51 + if ( isset($_POST['missing']) && $_POST['missing'] == '_floorplans' ) { echo ' selected'; } ?>>Floorplans</option>
52 + <option value="_epcs"<?php
53 +// phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
54 + if ( isset($_POST['missing']) && $_POST['missing'] == '_epcs' ) { echo ' selected'; } ?>>EPCS</option>
55 + <option value="_brochures"<?php
56 +// phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
57 + if ( isset($_POST['missing']) && $_POST['missing'] == '_brochures' ) { echo ' selected'; } ?>>Brochures</option>
58 + <option value="_virtual_tours"<?php
59 +// phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
60 + if ( isset($_POST['missing']) && $_POST['missing'] == '_virtual_tours' ) { echo ' selected'; } ?>>Virtual Tours</option>
61 + <option value="summary"<?php
62 +// phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
63 + if ( isset($_POST['missing']) && $_POST['missing'] == 'summary' ) { echo ' selected'; } ?>>Summary Description</option>
64 + <option value="_latitude"<?php
65 +// phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
66 + if ( isset($_POST['missing']) && $_POST['missing'] == '_latitude' ) { echo ' selected'; } ?>>Map Co-ordinates</option>
49 67 </select>
50 68
51 69 <br><br>
52 70
@@ -52,17 +70,23 @@
52 70
53 71 <label for="department">Department:</label>
54 72 <select name="department" id="department" style="width:100%;">
55 73 <option value="">All</option>
56 - <?php if ( get_option('propertyhive_active_departments_sales', '') == 'yes' ) { ?>
57 - <option value="residential-sales"<?php if ( isset($_POST['department']) && $_POST['department'] == 'residential-sales' ) { echo ' selected'; } ?>>Residential Sales</option>
58 - <?php } ?>
59 - <?php if ( get_option('propertyhive_active_departments_lettings', '') == 'yes' ) { ?>
60 - <option value="residential-lettings"<?php if ( isset($_POST['department']) && $_POST['department'] == 'residential-lettings' ) { echo ' selected'; } ?>>Residential Lettings</option>
61 - <?php } ?>
62 - <?php if ( get_option('propertyhive_active_departments_commercial', '') == 'yes' ) { ?>
63 - <option value="commercial"<?php if ( isset($_POST['department']) && $_POST['department'] == 'commercial' ) { echo ' selected'; } ?>>Commercial</option>
64 - <?php } ?>
74 +
75 + <?php
76 + $departments = ph_get_departments();
77 +
78 + foreach ( $departments as $key => $value )
79 + {
80 + if ( get_option( 'propertyhive_active_departments_' . str_replace("residential-", "", $key) ) == 'yes' )
81 + {
82 + echo '<option value="' . esc_attr($key) . '"';
83 + // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
84 + if ( isset($_POST['department']) && $_POST['department'] == $key ) { echo ' selected'; }
85 + echo '>' . esc_html($value) . '</option>';
86 + }
87 + }
88 + ?>
65 89 </select>
66 90
67 91 <br><br>
68 92
@@ -67,13 +91,49 @@
67 91 <br><br>
68 92
69 93 <label for="on_market">Market Status:</label>
70 94 <select name="on_market" id="on_market" style="width:100%;">
71 - <option value=""<?php if ( isset($_POST['on_market']) && $_POST['on_market'] == '' ) { echo ' selected'; } ?>>On Market Properties Only</option>
72 - <option value="all"<?php if ( isset($_POST['on_market']) && $_POST['on_market'] == 'all' ) { echo ' selected'; } ?>>All Properties</option>
95 + <option value=""<?php
96 +// phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
97 + if ( isset($_POST['on_market']) && $_POST['on_market'] == '' ) { echo ' selected'; } ?>>On Market Properties Only</option>
98 + <option value="all"<?php
99 +// phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
100 + if ( isset($_POST['on_market']) && $_POST['on_market'] == 'all' ) { echo ' selected'; } ?>>All Properties</option>
73 101 </select>
74 102
75 103 <br><br>
104 +
105 + <label for="metric_two">Office:</label>
106 + <select name="office_id" id="office_id" style="width:100%;">
107 + <option value="">All Offices</option>
108 + <?php
109 + $args = array(
110 + 'post_type' => 'office',
111 + 'orderby' => 'post_title',
112 + 'order' => 'ASC',
113 + 'nopaging' => true,
114 + );
115 +
116 + $office_query = new WP_Query( $args );
117 +
118 + if ( $office_query->have_posts() )
119 + {
120 + while ( $office_query->have_posts() )
121 + {
122 + $office_query->the_post();
123 + ?>
124 + <option value="<?php
125 +// phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
126 + echo esc_attr(get_the_ID()); ?>"<?php if ( isset($_POST['office_id']) && ($_POST['office_id'] == get_the_ID()) ) { echo ' selected'; } ?>><?php echo esc_html(get_the_title(get_the_ID())); ?></option>
127 + <?php
128 + }
129 + }
130 +
131 + wp_reset_postdata();
132 + ?>
133 + </select>
134 +
135 + <br><br>
76 136 <input type="submit" value="Update" class="button button-primary">
77 137
78 138 </form>
79 139
@@ -89,8 +149,9 @@
89 149 );
90 150
91 151 $meta_query = array('relation' => 'AND');
92 152
153 + // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
93 154 if ( isset($_POST['on_market']) && $_POST['on_market'] == 'all' )
94 155 {
95 156
96 157 }
@@ -101,16 +162,29 @@
101 162 'value' => 'yes',
102 163 );
103 164 }
104 165
105 - if ( isset($_POST['department']) && $_POST['department'] != '' )
166 + // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
167 + if ( isset($_POST['department']) && is_string( $_POST['department'] ) && $_POST['department'] != '' )
106 168 {
107 169 $meta_query[] = array(
108 170 'key' => '_department',
109 - 'value' => $_POST['department'],
171 + // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
172 + 'value' => ph_clean( wp_unslash( $_POST['department'] ) ),
110 173 );
111 174 }
112 175
176 + // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
177 + if ( isset($_POST['office_id']) && is_scalar( $_POST['office_id'] ) && $_POST['office_id'] != '' )
178 + {
179 + $meta_query[] = array(
180 + 'key' => '_office_id',
181 + // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
182 + 'value' => (int)$_POST['office_id']
183 + );
184 + }
185 +
186 + // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query -- Incomplete-property report must filter existing department, office and market metadata before inspecting all matching properties; the query retrieves IDs only.
113 187 $args['meta_query'] = $meta_query;
114 188
115 189 $property_query = new WP_Query( $args );
116 190
@@ -129,15 +203,18 @@
129 203
130 204 $missing = array();
131 205
132 206 if (
207 + // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
133 208 (isset($_POST['missing']) && $_POST['missing'] == '_photos') ||
209 + // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
134 210 (isset($_POST['missing']) && $_POST['missing'] == '') ||
211 + // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
135 212 !isset($_POST['missing'])
136 213 )
137 214 {
138 - $photos = $property->get_gallery_attachment_ids();
139 - if ( $photos === false || ( is_array($photos) && empty($photos) ) )
215 + $photo = $property->get_main_photo_src();
216 + if ( $photo === false )
140 217 {
141 218 $missing[] = 'Photos';
142 219 }
143 220 }
@@ -142,49 +219,106 @@
142 219 }
143 220 }
144 221
145 222 if (
223 + // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
146 224 (isset($_POST['missing']) && $_POST['missing'] == '_floorplans') ||
225 + // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
147 226 (isset($_POST['missing']) && $_POST['missing'] == '') ||
227 + // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
148 228 !isset($_POST['missing'])
149 229 )
150 230 {
151 - $floorplans = $property->get_floorplan_attachment_ids();
152 - if ( $floorplans === false || ( is_array($floorplans) && empty($floorplans) ) )
153 - {
154 - $missing[] = 'Floorplans';
231 + if ( get_option('propertyhive_brochures_stored_as', '') == 'urls' )
232 + {
233 + $floorplans = $property->_floorplan_urls;
234 + if (isset($floorplans) && is_array($floorplans) && !empty($floorplans) && isset($floorplans[0]) && isset($floorplans[0]['url']))
235 + {
236 +
237 + }
238 + else
239 + {
240 + $missing[] = 'Floorplans';
241 + }
242 + }
243 + else
244 + {
245 + $floorplans = $property->get_floorplan_attachment_ids();
246 + if ( $floorplans === false || ( is_array($floorplans) && empty($floorplans) ) )
247 + {
248 + $missing[] = 'Floorplans';
249 + }
155 250 }
156 251 }
157 252
158 253 if (
254 + // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
159 255 (isset($_POST['missing']) && $_POST['missing'] == '_epcs') ||
256 + // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
160 257 (isset($_POST['missing']) && $_POST['missing'] == '') ||
258 + // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
161 259 !isset($_POST['missing'])
162 260 )
163 261 {
164 - $epcs = $property->get_epc_attachment_ids();
165 - if ( $epcs === false || ( is_array($epcs) && empty($epcs) ) )
166 - {
167 - $missing[] = 'EPCs';
262 + if ( get_option('propertyhive_epcs_stored_as', '') == 'urls' )
263 + {
264 + $epcs = $property->_epc_urls;
265 + if (isset($epcs) && is_array($epcs) && !empty($epcs) && isset($epcs[0]) && isset($epcs[0]['url']))
266 + {
267 +
268 + }
269 + else
270 + {
271 + $missing[] = 'EPCs';
272 + }
273 + }
274 + else
275 + {
276 + $epcs = $property->get_epc_attachment_ids();
277 + if ( $epcs === false || ( is_array($epcs) && empty($epcs) ) )
278 + {
279 + $missing[] = 'EPCs';
280 + }
168 281 }
169 282 }
170 283
171 284 if (
285 + // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
172 286 (isset($_POST['missing']) && $_POST['missing'] == '_brochures') ||
287 + // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
173 288 (isset($_POST['missing']) && $_POST['missing'] == '') ||
289 + // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
174 290 !isset($_POST['missing'])
175 291 )
176 292 {
177 - $brochures = $property->get_epc_attachment_ids();
178 - if ( $brochures === false || ( is_array($brochures) && empty($brochures) ) )
179 - {
180 - $missing[] = 'Brochures';
293 + if ( get_option('propertyhive_brochures_stored_as', '') == 'urls' )
294 + {
295 + $brochures = $property->_brochure_urls;
296 + if (isset($brochures) && is_array($brochures) && !empty($brochures) && isset($brochures[0]) && isset($brochures[0]['url']))
297 + {
298 +
299 + }
300 + else
301 + {
302 + $missing[] = 'Brochures';
303 + }
304 + }
305 + else
306 + {
307 + $brochures = $property->get_epc_attachment_ids();
308 + if ( $brochures === false || ( is_array($brochures) && empty($brochures) ) )
309 + {
310 + $missing[] = 'Brochures';
311 + }
181 312 }
182 313 }
183 314
184 315 if (
316 + // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
185 317 (isset($_POST['missing']) && $_POST['missing'] == '_virtual_tours') ||
318 + // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
186 319 (isset($_POST['missing']) && $_POST['missing'] == '') ||
320 + // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
187 321 !isset($_POST['missing'])
188 322 )
189 323 {
190 324 $virtual_tours = $property->get_virtual_tour_urls();
@@ -194,10 +328,13 @@
194 328 }
195 329 }
196 330
197 331 if (
332 + // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
198 333 (isset($_POST['missing']) && $_POST['missing'] == 'summary') ||
334 + // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
199 335 (isset($_POST['missing']) && $_POST['missing'] == '') ||
336 + // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
200 337 !isset($_POST['missing'])
201 338 )
202 339 {
203 340 $summary = $property->post_excerpt;
@@ -207,10 +344,13 @@
207 344 }
208 345 }
209 346
210 347 if (
348 + // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
211 349 (isset($_POST['missing']) && $_POST['missing'] == '_latitude') ||
350 + // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
212 351 (isset($_POST['missing']) && $_POST['missing'] == '') ||
352 + // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
213 353 !isset($_POST['missing'])
214 354 )
215 355 {
216 356 $latitude = $property->latitude;
@@ -223,11 +363,11 @@
223 363 if ( !empty($missing) )
224 364 {
225 365 echo '<tr>';
226 366
227 - echo '<td><a href="' . get_edit_post_link( get_the_ID() ) . '">' . $property->get_formatted_full_address() . '</a></td>';
367 + echo '<td><a href="' . esc_url(get_edit_post_link( get_the_ID() )) . '">' . esc_html($property->get_formatted_full_address()) . '</a></td>';
228 368
229 - echo '<td>' . implode(", ", $missing) . '</td>';
369 + echo '<td>' . esc_html(implode(", ", $missing)) . '</td>';
230 370
231 371 echo '</tr>';
232 372 }
233 373 }
@@ -242,5 +382,5 @@
242 382
243 383 <?php
244 384 }
245 385
246 -}
386 +}