PluginProbe
Property Hive / 2.3.1
Property Hive v2.3.1
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
← All changes | includes/admin/settings/class-ph-settings-custom-fields.php +1901 -604 1.4.592.3.1 View file →
@@ -1,5 +1,8 @@
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.
4 +
2 5 /**
3 6 * PropertyHive Custom Fields Settings
4 7 *
5 8 * @author PropertyHive
@@ -16,23 +19,178 @@
16 19
17 20 /**
18 21 * PH_Settings_General
19 22 */
23 +// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound -- Legacy public global class PH_Settings_Custom_Fields; preserving the existing PH_* class name is required for plugin and extension compatibility.
20 24 class PH_Settings_Custom_Fields extends PH_Settings_Page {
21 25
26 + const LINKED_POSTS_COLUMN_HEADING = 'Assigned Properties';
27 +
28 + private $custom_field_sections;
29 +
22 30 /**
23 31 * Constructor.
24 32 */
25 33 public function __construct() {
26 34 $this->id = 'customfields';
27 - $this->label = __( 'Custom Fields', 'propertyhive' );
35 + $this->label = __( 'Field Manager', 'propertyhive' );
28 36
37 + add_action( 'admin_init', array( $this, 'check_for_delete_additional_field') );
38 + add_action( 'admin_init', array( $this, 'check_for_reorder_additional_fields') );
39 +
29 40 add_filter( 'propertyhive_settings_tabs_array', array( $this, 'add_settings_page' ), 15 );
30 41 add_action( 'propertyhive_sections_' . $this->id, array( $this, 'output_sections' ) );
31 42 add_action( 'propertyhive_settings_' . $this->id, array( $this, 'output' ) );
32 43 add_action( 'propertyhive_settings_save_' . $this->id, array( $this, 'save' ) );
44 +
45 + add_action( 'propertyhive_admin_field_additional_fields_table', array( $this, 'additional_fields_table' ) );
46 +
47 + add_action( 'propertyhive_admin_field_additional_field_dropdown_options', array( $this, 'additional_field_dropdown_options' ) );
48 +
49 + $this->get_custom_field_sections();
33 50 }
34 -
51 +
52 + public function check_for_delete_additional_field()
53 + {
54 + if (
55 + ! isset( $_GET['action'] ) ||
56 + 'deleteadditionalfield' !== $_GET['action']
57 + ) {
58 + return;
59 + }
60 +
61 + if ( ! current_user_can( 'manage_options' ) ) {
62 + wp_die(
63 + esc_html__( 'You do not have permission to manage Property Hive fields.', 'propertyhive' ),
64 + '',
65 + array( 'response' => 403 )
66 + );
67 + }
68 +
69 + check_admin_referer( 'propertyhive_delete_additional_field' );
70 +
71 + $current_id = isset( $_GET['id'] ) && is_string( $_GET['id'] )
72 + ? sanitize_title( wp_unslash( $_GET['id'] ) )
73 + : '';
74 +
75 + if ( '' === $current_id ) {
76 + wp_die(
77 + esc_html__( 'Invalid additional field.', 'propertyhive' ),
78 + '',
79 + array( 'response' => 400 )
80 + );
81 + }
82 +
83 + $current_settings = get_option(
84 + 'propertyhive_template_assistant',
85 + array()
86 + );
87 +
88 + $existing_custom_fields =
89 + isset( $current_settings['custom_fields'] )
90 + && is_array( $current_settings['custom_fields'] )
91 + ? $current_settings['custom_fields']
92 + : array();
93 +
94 + if ( ! isset( $existing_custom_fields[ $current_id ] ) ) {
95 + wp_die(
96 + esc_html__( 'The additional field does not exist.', 'propertyhive' ),
97 + '',
98 + array( 'response' => 404 )
99 + );
100 + }
101 +
102 + unset( $existing_custom_fields[ $current_id ] );
103 +
104 + $current_settings['custom_fields'] = $existing_custom_fields;
105 +
106 + update_option(
107 + 'propertyhive_template_assistant',
108 + $current_settings
109 + );
110 +
111 + wp_safe_redirect(
112 + admin_url(
113 + 'admin.php?page=ph-settings&tab=customfields&section=additional&ph_message=' . __( 'Additional field deleted successfully', 'propertyhive' )
114 + )
115 + );
116 + exit;
117 + }
118 +
119 + public function check_for_reorder_additional_fields()
120 + {
121 + if ( ! isset( $_GET['neworder'] ) ) {
122 + return;
123 + }
124 +
125 + if ( ! current_user_can( 'manage_options' ) ) {
126 + wp_die(
127 + esc_html__( 'You do not have permission to manage Property Hive fields.', 'propertyhive' ),
128 + '',
129 + array( 'response' => 403 )
130 + );
131 + }
132 +
133 + check_admin_referer( 'propertyhive_reorder_additional_fields' );
134 +
135 + if ( ! is_string( $_GET['neworder'] ) ) {
136 + wp_die( esc_html__( 'Invalid additional field order.', 'propertyhive' ), '', array( 'response' => 400 ) );
137 + }
138 +
139 + $new_order = array_map(
140 + 'sanitize_title',
141 + explode(
142 + ',',
143 + sanitize_text_field(
144 + wp_unslash( $_GET['neworder'] )
145 + )
146 + )
147 + );
148 +
149 + $current_settings = get_option(
150 + 'propertyhive_template_assistant',
151 + array()
152 + );
153 +
154 + $existing_custom_fields =
155 + isset( $current_settings['custom_fields'] )
156 + && is_array( $current_settings['custom_fields'] )
157 + ? $current_settings['custom_fields']
158 + : array();
159 +
160 + if (
161 + count( $new_order ) !== count( $existing_custom_fields ) ||
162 + array_diff( $new_order, array_keys( $existing_custom_fields ) ) ||
163 + array_diff( array_keys( $existing_custom_fields ), $new_order )
164 + ) {
165 + wp_die(
166 + esc_html__( 'Invalid additional field order.', 'propertyhive' ),
167 + '',
168 + array( 'response' => 400 )
169 + );
170 + }
171 +
172 + $new_custom_fields = array();
173 +
174 + foreach ( $new_order as $id ) {
175 + $new_custom_fields[ $id ] = $existing_custom_fields[ $id ];
176 + }
177 +
178 + $current_settings['custom_fields'] = $new_custom_fields;
179 +
180 + update_option(
181 + 'propertyhive_template_assistant',
182 + $current_settings
183 + );
184 +
185 + wp_safe_redirect(
186 + admin_url(
187 + 'admin.php?page=ph-settings&tab=customfields&section=additional&ph_message=' . __( 'Additional fields reordered successfully', 'propertyhive' )
188 + )
189 + );
190 + exit;
191 + }
192 +
35 193 /**
36 194 * Get sections
37 195 *
38 196 * @return array
@@ -38,32 +196,64 @@
38 196 * @return array
39 197 */
40 198 public function get_sections() {
41 199 $sections = array(
42 - '' => __( 'Custom Fields', 'propertyhive' )
200 + '' => __( 'Field Values', 'propertyhive' ),
201 + 'additional' => __( 'Additional Fields', 'propertyhive' )
43 202 );
44 203
45 - $residential_active = false;
46 - $residential_sales_active = false;
47 - $residential_lettings_active = false;
48 - $commercial_active = false;
204 + return $sections;
205 + }
49 206
207 + public function get_custom_field_sections()
208 + {
209 + $sections = array();
210 +
211 + $residential_active = false;
212 + $residential_sales_active = false;
213 + $residential_lettings_active = false;
214 + $commercial_active = false;
215 +
50 216 if ( get_option( 'propertyhive_active_departments_sales' ) == 'yes' || get_option( 'propertyhive_active_departments_lettings' ) == 'yes' )
51 217 {
52 - $residential_active = true;
218 + $residential_active = true;
53 219 if ( get_option( 'propertyhive_active_departments_sales' ) == 'yes' )
54 220 {
55 - $residential_sales_active = true;
221 + $residential_sales_active = true;
56 222 }
57 223 if ( get_option( 'propertyhive_active_departments_lettings' ) == 'yes' )
58 224 {
59 - $residential_lettings_active = true;
225 + $residential_lettings_active = true;
60 226 }
61 227 }
62 228 if ( get_option( 'propertyhive_active_departments_commercial' ) == 'yes' )
63 229 {
64 - $commercial_active = true;
230 + $commercial_active = true;
65 231 }
232 +
233 + $default_departments = ph_get_departments(true);
234 + $custom_departments = ph_get_custom_departments(false);
235 + if ( $custom_departments )
236 + {
237 + foreach ( $custom_departments as $key => $custom_department )
238 + {
239 + if ( isset($custom_department['based_on']) && get_option('propertyhive_active_departments_' . $key) == 'yes' )
240 + {
241 + foreach ( $default_departments as $dept_key => $value )
242 + {
243 + if ( $custom_department['based_on'] == $dept_key )
244 + {
245 + switch ( $custom_department['based_on'] )
246 + {
247 + case "residential-sales": { $residential_active = true; $residential_sales_active = true; }
248 + case "residential-lettings": { $residential_active = true; $residential_lettings_active = true; }
249 + case "commercial": { $commercial_active = true; }
250 + }
251 + }
252 + }
253 + }
254 + }
255 + }
66 256
67 257 // Residential Custom Fields
68 258 $sections[ 'availability' ] = __( 'Availabilities', 'propertyhive' );
69 259 add_action( 'propertyhive_admin_field_custom_fields_availability', array( $this, 'custom_fields_availability_setting' ) );
@@ -114,8 +304,14 @@
114 304 if ( $residential_lettings_active )
115 305 {
116 306 $sections[ 'furnished' ] = __( 'Furnished', 'propertyhive' );
117 307 add_action( 'propertyhive_admin_field_custom_fields_furnished', array( $this, 'custom_fields_furnished_setting' ) );
308 +
309 + if ( get_option( 'propertyhive_module_disabled_tenancies', '' ) != 'yes' )
310 + {
311 + $sections[ 'management-key-date-type' ] = __( 'Management Date Types', 'propertyhive' );
312 + add_action( 'propertyhive_admin_field_custom_fields_management_key_date_type', array( $this, 'custom_fields_management_key_date_type_setting' ) );
313 + }
118 314 }
119 315
120 316 // Other
121 317 $sections[ 'marketing-flag' ] = __( 'Marketing Flags', 'propertyhive' );
@@ -126,9 +322,11 @@
126 322 $sections[ 'property-feature' ] = __( 'Property Features', 'propertyhive' );
127 323 add_action( 'propertyhive_admin_field_custom_fields_property_feature', array( $this, 'custom_fields_property_feature_setting' ) );
128 324 }
129 325
130 - return $sections;
326 + $sections = apply_filters( 'propertyhive_admin_field_custom_fields_sections', $sections );
327 +
328 + $this->custom_field_sections = $sections;
131 329 }
132 330
133 331 /**
134 332 * Get settings array
@@ -138,36 +336,44 @@
138 336 public function get_settings() {
139 337
140 338 global $hide_save_button;
141 339
340 + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Shared admin settings-view state; this global is intentionally used to control the common settings template and is not an arbitrary application global.
142 341 $hide_save_button = true;
143 342
144 - $html = '';
145 -
146 - $sections = $this->get_sections();
147 -
148 - //$sections = array_shift($sections); // Remove 'Custom Fields' from list of custom fields sections
149 343 $i = 0;
150 - foreach ($sections as $key => $value)
344 + $html = '<div class="ph-custom-fields-grid">';
345 + foreach ( $this->custom_field_sections as $key => $value )
151 346 {
152 - if ($i > 0)
347 + $image = 'default.png';
348 + if ( file_exists(PH()->plugin_path() . '/assets/images/admin/settings/custom-fields/' . $key . '.png') )
153 349 {
154 - $html .= '<p><a href="' . admin_url( 'admin.php?page=ph-settings&tab=customfields&section=' . $key ) . '">' . $value . '</a></p>';
350 + $image = $key . '.png';
155 351 }
156 - ++$i;
352 + $html .= '<div>
353 + <div class="ph-grid-image">
354 + <div class="ph-grid-image-bg"><img alt="" src="' . esc_url(PH()->plugin_url() . '/assets/images/admin/settings/custom-fields/' . $image) . '" /></div>
355 + </div>
356 + <div class="feature-card-content">
357 + <h3>' . esc_html($value) . '</h3>
358 + <p style="margin-top:12px;"><a href="' . esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=' . $key )) . '" class="button-primary">Manage values</a></p>
359 + </div>
360 + </div>';
157 361 }
362 + $html .= '</div>';
158 363
159 364 return apply_filters( 'propertyhive_custom_fields_settings', array(
160 365
161 - array( 'title' => __( 'Custom Fields', 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_options' ),
366 + array( 'title' => __( 'Field Values', 'propertyhive' ), 'type' => 'title', 'desc' => __( 'Manage the values used in dropdowns, filters and fields across properties, contacts and other records.', 'propertyhive' ), 'id' => 'custom_field_options' ),
162 367
163 368 array(
164 369 'type' => 'html',
165 - 'title' => __( 'Custom Fields', 'propertyhive' ),
166 - 'html' => $html
370 + 'title' => '',
371 + 'html' => $html,
372 + 'full_width' => true
167 373 ),
168 374
169 - array( 'type' => 'sectionend', 'id' => 'custom_field_options'),
375 + array( 'type' => 'sectionend', 'id' => 'custom_field_options')
170 376
171 377 ));
172 378 }
173 379
@@ -174,72 +380,661 @@
174 380 /**
175 381 * Output the settings
176 382 */
177 383 public function output() {
178 - global $current_section;
384 + global $current_section, $redirect_after_save;
179 385
180 - if ( $current_section ) {
386 + if ( $current_section )
387 + {
388 + switch ( $current_section )
389 + {
390 + case "additional":
391 + {
392 + global $hide_save_button;
393 +
394 + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Shared admin settings-view state; this global is intentionally used to control the common settings template and is not an arbitrary application global.
395 + $hide_save_button = true;
181 396
182 - if (isset($_REQUEST['id'])) // we're either adding or editing
183 - {
184 - $current_id = empty( $_REQUEST['id'] ) ? '' : sanitize_text_field($_REQUEST['id']);
397 + // The main custom field screen listing them in a table
398 + $settings = $this->get_custom_fields_additional_fields_setting();
185 399
186 - switch ($current_section)
400 + PH_Admin_Settings::output_fields( $settings );
401 + break;
402 + }
403 + case "addadditionalfield":
404 + case "editadditionalfield":
187 405 {
188 - case "availability": { $settings = $this->get_custom_fields_availability_setting(); break; }
189 - case "availability-delete": { $settings = $this->get_custom_fields_delete($current_id, 'availability', __( 'Availability', 'propertyhive' )); break; }
190 - case "property-type": { $settings = $this->get_custom_fields_property_type_setting(); break; }
191 - case "property-type-delete": { $settings = $this->get_custom_fields_delete($current_id, 'property_type', __( 'Property Type', 'propertyhive' )); break; }
192 - case "commercial-property-type": { $settings = $this->get_custom_fields_commercial_property_type_setting(); break; }
193 - case "commercial-property-type-delete": { $settings = $this->get_custom_fields_delete($current_id, 'commercial_property_type', __( 'Property Type', 'propertyhive' )); break; }
194 - case "location": { $settings = $this->get_custom_fields_location_setting(); break; }
195 - case "location-delete": { $settings = $this->get_custom_fields_delete($current_id, 'location', __( 'Location', 'propertyhive' )); break; }
196 - case "parking": { $settings = $this->get_custom_fields_parking_setting(); break; }
197 - case "parking-delete": { $settings = $this->get_custom_fields_delete($current_id, 'parking', __( 'Parking', 'propertyhive' )); break; }
198 - case "outside-space": { $settings = $this->get_custom_fields_outside_space_setting(); break; }
199 - case "outside-space-delete": { $settings = $this->get_custom_fields_delete($current_id, 'outside_space', __( 'Outside Space', 'propertyhive' )); break; }
406 + $settings = $this->get_custom_fields_additional_field_settings();
407 +
408 + $redirect_after_save = admin_url('admin.php?page=ph-settings&tab=customfields&section=additional');
409 +
410 + PH_Admin_Settings::output_fields( $settings );
411 +
412 + break;
413 + }
414 + default:
415 + {
416 + // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- This branch only renders a settings form from an optional id; it does not mutate state. The corresponding save path verifies the settings nonce and capability.
417 + if ( isset( $_REQUEST['id'] ) ) // we're either adding or editing
418 + {
419 + // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- This id is used only to render a settings form; the corresponding save path verifies the settings nonce and capability.
420 + $current_id = ( isset( $_REQUEST['id'] ) && is_string( $_REQUEST['id'] ) ) ? sanitize_text_field( wp_unslash( $_REQUEST['id'] ) ) : '';
421 +
422 + switch ($current_section)
423 + {
424 + case "availability": { $settings = $this->get_custom_fields_availability_setting(); break; }
425 + case "availability-delete": { $settings = $this->get_custom_fields_delete($current_id, 'availability', __( 'Availability', 'propertyhive' )); break; }
426 + case "property-type": { $settings = $this->get_custom_fields_property_type_setting(); break; }
427 + case "property-type-delete": { $settings = $this->get_custom_fields_delete($current_id, 'property_type', __( 'Property Type', 'propertyhive' )); break; }
428 + case "commercial-property-type": { $settings = $this->get_custom_fields_commercial_property_type_setting(); break; }
429 + case "commercial-property-type-delete": { $settings = $this->get_custom_fields_delete($current_id, 'commercial_property_type', __( 'Property Type', 'propertyhive' )); break; }
430 + case "location": { $settings = $this->get_custom_fields_location_setting(); break; }
431 + case "location-delete": { $settings = $this->get_custom_fields_delete($current_id, 'location', __( 'Location', 'propertyhive' )); break; }
432 + case "parking": { $settings = $this->get_custom_fields_parking_setting(); break; }
433 + case "parking-delete": { $settings = $this->get_custom_fields_delete($current_id, 'parking', __( 'Parking', 'propertyhive' )); break; }
434 + case "outside-space": { $settings = $this->get_custom_fields_outside_space_setting(); break; }
435 + case "outside-space-delete": { $settings = $this->get_custom_fields_delete($current_id, 'outside_space', __( 'Outside Space', 'propertyhive' )); break; }
436 +
437 + case "price-qualifier": { $settings = $this->get_custom_fields_price_qualifier_setting(); break; }
438 + case "price-qualifier-delete": { $settings = $this->get_custom_fields_delete($current_id, 'price_qualifier', __( 'Price Qualifier', 'propertyhive' )); break; }
439 + case "sale-by": { $settings = $this->get_custom_fields_sale_by_setting(); break; }
440 + case "sale-by-delete": { $settings = $this->get_custom_fields_delete($current_id, 'sale_by', __( 'Sale By', 'propertyhive' )); break; }
441 + case "tenure": { $settings = $this->get_custom_fields_tenure_setting(); break; }
442 + case "tenure-delete": { $settings = $this->get_custom_fields_delete($current_id, 'tenure', __( 'Tenure', 'propertyhive' )); break; }
443 + case "commercial-tenure": { $settings = $this->get_custom_fields_commercial_tenure_setting(); break; }
444 + case "commercial-tenure-delete": { $settings = $this->get_custom_fields_delete($current_id, 'commercial_tenure', __( 'Tenure', 'propertyhive' )); break; }
445 +
446 + case "furnished": { $settings = $this->get_custom_fields_furnished_setting(); break; }
447 + case "furnished-delete": { $settings = $this->get_custom_fields_delete($current_id, 'furnished', __( 'Furnished', 'propertyhive' )); break; }
448 + case "management-key-date-type": { $settings = $this->get_custom_fields_management_key_date_type_setting(); break; }
449 + case "management-key-date-type-delete": { $settings = $this->get_custom_fields_delete($current_id, 'management_key_date_type', __( 'Management Date Types', 'propertyhive' )); break; }
450 +
451 + case "marketing-flag": { $settings = $this->get_custom_fields_marketing_flag_setting(); break; }
452 + case "marketing-flag-delete": { $settings = $this->get_custom_fields_delete($current_id, 'marketing_flag', __( 'Marketing Flag', 'propertyhive' )); break; }
453 +
454 + case "property-feature": { $settings = $this->get_custom_fields_property_feature_setting(); break; }
455 + case "property-feature-delete": { $settings = $this->get_custom_fields_delete($current_id, 'property_feature', __( 'Property Feature', 'propertyhive' )); break; }
456 +
457 + default:
458 + {
459 + $settings = apply_filters( 'propertyhive_custom_fields_section_settings', array(), $current_section );
460 +
461 + if ( empty($settings) )
462 + {
463 + echo 'UNKNOWN CUSTOM FIELD';
464 + }
465 + }
466 + }
467 +
468 + if ( strpos($current_section, '-delete') === FALSE )
469 + {
470 + $redirect_after_save = admin_url('admin.php?page=ph-settings&tab=customfields&section=' . $current_section);
471 + }
472 +
473 + PH_Admin_Settings::output_fields( $settings );
474 + }
475 + else
476 + {
477 + global $hide_save_button;
478 +
479 + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Shared admin settings-view state; this global is intentionally used to control the common settings template and is not an arbitrary application global.
480 + $hide_save_button = true;
481 +
482 + // The main custom field screen listing them in a table
483 + $settings = $this->get_custom_fields_setting($current_section);
200 484
201 - case "price-qualifier": { $settings = $this->get_custom_fields_price_qualifier_setting(); break; }
202 - case "price-qualifier-delete": { $settings = $this->get_custom_fields_delete($current_id, 'price_qualifier', __( 'Price Qualifier', 'propertyhive' )); break; }
203 - case "sale-by": { $settings = $this->get_custom_fields_sale_by_setting(); break; }
204 - case "sale-by-delete": { $settings = $this->get_custom_fields_delete($current_id, 'sale_by', __( 'Sale By', 'propertyhive' )); break; }
205 - case "tenure": { $settings = $this->get_custom_fields_tenure_setting(); break; }
206 - case "tenure-delete": { $settings = $this->get_custom_fields_delete($current_id, 'tenure', __( 'Tenure', 'propertyhive' )); break; }
207 - case "commercial-tenure": { $settings = $this->get_custom_fields_commercial_tenure_setting(); break; }
208 - case "commercial-tenure-delete": { $settings = $this->get_custom_fields_delete($current_id, 'commercial_tenure', __( 'Tenure', 'propertyhive' )); break; }
209 -
210 - case "furnished": { $settings = $this->get_custom_fields_furnished_setting(); break; }
211 - case "furnished-delete": { $settings = $this->get_custom_fields_delete($current_id, 'furnished', __( 'Furnished', 'propertyhive' )); break; }
485 + PH_Admin_Settings::output_fields( $settings );
486 + }
487 + }
488 + }
489 + }
490 + else
491 + {
492 + $settings = $this->get_settings();
212 493
213 - case "marketing-flag": { $settings = $this->get_custom_fields_marketing_flag_setting(); break; }
214 - case "marketing-flag-delete": { $settings = $this->get_custom_fields_delete($current_id, 'marketing_flag', __( 'Marketing Flag', 'propertyhive' )); break; }
215 -
216 - case "property-feature": { $settings = $this->get_custom_fields_property_feature_setting(); break; }
217 - case "property-feature-delete": { $settings = $this->get_custom_fields_delete($current_id, 'property_feature', __( 'Property Feature', 'propertyhive' )); break; }
218 -
494 + PH_Admin_Settings::output_fields( $settings );
495 + }
496 + }
219 497
220 - default: { echo 'UNKNOWN CUSTOM FIELD'; }
498 + public function get_custom_fields_additional_field_settings()
499 + {
500 + global $current_section;
501 +
502 + $current_settings = get_option( 'propertyhive_template_assistant', array() );
503 +
504 + if ( !isset($current_settings['custom_fields']) )
505 + {
506 + $current_settings['custom_fields'] = array();
507 + }
508 +
509 + // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- This settings getter only loads stored configuration for rendering; it does not mutate state.
510 + $current_id = ( isset( $_REQUEST['id'] ) && is_string( $_REQUEST['id'] ) ) ? sanitize_title( wp_unslash( $_REQUEST['id'] ) ) : '';
511 +
512 + $custom_field_details = array();
513 +
514 + if ($current_id != '')
515 + {
516 + $custom_fields = $current_settings['custom_fields'];
517 +
518 + if (isset($custom_fields[$current_id]))
519 + {
520 + $custom_field_details = $custom_fields[$current_id];
521 + }
522 + else
523 + {
524 + die('Trying to edit an additional field which does not exist. Please go back and try again.');
525 + }
526 + }
527 +
528 + $settings = array(
529 +
530 + array( 'title' => ( $current_section == 'addadditionalfield' ? __( 'Add Additional Field', 'propertyhive' ) : __( 'Edit Additional Field', 'propertyhive' ) ), 'type' => 'title', 'desc' => '', 'id' => 'customfield' ),
531 +
532 + );
533 +
534 + $settings[] = array(
535 + 'title' => __( 'Field Label', 'propertyhive' ),
536 + 'id' => 'field_label',
537 + 'default' => ( (isset($custom_field_details['field_label'])) ? $custom_field_details['field_label'] : ''),
538 + 'type' => 'text',
539 + 'desc_tip' => false,
540 + 'custom_attributes' => array(
541 + 'placeholder' => 'My New Field'
542 + )
543 + );
544 +
545 + if ( isset($custom_field_details['field_name']) )
546 + {
547 + $settings[] = array(
548 + 'title' => __( 'Field Name', 'propertyhive' ),
549 + 'id' => 'field_name',
550 + 'default' => ( (isset($custom_field_details['field_name'])) ? $custom_field_details['field_name'] : ''),
551 + 'type' => 'text',
552 + 'desc' => __( 'Please note that changing this after properties have been saved will result in any data entered being lost', 'propertyhive' ),
553 + );
554 + }
555 +
556 + $settings[] = array(
557 + 'title' => __( 'Field Type', 'propertyhive' ),
558 + 'id' => 'field_type',
559 + 'default' => ( (isset($custom_field_details['field_type'])) ? $custom_field_details['field_type'] : 'text'),
560 + 'type' => 'select',
561 + 'desc_tip' => false,
562 + 'options' => array(
563 + 'text' => 'Text',
564 + 'textarea' => 'Textarea',
565 + 'select' => 'Dropdown',
566 + 'multiselect' => 'Multi-Select',
567 + 'checkbox' => 'Checkbox',
568 + 'date' => 'Date',
569 + 'image' => 'Image',
570 + 'file' => 'File',
571 + )
572 + );
573 +
574 + $settings[] = array(
575 + 'title' => __( 'Dropdown Options', 'propertyhive' ),
576 + 'id' => 'dropdown_options',
577 + 'type' => 'additional_field_dropdown_options',
578 + );
579 +
580 + $options = array(
581 + 'property_address' => 'Property Address',
582 + 'property_department' => 'Property Department',
583 + );
584 +
585 + if ( get_option( 'propertyhive_active_departments_sales', '' ) == 'yes' || get_option( 'propertyhive_active_departments_lettings', '' ) == 'yes' )
586 + {
587 + $options['property_residential_details'] = __( 'Property Residential Details', 'propertyhive' );
588 +
589 + if ( get_option( 'propertyhive_active_departments_sales', '' ) == 'yes' )
590 + {
591 + $options['property_residential_sales_details'] = __( 'Property Residential Sales Details', 'propertyhive' );
592 + }
593 + if ( get_option( 'propertyhive_active_departments_lettings', '' ) == 'yes' )
594 + {
595 + $options['property_residential_lettings_details'] = __( 'Property Residential Lettings Details', 'propertyhive' );
596 + }
597 + }
598 +
599 + if ( get_option( 'propertyhive_active_departments_commercial', '' ) == 'yes' )
600 + {
601 + $options['property_commercial_details'] = __( 'Property Commercial Details', 'propertyhive' );
602 + }
603 +
604 + $options['property_marketing'] = __( 'Property Marketing', 'propertyhive' );
605 +
606 + if ( get_option('propertyhive_module_disabled_contacts', '') != 'yes' )
607 + {
608 + $options['contact_correspondence_address'] = __( 'Contact Correspondence Address', 'propertyhive' );
609 + $options['contact_contact_details'] = __( 'Contact Contact Details', 'propertyhive' );
610 + }
611 +
612 + if ( get_option('propertyhive_module_disabled_enquiries', '') != 'yes' )
613 + {
614 + $options['enquiry_record_details'] = __( 'Enquiry Record Details', 'propertyhive' );
615 + }
616 +
617 + if ( get_option('propertyhive_module_disabled_appraisals', '') != 'yes' )
618 + {
619 + $options['appraisal_details'] = __( 'Appraisal Details', 'propertyhive' );
620 + $options['appraisal_event'] = __( 'Appraisal Event Details', 'propertyhive' );
621 + }
622 +
623 + if ( get_option('propertyhive_module_disabled_viewings', '') != 'yes' )
624 + {
625 + $options['viewing_details'] = __( 'Viewing Details', 'propertyhive' );
626 + $options['viewing_event'] = __( 'Viewing Event Details', 'propertyhive' );
627 + }
628 +
629 + if ( get_option('propertyhive_module_disabled_offers_sales', '') != 'yes' )
630 + {
631 + $options['offer_details'] = __( 'Offer Details', 'propertyhive' );
632 + $options['sale_details'] = __( 'Sale Details', 'propertyhive' );
633 + }
634 +
635 + if ( get_option( 'propertyhive_active_departments_lettings' ) == 'yes' && get_option('propertyhive_module_disabled_tenancies', '') != 'yes' )
636 + {
637 + $options['tenancy_details'] = __( 'Tenancy Details', 'propertyhive' );
638 + $options['tenancy_management_details'] = __( 'Tenancy Management Details', 'propertyhive' );
639 + $options['tenancy_deposit_scheme'] = __( 'Tenancy Deposit Scheme Details', 'propertyhive' );
640 + $options['tenancy_meter_readings'] = __( 'Tenancy Meter Readings', 'propertyhive' );
641 + }
642 +
643 + $options['office_details'] = __( 'Office Details', 'propertyhive' );
644 +
645 + $options = apply_filters( 'propertyhive_template_assistant_custom_field_sections', $options );
646 +
647 + $settings[] = array(
648 + 'title' => __( 'Section', 'propertyhive' ),
649 + 'id' => 'meta_box',
650 + 'default' => ( (isset($custom_field_details['meta_box'])) ? $custom_field_details['meta_box'] : ''),
651 + 'type' => 'select',
652 + 'desc' => __( 'Please select which meta box on the property record this field should appear in', 'propertyhive' ),
653 + 'options' => $options
654 + );
655 +
656 + $settings[] = array(
657 + 'title' => __( 'Display On Website', 'propertyhive' ),
658 + 'id' => 'display_on_website',
659 + 'default' => ( (isset($custom_field_details['display_on_website']) && $custom_field_details['display_on_website'] == '1') ? 'yes' : ''),
660 + 'type' => 'checkbox',
661 + );
662 +
663 + if ( get_option('propertyhive_module_disabled_contacts', '') != 'yes' )
664 + {
665 + $settings[] = array(
666 + 'title' => __( 'Add As Match Field To Applicant Requirements', 'propertyhive' ),
667 + 'id' => 'display_on_applicant_requirements',
668 + 'default' => ( (isset($custom_field_details['display_on_applicant_requirements']) && $custom_field_details['display_on_applicant_requirements'] == '1') ? 'yes' : ''),
669 + 'type' => 'checkbox',
670 + );
671 + }
672 +
673 + $settings[] = array(
674 + 'title' => __( 'Exact Match Only If Searching On Field', 'propertyhive' ),
675 + 'id' => 'exact_match',
676 + 'default' => ( (isset($custom_field_details['exact_match']) && $custom_field_details['exact_match'] == '1') ? 'yes' : ''),
677 + 'type' => 'checkbox',
678 + 'desc' => __( 'If you\'re using this checkbox in property searches or matches tick this if properties should only be returned with the same ticked status. Alternatively, leave unticked for scenarios like \'Pets Allowed\' whereby properties with it ticked should come back whether search is ticked or not, but not vice versa.', 'propertyhive' ),
679 + );
680 +
681 + $settings[] = array(
682 + 'title' => __( 'Display On Registration Form / My Account', 'propertyhive' ),
683 + 'id' => 'display_on_user_details',
684 + 'default' => ( (isset($custom_field_details['display_on_user_details']) && $custom_field_details['display_on_user_details'] == '1') ? 'yes' : ''),
685 + 'type' => 'checkbox',
686 + );
687 +
688 + $settings[] = array(
689 + 'title' => __( 'Show In Admin List', 'propertyhive' ),
690 + 'id' => 'admin_list',
691 + 'default' => ( (isset($custom_field_details['admin_list']) && $custom_field_details['admin_list'] == '1') ? 'yes' : ''),
692 + 'type' => 'checkbox',
693 + );
694 +
695 + $settings[] = array(
696 + 'title' => __( 'Sortable In Admin List', 'propertyhive' ),
697 + 'id' => 'admin_list_sortable',
698 + 'default' => ( (isset($custom_field_details['admin_list_sortable']) && $custom_field_details['admin_list_sortable'] == '1') ? 'yes' : ''),
699 + 'type' => 'checkbox',
700 + );
701 +
702 + $settings[] = array( 'type' => 'sectionend', 'id' => 'customfield');
703 +
704 + $settings[] = array(
705 + 'type' => 'html',
706 + 'html' => '<script>
707 +
708 + jQuery(document).ready(function()
709 + {
710 + ph_hide_show_type_related_checkboxes();
711 +
712 + jQuery(\'#meta_box\').change(function()
713 + {
714 + ph_hide_show_type_related_checkboxes();
715 + });
716 +
717 + jQuery(\'#field_type\').change(function()
718 + {
719 + ph_hide_show_type_related_checkboxes();
720 + });
721 + });
722 +
723 + function ph_hide_show_type_related_checkboxes()
724 + {
725 + var meta_box = jQuery(\'#meta_box\').val();
726 +
727 + jQuery(\'#row_display_on_website\').hide();
728 + jQuery(\'#row_display_on_applicant_requirements\').hide();
729 + jQuery(\'#row_display_on_user_details\').hide();
730 + jQuery(\'#row_exact_match\').hide();
731 +
732 + jQuery(\'#row_admin_list\').show();
733 + jQuery(\'#row_admin_list_sortable\').show();
734 +
735 + if ( meta_box.indexOf(\'property_\') != -1 )
736 + {
737 + jQuery(\'#row_display_on_website\').show();
738 +
739 + if ( jQuery(\'#field_type\').val() == \'select\' || jQuery(\'#field_type\').val() == \'multiselect\' || jQuery(\'#field_type\').val() == \'checkbox\' )
740 + {
741 + jQuery(\'#row_display_on_applicant_requirements\').show();
742 + }
743 +
744 + if ( jQuery(\'#field_type\').val() == \'checkbox\' )
745 + {
746 + jQuery(\'#row_exact_match\').show();
747 + }
748 + }
749 + if ( meta_box.indexOf(\'contact_\') != -1 )
750 + {
751 + jQuery(\'#row_display_on_user_details\').show();
752 + }
753 + if ( meta_box == \'tenancy_management_details\' )
754 + {
755 + jQuery(\'#row_admin_list\').hide();
756 + jQuery(\'#row_admin_list_sortable\').hide();
757 + }
221 758 }
222 -
223 - PH_Admin_Settings::output_fields( $settings );
759 +
760 + </script>'
761 + );
762 +
763 + return $settings;
764 + }
765 +
766 + public function additional_field_dropdown_options()
767 + {
768 + $current_settings = get_option( 'propertyhive_template_assistant', array() );
769 +
770 + if ( !isset($current_settings['custom_fields']) )
771 + {
772 + $current_settings['custom_fields'] = array();
773 + }
774 +
775 + // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- This settings getter only loads stored configuration for rendering; it does not mutate state.
776 + $current_id = ( isset( $_REQUEST['id'] ) && is_string( $_REQUEST['id'] ) ) ? sanitize_title( wp_unslash( $_REQUEST['id'] ) ) : '';
777 +
778 + $custom_field_details = array();
779 +
780 + if ($current_id != '')
781 + {
782 + $custom_fields = $current_settings['custom_fields'];
783 +
784 + if (isset($custom_fields[$current_id]))
785 + {
786 + $custom_field_details = $custom_fields[$current_id];
224 787 }
225 788 else
226 789 {
227 - global $hide_save_button;
228 -
229 - $hide_save_button = true;
230 -
231 - // The main custom field screen listing them in a table
232 - $settings = $this->get_custom_fields_setting($current_section);
790 + die('Trying to edit an additional field which does not exist. Please go back and try again.');
791 + }
792 + }
793 +
794 + echo '
795 + <tr valign="top" id="row_dropdown_options">
796 + <th scope="row" class="titledesc">
797 + <label for="field_type">Dropdown Options</label>
798 + </th>
799 + <td class="forminp forminp-dropdown-options"><div id="sortable_options_' . esc_attr( $current_id ) . '">';
800 + if ( isset($custom_field_details['dropdown_options']) && !empty($custom_field_details['dropdown_options']) )
801 + {
802 + foreach ( $custom_field_details['dropdown_options'] as $dropdown_option )
803 + {
804 + echo '
805 + <div><i class="fa fa-reorder" style="cursor:pointer; opacity:0.3"></i> <input type="text" name="dropdown_options[]" value="' . esc_attr( $dropdown_option ) . '"> <a href="" class="delete-dropdown-option">Delete Option</a></div>
806 + ';
807 + }
808 + }
809 + else
810 + {
811 + // None exist
812 + echo '
813 + <div><i class="fa fa-reorder" style="cursor:pointer; opacity:0.3"></i> <input type="text" name="dropdown_options[]" placeholder="Add Option"> <a href="" class="delete-dropdown-option">Delete Option</a></div>
814 + ';
815 + }
816 + echo '
817 + </div>
818 + <a href="" class="add-dropdown-option">Add New Option</a>
819 + </td>
820 + </tr>
821 +
822 + <script>
823 + jQuery(document).ready(function()
824 + {
825 + toggle_dropdown_options();
826 +
827 + jQuery(\'#field_type\').change(function()
828 + {
829 + toggle_dropdown_options();
830 + });
831 +
832 + jQuery(\'body\').on(\'click\', \'a.add-dropdown-option\', function(e)
833 + {
834 + e.preventDefault();
835 +
836 + jQuery(\'.forminp-dropdown-options > div\').append(\'<div><i class="fa fa-reorder" style="cursor:pointer; opacity:0.3"></i> <input type="text" name="dropdown_options[]" placeholder="Add Option"> <a href="" class="delete-dropdown-option">Delete Option</a></div>\');
837 + });
838 +
839 + jQuery(\'body\').on(\'click\', \'a.delete-dropdown-option\', function(e)
840 + {
841 + e.preventDefault();
842 +
843 + var confirmBox = confirm(\'Are you sure you wish to delete this option?\');
844 +
845 + if ( confirmBox )
846 + {
847 + jQuery(this).parent().remove();
848 + }
849 + });
850 +
851 + jQuery( \'#sortable_options_' . esc_js( $current_id ) . '\' )
852 + .sortable({
853 + axis: "y",
854 + handle: "i",
855 + stop: function( event, ui )
856 + {
857 + // IE doesn\'t register the blur when sorting
858 + // so trigger focusout handlers to remove .ui-state-focus
859 + //ui.item.children( "h3" ).triggerHandler( "focusout" );
860 +
861 + // Refresh accordion to handle new order
862 + //jQuery( this ).accordion( "refresh" );
863 + },
864 + update: function( event, ui )
865 + {
866 + // Update hidden fields
867 + var fields_order = jQuery(this).sortable(\'toArray\');
868 +
869 + //$(\'#active_fields_order\').val( fields_order.join("|") );
870 + }
871 + });
872 + });
873 +
874 + function toggle_dropdown_options()
875 + {
876 + if ( jQuery(\'#field_type\').val() == \'select\' || jQuery(\'#field_type\').val() == \'multiselect\' )
877 + {
878 + jQuery(\'#row_dropdown_options\').show();
879 + }
880 + else
881 + {
882 + jQuery(\'#row_dropdown_options\').hide();
883 + }
884 + }
885 + </script>
886 + ';
887 + }
888 +
889 + public function get_custom_fields_additional_fields_setting()
890 + {
891 + return apply_filters( 'propertyhive_custom_fields_settings', array(
892 +
893 + array( 'title' => __( 'Additional Fields', 'propertyhive' ), 'type' => 'title', 'desc' => __( 'Create new fields to store information not included by default.', 'propertyhive' ), 'id' => 'additional_field_options' ),
233 894
234 - PH_Admin_Settings::output_fields( $settings );
235 - }
895 + array(
896 + 'type' => 'additional_fields_table',
897 + ),
236 898
237 - } else {
238 - $settings = $this->get_settings();
899 + array( 'type' => 'sectionend', 'id' => 'additional_field_options')
900 +
901 + ));
902 + }
239 903
240 - PH_Admin_Settings::output_fields( $settings );
904 + /**
905 + * Output list of additional fields
906 + *
907 + * @access public
908 + * @return void
909 + */
910 + public function additional_fields_table() {
911 + global $wpdb, $post;
912 +
913 + $current_settings = get_option( 'propertyhive_template_assistant', array() );
914 + $custom_fields = array();
915 + if ($current_settings !== FALSE)
916 + {
917 + if (isset($current_settings['custom_fields']))
918 + {
919 + $custom_fields = $current_settings['custom_fields'];
920 + }
241 921 }
922 +?>
923 + <tr valign="top">
924 + <td class="forminp forminp-button">
925 + <a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=addadditionalfield' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Field', 'propertyhive' )); ?></a>
926 + </td>
927 + </tr>
928 + <tr valign="top">
929 + <td class="forminp">
930 + <style type="text/css">
931 + .ui-sortable-helper {
932 + display: table;
933 + }
934 + </style>
935 + <table class="ph_additional_fields widefat" cellspacing="0">
936 + <thead>
937 + <tr>
938 + <th style="padding:8px 10px;" class="field-label"><?php esc_html_e( 'Field Name', 'propertyhive' ); ?></th>
939 + <th style="padding:8px 10px;" class="section"><?php esc_html_e( 'Section', 'propertyhive' ); ?></th>
940 + <th style="padding:8px 10px;" class="usage"><?php esc_html_e( 'Usage', 'propertyhive' ); ?></th>
941 + <th style="padding:8px 10px;" class="website"><?php esc_html_e( 'Display On Website', 'propertyhive' ); ?></th>
942 + <th style="padding:8px 10px;" class="admin-list"><?php esc_html_e( 'Show In Admin List', 'propertyhive' ); ?></th>
943 + <th style="padding:8px 10px;" class="admin-list-sorting"><?php esc_html_e( 'Sortable In Admin List', 'propertyhive' ); ?></th>
944 + <th style="padding:8px 10px;" class="settings">&nbsp;</th>
945 + </tr>
946 + </thead>
947 + <tbody class="<?php echo !empty($custom_fields) ? 'has-rows' : ''; ?>">
948 + <?php
949 +
950 + if (!empty($custom_fields))
951 + {
952 + foreach ($custom_fields as $id => $custom_field)
953 + {
954 + echo '<tr id="custom_field_' . esc_attr($id) . '">';
955 + echo '<td class="field-label"><span class="sort_anchor" style="cursor:grab "> ⇅ </span>' . esc_html($custom_field['field_label']) . '</td>';
956 + echo '<td class="section">' . esc_html(ucwords( str_replace("_", " ", $custom_field['meta_box']) )) . '</td>';
957 + echo '<td class="usage">';
958 + if ( substr( $custom_field['meta_box'], 0, 8 ) == 'property' ) { echo '<pre style="background:#EEE; padding:5px; display:inline">&lt;?php $property->' . esc_html(ltrim( $custom_field['field_name'], '_' )) . '; ?&gt;</pre>'; }else{ echo '-';}
959 + echo '</td>';
960 + echo '<td class="website">';
961 + if ( substr( $custom_field['meta_box'], 0, 8 ) == 'property' ) { echo esc_html( ( ( isset($custom_field['display_on_website']) && $custom_field['display_on_website'] == '1' ) ? __( 'Yes', 'propertyhive' ) : __( 'No', 'propertyhive' ) ) ); }else{ echo '-'; }
962 + echo '</td>';
963 + echo '<td class="admin-list">';
964 + echo esc_html( ( ( isset($custom_field['admin_list']) && $custom_field['admin_list'] == '1' ) ? __( 'Yes', 'propertyhive' ) : __( 'No', 'propertyhive' ) ) );
965 + echo '</td>';
966 + echo '<td class="sorting">';
967 + if ( ( isset($custom_field['admin_list']) && $custom_field['admin_list'] == '1' ) )
968 + {
969 + echo esc_html( ( ( isset($custom_field['admin_list_sortable']) && $custom_field['admin_list_sortable'] == '1' ) ? __( 'Yes', 'propertyhive' ) : __( 'No', 'propertyhive' ) ) );
970 + }
971 + else
972 + {
973 + echo '-';
974 + }
975 + echo '</td>';
976 +
977 + $delete_url = wp_nonce_url(
978 + admin_url(
979 + 'admin.php?page=ph-settings&tab=customfields&section=additional&action=deleteadditionalfield&id=' . rawurlencode( $id )
980 + ),
981 + 'propertyhive_delete_additional_field'
982 + );
983 +
984 + echo '<td class="settings">
985 + <a class="button" href="' . esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=editadditionalfield&id=' . $id )) . '">' . esc_html(__( 'Edit Field', 'propertyhive' )) . '</a>
986 + <a class="button" href="' . esc_url( $delete_url ) . '" onclick="var confirmBox = confirm(\'Are you sure you wish to delete this custom field?\'); return confirmBox;">' . esc_html(__( 'Delete', 'propertyhive' )) . '</a>
987 + </td>';
988 + echo '</tr>';
989 + }
990 + }
991 + else
992 + {
993 + echo '<tr>';
994 + echo '<td align="center" colspan="7">' . esc_html(__( 'No additional fields exist', 'propertyhive' )) . '</td>';
995 + echo '</tr>';
996 + }
997 + ?>
998 + </tbody>
999 + </table>
1000 +
1001 + <script>
1002 + jQuery( function($){
1003 +
1004 + $('.ph_additional_fields tbody.has-rows').sortable({
1005 + opacity: 0.8,
1006 + revert: true,
1007 + handle: ".sort_anchor",
1008 + update : function (event, ui)
1009 + {
1010 + $('.ph_additional_fields tbody.has-rows').sortable( "destroy" );
1011 +
1012 + var new_order = '';
1013 + jQuery('.ph_additional_fields tbody.has-rows').find('tr').each( function ()
1014 + {
1015 + if (new_order != '')
1016 + {
1017 + new_order += ',';
1018 + }
1019 + new_order = new_order + jQuery(this).attr('id').replace('custom_field_', '');
1020 + });
1021 +
1022 + // reload page
1023 + window.location.href = <?php echo wp_json_encode( add_query_arg( '_wpnonce', wp_create_nonce( 'propertyhive_reorder_additional_fields' ), admin_url( 'admin.php?page=ph-settings&tab=customfields&section=additional' ) ), JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT ); ?> + '&neworder=' + encodeURIComponent( new_order );
1024 + }
1025 + });
1026 +
1027 + });
1028 + </script>
1029 + </td>
1030 + </tr>
1031 + <tr valign="top">
1032 + <td class="forminp forminp-button">
1033 + <a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=addadditionalfield' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Field', 'propertyhive' )); ?></a>
1034 + </td>
1035 + </tr>
1036 +<?php
242 1037 }
243 1038
244 1039 /**
245 1040 * Output custom fields settings.
@@ -248,9 +1043,9 @@
248 1043 * @return void
249 1044 */
250 1045 public function get_custom_fields_setting($current_section) {
251 1046
252 - $sections = $this->get_sections();
1047 + $sections = $this->custom_field_sections;
253 1048
254 1049 return apply_filters( 'propertyhive_custom_fields_' . $current_section . '_settings', array(
255 1050
256 1051 array( 'title' => $sections[$current_section], 'type' => 'title', 'desc' => '', 'id' => 'custom_fields_' . $current_section . '_options' ),
@@ -283,22 +1078,24 @@
283 1078 <th scope="row" class="titledesc">
284 1079 &nbsp;
285 1080 </th>
286 1081 <td class="forminp forminp-button">
287 - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
288 - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=availability&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Availability', 'propertyhive' ); ?></a>
1082 + <a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a>
1083 + <a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=availability&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Availability', 'propertyhive' )); ?></a>
289 1084 </td>
290 1085 </tr>
291 1086 <tr valign="top">
292 - <th scope="row" class="titledesc"><?php _e( 'Availability Options', 'propertyhive' ) ?></th>
1087 + <th scope="row" class="titledesc"><?php echo esc_html(__( 'Availability Options', 'propertyhive' )); ?></th>
293 1088 <td class="forminp">
294 - <table class="ph_customfields widefat" cellspacing="0">
1089 + <table class="ph_customfields sortable-custom-field widefat" data-taxonomy="availability" cellspacing="0">
295 1090 <thead>
296 1091 <tr>
297 - <th class="cb" style="width:1px;">&nbsp;</th>
298 - <th class="id" style="width:45px;"><?php _e( 'ID', 'propertyhive' ); ?></th>
299 - <th class="type"><?php _e( 'Availability', 'propertyhive' ); ?></th>
300 - <th class="department"><?php _e( 'Applies To', 'propertyhive' ); ?></th>
1092 + <th class="cb" style="width:1px;"><input class="select_all" type="checkbox" style="margin: 2px 0 0 0;"></th>
1093 + <th class="id" style="width:45px;"><?php echo esc_html(__( 'ID', 'propertyhive' )); ?></th>
1094 + <?php do_action( 'propertyhive_custom_field_availability_table_before_header_column' ); ?>
1095 + <th class="type"><?php echo esc_html(__( 'Availability', 'propertyhive' )); ?></th>
1096 + <th class="department"><?php echo esc_html(__( 'Applies To', 'propertyhive' )); ?></th>
1097 + <th class="assigned_count"><?php echo esc_html(__( 'Assigned Properties', 'propertyhive' )); ?></th>
301 1098 <th class="settings">&nbsp;</th>
302 1099 </tr>
303 1100 </thead>
304 1101 <tbody>
@@ -306,19 +1103,20 @@
306 1103 $args = array(
307 1104 'hide_empty' => false,
308 1105 'parent' => 0
309 1106 );
310 - $terms = get_terms( 'availability', $args );
1107 + $terms = get_terms( array_merge( wp_parse_args( $args ), array( 'taxonomy' => 'availability' ) ) );
311 1108
312 1109 if ( !empty( $terms ) && !is_wp_error( $terms ) )
313 1110 {
314 1111 foreach ( $terms as $term )
315 - {
1112 + {
316 1113 ?>
317 - <tr>
318 - <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"></td>
319 - <td class="id"><?php echo $term->term_id; ?></td>
320 - <td class="type"><?php echo $term->name; ?></td>
1114 + <tr id="term-<?php echo esc_attr($term->term_id); ?>">
1115 + <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo esc_attr($term->term_id); ?>"></td>
1116 + <td class="id"><?php echo esc_html($term->term_id); ?></td>
1117 + <?php do_action( 'propertyhive_custom_field_availability_table_before_row_column', $term->term_id ); ?>
1118 + <td class="type"><?php echo esc_html($term->name); ?></td>
321 1119 <td class="department"><?php
322 1120 $this_availability_departments = array();
323 1121 if ( isset($availability_departments[$term->term_id]) )
324 1122 {
@@ -340,13 +1138,14 @@
340 1138 }
341 1139 }
342 1140 }
343 1141
344 - echo !empty($this_availability_departments) ? implode(", ", $this_availability_departments) : '-';
1142 + echo !empty($this_availability_departments) ? esc_html(implode(", ", $this_availability_departments)) : '-';
345 1143 ?></td>
1144 + <td class="assigned_count"><?php echo esc_html($term->count); ?></td>
346 1145 <td class="settings">
347 - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=availability&id=' . $term->term_id ); ?>"><?php echo __( 'Edit', 'propertyhive' ); ?></a>
348 - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=availability-delete&id=' . $term->term_id ); ?>"><?php echo __( 'Delete', 'propertyhive' ); ?></a>
1146 + <a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=availability&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Edit', 'propertyhive' )); ?></a>
1147 + <a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=availability-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a>
349 1148 </td>
350 1149 </tr>
351 1150 <?php
352 1151 }
@@ -354,12 +1153,9 @@
354 1153 else
355 1154 {
356 1155 ?>
357 1156 <tr>
358 - <td><?php echo __( 'No availability options found', 'propertyhive' ); ?></td>
359 - <td class="settings">
360 -
361 - </td>
1157 + <td colspan="6"><?php echo esc_html(__( 'No availability options found', 'propertyhive' )); ?></td>
362 1158 </tr>
363 1159 <?php
364 1160 }
365 1161 ?>
@@ -371,10 +1167,10 @@
371 1167 <th scope="row" class="titledesc">
372 1168 &nbsp;
373 1169 </th>
374 1170 <td class="forminp forminp-button">
375 - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
376 - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=availability&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Availability', 'propertyhive' ); ?></a>
1171 + <a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a>
1172 + <a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=availability&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Availability', 'propertyhive' )); ?></a>
377 1173 </td>
378 1174 </tr>
379 1175 <?php
380 1176 }
@@ -392,22 +1188,23 @@
392 1188 <th scope="row" class="titledesc">
393 1189 &nbsp;
394 1190 </th>
395 1191 <td class="forminp forminp-button">
396 - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
397 - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=property-type&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Property Type', 'propertyhive' ); ?></a>
1192 + <a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a>
1193 + <a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=property-type&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Property Type', 'propertyhive' )); ?></a>
398 1194 </td>
399 1195 </tr>
400 1196 <tr valign="top">
401 - <th scope="row" class="titledesc"><?php _e( 'Property Types', 'propertyhive' ) ?></th>
1197 + <th scope="row" class="titledesc"><?php echo esc_html(__( 'Property Types', 'propertyhive' )); ?></th>
402 1198 <td class="forminp">
403 1199 <table class="ph_customfields widefat" cellspacing="0">
404 1200 <thead>
405 1201 <tr>
406 - <th class="cb" style="width:1px;">&nbsp;</th>
407 - <th class="id" style="width:45px;"><?php _e( 'ID', 'propertyhive' ); ?></th>
1202 + <th class="cb" style="width:1px;"><input class="select_all" type="checkbox" style="margin: 2px 0 0 0;"></th>
1203 + <th class="id" style="width:45px;"><?php echo esc_html(__( 'ID', 'propertyhive' )); ?></th>
408 1204 <?php do_action( 'propertyhive_custom_field_property_type_table_before_header_column' ); ?>
409 - <th class="type"><?php _e( 'Property Type', 'propertyhive' ); ?></th>
1205 + <th class="type"><?php echo esc_html(__( 'Property Type', 'propertyhive' )); ?></th>
1206 + <th class="assigned_count"><?php echo esc_html(__( 'Assigned Properties', 'propertyhive' )); ?></th>
410 1207 <th class="settings">&nbsp;</th>
411 1208 </tr>
412 1209 </thead>
413 1210 <tbody>
@@ -415,10 +1212,10 @@
415 1212 $args = array(
416 1213 'hide_empty' => false,
417 1214 'parent' => 0
418 1215 );
419 - $terms = get_terms( 'property_type', $args );
420 -
1216 + $terms = get_terms( array_merge( wp_parse_args( $args ), array( 'taxonomy' => 'property_type' ) ) );
1217 +
421 1218 if ( !empty( $terms ) && !is_wp_error( $terms ) )
422 1219 {
423 1220 foreach ($terms as $term)
424 1221 {
@@ -427,19 +1224,20 @@
427 1224 $args = array(
428 1225 'hide_empty' => false,
429 1226 'parent' => $parent_term_id
430 1227 );
431 - $subterms = get_terms( 'property_type', $args );
1228 + $subterms = get_terms( array_merge( wp_parse_args( $args ), array( 'taxonomy' => 'property_type' ) ) );
432 1229 ?>
433 1230 <tr>
434 - <td class="cb"><?php if ( empty( $subterms ) ) { ?><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"><?php }else{ echo '&nbsp;'; } ?></td>
435 - <td class="id"><?php echo $term->term_id; ?></td>
1231 + <td class="cb"><?php if ( empty( $subterms ) ) { ?><input type="checkbox" name="term_id[]" value="<?php echo esc_attr($term->term_id); ?>"><?php }else{ echo '&nbsp;'; } ?></td>
1232 + <td class="id"><?php echo esc_html($term->term_id); ?></td>
436 1233 <?php do_action( 'propertyhive_custom_field_property_type_table_before_row_column', $term->term_id ); ?>
437 - <td class="type"><?php echo $term->name; ?></td>
1234 + <td class="type"><?php echo esc_html($term->name); ?></td>
1235 + <td class="assigned_count"><?php echo esc_html($term->count); ?></td>
438 1236 <td class="settings">
439 - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=property-type&id=' . $term->term_id ); ?>"><?php echo __( 'Edit', 'propertyhive' ); ?></a>
1237 + <a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=property-type&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Edit', 'propertyhive' )); ?></a>
440 1238 <?php if ( empty( $subterms ) ) { ?>
441 - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=property-type-delete&id=' . $term->term_id ); ?>"><?php echo __( 'Delete', 'propertyhive' ); ?></a>
1239 + <a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=property-type-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a>
442 1240 <?php } ?>
443 1241 </td>
444 1242 </tr>
445 1243 <?php
@@ -448,15 +1246,16 @@
448 1246 foreach ($subterms as $term)
449 1247 {
450 1248 ?>
451 1249 <tr>
452 - <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"></td>
453 - <td class="id"><?php echo $term->term_id; ?></td>
1250 + <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo esc_attr($term->term_id); ?>"></td>
1251 + <td class="id"><?php echo esc_html($term->term_id); ?></td>
454 1252 <?php do_action( 'propertyhive_custom_field_property_type_table_before_row_column', $term->term_id, $parent_term_id ); ?>
455 - <td class="type subtype">&nbsp;&nbsp;&nbsp;- <?php echo $term->name; ?></td>
1253 + <td class="type subtype">&nbsp;&nbsp;&nbsp;- <?php echo esc_html($term->name); ?></td>
1254 + <td class="assigned_count"><?php echo esc_html($term->count); ?></td>
456 1255 <td class="settings">
457 - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=property-type&id=' . $term->term_id ); ?>"><?php echo __( 'Edit', 'propertyhive' ); ?></a>
458 - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=property-type-delete&id=' . $term->term_id ); ?>"><?php echo __( 'Delete', 'propertyhive' ); ?></a>
1256 + <a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=property-type&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Edit', 'propertyhive' )); ?></a>
1257 + <a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=property-type-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a>
459 1258 </td>
460 1259 </tr>
461 1260 <?php
462 1261 }
@@ -468,9 +1267,9 @@
468 1267 else
469 1268 {
470 1269 ?>
471 1270 <tr>
472 - <td colspan="3"><?php echo __( 'No property types found', 'propertyhive' ); ?></td>
1271 + <td colspan="5"><?php echo esc_html(__( 'No property types found', 'propertyhive' )); ?></td>
473 1272 </tr>
474 1273 <?php
475 1274 }
476 1275 ?>
@@ -482,10 +1281,10 @@
482 1281 <th scope="row" class="titledesc">
483 1282 &nbsp;
484 1283 </th>
485 1284 <td class="forminp forminp-button">
486 - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
487 - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=property-type&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Property Type', 'propertyhive' ); ?></a>
1285 + <a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a>
1286 + <a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=property-type&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Property Type', 'propertyhive' )); ?></a>
488 1287 </td>
489 1288 </tr>
490 1289 <?php
491 1290 }
@@ -503,22 +1302,23 @@
503 1302 <th scope="row" class="titledesc">
504 1303 &nbsp;
505 1304 </th>
506 1305 <td class="forminp forminp-button">
507 - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
508 - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=commercial-property-type&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Property Type', 'propertyhive' ); ?></a>
1306 + <a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a>
1307 + <a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=commercial-property-type&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Property Type', 'propertyhive' )); ?></a>
509 1308 </td>
510 1309 </tr>
511 1310 <tr valign="top">
512 - <th scope="row" class="titledesc"><?php _e( 'Property Types', 'propertyhive' ) ?></th>
1311 + <th scope="row" class="titledesc"><?php echo esc_html(__( 'Property Types', 'propertyhive' )); ?></th>
513 1312 <td class="forminp">
514 1313 <table class="ph_customfields widefat" cellspacing="0">
515 1314 <thead>
516 1315 <tr>
517 - <th class="cb" style="width:1px;">&nbsp;</th>
518 - <th class="id" style="width:45px;"><?php _e( 'ID', 'propertyhive' ); ?></th>
1316 + <th class="cb" style="width:1px;"><input class="select_all" type="checkbox" style="margin: 2px 0 0 0;"></th>
1317 + <th class="id" style="width:45px;"><?php echo esc_html(__( 'ID', 'propertyhive' )); ?></th>
519 1318 <?php do_action( 'propertyhive_custom_field_commercial_property_type_table_before_header_column' ); ?>
520 - <th class="type"><?php _e( 'Property Type', 'propertyhive' ); ?></th>
1319 + <th class="type"><?php echo esc_html(__( 'Property Type', 'propertyhive' )); ?></th>
1320 + <th class="assigned_count"><?php echo esc_html(__( 'Assigned Properties', 'propertyhive' )); ?></th>
521 1321 <th class="settings">&nbsp;</th>
522 1322 </tr>
523 1323 </thead>
524 1324 <tbody>
@@ -526,9 +1326,9 @@
526 1326 $args = array(
527 1327 'hide_empty' => false,
528 1328 'parent' => 0
529 1329 );
530 - $terms = get_terms( 'commercial_property_type', $args );
1330 + $terms = get_terms( array_merge( wp_parse_args( $args ), array( 'taxonomy' => 'commercial_property_type' ) ) );
531 1331
532 1332 if ( !empty( $terms ) && !is_wp_error( $terms ) )
533 1333 {
534 1334 foreach ($terms as $term)
@@ -538,19 +1338,20 @@
538 1338 $args = array(
539 1339 'hide_empty' => false,
540 1340 'parent' => $parent_term_id
541 1341 );
542 - $subterms = get_terms( 'commercial_property_type', $args );
1342 + $subterms = get_terms( array_merge( wp_parse_args( $args ), array( 'taxonomy' => 'commercial_property_type' ) ) );
543 1343 ?>
544 1344 <tr>
545 - <td class="cb"><?php if ( empty( $subterms ) ) { ?><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"><?php }else{ echo '&nbsp;'; } ?></td>
546 - <td class="id"><?php echo $term->term_id; ?></td>
1345 + <td class="cb"><?php if ( empty( $subterms ) ) { ?><input type="checkbox" name="term_id[]" value="<?php echo esc_attr($term->term_id); ?>"><?php }else{ echo '&nbsp;'; } ?></td>
1346 + <td class="id"><?php echo esc_html($term->term_id); ?></td>
547 1347 <?php do_action( 'propertyhive_custom_field_commercial_property_type_table_before_row_column', $term->term_id ); ?>
548 - <td class="type"><?php echo $term->name; ?></td>
1348 + <td class="type"><?php echo esc_html($term->name); ?></td>
1349 + <td class="assigned_count"><?php echo esc_html($term->count); ?></td>
549 1350 <td class="settings">
550 - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=commercial-property-type&id=' . $term->term_id ); ?>"><?php echo __( 'Edit', 'propertyhive' ); ?></a>
1351 + <a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=commercial-property-type&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Edit', 'propertyhive' )); ?></a>
551 1352 <?php if ( empty( $subterms ) ) { ?>
552 - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=commercial-property-type-delete&id=' . $term->term_id ); ?>"><?php echo __( 'Delete', 'propertyhive' ); ?></a>
1353 + <a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=commercial-property-type-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a>
553 1354 <?php } ?>
554 1355 </td>
555 1356 </tr>
556 1357 <?php
@@ -559,15 +1360,16 @@
559 1360 foreach ($subterms as $term)
560 1361 {
561 1362 ?>
562 1363 <tr>
563 - <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"></td>
564 - <td class="id"><?php echo $term->term_id; ?></td>
1364 + <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo esc_attr($term->term_id); ?>"></td>
1365 + <td class="id"><?php echo esc_html($term->term_id); ?></td>
565 1366 <?php do_action( 'propertyhive_custom_field_commercial_property_type_table_before_row_column', $term->term_id, $parent_term_id ); ?>
566 - <td class="type subtype">&nbsp;&nbsp;&nbsp;- <?php echo $term->name; ?></td>
1367 + <td class="type subtype">&nbsp;&nbsp;&nbsp;- <?php echo esc_html($term->name); ?></td>
1368 + <td class="assigned_count"><?php echo esc_html($term->count); ?></td>
567 1369 <td class="settings">
568 - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=commercial-property-type&id=' . $term->term_id ); ?>"><?php echo __( 'Edit', 'propertyhive' ); ?></a>
569 - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=commercial-property-type-delete&id=' . $term->term_id ); ?>"><?php echo __( 'Delete', 'propertyhive' ); ?></a>
1370 + <a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=commercial-property-type&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Edit', 'propertyhive' )); ?></a>
1371 + <a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=commercial-property-type-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a>
570 1372 </td>
571 1373 </tr>
572 1374 <?php
573 1375 }
@@ -579,9 +1381,9 @@
579 1381 else
580 1382 {
581 1383 ?>
582 1384 <tr>
583 - <td colspan="3"><?php echo __( 'No property types found', 'propertyhive' ); ?></td>
1385 + <td colspan="5"><?php echo esc_html(__( 'No property types found', 'propertyhive' )); ?></td>
584 1386 </tr>
585 1387 <?php
586 1388 }
587 1389 ?>
@@ -593,10 +1395,10 @@
593 1395 <th scope="row" class="titledesc">
594 1396 &nbsp;
595 1397 </th>
596 1398 <td class="forminp forminp-button">
597 - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
598 - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=commercial-property-type&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Property Type', 'propertyhive' ); ?></a>
1399 + <a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a>
1400 + <a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=commercial-property-type&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Property Type', 'propertyhive' )); ?></a>
599 1401 </td>
600 1402 </tr>
601 1403 <?php
602 1404 }
@@ -614,21 +1416,22 @@
614 1416 <th scope="row" class="titledesc">
615 1417 &nbsp;
616 1418 </th>
617 1419 <td class="forminp forminp-button">
618 - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
619 - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=location&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Location', 'propertyhive' ); ?></a>
1420 + <a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a>
1421 + <a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=location&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Location', 'propertyhive' )); ?></a>
620 1422 </td>
621 1423 </tr>
622 1424 <tr valign="top">
623 - <th scope="row" class="titledesc"><?php _e( 'Locations', 'propertyhive' ) ?></th>
1425 + <th scope="row" class="titledesc"><?php echo esc_html(__( 'Locations', 'propertyhive' )); ?></th>
624 1426 <td class="forminp">
625 1427 <table class="ph_customfields widefat" cellspacing="0">
626 1428 <thead>
627 1429 <tr>
628 - <th class="cb" style="width:1px;">&nbsp;</th>
629 - <th class="id" style="width:45px;"><?php _e( 'ID', 'propertyhive' ); ?></th>
630 - <th class="type"><?php _e( 'Location', 'propertyhive' ); ?></th>
1430 + <th class="cb" style="width:1px;"><input class="select_all" type="checkbox" style="margin: 2px 0 0 0;"></th>
1431 + <th class="id" style="width:45px;"><?php echo esc_html(__( 'ID', 'propertyhive' )); ?></th>
1432 + <th class="type"><?php echo esc_html(__( 'Location', 'propertyhive' )); ?></th>
1433 + <th class="assigned_count"><?php echo esc_html(__( 'Assigned Properties', 'propertyhive' )); ?></th>
631 1434 <th class="settings">&nbsp;</th>
632 1435 </tr>
633 1436 </thead>
634 1437 <tbody>
@@ -636,9 +1439,9 @@
636 1439 $args = array(
637 1440 'hide_empty' => false,
638 1441 'parent' => 0
639 1442 );
640 - $terms = get_terms( 'location', $args );
1443 + $terms = get_terms( array_merge( wp_parse_args( $args ), array( 'taxonomy' => 'location' ) ) );
641 1444
642 1445 if ( !empty( $terms ) && !is_wp_error( $terms ) )
643 1446 {
644 1447 foreach ($terms as $term)
@@ -646,18 +1449,19 @@
646 1449 $args = array(
647 1450 'hide_empty' => false,
648 1451 'parent' => $term->term_id
649 1452 );
650 - $subterms = get_terms( 'location', $args );
1453 + $subterms = get_terms( array_merge( wp_parse_args( $args ), array( 'taxonomy' => 'location' ) ) );
651 1454 ?>
652 1455 <tr>
653 - <td class="cb"><?php if ( empty( $subterms ) ) { ?><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"><?php }else{ echo '&nbsp;'; } ?></td>
654 - <td class="id"><?php echo $term->term_id; ?></td>
655 - <td class="type"><?php echo $term->name; ?></td>
1456 + <td class="cb"><?php if ( empty( $subterms ) ) { ?><input type="checkbox" name="term_id[]" value="<?php echo esc_attr($term->term_id); ?>"><?php }else{ echo '&nbsp;'; } ?></td>
1457 + <td class="id"><?php echo esc_html($term->term_id); ?></td>
1458 + <td class="type"><?php echo esc_html($term->name); ?></td>
1459 + <td class="assigned_count"><?php echo esc_html($term->count); ?></td>
656 1460 <td class="settings">
657 - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=location&id=' . $term->term_id ); ?>"><?php echo __( 'Edit', 'propertyhive' ); ?></a>
1461 + <a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=location&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Edit', 'propertyhive' )); ?></a>
658 1462 <?php if ( empty( $subterms ) ) { ?>
659 - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=location-delete&id=' . $term->term_id ); ?>"><?php echo __( 'Delete', 'propertyhive' ); ?></a>
1463 + <a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=location-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a>
660 1464 <?php } ?>
661 1465 </td>
662 1466 </tr>
663 1467 <?php
@@ -668,18 +1472,19 @@
668 1472 $args = array(
669 1473 'hide_empty' => false,
670 1474 'parent' => $term->term_id
671 1475 );
672 - $subsubterms = get_terms( 'location', $args );
1476 + $subsubterms = get_terms( array_merge( wp_parse_args( $args ), array( 'taxonomy' => 'location' ) ) );
673 1477 ?>
674 1478 <tr>
675 - <td class="cb"><?php if ( empty( $subsubterms ) ) { ?><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"><?php }else{ echo '&nbsp;'; } ?></td>
676 - <td class="id"><?php echo $term->term_id; ?></td>
677 - <td class="type subtype">&nbsp;&nbsp;&nbsp;- <?php echo $term->name; ?></td>
1479 + <td class="cb"><?php if ( empty( $subsubterms ) ) { ?><input type="checkbox" name="term_id[]" value="<?php echo esc_attr($term->term_id); ?>"><?php }else{ echo '&nbsp;'; } ?></td>
1480 + <td class="id"><?php echo esc_html($term->term_id); ?></td>
1481 + <td class="type subtype">&nbsp;&nbsp;&nbsp;- <?php echo esc_html($term->name); ?></td>
1482 + <td class="assigned_count"><?php echo esc_html($term->count); ?></td>
678 1483 <td class="settings">
679 - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=location&id=' . $term->term_id ); ?>"><?php echo __( 'Edit', 'propertyhive' ); ?></a>
1484 + <a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=location&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Edit', 'propertyhive' )); ?></a>
680 1485 <?php if ( empty( $subsubterms ) ) { ?>
681 - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=location-delete&id=' . $term->term_id ); ?>"><?php echo __( 'Delete', 'propertyhive' ); ?></a>
1486 + <a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=location-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a>
682 1487 <?php } ?>
683 1488 </td>
684 1489 </tr>
685 1490 <?php
@@ -688,14 +1493,15 @@
688 1493 foreach ($subsubterms as $term)
689 1494 {
690 1495 ?>
691 1496 <tr>
692 - <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"></td>
693 - <td class="id"><?php echo $term->term_id; ?></td>
694 - <td class="type subtype">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- <?php echo $term->name; ?></td>
1497 + <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo esc_attr($term->term_id); ?>"></td>
1498 + <td class="id"><?php echo esc_html($term->term_id); ?></td>
1499 + <td class="type subtype">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- <?php echo esc_html($term->name); ?></td>
1500 + <td class="assigned_count"><?php echo esc_html($term->count); ?></td>
695 1501 <td class="settings">
696 - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=location&id=' . $term->term_id ); ?>"><?php echo __( 'Edit', 'propertyhive' ); ?></a>
697 - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=location-delete&id=' . $term->term_id ); ?>"><?php echo __( 'Delete', 'propertyhive' ); ?></a>
1502 + <a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=location&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Edit', 'propertyhive' )); ?></a>
1503 + <a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=location-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a>
698 1504 </td>
699 1505 </tr>
700 1506 <?php
701 1507 }
@@ -709,12 +1515,9 @@
709 1515 else
710 1516 {
711 1517 ?>
712 1518 <tr>
713 - <td><?php echo __( 'No locations found', 'propertyhive' ); ?></td>
714 - <td class="settings">
715 -
716 - </td>
1519 + <td colspan="5"><?php echo esc_html(__( 'No locations found', 'propertyhive' )); ?></td>
717 1520 </tr>
718 1521 <?php
719 1522 }
720 1523 ?>
@@ -726,10 +1529,10 @@
726 1529 <th scope="row" class="titledesc">
727 1530 &nbsp;
728 1531 </th>
729 1532 <td class="forminp forminp-button">
730 - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
731 - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=location&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Location', 'propertyhive' ); ?></a>
1533 + <a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a>
1534 + <a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=location&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Location', 'propertyhive' )); ?></a>
732 1535 </td>
733 1536 </tr>
734 1537 <?php
735 1538 }
@@ -747,21 +1550,22 @@
747 1550 <th scope="row" class="titledesc">
748 1551 &nbsp;
749 1552 </th>
750 1553 <td class="forminp forminp-button">
751 - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
752 - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=parking&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Parking', 'propertyhive' ); ?></a>
1554 + <a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a>
1555 + <a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=parking&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Parking', 'propertyhive' )); ?></a>
753 1556 </td>
754 1557 </tr>
755 1558 <tr valign="top">
756 - <th scope="row" class="titledesc"><?php _e( 'Parking Options', 'propertyhive' ) ?></th>
1559 + <th scope="row" class="titledesc"><?php echo esc_html(__( 'Parking Options', 'propertyhive' )); ?></th>
757 1560 <td class="forminp">
758 - <table class="ph_customfields widefat" cellspacing="0">
1561 + <table class="ph_customfields sortable-custom-field widefat" data-taxonomy="parking" cellspacing="0">
759 1562 <thead>
760 1563 <tr>
761 - <th class="cb" style="width:1px;">&nbsp;</th>
762 - <th class="id" style="width:45px;"><?php _e( 'ID', 'propertyhive' ); ?></th>
763 - <th class="type"><?php _e( 'Parking', 'propertyhive' ); ?></th>
1564 + <th class="cb" style="width:1px;"><input class="select_all" type="checkbox" style="margin: 2px 0 0 0;"></th>
1565 + <th class="id" style="width:45px;"><?php echo esc_html(__( 'ID', 'propertyhive' )); ?></th>
1566 + <th class="type"><?php echo esc_html(__( 'Parking', 'propertyhive' )); ?></th>
1567 + <th class="assigned_count"><?php echo esc_html(__( 'Assigned Properties', 'propertyhive' )); ?></th>
764 1568 <th class="settings">&nbsp;</th>
765 1569 </tr>
766 1570 </thead>
767 1571 <tbody>
@@ -769,22 +1573,23 @@
769 1573 $args = array(
770 1574 'hide_empty' => false,
771 1575 'parent' => 0
772 1576 );
773 - $terms = get_terms( 'parking', $args );
774 -
1577 + $terms = get_terms( array_merge( wp_parse_args( $args ), array( 'taxonomy' => 'parking' ) ) );
1578 +
775 1579 if ( !empty( $terms ) && !is_wp_error( $terms ) )
776 1580 {
777 1581 foreach ($terms as $term)
778 1582 {
779 1583 ?>
780 - <tr>
781 - <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"></td>
782 - <td class="id"><?php echo $term->term_id; ?></td>
783 - <td class="type"><?php echo $term->name; ?></td>
1584 + <tr id="term-<?php echo esc_attr($term->term_id); ?>">
1585 + <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo esc_attr($term->term_id); ?>"></td>
1586 + <td class="id"><?php echo esc_html($term->term_id); ?></td>
1587 + <td class="type"><?php echo esc_html($term->name); ?></td>
1588 + <td class="assigned_count"><?php echo esc_html($term->count); ?></td>
784 1589 <td class="settings">
785 - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=parking&id=' . $term->term_id ); ?>"><?php echo __( 'Edit', 'propertyhive' ); ?></a>
786 - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=parking-delete&id=' . $term->term_id ); ?>"><?php echo __( 'Delete', 'propertyhive' ); ?></a>
1590 + <a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=parking&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Edit', 'propertyhive' )); ?></a>
1591 + <a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=parking-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a>
787 1592 </td>
788 1593 </tr>
789 1594 <?php
790 1595 }
@@ -792,12 +1597,9 @@
792 1597 else
793 1598 {
794 1599 ?>
795 1600 <tr>
796 - <td><?php echo __( 'No parking options found', 'propertyhive' ); ?></td>
797 - <td class="settings">
798 -
799 - </td>
1601 + <td colspan="5"><?php echo esc_html(__( 'No parking options found', 'propertyhive' )); ?></td>
800 1602 </tr>
801 1603 <?php
802 1604 }
803 1605 ?>
@@ -809,10 +1611,10 @@
809 1611 <th scope="row" class="titledesc">
810 1612 &nbsp;
811 1613 </th>
812 1614 <td class="forminp forminp-button">
813 - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
814 - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=parking&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Parking', 'propertyhive' ); ?></a>
1615 + <a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a>
1616 + <a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=parking&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Parking', 'propertyhive' )); ?></a>
815 1617 </td>
816 1618 </tr>
817 1619 <?php
818 1620 }
@@ -830,21 +1632,22 @@
830 1632 <th scope="row" class="titledesc">
831 1633 &nbsp;
832 1634 </th>
833 1635 <td class="forminp forminp-button">
834 - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
835 - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=outside-space&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Outside Space', 'propertyhive' ); ?></a>
1636 + <a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a>
1637 + <a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=outside-space&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Outside Space', 'propertyhive' )); ?></a>
836 1638 </td>
837 1639 </tr>
838 1640 <tr valign="top">
839 - <th scope="row" class="titledesc"><?php _e( 'Outside Spaces', 'propertyhive' ) ?></th>
1641 + <th scope="row" class="titledesc"><?php echo esc_html(__( 'Outside Spaces', 'propertyhive' )); ?></th>
840 1642 <td class="forminp">
841 - <table class="ph_customfields widefat" cellspacing="0">
1643 + <table class="ph_customfields sortable-custom-field widefat" data-taxonomy="outside_space" cellspacing="0">
842 1644 <thead>
843 1645 <tr>
844 - <th class="cb" style="width:1px;">&nbsp;</th>
845 - <th class="id" style="width:45px;"><?php _e( 'ID', 'propertyhive' ); ?></th>
846 - <th class="type"><?php _e( 'Outside Space', 'propertyhive' ); ?></th>
1646 + <th class="cb" style="width:1px;"><input class="select_all" type="checkbox" style="margin: 2px 0 0 0;"></th>
1647 + <th class="id" style="width:45px;"><?php echo esc_html(__( 'ID', 'propertyhive' )); ?></th>
1648 + <th class="type"><?php echo esc_html(__( 'Outside Space', 'propertyhive' )); ?></th>
1649 + <th class="assigned_count"><?php echo esc_html(__( 'Assigned Properties', 'propertyhive' )); ?></th>
847 1650 <th class="settings">&nbsp;</th>
848 1651 </tr>
849 1652 </thead>
850 1653 <tbody>
@@ -852,9 +1655,9 @@
852 1655 $args = array(
853 1656 'hide_empty' => false,
854 1657 'parent' => 0
855 1658 );
856 - $terms = get_terms( 'outside_space', $args );
1659 + $terms = get_terms( array_merge( wp_parse_args( $args ), array( 'taxonomy' => 'outside_space' ) ) );
857 1660
858 1661 if ( !empty( $terms ) && !is_wp_error( $terms ) )
859 1662 {
860 1663 foreach ($terms as $term)
@@ -859,15 +1662,16 @@
859 1662 {
860 1663 foreach ($terms as $term)
861 1664 {
862 1665 ?>
863 - <tr>
864 - <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"></td>
865 - <td class="id"><?php echo $term->term_id; ?></td>
866 - <td class="type"><?php echo $term->name; ?></td>
1666 + <tr id="term-<?php echo esc_attr($term->term_id); ?>">
1667 + <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo esc_attr($term->term_id); ?>"></td>
1668 + <td class="id"><?php echo esc_html($term->term_id); ?></td>
1669 + <td class="type"><?php echo esc_html($term->name); ?></td>
1670 + <td class="assigned_count"><?php echo esc_html($term->count); ?></td>
867 1671 <td class="settings">
868 - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=outside-space&id=' . $term->term_id ); ?>"><?php echo __( 'Edit', 'propertyhive' ); ?></a>
869 - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=outside-space-delete&id=' . $term->term_id ); ?>"><?php echo __( 'Delete', 'propertyhive' ); ?></a>
1672 + <a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=outside-space&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Edit', 'propertyhive' )); ?></a>
1673 + <a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=outside-space-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a>
870 1674 </td>
871 1675 </tr>
872 1676 <?php
873 1677 }
@@ -875,12 +1679,9 @@
875 1679 else
876 1680 {
877 1681 ?>
878 1682 <tr>
879 - <td><?php echo __( 'No outside spaces found', 'propertyhive' ); ?></td>
880 - <td class="settings">
881 -
882 - </td>
1683 + <td colspan="5"><?php echo esc_html(__( 'No outside spaces found', 'propertyhive' )); ?></td>
883 1684 </tr>
884 1685 <?php
885 1686 }
886 1687 ?>
@@ -892,10 +1693,10 @@
892 1693 <th scope="row" class="titledesc">
893 1694 &nbsp;
894 1695 </th>
895 1696 <td class="forminp forminp-button">
896 - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
897 - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=outside-space&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Outside Space', 'propertyhive' ); ?></a>
1697 + <a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a>
1698 + <a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=outside-space&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Outside Space', 'propertyhive' )); ?></a>
898 1699 </td>
899 1700 </tr>
900 1701 <?php
901 1702 }
@@ -913,21 +1714,22 @@
913 1714 <th scope="row" class="titledesc">
914 1715 &nbsp;
915 1716 </th>
916 1717 <td class="forminp forminp-button">
917 - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
918 - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=price-qualifier&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Price Qualifier', 'propertyhive' ); ?></a>
1718 + <a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a>
1719 + <a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=price-qualifier&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Price Qualifier', 'propertyhive' )); ?></a>
919 1720 </td>
920 1721 </tr>
921 1722 <tr valign="top">
922 - <th scope="row" class="titledesc"><?php _e( 'Price Qualifiers', 'propertyhive' ) ?></th>
1723 + <th scope="row" class="titledesc"><?php echo esc_html(__( 'Price Qualifiers', 'propertyhive' )); ?></th>
923 1724 <td class="forminp">
924 - <table class="ph_customfields widefat" cellspacing="0">
1725 + <table class="ph_customfields sortable-custom-field widefat" data-taxonomy="price_qualifier" cellspacing="0">
925 1726 <thead>
926 1727 <tr>
927 - <th class="cb" style="width:1px;">&nbsp;</th>
928 - <th class="id" style="width:45px;"><?php _e( 'ID', 'propertyhive' ); ?></th>
929 - <th class="type"><?php _e( 'Price Qualifier', 'propertyhive' ); ?></th>
1728 + <th class="cb" style="width:1px;"><input class="select_all" type="checkbox" style="margin: 2px 0 0 0;"></th>
1729 + <th class="id" style="width:45px;"><?php echo esc_html(__( 'ID', 'propertyhive' )); ?></th>
1730 + <th class="type"><?php echo esc_html(__( 'Price Qualifier', 'propertyhive' )); ?></th>
1731 + <th class="assigned_count"><?php echo esc_html(__( 'Assigned Properties', 'propertyhive' )); ?></th>
930 1732 <th class="settings">&nbsp;</th>
931 1733 </tr>
932 1734 </thead>
933 1735 <tbody>
@@ -935,9 +1737,9 @@
935 1737 $args = array(
936 1738 'hide_empty' => false,
937 1739 'parent' => 0
938 1740 );
939 - $terms = get_terms( 'price_qualifier', $args );
1741 + $terms = get_terms( array_merge( wp_parse_args( $args ), array( 'taxonomy' => 'price_qualifier' ) ) );
940 1742
941 1743 if ( !empty( $terms ) && !is_wp_error( $terms ) )
942 1744 {
943 1745 foreach ($terms as $term)
@@ -942,15 +1744,16 @@
942 1744 {
943 1745 foreach ($terms as $term)
944 1746 {
945 1747 ?>
946 - <tr>
947 - <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"></td>
948 - <td class="id"><?php echo $term->term_id; ?></td>
949 - <td class="type"><?php echo $term->name; ?></td>
1748 + <tr id="term-<?php echo esc_attr($term->term_id); ?>">
1749 + <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo esc_attr($term->term_id); ?>"></td>
1750 + <td class="id"><?php echo esc_html($term->term_id); ?></td>
1751 + <td class="type"><?php echo esc_html($term->name); ?></td>
1752 + <td class="assigned_count"><?php echo esc_html($term->count); ?></td>
950 1753 <td class="settings">
951 - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=price-qualifier&id=' . $term->term_id ); ?>"><?php echo __( 'Edit', 'propertyhive' ); ?></a>
952 - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=price-qualifier-delete&id=' . $term->term_id ); ?>"><?php echo __( 'Delete', 'propertyhive' ); ?></a>
1754 + <a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=price-qualifier&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Edit', 'propertyhive' )); ?></a>
1755 + <a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=price-qualifier-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a>
953 1756 </td>
954 1757 </tr>
955 1758 <?php
956 1759 }
@@ -958,12 +1761,9 @@
958 1761 else
959 1762 {
960 1763 ?>
961 1764 <tr>
962 - <td><?php echo __( 'No price qualifiers found', 'propertyhive' ); ?></td>
963 - <td class="settings">
964 -
965 - </td>
1765 + <td colspan="5"><?php echo esc_html(__( 'No price qualifiers found', 'propertyhive' )); ?></td>
966 1766 </tr>
967 1767 <?php
968 1768 }
969 1769 ?>
@@ -975,10 +1775,10 @@
975 1775 <th scope="row" class="titledesc">
976 1776 &nbsp;
977 1777 </th>
978 1778 <td class="forminp forminp-button">
979 - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
980 - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=price-qualifier&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Price Qualifier', 'propertyhive' ); ?></a>
1779 + <a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a>
1780 + <a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=price-qualifier&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Price Qualifier', 'propertyhive' )); ?></a>
981 1781 </td>
982 1782 </tr>
983 1783 <?php
984 1784 }
@@ -996,21 +1796,22 @@
996 1796 <th scope="row" class="titledesc">
997 1797 &nbsp;
998 1798 </th>
999 1799 <td class="forminp forminp-button">
1000 - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
1001 - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=sale-by&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Sale By', 'propertyhive' ); ?></a>
1800 + <a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a>
1801 + <a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=sale-by&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Sale By', 'propertyhive' )); ?></a>
1002 1802 </td>
1003 1803 </tr>
1004 1804 <tr valign="top">
1005 - <th scope="row" class="titledesc"><?php _e( 'Sale By Options', 'propertyhive' ) ?></th>
1805 + <th scope="row" class="titledesc"><?php echo esc_html(__( 'Sale By Options', 'propertyhive' )); ?></th>
1006 1806 <td class="forminp">
1007 - <table class="ph_customfields widefat" cellspacing="0">
1807 + <table class="ph_customfields sortable-custom-field widefat" data-taxonomy="sale_by" cellspacing="0">
1008 1808 <thead>
1009 1809 <tr>
1010 - <th class="cb" style="width:1px;">&nbsp;</th>
1011 - <th class="id" style="width:45px;"><?php _e( 'ID', 'propertyhive' ); ?></th>
1012 - <th class="type"><?php _e( 'Sale By', 'propertyhive' ); ?></th>
1810 + <th class="cb" style="width:1px;"><input class="select_all" type="checkbox" style="margin: 2px 0 0 0;"></th>
1811 + <th class="id" style="width:45px;"><?php echo esc_html(__( 'ID', 'propertyhive' )); ?></th>
1812 + <th class="type"><?php echo esc_html(__( 'Sale By', 'propertyhive' )); ?></th>
1813 + <th class="assigned_count"><?php echo esc_html(__( 'Assigned Properties', 'propertyhive' )); ?></th>
1013 1814 <th class="settings">&nbsp;</th>
1014 1815 </tr>
1015 1816 </thead>
1016 1817 <tbody>
@@ -1018,9 +1819,9 @@
1018 1819 $args = array(
1019 1820 'hide_empty' => false,
1020 1821 'parent' => 0
1021 1822 );
1022 - $terms = get_terms( 'sale_by', $args );
1823 + $terms = get_terms( array_merge( wp_parse_args( $args ), array( 'taxonomy' => 'sale_by' ) ) );
1023 1824
1024 1825 if ( !empty( $terms ) && !is_wp_error( $terms ) )
1025 1826 {
1026 1827 foreach ($terms as $term)
@@ -1026,14 +1827,15 @@
1026 1827 foreach ($terms as $term)
1027 1828 {
1028 1829 ?>
1029 1830 <tr>
1030 - <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"></td>
1031 - <td class="id"><?php echo $term->term_id; ?></td>
1032 - <td class="type"><?php echo $term->name; ?></td>
1831 + <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo esc_attr($term->term_id); ?>"></td>
1832 + <td class="id"><?php echo esc_html($term->term_id); ?></td>
1833 + <td class="type"><?php echo esc_html($term->name); ?></td>
1834 + <td class="assigned_count"><?php echo esc_html($term->count); ?></td>
1033 1835 <td class="settings">
1034 - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=sale-by&id=' . $term->term_id ); ?>"><?php echo __( 'Edit', 'propertyhive' ); ?></a>
1035 - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=sale-by-delete&id=' . $term->term_id ); ?>"><?php echo __( 'Delete', 'propertyhive' ); ?></a>
1836 + <a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=sale-by&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Edit', 'propertyhive' )); ?></a>
1837 + <a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=sale-by-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a>
1036 1838 </td>
1037 1839 </tr>
1038 1840 <?php
1039 1841 }
@@ -1041,12 +1843,9 @@
1041 1843 else
1042 1844 {
1043 1845 ?>
1044 1846 <tr>
1045 - <td><?php echo __( 'No sale by options found', 'propertyhive' ); ?></td>
1046 - <td class="settings">
1047 -
1048 - </td>
1847 + <td colspan="5"><?php echo esc_html(__( 'No sale by options found', 'propertyhive' )); ?></td>
1049 1848 </tr>
1050 1849 <?php
1051 1850 }
1052 1851 ?>
@@ -1058,10 +1857,10 @@
1058 1857 <th scope="row" class="titledesc">
1059 1858 &nbsp;
1060 1859 </th>
1061 1860 <td class="forminp forminp-button">
1062 - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
1063 - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=sale-by&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Sale By', 'propertyhive' ); ?></a>
1861 + <a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a>
1862 + <a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=sale-by&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Sale By', 'propertyhive' )); ?></a>
1064 1863 </td>
1065 1864 </tr>
1066 1865 <?php
1067 1866 }
@@ -1079,21 +1878,22 @@
1079 1878 <th scope="row" class="titledesc">
1080 1879 &nbsp;
1081 1880 </th>
1082 1881 <td class="forminp forminp-button">
1083 - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
1084 - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=tenure&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Tenure', 'propertyhive' ); ?></a>
1882 + <a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a>
1883 + <a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=tenure&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Tenure', 'propertyhive' )); ?></a>
1085 1884 </td>
1086 1885 </tr>
1087 1886 <tr valign="top">
1088 - <th scope="row" class="titledesc"><?php _e( 'Tenures', 'propertyhive' ) ?></th>
1887 + <th scope="row" class="titledesc"><?php echo esc_html(__( 'Tenures', 'propertyhive' )); ?></th>
1089 1888 <td class="forminp">
1090 - <table class="ph_customfields widefat" cellspacing="0">
1889 + <table class="ph_customfields sortable-custom-field widefat" data-taxonomy="tenure" cellspacing="0">
1091 1890 <thead>
1092 1891 <tr>
1093 - <th class="cb" style="width:1px;">&nbsp;</th>
1094 - <th class="id" style="width:45px;"><?php _e( 'ID', 'propertyhive' ); ?></th>
1095 - <th class="type"><?php _e( 'Tenure', 'propertyhive' ); ?></th>
1892 + <th class="cb" style="width:1px;"><input class="select_all" type="checkbox" style="margin: 2px 0 0 0;"></th>
1893 + <th class="id" style="width:45px;"><?php echo esc_html(__( 'ID', 'propertyhive' )); ?></th>
1894 + <th class="type"><?php echo esc_html(__( 'Tenure', 'propertyhive' )); ?></th>
1895 + <th class="assigned_count"><?php echo esc_html(__( 'Assigned Properties', 'propertyhive' )); ?></th>
1096 1896 <th class="settings">&nbsp;</th>
1097 1897 </tr>
1098 1898 </thead>
1099 1899 <tbody>
@@ -1101,9 +1901,9 @@
1101 1901 $args = array(
1102 1902 'hide_empty' => false,
1103 1903 'parent' => 0
1104 1904 );
1105 - $terms = get_terms( 'tenure', $args );
1905 + $terms = get_terms( array_merge( wp_parse_args( $args ), array( 'taxonomy' => 'tenure' ) ) );
1106 1906
1107 1907 if ( !empty( $terms ) && !is_wp_error( $terms ) )
1108 1908 {
1109 1909 foreach ($terms as $term)
@@ -1108,15 +1908,16 @@
1108 1908 {
1109 1909 foreach ($terms as $term)
1110 1910 {
1111 1911 ?>
1112 - <tr>
1113 - <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"></td>
1114 - <td class="id"><?php echo $term->term_id; ?></td>
1115 - <td class="type"><?php echo $term->name; ?></td>
1912 + <tr id="term-<?php echo esc_attr($term->term_id); ?>">
1913 + <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo esc_attr($term->term_id); ?>"></td>
1914 + <td class="id"><?php echo esc_html($term->term_id); ?></td>
1915 + <td class="type"><?php echo esc_html($term->name); ?></td>
1916 + <td class="assigned_count"><?php echo esc_html($term->count); ?></td>
1116 1917 <td class="settings">
1117 - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=tenure&id=' . $term->term_id ); ?>"><?php echo __( 'Edit', 'propertyhive' ); ?></a>
1118 - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=tenure-delete&id=' . $term->term_id ); ?>"><?php echo __( 'Delete', 'propertyhive' ); ?></a>
1918 + <a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=tenure&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Edit', 'propertyhive' )); ?></a>
1919 + <a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=tenure-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a>
1119 1920 </td>
1120 1921 </tr>
1121 1922 <?php
1122 1923 }
@@ -1124,12 +1925,9 @@
1124 1925 else
1125 1926 {
1126 1927 ?>
1127 1928 <tr>
1128 - <td><?php echo __( 'No tenure found', 'propertyhive' ); ?></td>
1129 - <td class="settings">
1130 -
1131 - </td>
1929 + <td colspan="5"><?php echo esc_html(__( 'No tenure found', 'propertyhive' )); ?></td>
1132 1930 </tr>
1133 1931 <?php
1134 1932 }
1135 1933 ?>
@@ -1141,10 +1939,10 @@
1141 1939 <th scope="row" class="titledesc">
1142 1940 &nbsp;
1143 1941 </th>
1144 1942 <td class="forminp forminp-button">
1145 - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
1146 - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=tenure&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Tenure', 'propertyhive' ); ?></a>
1943 + <a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a>
1944 + <a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=tenure&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Tenure', 'propertyhive' )); ?></a>
1147 1945 </td>
1148 1946 </tr>
1149 1947 <?php
1150 1948 }
@@ -1162,21 +1960,22 @@
1162 1960 <th scope="row" class="titledesc">
1163 1961 &nbsp;
1164 1962 </th>
1165 1963 <td class="forminp forminp-button">
1166 - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
1167 - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=commercial-tenure&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Tenure', 'propertyhive' ); ?></a>
1964 + <a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a>
1965 + <a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=commercial-tenure&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Tenure', 'propertyhive' )); ?></a>
1168 1966 </td>
1169 1967 </tr>
1170 1968 <tr valign="top">
1171 - <th scope="row" class="titledesc"><?php _e( 'Tenures', 'propertyhive' ) ?></th>
1969 + <th scope="row" class="titledesc"><?php echo esc_html(__( 'Tenures', 'propertyhive' )); ?></th>
1172 1970 <td class="forminp">
1173 - <table class="ph_customfields widefat" cellspacing="0">
1971 + <table class="ph_customfields sortable-custom-field widefat" data-taxonomy="commercial_tenure" cellspacing="0">
1174 1972 <thead>
1175 1973 <tr>
1176 - <th class="cb" style="width:1px;">&nbsp;</th>
1177 - <th class="id" style="width:45px;"><?php _e( 'ID', 'propertyhive' ); ?></th>
1178 - <th class="type"><?php _e( 'Tenure', 'propertyhive' ); ?></th>
1974 + <th class="cb" style="width:1px;"><input class="select_all" type="checkbox" style="margin: 2px 0 0 0;"></th>
1975 + <th class="id" style="width:45px;"><?php echo esc_html(__( 'ID', 'propertyhive' )); ?></th>
1976 + <th class="type"><?php echo esc_html(__( 'Tenure', 'propertyhive' )); ?></th>
1977 + <th class="assigned_count"><?php echo esc_html(__( 'Assigned Properties', 'propertyhive' )); ?></th>
1179 1978 <th class="settings">&nbsp;</th>
1180 1979 </tr>
1181 1980 </thead>
1182 1981 <tbody>
@@ -1184,9 +1983,9 @@
1184 1983 $args = array(
1185 1984 'hide_empty' => false,
1186 1985 'parent' => 0
1187 1986 );
1188 - $terms = get_terms( 'commercial_tenure', $args );
1987 + $terms = get_terms( array_merge( wp_parse_args( $args ), array( 'taxonomy' => 'commercial_tenure' ) ) );
1189 1988
1190 1989 if ( !empty( $terms ) && !is_wp_error( $terms ) )
1191 1990 {
1192 1991 foreach ($terms as $term)
@@ -1191,15 +1990,16 @@
1191 1990 {
1192 1991 foreach ($terms as $term)
1193 1992 {
1194 1993 ?>
1195 - <tr>
1196 - <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"></td>
1197 - <td class="id"><?php echo $term->term_id; ?></td>
1198 - <td class="type"><?php echo $term->name; ?></td>
1994 + <tr id="term-<?php echo esc_attr($term->term_id); ?>">
1995 + <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo esc_attr($term->term_id); ?>"></td>
1996 + <td class="id"><?php echo esc_html($term->term_id); ?></td>
1997 + <td class="type"><?php echo esc_html($term->name); ?></td>
1998 + <td class="assigned_count"><?php echo esc_html($term->count); ?></td>
1199 1999 <td class="settings">
1200 - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=commercial-tenure&id=' . $term->term_id ); ?>"><?php echo __( 'Edit', 'propertyhive' ); ?></a>
1201 - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=commercial-tenure-delete&id=' . $term->term_id ); ?>"><?php echo __( 'Delete', 'propertyhive' ); ?></a>
2000 + <a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=commercial-tenure&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Edit', 'propertyhive' )); ?></a>
2001 + <a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=commercial-tenure-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a>
1202 2002 </td>
1203 2003 </tr>
1204 2004 <?php
1205 2005 }
@@ -1207,12 +2007,9 @@
1207 2007 else
1208 2008 {
1209 2009 ?>
1210 2010 <tr>
1211 - <td><?php echo __( 'No tenure found', 'propertyhive' ); ?></td>
1212 - <td class="settings">
1213 -
1214 - </td>
2011 + <td colspan="5"><?php echo esc_html(__( 'No tenure found', 'propertyhive' )); ?></td>
1215 2012 </tr>
1216 2013 <?php
1217 2014 }
1218 2015 ?>
@@ -1224,10 +2021,10 @@
1224 2021 <th scope="row" class="titledesc">
1225 2022 &nbsp;
1226 2023 </th>
1227 2024 <td class="forminp forminp-button">
1228 - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
1229 - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=commercial-tenure&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Tenure', 'propertyhive' ); ?></a>
2025 + <a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a>
2026 + <a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=commercial-tenure&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Tenure', 'propertyhive' )); ?></a>
1230 2027 </td>
1231 2028 </tr>
1232 2029 <?php
1233 2030 }
@@ -1245,21 +2042,22 @@
1245 2042 <th scope="row" class="titledesc">
1246 2043 &nbsp;
1247 2044 </th>
1248 2045 <td class="forminp forminp-button">
1249 - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
1250 - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=furnished&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Furnished Option', 'propertyhive' ); ?></a>
2046 + <a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a>
2047 + <a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=furnished&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Furnished Option', 'propertyhive' )); ?></a>
1251 2048 </td>
1252 2049 </tr>
1253 2050 <tr valign="top">
1254 - <th scope="row" class="titledesc"><?php _e( 'Furnished Options', 'propertyhive' ) ?></th>
2051 + <th scope="row" class="titledesc"><?php echo esc_html(__( 'Furnished Options', 'propertyhive' )); ?></th>
1255 2052 <td class="forminp">
1256 - <table class="ph_customfields widefat" cellspacing="0">
2053 + <table class="ph_customfields sortable-custom-field widefat" data-taxonomy="furnished" cellspacing="0">
1257 2054 <thead>
1258 2055 <tr>
1259 - <th class="cb" style="width:1px;">&nbsp;</th>
1260 - <th class="id" style="width:45px;"><?php _e( 'ID', 'propertyhive' ); ?></th>
1261 - <th class="type"><?php _e( 'Furnished', 'propertyhive' ); ?></th>
2056 + <th class="cb" style="width:1px;"><input class="select_all" type="checkbox" style="margin: 2px 0 0 0;"></th>
2057 + <th class="id" style="width:45px;"><?php echo esc_html(__( 'ID', 'propertyhive' )); ?></th>
2058 + <th class="type"><?php echo esc_html(__( 'Furnished', 'propertyhive' )); ?></th>
2059 + <th class="assigned_count"><?php echo esc_html(__( 'Assigned Properties', 'propertyhive' )); ?></th>
1262 2060 <th class="settings">&nbsp;</th>
1263 2061 </tr>
1264 2062 </thead>
1265 2063 <tbody>
@@ -1267,9 +2065,9 @@
1267 2065 $args = array(
1268 2066 'hide_empty' => false,
1269 2067 'parent' => 0
1270 2068 );
1271 - $terms = get_terms( 'furnished', $args );
2069 + $terms = get_terms( array_merge( wp_parse_args( $args ), array( 'taxonomy' => 'furnished' ) ) );
1272 2070
1273 2071 if ( !empty( $terms ) && !is_wp_error( $terms ) )
1274 2072 {
1275 2073 foreach ($terms as $term)
@@ -1274,15 +2072,16 @@
1274 2072 {
1275 2073 foreach ($terms as $term)
1276 2074 {
1277 2075 ?>
1278 - <tr>
1279 - <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"></td>
1280 - <td class="id"><?php echo $term->term_id; ?></td>
1281 - <td class="type"><?php echo $term->name; ?></td>
2076 + <tr id="term-<?php echo esc_attr($term->term_id); ?>">
2077 + <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo esc_attr($term->term_id); ?>"></td>
2078 + <td class="id"><?php echo esc_html($term->term_id); ?></td>
2079 + <td class="type"><?php echo esc_html($term->name); ?></td>
2080 + <td class="assigned_count"><?php echo esc_html($term->count); ?></td>
1282 2081 <td class="settings">
1283 - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=furnished&id=' . $term->term_id ); ?>"><?php echo __( 'Edit', 'propertyhive' ); ?></a>
1284 - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=furnished-delete&id=' . $term->term_id ); ?>"><?php echo __( 'Delete', 'propertyhive' ); ?></a>
2082 + <a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=furnished&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Edit', 'propertyhive' )); ?></a>
2083 + <a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=furnished-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a>
1285 2084 </td>
1286 2085 </tr>
1287 2086 <?php
1288 2087 }
@@ -1290,12 +2089,9 @@
1290 2089 else
1291 2090 {
1292 2091 ?>
1293 2092 <tr>
1294 - <td><?php echo __( 'No furnished options found', 'propertyhive' ); ?></td>
1295 - <td class="settings">
1296 -
1297 - </td>
2093 + <td colspan="5"><?php echo esc_html(__( 'No furnished options found', 'propertyhive' )); ?></td>
1298 2094 </tr>
1299 2095 <?php
1300 2096 }
1301 2097 ?>
@@ -1307,15 +2103,141 @@
1307 2103 <th scope="row" class="titledesc">
1308 2104 &nbsp;
1309 2105 </th>
1310 2106 <td class="forminp forminp-button">
1311 - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
1312 - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=furnished&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Furnished Option', 'propertyhive' ); ?></a>
2107 + <a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a>
2108 + <a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=furnished&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Furnished Option', 'propertyhive' )); ?></a>
1313 2109 </td>
1314 2110 </tr>
1315 2111 <?php
1316 2112 }
1317 2113
2114 + public function custom_fields_management_key_date_type_setting() {
2115 + ?>
2116 + <tr valign="top">
2117 + <th scope="row" class="titledesc">
2118 + &nbsp;
2119 + </th>
2120 + <td class="forminp forminp-button">
2121 + <a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a>
2122 + <a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=management-key-date-type&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Management Date Type', 'propertyhive' )); ?></a>
2123 + </td>
2124 + </tr>
2125 + <?php foreach( array ('property_management' => __( 'Property Management', 'propertyhive' ), 'tenancy_management' => __( 'Tenancy Management', 'propertyhive' ) ) as $type => $title): ?>
2126 + <tr valign="top">
2127 + <th scope="row" class="titledesc no-auto"><?php echo esc_html( $title ); ?></th>
2128 + <td class="forminp no-auto">
2129 + <table class="ph_customfields widefat" cellspacing="0">
2130 + <thead>
2131 + <tr>
2132 + <th style="width:1px;">&nbsp;</th>
2133 + <th style="width:40%;"><?php echo esc_html(__( 'Description', 'propertyhive' )); ?></th>
2134 + <th><?php echo esc_html(__( 'Recurrence', 'propertyhive' )); ?></th>
2135 + <th>&nbsp;</th>
2136 + </tr>
2137 + </thead>
2138 + <tbody>
2139 + <?php
2140 + $args = array(
2141 + 'hide_empty' => false,
2142 + 'parent' => 0
2143 + );
2144 + $terms = get_terms( array_merge( wp_parse_args( $args ), array( 'taxonomy' => 'management_key_date_type' ) ) );
2145 +
2146 + if ( !empty( $terms ) && !is_wp_error( $terms ) )
2147 + {
2148 + $recurrence_rules = get_option( 'propertyhive_key_date_type', array() );
2149 + $recurrence_rules = is_array( $recurrence_rules ) ? $recurrence_rules : array();
2150 +
2151 + foreach ($terms as $term)
2152 + {
2153 + $recurrence_type = isset($recurrence_rules[$term->term_id]) ? $recurrence_rules[$term->term_id]['recurrence_type'] : '';
2154 +
2155 + if ( $recurrence_type !== $type)
2156 + {
2157 + continue;
2158 + }
2159 +
2160 +
2161 + $recurrence_rule = isset($recurrence_rules[$term->term_id]) ? $recurrence_rules[$term->term_id]['recurrence_rule'] : '';
2162 + $recurrence = array('FREQ' => '', 'INTERVAL' => '');
2163 + foreach (explode(';', $recurrence_rule) as $key_value_pair) {
2164 + list($key, $value) = explode('=', $key_value_pair);
2165 + $recurrence[$key] = $value;
2166 + }
2167 +
2168 + $frequency = '';
2169 + if ($recurrence['INTERVAL'] <= 1)
2170 + {
2171 + $frequencies = array(
2172 + 'ONCE' => __( 'Once', 'propertyhive' ),
2173 + 'DAILY' => __( 'Daily', 'propertyhive' ),
2174 + 'WEEKLY' => __( 'Weekly', 'propertyhive' ),
2175 + 'MONTHLY' => __( 'Monthly', 'propertyhive' ),
2176 + 'YEARLY' => __( 'Annually', 'propertyhive' ),
2177 + );
2178 +
2179 + $frequency = $frequencies[$recurrence['FREQ']];
2180 + }
2181 + else
2182 + {
2183 + $interval = $recurrence['INTERVAL'];
2184 + if (extension_loaded('intl'))
2185 + {
2186 + $formatter = new NumberFormatter(get_locale(), NumberFormatter::SPELLOUT);
2187 + $interval = $formatter->format($recurrence['INTERVAL']);
2188 + }
2189 +
2190 + $periods = array(
2191 + 'DAILY' => __( 'days', 'propertyhive' ),
2192 + 'WEEKLY' => __( 'weeks', 'propertyhive' ),
2193 + 'MONTHLY' => __( 'months', 'propertyhive' ),
2194 + 'YEARLY' => __( 'years', 'propertyhive' ),
2195 + );
2196 +
2197 +
2198 + $frequency = sprintf('Every %s %s', $interval, $periods[$recurrence['FREQ']]);
2199 + }
2200 +
2201 + ?>
2202 + <tr>
2203 + <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo esc_attr($term->term_id); ?>"></td>
2204 + <td><?php echo esc_html($term->name); ?></td>
2205 + <td><?php echo esc_html($frequency); ?></td>
2206 + <td class="settings">
2207 + <a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=management-key-date-type&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Edit', 'propertyhive' )); ?></a>
2208 + <a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=management-key-date-type-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a>
2209 + </td>
2210 + </tr>
2211 + <?php
2212 + }
2213 + }
2214 + else
2215 + {
2216 + ?>
2217 + <tr>
2218 + <td colspan="4"><?php echo esc_html(__( 'No management date types found', 'propertyhive' )); ?></td>
2219 + </tr>
2220 + <?php
2221 + }
2222 + ?>
2223 + </tbody>
2224 + </table>
2225 + </td>
2226 + </tr>
2227 + <?php endforeach; ?>
2228 + <tr valign="top">
2229 + <th scope="row" class="titledesc">
2230 + &nbsp;
2231 + </th>
2232 + <td class="forminp forminp-button">
2233 + <a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a>
2234 + <a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=management-key-date-type&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Management Date Type', 'propertyhive' )); ?></a>
2235 + </td>
2236 + </tr>
2237 + <?php
2238 + }
2239 +
1318 2240 /**
1319 2241 * Output list of marketing flag options
1320 2242 *
1321 2243 * @access public
@@ -1328,21 +2250,22 @@
1328 2250 <th scope="row" class="titledesc">
1329 2251 &nbsp;
1330 2252 </th>
1331 2253 <td class="forminp forminp-button">
1332 - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
1333 - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=marketing-flag&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Marketing Flag', 'propertyhive' ); ?></a>
2254 + <a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a>
2255 + <a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=marketing-flag&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Marketing Flag', 'propertyhive' )); ?></a>
1334 2256 </td>
1335 2257 </tr>
1336 2258 <tr valign="top">
1337 - <th scope="row" class="titledesc"><?php _e( 'Marketing Flags', 'propertyhive' ) ?></th>
2259 + <th scope="row" class="titledesc"><?php echo esc_html(__( 'Marketing Flags', 'propertyhive' )); ?></th>
1338 2260 <td class="forminp">
1339 - <table class="ph_customfields widefat" cellspacing="0">
2261 + <table class="ph_customfields sortable-custom-field widefat" data-taxonomy="marketing_flag" cellspacing="0">
1340 2262 <thead>
1341 2263 <tr>
1342 - <th class="cb" style="width:1px;">&nbsp;</th>
1343 - <th class="id" style="width:45px;"><?php _e( 'ID', 'propertyhive' ); ?></th>
1344 - <th class="type"><?php _e( 'Marketing Flag', 'propertyhive' ); ?></th>
2264 + <th class="cb" style="width:1px;"><input class="select_all" type="checkbox" style="margin: 2px 0 0 0;"></th>
2265 + <th class="id" style="width:45px;"><?php echo esc_html(__( 'ID', 'propertyhive' )); ?></th>
2266 + <th class="type"><?php echo esc_html(__( 'Marketing Flag', 'propertyhive' )); ?></th>
2267 + <th class="assigned_count"><?php echo esc_html(__( 'Assigned Properties', 'propertyhive' )); ?></th>
1345 2268 <th class="settings">&nbsp;</th>
1346 2269 </tr>
1347 2270 </thead>
1348 2271 <tbody>
@@ -1350,9 +2273,9 @@
1350 2273 $args = array(
1351 2274 'hide_empty' => false,
1352 2275 'parent' => 0
1353 2276 );
1354 - $terms = get_terms( 'marketing_flag', $args );
2277 + $terms = get_terms( array_merge( wp_parse_args( $args ), array( 'taxonomy' => 'marketing_flag' ) ) );
1355 2278
1356 2279 if ( !empty( $terms ) && !is_wp_error( $terms ) )
1357 2280 {
1358 2281 foreach ($terms as $term)
@@ -1357,15 +2280,16 @@
1357 2280 {
1358 2281 foreach ($terms as $term)
1359 2282 {
1360 2283 ?>
1361 - <tr>
1362 - <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"></td>
1363 - <td class="id"><?php echo $term->term_id; ?></td>
1364 - <td class="type"><?php echo $term->name; ?></td>
2284 + <tr id="term-<?php echo esc_attr($term->term_id); ?>">
2285 + <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo esc_attr($term->term_id); ?>"></td>
2286 + <td class="id"><?php echo esc_html($term->term_id); ?></td>
2287 + <td class="type"><?php echo esc_html($term->name); ?></td>
2288 + <td class="assigned_count"><?php echo esc_html($term->count); ?></td>
1365 2289 <td class="settings">
1366 - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=marketing-flag&id=' . $term->term_id ); ?>"><?php echo __( 'Edit', 'propertyhive' ); ?></a>
1367 - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=marketing-flag-delete&id=' . $term->term_id ); ?>"><?php echo __( 'Delete', 'propertyhive' ); ?></a>
2290 + <a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=marketing-flag&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Edit', 'propertyhive' )); ?></a>
2291 + <a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=marketing-flag-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a>
1368 2292 </td>
1369 2293 </tr>
1370 2294 <?php
1371 2295 }
@@ -1373,12 +2297,9 @@
1373 2297 else
1374 2298 {
1375 2299 ?>
1376 2300 <tr>
1377 - <td><?php echo __( 'No marketing flags found', 'propertyhive' ); ?></td>
1378 - <td class="settings">
1379 -
1380 - </td>
2301 + <td colspan="5"><?php echo esc_html(__( 'No marketing flags found', 'propertyhive' )); ?></td>
1381 2302 </tr>
1382 2303 <?php
1383 2304 }
1384 2305 ?>
@@ -1390,10 +2311,10 @@
1390 2311 <th scope="row" class="titledesc">
1391 2312 &nbsp;
1392 2313 </th>
1393 2314 <td class="forminp forminp-button">
1394 - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
1395 - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=marketing-flag&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Marketing Flag', 'propertyhive' ); ?></a>
2315 + <a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a>
2316 + <a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=marketing-flag&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Marketing Flag', 'propertyhive' )); ?></a>
1396 2317 </td>
1397 2318 </tr>
1398 2319 <?php
1399 2320 }
@@ -1411,21 +2332,22 @@
1411 2332 <th scope="row" class="titledesc">
1412 2333 &nbsp;
1413 2334 </th>
1414 2335 <td class="forminp forminp-button">
1415 - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
1416 - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=property-feature&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Property Feature', 'propertyhive' ); ?></a>
2336 + <a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a>
2337 + <a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=property-feature&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Property Feature', 'propertyhive' )); ?></a>
1417 2338 </td>
1418 2339 </tr>
1419 2340 <tr valign="top">
1420 - <th scope="row" class="titledesc"><?php _e( 'Property Features', 'propertyhive' ) ?></th>
2341 + <th scope="row" class="titledesc"><?php echo esc_html(__( 'Property Features', 'propertyhive' )); ?></th>
1421 2342 <td class="forminp">
1422 2343 <table class="ph_customfields widefat" cellspacing="0">
1423 2344 <thead>
1424 2345 <tr>
1425 - <th class="cb" style="width:1px;">&nbsp;</th>
1426 - <th class="id" style="width:45px;"><?php _e( 'ID', 'propertyhive' ); ?></th>
1427 - <th class="type"><?php _e( 'Property Feature', 'propertyhive' ); ?></th>
2346 + <th class="cb" style="width:1px;"><input class="select_all" type="checkbox" style="margin: 2px 0 0 0;"></th>
2347 + <th class="id" style="width:45px;"><?php echo esc_html(__( 'ID', 'propertyhive' )); ?></th>
2348 + <th class="type"><?php echo esc_html(__( 'Property Feature', 'propertyhive' )); ?></th>
2349 + <th class="assigned_count"><?php echo esc_html(__( 'Assigned Properties', 'propertyhive' )); ?></th>
1428 2350 <th class="settings">&nbsp;</th>
1429 2351 </tr>
1430 2352 </thead>
1431 2353 <tbody>
@@ -1433,9 +2355,9 @@
1433 2355 $args = array(
1434 2356 'hide_empty' => false,
1435 2357 'parent' => 0
1436 2358 );
1437 - $terms = get_terms( 'property_feature', $args );
2359 + $terms = get_terms( array_merge( wp_parse_args( $args ), array( 'taxonomy' => 'property_feature' ) ) );
1438 2360
1439 2361 if ( !empty( $terms ) && !is_wp_error( $terms ) )
1440 2362 {
1441 2363 foreach ($terms as $term)
@@ -1441,14 +2363,15 @@
1441 2363 foreach ($terms as $term)
1442 2364 {
1443 2365 ?>
1444 2366 <tr>
1445 - <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"></td>
1446 - <td class="id"><?php echo $term->term_id; ?></td>
1447 - <td class="type"><?php echo $term->name; ?></td>
2367 + <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo esc_attr($term->term_id); ?>"></td>
2368 + <td class="id"><?php echo esc_html($term->term_id); ?></td>
2369 + <td class="type"><?php echo esc_html($term->name); ?></td>
2370 + <td class="assigned_count"><?php echo esc_html($term->count); ?></td>
1448 2371 <td class="settings">
1449 - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=property-feature&id=' . $term->term_id ); ?>"><?php echo __( 'Edit', 'propertyhive' ); ?></a>
1450 - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=property-feature-delete&id=' . $term->term_id ); ?>"><?php echo __( 'Delete', 'propertyhive' ); ?></a>
2372 + <a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=property-feature&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Edit', 'propertyhive' )); ?></a>
2373 + <a class="button" href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=property-feature-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a>
1451 2374 </td>
1452 2375 </tr>
1453 2376 <?php
1454 2377 }
@@ -1456,9 +2379,9 @@
1456 2379 else
1457 2380 {
1458 2381 ?>
1459 2382 <tr>
1460 - <td colspan="3"><?php echo __( 'No property features found', 'propertyhive' ); ?></td>
2383 + <td colspan="5"><?php echo esc_html(__( 'No property features found', 'propertyhive' )); ?></td>
1461 2384 </tr>
1462 2385 <?php
1463 2386 }
1464 2387 ?>
@@ -1470,10 +2393,10 @@
1470 2393 <th scope="row" class="titledesc">
1471 2394 &nbsp;
1472 2395 </th>
1473 2396 <td class="forminp forminp-button">
1474 - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a>
1475 - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields&section=property-feature&id=' ); ?>" class="button alignright"><?php echo __( 'Add New Property Feature', 'propertyhive' ); ?></a>
2397 + <a href="" class="button alignright batch-delete" disabled><?php echo esc_html(__( 'Delete Selected', 'propertyhive' )); ?></a>
2398 + <a href="<?php echo esc_url(admin_url( 'admin.php?page=ph-settings&tab=customfields&section=property-feature&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Property Feature', 'propertyhive' )); ?></a>
1476 2399 </td>
1477 2400 </tr>
1478 2401 <?php
1479 2402 }
@@ -1485,9 +2408,10 @@
1485 2408 * @return string
1486 2409 */
1487 2410 public function get_custom_fields_availability_setting()
1488 2411 {
1489 - $current_id = empty( $_REQUEST['id'] ) ? '' : (int)$_REQUEST['id'];
2412 + // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- This getter only renders stored taxonomy settings and does not mutate state.
2413 + $current_id = $this->normalize_custom_fields_render_term_id( ( isset( $_REQUEST['id'] ) && is_string( $_REQUEST['id'] ) ) ? sanitize_text_field( wp_unslash( $_REQUEST['id'] ) ) : '' );
1490 2414
1491 2415 $taxonomy = 'availability';
1492 2416 $term_name = '';
1493 2417 if ($current_id != '')
@@ -1499,9 +2423,9 @@
1499 2423 $departments = ph_get_departments();
1500 2424
1501 2425 $args = array(
1502 2426
1503 - array( 'title' => __( ( $current_id == '' ? 'Add New Availability Option' : 'Edit Availability' ), 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_availability_settings' ),
2427 + array( 'title' => ( $current_id == '' ? __( 'Add New Availability Option', 'propertyhive' ) : __( 'Edit Availability', 'propertyhive' ) ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_availability_settings' ),
1504 2428
1505 2429 array(
1506 2430 'title' => __( 'Availability', 'propertyhive' ),
1507 2431 'id' => 'availability_name',
@@ -1553,9 +2477,10 @@
1553 2477 * @return string
1554 2478 */
1555 2479 public function get_custom_fields_property_type_setting()
1556 2480 {
1557 - $current_id = empty( $_REQUEST['id'] ) ? '' : (int)$_REQUEST['id'];
2481 + // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- This getter only renders stored taxonomy settings and does not mutate state.
2482 + $current_id = $this->normalize_custom_fields_render_term_id( ( isset( $_REQUEST['id'] ) && is_string( $_REQUEST['id'] ) ) ? sanitize_text_field( wp_unslash( $_REQUEST['id'] ) ) : '' );
1558 2483
1559 2484 $taxonomy = 'property_type';
1560 2485 $term_name = '';
1561 2486 $term_parent = '';
@@ -1570,11 +2495,12 @@
1570 2495
1571 2496 $args = array(
1572 2497 'hide_empty' => false,
1573 2498 'parent' => 0,
2499 + // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude -- Edit screens exclude only the currently edited term from its own parent choices. Each line is exclude=>array($current_id), where current_id is cast to int from the request; one term ID prevents self-parenting.
1574 2500 'exclude' => array($current_id)
1575 2501 );
1576 - $terms = get_terms( 'property_type', $args );
2502 + $terms = get_terms( array_merge( wp_parse_args( $args ), array( 'taxonomy' => 'property_type' ) ) );
1577 2503 if ( !empty( $terms ) && !is_wp_error( $terms ) )
1578 2504 {
1579 2505 foreach ($terms as $term)
1580 2506 {
@@ -1583,9 +2509,9 @@
1583 2509 }
1584 2510
1585 2511 $args = array(
1586 2512
1587 - array( 'title' => __( ( $current_id == '' ? 'Add New Property Type' : 'Edit Property Type' ), 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_property_type_settings' ),
2513 + array( 'title' => ( $current_id == '' ? __( 'Add New Property Type', 'propertyhive' ) : __( 'Edit Property Type', 'propertyhive' ) ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_property_type_settings' ),
1588 2514
1589 2515 array(
1590 2516 'title' => __( 'Property Type', 'propertyhive' ),
1591 2517 'id' => 'property_type_name',
@@ -1624,9 +2550,10 @@
1624 2550 * @return string
1625 2551 */
1626 2552 public function get_custom_fields_commercial_property_type_setting()
1627 2553 {
1628 - $current_id = empty( $_REQUEST['id'] ) ? '' : (int)$_REQUEST['id'];
2554 + // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- This getter only renders stored taxonomy settings and does not mutate state.
2555 + $current_id = $this->normalize_custom_fields_render_term_id( ( isset( $_REQUEST['id'] ) && is_string( $_REQUEST['id'] ) ) ? sanitize_text_field( wp_unslash( $_REQUEST['id'] ) ) : '' );
1629 2556
1630 2557 $taxonomy = 'commercial_property_type';
1631 2558 $term_name = '';
1632 2559 $term_parent = '';
@@ -1641,11 +2568,12 @@
1641 2568
1642 2569 $args = array(
1643 2570 'hide_empty' => false,
1644 2571 'parent' => 0,
2572 + // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude -- Edit screens exclude only the currently edited term from its own parent choices. Each line is exclude=>array($current_id), where current_id is cast to int from the request; one term ID prevents self-parenting.
1645 2573 'exclude' => array($current_id)
1646 2574 );
1647 - $terms = get_terms( 'commercial_property_type', $args );
2575 + $terms = get_terms( array_merge( wp_parse_args( $args ), array( 'taxonomy' => 'commercial_property_type' ) ) );
1648 2576 if ( !empty( $terms ) && !is_wp_error( $terms ) )
1649 2577 {
1650 2578 foreach ($terms as $term)
1651 2579 {
@@ -1654,9 +2582,9 @@
1654 2582 }
1655 2583
1656 2584 $args = array(
1657 2585
1658 - array( 'title' => __( ( $current_id == '' ? 'Add New Property Type' : 'Edit Property Type' ), 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_commercial_property_type_settings' ),
2586 + array( 'title' => ( $current_id == '' ? __( 'Add New Property Type', 'propertyhive' ) : __( 'Edit Property Type', 'propertyhive' ) ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_commercial_property_type_settings' ),
1659 2587
1660 2588 array(
1661 2589 'title' => __( 'Property Type', 'propertyhive' ),
1662 2590 'id' => 'commercial_property_type_name',
@@ -1695,9 +2623,10 @@
1695 2623 * @return string
1696 2624 */
1697 2625 public function get_custom_fields_location_setting()
1698 2626 {
1699 - $current_id = empty( $_REQUEST['id'] ) ? '' : (int)$_REQUEST['id'];
2627 + // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- This getter only renders stored taxonomy settings and does not mutate state.
2628 + $current_id = $this->normalize_custom_fields_render_term_id( ( isset( $_REQUEST['id'] ) && is_string( $_REQUEST['id'] ) ) ? sanitize_text_field( wp_unslash( $_REQUEST['id'] ) ) : '' );
1700 2629
1701 2630 $taxonomy = 'location';
1702 2631 $term_name = '';
1703 2632 $term_parent = '';
@@ -1712,11 +2641,12 @@
1712 2641
1713 2642 $args = array(
1714 2643 'hide_empty' => false,
1715 2644 'parent' => 0,
2645 + // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude -- Edit screens exclude only the currently edited term from its own parent choices. Each line is exclude=>array($current_id), where current_id is cast to int from the request; one term ID prevents self-parenting.
1716 2646 'exclude' => array($current_id)
1717 2647 );
1718 - $terms = get_terms( $taxonomy, $args );
2648 + $terms = get_terms( array_merge( wp_parse_args( $args ), array( 'taxonomy' => $taxonomy ) ) );
1719 2649 if ( !empty( $terms ) && !is_wp_error( $terms ) )
1720 2650 {
1721 2651 foreach ($terms as $term)
1722 2652 {
@@ -1724,11 +2654,12 @@
1724 2654
1725 2655 $args = array(
1726 2656 'hide_empty' => false,
1727 2657 'parent' => $term->term_id,
2658 + // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude -- Edit screens exclude only the currently edited term from its own parent choices. Each line is exclude=>array($current_id), where current_id is cast to int from the request; one term ID prevents self-parenting.
1728 2659 'exclude' => array($current_id)
1729 2660 );
1730 - $terms = get_terms( $taxonomy, $args );
2661 + $terms = get_terms( array_merge( wp_parse_args( $args ), array( 'taxonomy' => $taxonomy ) ) );
1731 2662 if ( !empty( $terms ) && !is_wp_error( $terms ) )
1732 2663 {
1733 2664 foreach ($terms as $term)
1734 2665 {
@@ -1739,9 +2670,9 @@
1739 2670 }
1740 2671
1741 2672 $args = array(
1742 2673
1743 - array( 'title' => __( ( $current_id == '' ? 'Add New Location' : 'Edit Location' ), 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_location_settings' ),
2674 + array( 'title' => ( $current_id == '' ? __( 'Add New Location', 'propertyhive' ) : __( 'Edit Location', 'propertyhive' ) ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_location_settings' ),
1744 2675
1745 2676 array(
1746 2677 'title' => __( 'Location', 'propertyhive' ),
1747 2678 'id' => 'location_name',
@@ -1780,9 +2711,10 @@
1780 2711 * @return string
1781 2712 */
1782 2713 public function get_custom_fields_parking_setting()
1783 2714 {
1784 - $current_id = empty( $_REQUEST['id'] ) ? '' : (int)$_REQUEST['id'];
2715 + // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- This getter only renders stored taxonomy settings and does not mutate state.
2716 + $current_id = $this->normalize_custom_fields_render_term_id( ( isset( $_REQUEST['id'] ) && is_string( $_REQUEST['id'] ) ) ? sanitize_text_field( wp_unslash( $_REQUEST['id'] ) ) : '' );
1785 2717
1786 2718 $taxonomy = 'parking';
1787 2719 $term_name = '';
1788 2720 if ($current_id != '')
@@ -1792,9 +2724,9 @@
1792 2724 }
1793 2725
1794 2726 $args = array(
1795 2727
1796 - array( 'title' => __( ( $current_id == '' ? 'Add New Parking Option' : 'Edit Parking' ), 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_parking_settings' ),
2728 + array( 'title' => ( $current_id == '' ? __( 'Add New Parking Option', 'propertyhive' ) : __( 'Edit Parking', 'propertyhive' ) ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_parking_settings' ),
1797 2729
1798 2730 array(
1799 2731 'title' => __( 'Parking', 'propertyhive' ),
1800 2732 'id' => 'parking_name',
@@ -1823,9 +2755,10 @@
1823 2755 * @return string
1824 2756 */
1825 2757 public function get_custom_fields_outside_space_setting()
1826 2758 {
1827 - $current_id = empty( $_REQUEST['id'] ) ? '' : (int)$_REQUEST['id'];
2759 + // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- This getter only renders stored taxonomy settings and does not mutate state.
2760 + $current_id = $this->normalize_custom_fields_render_term_id( ( isset( $_REQUEST['id'] ) && is_string( $_REQUEST['id'] ) ) ? sanitize_text_field( wp_unslash( $_REQUEST['id'] ) ) : '' );
1828 2761
1829 2762 $taxonomy = 'outside_space';
1830 2763 $term_name = '';
1831 2764 if ($current_id != '')
@@ -1835,9 +2768,9 @@
1835 2768 }
1836 2769
1837 2770 $args = array(
1838 2771
1839 - array( 'title' => __( ( $current_id == '' ? 'Add New Outside Space' : 'Edit Outside Space' ), 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_outside_space_settings' ),
2772 + array( 'title' => ( $current_id == '' ? __( 'Add New Outside Space', 'propertyhive' ) : __( 'Edit Outside Space', 'propertyhive' ) ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_outside_space_settings' ),
1840 2773
1841 2774 array(
1842 2775 'title' => __( 'Outside Space', 'propertyhive' ),
1843 2776 'id' => 'outside_space_name',
@@ -1868,20 +2801,26 @@
1868 2801 public function get_custom_fields_delete($current_id, $taxonomy, $taxonomy_name)
1869 2802 {
1870 2803 global $save_button_text;
1871 2804
2805 + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Shared admin settings-view state; this global is intentionally used to control the common settings template and is not an arbitrary application global.
1872 2806 $save_button_text = __( 'Delete', 'propertyhive' );
1873 2807
1874 2808 //$taxonomy = 'outside_space';
1875 2809 //$taxonomy_name = __( 'Outside Space', 'propertyhive' );
1876 2810
1877 - if ( isset($_POST['confirm_removal']) && $_POST['confirm_removal'] == 1 )
2811 + // phpcs:ignore WordPress.Security.NonceVerification.Missing -- This branch only selects a read-only success view; the deletion mutation occurs in save() after the settings nonce and capability checks.
2812 + $confirm_removal = ( isset( $_POST['confirm_removal'] ) && is_string( $_POST['confirm_removal'] ) ) ? sanitize_text_field( wp_unslash( $_POST['confirm_removal'] ) ) : '';
2813 + if ( '1' === $confirm_removal )
1878 2814 {
1879 2815 // A term has just been deleted
1880 2816 global $hide_save_button, $show_cancel_button, $cancel_button_href;
1881 2817
2818 + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Shared admin settings-view state; this global is intentionally used to control the common settings template and is not an arbitrary application global.
1882 2819 $hide_save_button = TRUE;
2820 + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Shared admin settings-view state; this global is intentionally used to control the common settings template and is not an arbitrary application global.
1883 2821 $show_cancel_button = TRUE;
2822 + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Shared admin settings-view state; this global is intentionally used to control the common settings template and is not an arbitrary application global.
1884 2823 $cancel_button_href = admin_url( 'admin.php?page=ph-settings&tab=customfields&section=' . str_replace("_", "-", $taxonomy) );
1885 2824
1886 2825 $args = array();
1887 2826
@@ -1928,8 +2867,9 @@
1928 2867 $query_args = array(
1929 2868 'post_type' => 'property',
1930 2869 'nopaging' => true,
1931 2870 'post_status' => array( 'pending', 'auto-draft', 'draft', 'private', 'publish', 'future', 'trash' ),
2871 + // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query -- Term deletion/reassignment must locate all properties or key dates attached to this selected term before removing it.
1932 2872 'tax_query' => array(
1933 2873 array(
1934 2874 'taxonomy' => $taxonomy,
1935 2875 'field' => 'id',
@@ -1950,8 +2890,9 @@
1950 2890 $query_args = array(
1951 2891 'post_type' => 'contact',
1952 2892 'nopaging' => true,
1953 2893 'post_status' => array( 'pending', 'auto-draft', 'draft', 'private', 'publish', 'future', 'trash' ),
2894 + // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query -- Applicant preferences are serialized profile metadata; deletion/reassignment must inspect every applicant profile to preserve its other selections.
1954 2895 'meta_query' => array(
1955 2896 array(
1956 2897 'key' => '_contact_types',
1957 2898 'value' => 'applicant',
@@ -2000,9 +2941,33 @@
2000 2941
2001 2942 wp_reset_postdata();
2002 2943 }
2003 2944
2004 - if ($num_properties > 0 || $num_applicants > 0)
2945 + // Get number of key dates assigned to this term
2946 + $num_key_dates= 0;
2947 + if ( $taxonomy == 'management_key_date_type' )
2948 + {
2949 + $query_args = array(
2950 + 'post_type' => 'key_date',
2951 + 'nopaging' => true,
2952 + 'post_status' => array( 'pending', 'auto-draft', 'draft', 'private', 'publish', 'future', 'trash' ),
2953 + // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query -- Term deletion/reassignment must locate all properties or key dates attached to this selected term before removing it.
2954 + 'tax_query' => array(
2955 + array(
2956 + 'taxonomy' => $taxonomy,
2957 + 'field' => 'id',
2958 + 'terms' => $current_id,
2959 + ),
2960 + ),
2961 + );
2962 + $key_date_query = new WP_Query( $query_args );
2963 +
2964 + $num_key_dates = $key_date_query->found_posts;
2965 +
2966 + wp_reset_postdata();
2967 + }
2968 +
2969 + if ($num_properties > 0 || $num_applicants > 0 || $num_key_dates > 0 )
2005 2970 {
2006 2971 $alternative_terms = array();
2007 2972
2008 2973 $alternative_terms['none'] = '-- ' . __( 'Don\'t Reassign', 'propertyhive' ) . ' --';
@@ -2008,12 +2973,13 @@
2008 2973 $alternative_terms['none'] = '-- ' . __( 'Don\'t Reassign', 'propertyhive' ) . ' --';
2009 2974
2010 2975 $term_args = array(
2011 2976 'hide_empty' => false,
2977 + // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude -- This is a get_terms argument excluding the terms being deleted from reassignment choices, not a posts exclusion query.
2012 2978 'exclude' => $term_ids,
2013 2979 'parent' => 0
2014 2980 );
2015 - $terms = get_terms( $taxonomy, $term_args );
2981 + $terms = get_terms( array_merge( wp_parse_args( $term_args ), array( 'taxonomy' => $taxonomy ) ) );
2016 2982
2017 2983 if ( !empty( $terms ) && !is_wp_error( $terms ) )
2018 2984 {
2019 2985 foreach ($terms as $term)
@@ -2021,12 +2987,13 @@
2021 2987 $alternative_terms[$term->term_id] = $term->name;
2022 2988
2023 2989 $term_args = array(
2024 2990 'hide_empty' => false,
2991 + // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude -- This is a get_terms argument excluding the terms being deleted from reassignment choices, not a posts exclusion query.
2025 2992 'exclude' => $term_ids,
2026 2993 'parent' => $term->term_id
2027 2994 );
2028 - $subterms = get_terms( $taxonomy, $term_args );
2995 + $subterms = get_terms( array_merge( wp_parse_args( $term_args ), array( 'taxonomy' => $taxonomy ) ) );
2029 2996
2030 2997 if ( !empty( $subterms ) && !is_wp_error( $subterms ) )
2031 2998 {
2032 2999 foreach ($subterms as $term)
@@ -2034,12 +3001,13 @@
2034 3001 $alternative_terms[$term->term_id] = '- ' . $term->name;
2035 3002
2036 3003 $term_args = array(
2037 3004 'hide_empty' => false,
3005 + // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude -- This is a get_terms argument excluding the terms being deleted from reassignment choices, not a posts exclusion query.
2038 3006 'exclude' => $term_ids,
2039 3007 'parent' => $term->term_id
2040 3008 );
2041 - $subsubterms = get_terms( $taxonomy, $term_args );
3009 + $subsubterms = get_terms( array_merge( wp_parse_args( $term_args ), array( 'taxonomy' => $taxonomy ) ) );
2042 3010
2043 3011 if ( !empty( $subsubterms ) && !is_wp_error( $subsubterms ) )
2044 3012 {
2045 3013 foreach ($subsubterms as $term)
@@ -2059,21 +3027,11 @@
2059 3027 'default' => '',
2060 3028 'options' => $alternative_terms,
2061 3029 'type' => 'select',
2062 3030 'desc_tip' => false,
2063 - 'desc' => __( 'There are properties or applicants that have this term assigned to them. Which, if any, term should they be reassigned to?' , 'propertyhive' )
3031 + 'desc' => __( 'There are properties, applicants or management dates that have this term assigned to them. Which, if any, term should they be reassigned to?' , 'propertyhive' )
2064 3032 );
2065 3033 }
2066 - else
2067 - {
2068 - // There are properties assigned to this term
2069 - $args[] = array(
2070 - 'title' => __( 'Re-assign to', 'propertyhive' ),
2071 - 'id' => 'reassign_to',
2072 - 'type' => 'html',
2073 - 'html' => __( 'No properties or applicants assigned to this term' , 'propertyhive' )
2074 - );
2075 - }
2076 3034
2077 3035 $args[] = array( 'type' => 'sectionend', 'id' => 'custom_field_' . $taxonomy . '_' . $current_id . '_delete' );
2078 3036 }
2079 3037 }
@@ -2107,9 +3065,10 @@
2107 3065 * @return string
2108 3066 */
2109 3067 public function get_custom_fields_price_qualifier_setting()
2110 3068 {
2111 - $current_id = empty( $_REQUEST['id'] ) ? '' : sanitize_title( $_REQUEST['id'] );
3069 + // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- This settings getter only loads stored configuration for rendering; it does not mutate state.
3070 + $current_id = ( isset( $_REQUEST['id'] ) && is_string( $_REQUEST['id'] ) ) ? sanitize_title( wp_unslash( $_REQUEST['id'] ) ) : '';
2112 3071
2113 3072 $taxonomy = 'price_qualifier';
2114 3073 $term_name = '';
2115 3074 if ($current_id != '')
@@ -2119,9 +3078,9 @@
2119 3078 }
2120 3079
2121 3080 $args = array(
2122 3081
2123 - array( 'title' => __( ( $current_id == '' ? 'Add New Price Qualifier' : 'Edit Price Qualifier' ), 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_price_qualifier_settings' ),
3082 + array( 'title' => ( $current_id == '' ? __( 'Add New Price Qualifier', 'propertyhive' ) : __( 'Edit Price Qualifier', 'propertyhive' ) ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_price_qualifier_settings' ),
2124 3083
2125 3084 array(
2126 3085 'title' => __( 'Price Qualifier', 'propertyhive' ),
2127 3086 'id' => 'price_qualifier_name',
@@ -2150,9 +3109,10 @@
2150 3109 * @return string
2151 3110 */
2152 3111 public function get_custom_fields_sale_by_setting()
2153 3112 {
2154 - $current_id = empty( $_REQUEST['id'] ) ? '' : sanitize_title( $_REQUEST['id'] );
3113 + // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- This settings getter only loads stored configuration for rendering; it does not mutate state.
3114 + $current_id = ( isset( $_REQUEST['id'] ) && is_string( $_REQUEST['id'] ) ) ? sanitize_title( wp_unslash( $_REQUEST['id'] ) ) : '';
2155 3115
2156 3116 $taxonomy = 'sale_by';
2157 3117 $term_name = '';
2158 3118 if ($current_id != '')
@@ -2162,9 +3122,9 @@
2162 3122 }
2163 3123
2164 3124 $args = array(
2165 3125
2166 - array( 'title' => __( ( $current_id == '' ? 'Add New Sale By' : 'Edit Sale By' ), 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_sale_by_settings' ),
3126 + array( 'title' => ( $current_id == '' ? __( 'Add New Sale By', 'propertyhive' ) : __( 'Edit Sale By', 'propertyhive' ) ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_sale_by_settings' ),
2167 3127
2168 3128 array(
2169 3129 'title' => __( 'Sale By', 'propertyhive' ),
2170 3130 'id' => 'sale_by_name',
@@ -2193,9 +3153,10 @@
2193 3153 * @return string
2194 3154 */
2195 3155 public function get_custom_fields_tenure_setting()
2196 3156 {
2197 - $current_id = empty( $_REQUEST['id'] ) ? '' : sanitize_title( $_REQUEST['id'] );
3157 + // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- This settings getter only loads stored configuration for rendering; it does not mutate state.
3158 + $current_id = ( isset( $_REQUEST['id'] ) && is_string( $_REQUEST['id'] ) ) ? sanitize_title( wp_unslash( $_REQUEST['id'] ) ) : '';
2198 3159
2199 3160 $taxonomy = 'tenure';
2200 3161 $term_name = '';
2201 3162 if ($current_id != '')
@@ -2205,9 +3166,9 @@
2205 3166 }
2206 3167
2207 3168 $args = array(
2208 3169
2209 - array( 'title' => __( ( $current_id == '' ? 'Add New Tenure' : 'Edit Tenure' ), 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_tenure_settings' ),
3170 + array( 'title' => ( $current_id == '' ? __( 'Add New Tenure', 'propertyhive' ) : __( 'Edit Tenure', 'propertyhive' ) ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_tenure_settings' ),
2210 3171
2211 3172 array(
2212 3173 'title' => __( 'Tenure', 'propertyhive' ),
2213 3174 'id' => 'tenure_name',
@@ -2236,9 +3197,10 @@
2236 3197 * @return string
2237 3198 */
2238 3199 public function get_custom_fields_commercial_tenure_setting()
2239 3200 {
2240 - $current_id = empty( $_REQUEST['id'] ) ? '' : sanitize_title( $_REQUEST['id'] );
3201 + // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- This settings getter only loads stored configuration for rendering; it does not mutate state.
3202 + $current_id = ( isset( $_REQUEST['id'] ) && is_string( $_REQUEST['id'] ) ) ? sanitize_title( wp_unslash( $_REQUEST['id'] ) ) : '';
2241 3203
2242 3204 $taxonomy = 'commercial_tenure';
2243 3205 $term_name = '';
2244 3206 if ($current_id != '')
@@ -2248,9 +3210,9 @@
2248 3210 }
2249 3211
2250 3212 $args = array(
2251 3213
2252 - array( 'title' => __( ( $current_id == '' ? 'Add New Tenure' : 'Edit Tenure' ), 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_commercial_tenure_settings' ),
3214 + array( 'title' => ( $current_id == '' ? __( 'Add New Tenure', 'propertyhive' ) : __( 'Edit Tenure', 'propertyhive' ) ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_commercial_tenure_settings' ),
2253 3215
2254 3216 array(
2255 3217 'title' => __( 'Tenure', 'propertyhive' ),
2256 3218 'id' => 'commercial_tenure_name',
@@ -2279,9 +3241,10 @@
2279 3241 * @return string
2280 3242 */
2281 3243 public function get_custom_fields_furnished_setting()
2282 3244 {
2283 - $current_id = empty( $_REQUEST['id'] ) ? '' : sanitize_title( $_REQUEST['id'] );
3245 + // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- This settings getter only loads stored configuration for rendering; it does not mutate state.
3246 + $current_id = ( isset( $_REQUEST['id'] ) && is_string( $_REQUEST['id'] ) ) ? sanitize_title( wp_unslash( $_REQUEST['id'] ) ) : '';
2284 3247
2285 3248 $taxonomy = 'furnished';
2286 3249 $term_name = '';
2287 3250 if ($current_id != '')
@@ -2291,9 +3254,9 @@
2291 3254 }
2292 3255
2293 3256 $args = array(
2294 3257
2295 - array( 'title' => __( ( $current_id == '' ? 'Add New Furnished' : 'Edit Furnished' ), 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_furnished_settings' ),
3258 + array( 'title' => ( $current_id == '' ? __( 'Add New Furnished', 'propertyhive' ) : __( 'Edit Furnished', 'propertyhive' ) ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_furnished_settings' ),
2296 3259
2297 3260 array(
2298 3261 'title' => __( 'Furnished', 'propertyhive' ),
2299 3262 'id' => 'furnished_name',
@@ -2314,8 +3277,113 @@
2314 3277
2315 3278 return apply_filters( 'propertyhive_custom_field_furnished_settings', $args );
2316 3279 }
2317 3280
3281 + /**
3282 + * Show key date add/edit options
3283 + *
3284 + * @return string
3285 + */
3286 + public function get_custom_fields_management_key_date_type_setting()
3287 + {
3288 + // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- This settings getter only loads stored configuration for rendering; it does not mutate state.
3289 + $current_id = ( isset( $_REQUEST['id'] ) && is_string( $_REQUEST['id'] ) ) ? sanitize_title( wp_unslash( $_REQUEST['id'] ) ) : '';
3290 +
3291 + $taxonomy = 'management_key_date_type';
3292 + $term_name = '';
3293 + if ($current_id != '')
3294 + {
3295 + $term = get_term( $current_id, $taxonomy );
3296 + $term_name = $term->name;
3297 + }
3298 +
3299 + $recurrence = get_option( 'propertyhive_key_date_type', array() );
3300 + if ( ! is_array($recurrence) )
3301 + {
3302 + $recurrence = array();
3303 + }
3304 + $recurrence_rule = isset($recurrence[$current_id]) ? $recurrence[$current_id]['recurrence_rule'] : '';
3305 + $recurrence_type = isset($recurrence[$current_id]) ? $recurrence[$current_id]['recurrence_type'] : '';
3306 +
3307 + $recurrence = array(
3308 + 'FREQ' => 'ONCE',
3309 + 'INTERVAL' => '1',
3310 + );
3311 +
3312 + if ( !empty($recurrence_rule) )
3313 + {
3314 + foreach (explode(';', $recurrence_rule) as $key_value_pair){
3315 + list($key, $value) = explode('=', $key_value_pair);
3316 + $recurrence[$key] = $value;
3317 + }
3318 + }
3319 +
3320 + $interval_disabled = $recurrence['FREQ'] == 'ONCE' ? array('disabled' => 'disabled') : array();
3321 +
3322 + $args = array(
3323 +
3324 + array( 'title' => ( $current_id == '' ? __( 'Add New Management Date Type', 'propertyhive' ) : __( 'Edit Management Date Type', 'propertyhive' ) ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_management_key_date_type_settings' ),
3325 +
3326 + array(
3327 + 'title' => __( 'Description', 'propertyhive' ),
3328 + 'id' => 'management_key_date_type_name',
3329 + 'default' => $term_name,
3330 + 'type' => 'text',
3331 + 'desc_tip' => false,
3332 + ),
3333 +
3334 + array(
3335 + 'title' => __( 'Type', 'propertyhive' ),
3336 + 'id' => 'management_key_date_type_recurrence_type',
3337 + 'default' => $recurrence_type,
3338 + 'type' => 'select',
3339 + 'desc_tip' => false,
3340 + 'options' => array(
3341 + 'tenancy_management' => __( 'Tenancy Management', 'propertyhive' ),
3342 + 'property_management' => __( 'Property Management', 'propertyhive' ),
3343 + ),
3344 + ),
3345 +
3346 + array(
3347 + 'title' => __( 'Frequency', 'propertyhive' ),
3348 + 'id' => 'management_key_date_type_recurrence_freq',
3349 + 'default' => $recurrence['FREQ'],
3350 + 'type' => 'select',
3351 + 'desc_tip' => false,
3352 + 'options' => array(
3353 + 'ONCE' => __( 'Once', 'propertyhive' ),
3354 + 'DAILY' => __( 'Daily', 'propertyhive' ),
3355 + 'WEEKLY' => __( 'Weekly', 'propertyhive' ),
3356 + 'MONTHLY' => __( 'Monthly', 'propertyhive' ),
3357 + 'YEARLY' => __( 'Yearly', 'propertyhive' ),
3358 + ),
3359 + 'custom_attributes' => array('onchange' => "
3360 + jQuery('#management_key_date_type_recurrence_interval').prop( 'disabled', this.value == 'ONCE');
3361 + "),
3362 + ),
3363 +
3364 + array(
3365 + 'title' => __( 'Interval', 'propertyhive' ),
3366 + 'id' => 'management_key_date_type_recurrence_interval',
3367 + 'default' => $recurrence['INTERVAL'],
3368 + 'type' => 'number',
3369 + 'custom_attributes' => array_merge( array( 'min' => '1', 'required' => 'true'), $interval_disabled ),
3370 + 'desc' => '<p>When setting a key date to Complete, these settings are used to calculate the date the next one should occur.<br>For example, if a key date should happen every 3 months, set Frequency to "Monthly" and Interval to "3".</p>',
3371 + ),
3372 +
3373 + array(
3374 + 'type' => 'hidden',
3375 + 'id' => 'taxonomy',
3376 + 'default' => $taxonomy
3377 + ),
3378 +
3379 + array( 'type' => 'sectionend', 'id' => 'custom_field_management_key_date_type_settings' )
3380 +
3381 + );
3382 +
3383 + return apply_filters( 'propertyhive_custom_field_management_key_date_type_setting', $args );
3384 + }
3385 +
2318 3386 /**
2319 3387 * Show marketing flag add/edit options
2320 3388 *
2321 3389 * @access public
@@ -2322,9 +3390,10 @@
2322 3390 * @return string
2323 3391 */
2324 3392 public function get_custom_fields_marketing_flag_setting()
2325 3393 {
2326 - $current_id = empty( $_REQUEST['id'] ) ? '' : sanitize_title( $_REQUEST['id'] );
3394 + // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- This settings getter only loads stored configuration for rendering; it does not mutate state.
3395 + $current_id = ( isset( $_REQUEST['id'] ) && is_string( $_REQUEST['id'] ) ) ? sanitize_title( wp_unslash( $_REQUEST['id'] ) ) : '';
2327 3396
2328 3397 $taxonomy = 'marketing_flag';
2329 3398 $term_name = '';
2330 3399 if ($current_id != '')
@@ -2334,9 +3403,9 @@
2334 3403 }
2335 3404
2336 3405 $args = array(
2337 3406
2338 - array( 'title' => __( ( $current_id == '' ? 'Add New Marketing Flag' : 'Edit Marketing Flag' ), 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_marketing_flag_settings' ),
3407 + array( 'title' => ( $current_id == '' ? __( 'Add New Marketing Flag', 'propertyhive' ) : __( 'Edit Marketing Flag', 'propertyhive' ) ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_marketing_flag_settings' ),
2339 3408
2340 3409 array(
2341 3410 'title' => __( 'Marketing Flag', 'propertyhive' ),
2342 3411 'id' => 'marketing_flag_name',
@@ -2365,9 +3434,10 @@
2365 3434 * @return string
2366 3435 */
2367 3436 public function get_custom_fields_property_feature_setting()
2368 3437 {
2369 - $current_id = empty( $_REQUEST['id'] ) ? '' : sanitize_title( $_REQUEST['id'] );
3438 + // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- This settings getter only loads stored configuration for rendering; it does not mutate state.
3439 + $current_id = ( isset( $_REQUEST['id'] ) && is_string( $_REQUEST['id'] ) ) ? sanitize_title( wp_unslash( $_REQUEST['id'] ) ) : '';
2370 3440
2371 3441 $taxonomy = 'property_feature';
2372 3442 $term_name = '';
2373 3443 if ($current_id != '')
@@ -2377,9 +3447,9 @@
2377 3447 }
2378 3448
2379 3449 $args = array(
2380 3450
2381 - array( 'title' => __( ( $current_id == '' ? 'Add New Property Feature' : 'Edit Property Feature' ), 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_property_feature_settings' ),
3451 + array( 'title' => ( $current_id == '' ? __( 'Add New Property Feature', 'propertyhive' ) : __( 'Edit Property Feature', 'propertyhive' ) ), 'type' => 'title', 'desc' => '', 'id' => 'custom_field_property_feature_settings' ),
2382 3452
2383 3453 array(
2384 3454 'title' => __( 'Property Feature', 'propertyhive' ),
2385 3455 'id' => 'property_feature_name',
@@ -2400,269 +3470,496 @@
2400 3470
2401 3471 return apply_filters( 'propertyhive_custom_field_property_feature_settings', $args );
2402 3472 }
2403 3473
3474 + private function normalize_custom_fields_field_type( $value ) {
3475 + if ( ! is_string( $value ) ) {
3476 + return 'text';
3477 + }
3478 +
3479 + $field_type = sanitize_key( $value );
3480 + $allowed_types = array( 'text', 'textarea', 'select', 'multiselect', 'checkbox', 'date', 'image', 'file' );
3481 +
3482 + return in_array( $field_type, $allowed_types, true ) ? $field_type : 'text';
3483 + }
3484 +
3485 + private function normalize_custom_fields_dropdown_options( $value ) {
3486 + if ( ! is_array( $value ) ) {
3487 + return '';
3488 + }
3489 +
3490 + $options = array();
3491 + foreach ( $value as $option ) {
3492 + if ( ! is_string( $option ) ) {
3493 + return '';
3494 + }
3495 + $options[] = sanitize_text_field( $option );
3496 + }
3497 +
3498 + return $options;
3499 + }
3500 +
3501 + private function normalize_custom_fields_checkbox( $value ) {
3502 + return ( is_string( $value ) && '1' === $value ) ? '1' : '';
3503 + }
3504 +
3505 + private function normalize_custom_fields_meta_box( $value ) {
3506 + return is_string( $value ) ? sanitize_key( $value ) : '';
3507 + }
3508 +
3509 + private function normalize_custom_fields_term_id( $value, $allow_empty = true ) {
3510 + if ( ! is_string( $value ) ) {
3511 + return null;
3512 + }
3513 +
3514 + $value = trim( $value );
3515 + if ( '' === $value ) {
3516 + return $allow_empty ? '' : null;
3517 + }
3518 +
3519 + if ( ! preg_match( '/^[0-9]+$/D', $value ) ) {
3520 + return null;
3521 + }
3522 +
3523 + $term_id = absint( $value );
3524 + return $term_id > 0 ? (string) $term_id : null;
3525 + }
3526 +
3527 + private function normalize_custom_fields_render_term_id( $value ) {
3528 + $term_id = $this->normalize_custom_fields_term_id( $value );
3529 + return ( null === $term_id || '' === $term_id ) ? '' : absint( $term_id );
3530 + }
3531 +
3532 + private function normalize_custom_fields_parent_id( $value ) {
3533 + if ( ! is_string( $value ) ) {
3534 + return null;
3535 + }
3536 +
3537 + $value = trim( $value );
3538 + if ( '' === $value ) {
3539 + return 0;
3540 + }
3541 +
3542 + if ( ! preg_match( '/^[0-9]+$/D', $value ) ) {
3543 + return null;
3544 + }
3545 +
3546 + return absint( $value );
3547 + }
3548 +
3549 + private function normalize_custom_fields_term_id_list( $value ) {
3550 + if ( ! is_string( $value ) || '' === trim( $value ) ) {
3551 + return array();
3552 + }
3553 +
3554 + $term_ids = array();
3555 + foreach ( explode( '-', trim( $value ) ) as $term_id ) {
3556 + if ( ! preg_match( '/^[0-9]+$/D', $term_id ) ) {
3557 + return array();
3558 + }
3559 +
3560 + $term_id = absint( $term_id );
3561 + if ( $term_id < 1 || in_array( (string) $term_id, $term_ids, true ) ) {
3562 + return array();
3563 + }
3564 +
3565 + $term_ids[] = (string) $term_id;
3566 + }
3567 +
3568 + return $term_ids;
3569 + }
3570 +
3571 + private function normalize_custom_fields_reassignment( $value, $deleted_ids ) {
3572 + if ( ! is_string( $value ) ) {
3573 + return null;
3574 + }
3575 +
3576 + $value = trim( $value );
3577 + if ( '' === $value || 'none' === $value || ! preg_match( '/^[0-9]+$/D', $value ) ) {
3578 + return null;
3579 + }
3580 +
3581 + $term_id = (string) absint( $value );
3582 + if ( '0' === $term_id || in_array( $term_id, $deleted_ids, true ) ) {
3583 + return null;
3584 + }
3585 +
3586 + return $term_id;
3587 + }
3588 +
3589 + private function get_custom_fields_taxonomy_for_section( $section ) {
3590 + $taxonomies = array(
3591 + 'availability' => 'availability',
3592 + 'property-type' => 'property_type',
3593 + 'commercial-property-type' => 'commercial_property_type',
3594 + 'location' => 'location',
3595 + 'parking' => 'parking',
3596 + 'outside-space' => 'outside_space',
3597 + 'price-qualifier' => 'price_qualifier',
3598 + 'sale-by' => 'sale_by',
3599 + 'tenure' => 'tenure',
3600 + 'commercial-tenure' => 'commercial_tenure',
3601 + 'furnished' => 'furnished',
3602 + 'management-key-date-type' => 'management_key_date_type',
3603 + 'marketing-flag' => 'marketing_flag',
3604 + 'property-feature' => 'property_feature',
3605 + );
3606 +
3607 + if ( isset( $taxonomies[ $section ] ) ) {
3608 + return $taxonomies[ $section ];
3609 + }
3610 +
3611 + if ( is_string( $section ) && '-delete' === substr( $section, -7 ) ) {
3612 + $base_section = substr( $section, 0, -7 );
3613 + return isset( $taxonomies[ $base_section ] ) ? $taxonomies[ $base_section ] : '';
3614 + }
3615 +
3616 + return '';
3617 + }
3618 +
2404 3619 /**
2405 - * Save settings
3620 + * Save settings.
2406 3621 */
2407 3622 public function save() {
3623 + if ( ! current_user_can( 'manage_options' ) || ! isset( $_REQUEST['_wpnonce'] ) || ! is_string( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ), 'propertyhive-settings' ) ) {
3624 + return;
3625 + }
3626 +
2408 3627 global $current_section, $post;
2409 3628
2410 - if ( $current_section != '' )
2411 - {
2412 - if (isset($_REQUEST['id'])) // we're either adding or editing
2413 - {
2414 - $current_id = empty( $_REQUEST['id'] ) ? '' : sanitize_text_field($_REQUEST['id']);
2415 -
2416 - switch ($current_section)
2417 - {
2418 - // With heirarchy
2419 - case "property-type":
2420 - case "commercial-property-type":
2421 - case "location":
2422 - {
2423 - // TODO: Validate (check for blank fields)
2424 -
2425 - if ($current_id == '')
2426 - {
2427 - // Adding new term
2428 -
2429 - // TODO: Check term doesn't exist already
2430 -
3629 + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Existing shared settings-router global; normalization preserves the public settings page contract.
3630 + $current_section = is_string( $current_section ) ? $current_section : '';
3631 + $request_id_present = isset( $_REQUEST['id'] ) && is_string( $_REQUEST['id'] );
3632 + $request_id = $request_id_present ? sanitize_text_field( wp_unslash( $_REQUEST['id'] ) ) : '';
3633 + $post_data = is_array( $_POST ) ? wp_unslash( $_POST ) : array();
3634 +
3635 + if ( '' === $current_section ) {
3636 + return;
3637 + }
3638 +
3639 + switch ( $current_section ) {
3640 + case 'addadditionalfield':
3641 + case 'editadditionalfield':
3642 + $current_settings = get_option( 'propertyhive_template_assistant', array() );
3643 + if ( ! is_array( $current_settings ) ) {
3644 + $current_settings = array();
3645 + }
3646 +
3647 + $current_id = $request_id_present ? sanitize_title( $request_id ) : '';
3648 + $existing_custom_fields = ( isset( $current_settings['custom_fields'] ) && is_array( $current_settings['custom_fields'] ) ) ? $current_settings['custom_fields'] : array();
3649 +
3650 + if ( 'editadditionalfield' === $current_section && 'default' !== $current_id && ! isset( $existing_custom_fields[ $current_id ] ) ) {
3651 + die( 'Trying to edit a non-existant custom field. Please go back and try again' );
3652 + }
3653 +
3654 + $field_label = ( isset( $post_data['field_label'] ) && is_string( $post_data['field_label'] ) ) ? sanitize_text_field( $post_data['field_label'] ) : '';
3655 + $field_name = ( isset( $post_data['field_name'] ) && is_string( $post_data['field_name'] ) ) ? sanitize_title( $post_data['field_name'] ) : '';
3656 + if ( '' === trim( $field_name ) ) {
3657 + $field_name = str_replace( '-', '_', sanitize_title( $field_label ) );
3658 + }
3659 + $field_name = '_' . ltrim( $field_name, '_' );
3660 +
3661 + $field_type = $this->normalize_custom_fields_field_type( isset( $post_data['field_type'] ) ? $post_data['field_type'] : '' );
3662 + $dropdown_options = ( in_array( $field_type, array( 'select', 'multiselect' ), true ) && isset( $post_data['dropdown_options'] ) ) ? $this->normalize_custom_fields_dropdown_options( $post_data['dropdown_options'] ) : '';
3663 + $field_settings = array(
3664 + 'field_label' => $field_label,
3665 + 'field_name' => $field_name,
3666 + 'field_type' => $field_type,
3667 + 'dropdown_options' => $dropdown_options,
3668 + 'meta_box' => $this->normalize_custom_fields_meta_box( isset( $post_data['meta_box'] ) ? $post_data['meta_box'] : '' ),
3669 + 'display_on_website' => $this->normalize_custom_fields_checkbox( isset( $post_data['display_on_website'] ) ? $post_data['display_on_website'] : '' ),
3670 + 'display_on_applicant_requirements' => $this->normalize_custom_fields_checkbox( isset( $post_data['display_on_applicant_requirements'] ) ? $post_data['display_on_applicant_requirements'] : '' ),
3671 + 'exact_match' => $this->normalize_custom_fields_checkbox( isset( $post_data['exact_match'] ) ? $post_data['exact_match'] : '' ),
3672 + 'display_on_user_details' => $this->normalize_custom_fields_checkbox( isset( $post_data['display_on_user_details'] ) ? $post_data['display_on_user_details'] : '' ),
3673 + 'admin_list' => $this->normalize_custom_fields_checkbox( isset( $post_data['admin_list'] ) ? $post_data['admin_list'] : '' ),
3674 + 'admin_list_sortable' => $this->normalize_custom_fields_checkbox( isset( $post_data['admin_list_sortable'] ) ? $post_data['admin_list_sortable'] : '' ),
3675 + );
3676 +
3677 + if ( 'addadditionalfield' === $current_section ) {
3678 + $existing_custom_fields[] = $field_settings;
3679 + } else {
3680 + $existing_custom_fields[ $current_id ] = $field_settings;
3681 + }
3682 +
3683 + $current_settings['custom_fields'] = $existing_custom_fields;
3684 +
3685 + if ( 'addadditionalfield' !== $current_section && ! empty( $current_settings['search_forms'] ) && is_array( $current_settings['search_forms'] ) ) {
3686 + foreach ( $current_settings['search_forms'] as $search_form_id => $search_form ) {
3687 + if ( isset( $search_form['active_fields'] ) && is_array( $search_form['active_fields'] ) ) {
3688 + foreach ( $search_form['active_fields'] as $field_id => $field_data ) {
3689 + if ( $field_name === $field_id ) {
3690 + $current_settings['search_forms'][ $search_form_id ]['active_fields'][ $field_id ]['type'] = $field_type;
3691 + }
3692 + }
3693 + }
3694 +
3695 + if ( isset( $search_form['inactive_fields'] ) && is_array( $search_form['inactive_fields'] ) ) {
3696 + foreach ( $search_form['inactive_fields'] as $field_id => $field_data ) {
3697 + if ( $field_name === $field_id ) {
3698 + $current_settings['search_forms'][ $search_form_id ]['inactive_fields'][ $field_id ]['type'] = $field_type;
3699 + }
3700 + }
3701 + }
3702 + }
3703 + }
3704 +
3705 + update_option( 'propertyhive_template_assistant', $current_settings );
3706 + break;
3707 +
3708 + default:
3709 + if ( ! $request_id_present ) {
3710 + break;
3711 + }
3712 +
3713 + $taxonomy = $this->get_custom_fields_taxonomy_for_section( $current_section );
3714 + $is_delete_section = '-delete' === substr( $current_section, -7 );
3715 +
3716 + if ( '' !== $taxonomy ) {
3717 + if ( $is_delete_section ) {
3718 + $term_ids = $this->normalize_custom_fields_term_id_list( $request_id );
3719 + if ( empty( $term_ids ) ) {
3720 + return;
3721 + }
3722 + $current_id = implode( '-', $term_ids );
3723 + } else {
3724 + $current_id = $this->normalize_custom_fields_term_id( $request_id );
3725 + if ( null === $current_id ) {
3726 + return;
3727 + }
3728 + }
3729 + } else {
3730 + $current_id = sanitize_text_field( $request_id );
3731 + }
3732 +
3733 + switch ( $current_section ) {
3734 + case 'property-type':
3735 + case 'commercial-property-type':
3736 + case 'location':
3737 + $term_name_key = $taxonomy . '_name';
3738 + $parent_key = 'parent_' . $taxonomy . '_id';
3739 + $term_name = ( isset( $post_data[ $term_name_key ] ) && is_string( $post_data[ $term_name_key ] ) ) ? sanitize_text_field( $post_data[ $term_name_key ] ) : '';
3740 + $parent_id = $this->normalize_custom_fields_parent_id( isset( $post_data[ $parent_key ] ) ? $post_data[ $parent_key ] : '' );
3741 + if ( '' === $term_name || null === $parent_id ) {
3742 + return;
3743 + }
3744 +
3745 + if ( '' === $current_id ) {
2431 3746 wp_insert_term(
2432 - ph_clean($_POST[ph_clean($_POST['taxonomy']) . '_name']), // the term
2433 - ph_clean($_POST['taxonomy']), // the taxonomy
3747 + $term_name,
3748 + $taxonomy,
3749 + array( 'parent' => $parent_id )
3750 + );
3751 + } else {
3752 + wp_update_term(
3753 + absint( $current_id ),
3754 + $taxonomy,
2434 3755 array(
2435 - 'parent' => $_POST['parent_' . ph_clean($_POST['taxonomy']) . '_id']
3756 + 'name' => $term_name,
3757 + 'parent' => $parent_id,
2436 3758 )
2437 3759 );
2438 -
2439 - // TODO: Check for errors returned from wp_insert_term()
2440 3760 }
2441 - else
2442 - {
2443 - // Editing term
2444 - wp_update_term($current_id, ph_clean($_POST['taxonomy']), array(
2445 - 'name' => ph_clean($_POST[ph_clean($_POST['taxonomy']).'_name']),
2446 - 'parent' => ph_clean($_POST['parent_' . $_POST['taxonomy'] . '_id'])
2447 - ));
2448 -
2449 - // TODO: Check for errors returned from wp_update_term()
3761 + break;
3762 +
3763 + case 'availability':
3764 + case 'outside-space':
3765 + case 'parking':
3766 + case 'price-qualifier':
3767 + case 'sale-by':
3768 + case 'tenure':
3769 + case 'commercial-tenure':
3770 + case 'furnished':
3771 + case 'management-key-date-type':
3772 + case 'marketing-flag':
3773 + case 'property-feature':
3774 + $term_name_key = $taxonomy . '_name';
3775 + $term_name = ( isset( $post_data[ $term_name_key ] ) && is_string( $post_data[ $term_name_key ] ) ) ? sanitize_text_field( $post_data[ $term_name_key ] ) : '';
3776 + if ( '' === $term_name ) {
3777 + return;
2450 3778 }
2451 - break;
2452 - }
2453 - // Without heirarchy
2454 - case "availability":
2455 - case "outside-space":
2456 - case "parking":
2457 - case "price-qualifier":
2458 - case "sale-by":
2459 - case "tenure":
2460 - case "commercial-tenure":
2461 - case "furnished":
2462 - case "marketing-flag":
2463 - case "property-feature":
2464 - {
2465 - // TODO: Validate (check for blank fields)
2466 -
2467 - if ($current_id == '')
2468 - {
2469 - // Adding new term
2470 -
2471 - // TODO: Check term doesn't exist already
2472 -
2473 - $term = wp_insert_term(
2474 - ph_clean($_POST[ph_clean($_POST['taxonomy']) . '_name']), // the term
2475 - $_POST['taxonomy'] // the taxonomy
2476 - );
2477 -
2478 - // TODO: Check for errors returned from wp_insert_term()
2479 3779
2480 - if ( ! is_wp_error( $term ) )
2481 - {
2482 - $current_id = isset( $term['term_id'] ) ? $term['term_id'] : 0;
3780 + if ( '' === $current_id ) {
3781 + $term = wp_insert_term( $term_name, $taxonomy );
3782 + if ( ! is_wp_error( $term ) ) {
3783 + $current_id = isset( $term['term_id'] ) ? (string) absint( $term['term_id'] ) : '0';
2483 3784 }
3785 + } else {
3786 + wp_update_term( absint( $current_id ), $taxonomy, array( 'name' => $term_name ) );
2484 3787 }
2485 - else
2486 - {
2487 - // Editing term
2488 - wp_update_term($current_id, ph_clean($_POST['taxonomy']), array(
2489 - 'name' => ph_clean($_POST[ph_clean($_POST['taxonomy']) . '_name'])
2490 - ));
2491 -
2492 - // TODO: Check for errors returned from wp_update_term()
2493 - }
2494 3788
2495 - if ( $current_section == 'availability' )
2496 - {
3789 + if ( 'availability' === $current_section ) {
2497 3790 $availability_departments = get_option( 'propertyhive_availability_departments', array() );
2498 - if ( !is_array($availability_departments) ) { $availability_departments = array(); }
3791 + if ( ! is_array( $availability_departments ) ) {
3792 + $availability_departments = array();
3793 + }
2499 3794
2500 3795 $departments = ph_get_departments();
2501 -
2502 - $availability_departments[$current_id] = array();
2503 - foreach ( $departments as $key => $value )
2504 - {
2505 - if ( isset($_POST['department'][$key]) && $_POST['department'][$key] == '1' )
2506 - {
2507 - $availability_departments[$current_id][] = $key;
3796 + $posted_departments = ( isset( $post_data['department'] ) && is_array( $post_data['department'] ) ) ? $post_data['department'] : array();
3797 + $availability_departments[ $current_id ] = array();
3798 + foreach ( $departments as $key => $value ) {
3799 + if ( isset( $posted_departments[ $key ] ) && is_string( $posted_departments[ $key ] ) && '1' === $posted_departments[ $key ] ) {
3800 + $availability_departments[ $current_id ][] = $key;
2508 3801 }
2509 3802 }
2510 -
2511 3803 update_option( 'propertyhive_availability_departments', $availability_departments );
2512 3804 }
2513 3805
3806 + if ( 'management-key-date-type' === $current_section ) {
3807 + $options = get_option( 'propertyhive_key_date_type', array() );
3808 + if ( ! is_array( $options ) ) {
3809 + $options = array();
3810 + }
3811 +
3812 + $recurrence = array();
3813 + $frequency = ( isset( $post_data['management_key_date_type_recurrence_freq'] ) && is_string( $post_data['management_key_date_type_recurrence_freq'] ) ) ? strtoupper( sanitize_text_field( $post_data['management_key_date_type_recurrence_freq'] ) ) : '';
3814 + if ( in_array( $frequency, array( 'ONCE', 'DAILY', 'WEEKLY', 'MONTHLY', 'YEARLY' ), true ) ) {
3815 + $recurrence[] = 'FREQ=' . $frequency;
3816 + }
3817 +
3818 + $interval = ( isset( $post_data['management_key_date_type_recurrence_interval'] ) && is_string( $post_data['management_key_date_type_recurrence_interval'] ) ) ? trim( $post_data['management_key_date_type_recurrence_interval'] ) : '';
3819 + if ( '' !== $interval && preg_match( '/^[1-9][0-9]*$/D', $interval ) ) {
3820 + $recurrence[] = 'INTERVAL=' . absint( $interval );
3821 + }
3822 +
3823 + $recurrence_type = ( isset( $post_data['management_key_date_type_recurrence_type'] ) && is_string( $post_data['management_key_date_type_recurrence_type'] ) ) ? sanitize_key( $post_data['management_key_date_type_recurrence_type'] ) : '';
3824 + if ( ! in_array( $recurrence_type, array( 'tenancy_management', 'property_management' ), true ) ) {
3825 + $recurrence_type = '';
3826 + }
3827 +
3828 + $options[ $current_id ]['recurrence_rule'] = join( ';', $recurrence );
3829 + $options[ $current_id ]['recurrence_type'] = $recurrence_type;
3830 + update_option( 'propertyhive_key_date_type', $options );
3831 + }
2514 3832 break;
2515 - }
2516 - case "availability-delete":
2517 - case "property-type-delete":
2518 - case "commercial-property-type-delete":
2519 - case "location-delete":
2520 - case "parking-delete":
2521 - case "outside-space-delete":
2522 - case "price-qualifier-delete":
2523 - case "sale-by-delete":
2524 - case "tenure-delete":
2525 - case "furnished-delete":
2526 - case "marketing-flag-delete":
2527 - case "property-feature-delete":
2528 - {
2529 - if ( isset($_POST['confirm_removal']) && $_POST['confirm_removal'] == '1' )
2530 - {
2531 - $term_ids = explode("-", $current_id);
2532 3833
2533 - foreach ( $term_ids as $current_id )
2534 - {
2535 - // Update properties that have this taxonomy term set
2536 - $query_args = array(
2537 - 'post_type' => 'property',
2538 - 'nopaging' => true,
2539 - 'post_status' => array( 'pending', 'auto-draft', 'draft', 'private', 'publish', 'future', 'trash' ),
2540 - 'tax_query' => array(
2541 - array(
2542 - 'taxonomy' => $_POST['taxonomy'],
2543 - 'field' => 'id',
2544 - 'terms' => $current_id,
2545 - ),
3834 + case 'availability-delete':
3835 + case 'property-type-delete':
3836 + case 'commercial-property-type-delete':
3837 + case 'location-delete':
3838 + case 'parking-delete':
3839 + case 'outside-space-delete':
3840 + case 'price-qualifier-delete':
3841 + case 'sale-by-delete':
3842 + case 'tenure-delete':
3843 + case 'commercial-tenure-delete':
3844 + case 'furnished-delete':
3845 + case 'management-key-date-type-delete':
3846 + case 'marketing-flag-delete':
3847 + case 'property-feature-delete':
3848 + if ( ! isset( $post_data['confirm_removal'] ) || ! is_string( $post_data['confirm_removal'] ) || '1' !== $post_data['confirm_removal'] ) {
3849 + break;
3850 + }
3851 +
3852 + foreach ( $term_ids as $current_id ) {
3853 + $query_args = array(
3854 + 'post_type' => 'property',
3855 + 'nopaging' => true,
3856 + 'post_status' => array( 'pending', 'auto-draft', 'draft', 'private', 'publish', 'future', 'trash' ),
3857 + // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query -- Term deletion/reassignment must locate all properties or key dates attached to this selected term before removing it.
3858 + 'tax_query' => array(
3859 + array(
3860 + 'taxonomy' => $taxonomy,
3861 + 'field' => 'id',
3862 + 'terms' => $current_id,
2546 3863 ),
2547 - );
2548 - $property_query = new WP_Query( $query_args );
2549 -
2550 - if ( $property_query->have_posts() )
2551 - {
2552 - while ( $property_query->have_posts() )
2553 - {
2554 - $property_query->the_post();
2555 -
2556 - wp_remove_object_terms( $post->ID, $current_id, ph_clean($_POST['taxonomy']) );
2557 -
2558 - // Re-assign to another term
2559 - if ( isset($_POST['reassign_to_' . $current_id]) && ! empty( $_POST['reassign_to_' . $current_id] ) && $_POST['reassign_to_' . $current_id] != 'none' )
2560 - {
2561 - $new_id = $_POST['reassign_to_' . $current_id];
2562 -
2563 - wp_set_post_terms( $post->ID, $new_id, ph_clean($_POST['taxonomy']), TRUE );
2564 -
2565 - // TODO: Check for WP_ERROR
2566 - }
3864 + ),
3865 + );
3866 + $property_query = new WP_Query( $query_args );
3867 +
3868 + if ( $property_query->have_posts() ) {
3869 + while ( $property_query->have_posts() ) {
3870 + $property_query->the_post();
3871 + wp_remove_object_terms( $post->ID, $current_id, $taxonomy );
3872 +
3873 + $new_id = $this->normalize_custom_fields_reassignment( isset( $post_data[ 'reassign_to_' . $current_id ] ) ? $post_data[ 'reassign_to_' . $current_id ] : '', $term_ids );
3874 + if ( null !== $new_id ) {
3875 + wp_set_post_terms( $post->ID, $new_id, $taxonomy, true );
2567 3876 }
2568 3877 }
2569 -
2570 - wp_reset_postdata();
3878 + }
3879 + wp_reset_postdata();
2571 3880
2572 - if ( $current_section == 'availability-delete' )
2573 - {
2574 - // Remove from propertyhive_availability_departments option
2575 - $availability_departments = get_option( 'propertyhive_availability_departments', array() );
2576 -
2577 - if ( isset($availability_departments[$current_id]) )
2578 - {
2579 - unset($availability_departments[$current_id]);
2580 - update_option( 'propertyhive_availability_departments', $availability_departments );
2581 - }
3881 + if ( 'availability-delete' === $current_section ) {
3882 + $availability_departments = get_option( 'propertyhive_availability_departments', array() );
3883 + if ( is_array( $availability_departments ) && isset( $availability_departments[ $current_id ] ) ) {
3884 + unset( $availability_departments[ $current_id ] );
3885 + update_option( 'propertyhive_availability_departments', $availability_departments );
2582 3886 }
3887 + }
2583 3888
2584 - if ( $_POST['taxonomy'] == 'property_type' || $_POST['taxonomy'] == 'commercial_property_type' || $_POST['taxonomy'] == 'location' )
2585 - {
2586 - $query_args = array(
2587 - 'post_type' => 'contact',
2588 - 'nopaging' => true,
2589 - 'post_status' => array( 'pending', 'auto-draft', 'draft', 'private', 'publish', 'future', 'trash' ),
2590 - 'meta_query' => array(
2591 - array(
2592 - 'key' => '_contact_types',
2593 - 'value' => 'applicant',
2594 - 'compare' => 'LIKE'
2595 - ),
3889 + if ( in_array( $taxonomy, array( 'property_type', 'commercial_property_type', 'location' ), true ) ) {
3890 + $query_args = array(
3891 + 'post_type' => 'contact',
3892 + 'nopaging' => true,
3893 + 'post_status' => array( 'pending', 'auto-draft', 'draft', 'private', 'publish', 'future', 'trash' ),
3894 + // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query -- Applicant preferences are serialized profile metadata; deletion/reassignment must inspect every applicant profile to preserve its other selections.
3895 + 'meta_query' => array(
3896 + array(
3897 + 'key' => '_contact_types',
3898 + 'value' => 'applicant',
3899 + 'compare' => 'LIKE',
2596 3900 ),
2597 - );
2598 - $applicant_query = new WP_Query( $query_args );
3901 + ),
3902 + );
3903 + $applicant_query = new WP_Query( $query_args );
2599 3904
2600 - if ( $applicant_query->have_posts() )
2601 - {
2602 - while ( $applicant_query->have_posts() )
2603 - {
2604 - $applicant_query->the_post();
2605 -
2606 - $num_applicant_profiles = get_post_meta( get_the_ID(), '_applicant_profiles', TRUE );
2607 - if ( $num_applicant_profiles == '' )
2608 - {
2609 - $num_applicant_profiles = 0;
2610 - }
3905 + if ( $applicant_query->have_posts() ) {
3906 + while ( $applicant_query->have_posts() ) {
3907 + $applicant_query->the_post();
3908 + $num_applicant_profiles = get_post_meta( get_the_ID(), '_applicant_profiles', true );
3909 + if ( '' === $num_applicant_profiles ) {
3910 + $num_applicant_profiles = 0;
3911 + }
2611 3912
2612 - if ( $num_applicant_profiles > 0 )
2613 - {
2614 - for ( $i = 0; $i < $num_applicant_profiles; ++$i )
2615 - {
2616 - $applicant_profile = get_post_meta( get_the_ID(), '_applicant_profile_' . $i, TRUE );
3913 + if ( $num_applicant_profiles > 0 ) {
3914 + for ( $i = 0; $i < $num_applicant_profiles; ++$i ) {
3915 + $applicant_profile = get_post_meta( get_the_ID(), '_applicant_profile_' . $i, true );
3916 + $profile_key = $taxonomy . 's';
3917 + if ( ! is_array( $applicant_profile ) || ! isset( $applicant_profile[ $profile_key ] ) || ! is_array( $applicant_profile[ $profile_key ] ) ) {
3918 + continue;
3919 + }
2617 3920
2618 - if ( isset($applicant_profile[ph_clean($_POST['taxonomy']).'s']) && is_array($applicant_profile[ph_clean($_POST['taxonomy']).'s']) && !empty($applicant_profile[ph_clean($_POST['taxonomy']).'s']) )
2619 - {
2620 - if (in_array($current_id, $applicant_profile[ph_clean($_POST['taxonomy']).'s']))
2621 - {
2622 - // This profile has this term set
2623 - unset($applicant_profile[ph_clean($_POST['taxonomy']).'s'][$current_id]);
3921 + $profile_terms = array();
3922 + foreach ( $applicant_profile[ $profile_key ] as $profile_term_id ) {
3923 + if ( is_scalar( $profile_term_id ) ) {
3924 + $profile_terms[] = (string) absint( $profile_term_id );
3925 + }
3926 + }
3927 + if ( ! in_array( (string) $current_id, $profile_terms, true ) ) {
3928 + continue;
3929 + }
2624 3930
2625 - if ( isset($_POST['reassign_to_' . $current_id]) && ! empty( $_POST['reassign_to_' . $current_id] ) && ph_clean($_POST['reassign_to_' . $current_id]) != 'none' )
2626 - {
2627 - $applicant_profile[ph_clean($_POST['taxonomy']).'s'][] = $_POST['reassign_to_' . $current_id];
2628 - $applicant_profile[ph_clean($_POST['taxonomy']).'s'] = array_unique($applicant_profile[ph_clean($_POST['taxonomy']).'s']);
2629 - }
2630 -
2631 - $applicant_profile[ph_clean($_POST['taxonomy']).'s'] = array_values($applicant_profile[ph_clean($_POST['taxonomy']).'s']);
2632 -
2633 - update_post_meta( get_the_ID(), '_applicant_profile_' . $i, $applicant_profile );
2634 - }
2635 - }
3931 + $profile_terms = array_values( array_filter( $profile_terms, static function ( $profile_term_id ) use ( $current_id ) {
3932 + return (string) $profile_term_id !== (string) $current_id;
3933 + } ) );
3934 + $new_id = $this->normalize_custom_fields_reassignment( isset( $post_data[ 'reassign_to_' . $current_id ] ) ? $post_data[ 'reassign_to_' . $current_id ] : '', $term_ids );
3935 + if ( null !== $new_id ) {
3936 + $profile_terms[] = $new_id;
2636 3937 }
3938 + $applicant_profile[ $profile_key ] = array_values( array_unique( $profile_terms ) );
3939 + update_post_meta( get_the_ID(), '_applicant_profile_' . $i, wp_slash( $applicant_profile ) );
2637 3940 }
2638 3941 }
2639 3942 }
2640 3943 }
2641 -
2642 3944 wp_reset_postdata();
3945 + }
2643 3946
2644 - wp_delete_term( $current_id, ph_clean($_POST['taxonomy']) );
2645 - }
3947 + wp_delete_term( absint( $current_id ), $taxonomy );
2646 3948 }
3949 + break;
2647 3950
3951 + default:
3952 + $section_found = apply_filters( 'propertyhive_custom_fields_save_section', false, $current_section, $current_id );
3953 + if ( ! $section_found ) {
3954 + echo 'UNKNOWN CUSTOM FIELD';
3955 + }
2648 3956 break;
2649 - }
2650 - default: { echo 'UNKNOWN CUSTOM FIELD'; }
2651 3957 }
2652 - }
2653 - else
2654 - {
2655 - // Nothing to save. Should always be an id set when editing custom fields.
2656 - // Even blank ids dictate something is being added
2657 - }
3958 + break;
2658 3959 }
2659 - else
2660 - {
2661 - // Nothing to save. Should always be a section when editing custom fields
2662 - }
2663 3960 }
2664 3961 }
2665 3962
2666 3963 endif;
2667 3964
2668 -return new PH_Settings_Custom_Fields();
3965 +return new PH_Settings_Custom_Fields();