← All changes
|
includes/admin/settings/class-ph-settings-custom-fields.php
+1976
-586
1.4.52
→
2.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§ion=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§ion=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§ion=' . $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§ion=' . $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§ion=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§ion=' . $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§ion=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"> </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"><?php $property->' . esc_html(ltrim( $custom_field['field_name'], '_' )) . '; ?></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§ion=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§ion=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§ion=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§ion=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' ), |
| @@ -272,8 +1067,13 @@ | ||
| 272 | 1067 | * @return void |
| 273 | 1068 | */ |
| 274 | 1069 | public function custom_fields_availability_setting() { |
| 275 | 1070 | global $post; |
| 1071 | + | |
| 1072 | + $departments = ph_get_departments(); | |
| 1073 | + | |
| 1074 | + $availability_departments = get_option( 'propertyhive_availability_departments', array() ); | |
| 1075 | + if ( !is_array($availability_departments) ) { $availability_departments = array(); } | |
| 276 | 1076 | ?> |
| 277 | 1077 | <tr valign="top"> |
| 278 | 1078 | <th scope="row" class="titledesc"> |
| 279 | 1079 | |
| @@ -278,21 +1078,24 @@ | ||
| 278 | 1078 | <th scope="row" class="titledesc"> |
| 279 | 1079 | |
| 280 | 1080 | </th> |
| 281 | 1081 | <td class="forminp forminp-button"> |
| 282 | - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a> | |
| 283 | - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=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§ion=availability&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Availability', 'propertyhive' )); ?></a> | |
| 284 | 1084 | </td> |
| 285 | 1085 | </tr> |
| 286 | 1086 | <tr valign="top"> |
| 287 | - <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> | |
| 288 | 1088 | <td class="forminp"> |
| 289 | - <table class="ph_customfields widefat" cellspacing="0"> | |
| 1089 | + <table class="ph_customfields sortable-custom-field widefat" data-taxonomy="availability" cellspacing="0"> | |
| 290 | 1090 | <thead> |
| 291 | 1091 | <tr> |
| 292 | - <th class="cb" style="width:1px;"> </th> | |
| 293 | - <th class="id" style="width:45px;"><?php _e( 'ID', 'propertyhive' ); ?></th> | |
| 294 | - <th class="type"><?php _e( 'Availability', '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> | |
| 295 | 1098 | <th class="settings"> </th> |
| 296 | 1099 | </tr> |
| 297 | 1100 | </thead> |
| 298 | 1101 | <tbody> |
| @@ -300,22 +1103,49 @@ | ||
| 300 | 1103 | $args = array( |
| 301 | 1104 | 'hide_empty' => false, |
| 302 | 1105 | 'parent' => 0 |
| 303 | 1106 | ); |
| 304 | - $terms = get_terms( 'availability', $args ); | |
| 1107 | + $terms = get_terms( array_merge( wp_parse_args( $args ), array( 'taxonomy' => 'availability' ) ) ); | |
| 305 | 1108 | |
| 306 | 1109 | if ( !empty( $terms ) && !is_wp_error( $terms ) ) |
| 307 | 1110 | { |
| 308 | - foreach ($terms as $term) | |
| 309 | - { | |
| 1111 | + foreach ( $terms as $term ) | |
| 1112 | + { | |
| 310 | 1113 | ?> |
| 311 | - <tr> | |
| 312 | - <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"></td> | |
| 313 | - <td class="id"><?php echo $term->term_id; ?></td> | |
| 314 | - <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> | |
| 1119 | + <td class="department"><?php | |
| 1120 | + $this_availability_departments = array(); | |
| 1121 | + if ( isset($availability_departments[$term->term_id]) ) | |
| 1122 | + { | |
| 1123 | + foreach ( $availability_departments[$term->term_id] as $availability_department ) | |
| 1124 | + { | |
| 1125 | + if ( get_option( 'propertyhive_active_departments_' . str_replace("residential-", "", $availability_department) ) == 'yes' ) | |
| 1126 | + { | |
| 1127 | + $this_availability_departments[] = $departments[$availability_department]; | |
| 1128 | + } | |
| 1129 | + } | |
| 1130 | + } | |
| 1131 | + else | |
| 1132 | + { | |
| 1133 | + foreach ( $departments as $key => $value ) | |
| 1134 | + { | |
| 1135 | + if ( get_option( 'propertyhive_active_departments_' . str_replace("residential-", "", $key) ) == 'yes' ) | |
| 1136 | + { | |
| 1137 | + $this_availability_departments[] = $value; | |
| 1138 | + } | |
| 1139 | + } | |
| 1140 | + } | |
| 1141 | + | |
| 1142 | + echo !empty($this_availability_departments) ? esc_html(implode(", ", $this_availability_departments)) : '-'; | |
| 1143 | + ?></td> | |
| 1144 | + <td class="assigned_count"><?php echo esc_html($term->count); ?></td> | |
| 315 | 1145 | <td class="settings"> |
| 316 | - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=availability&id=' . $term->term_id ); ?>"><?php echo __( 'Edit', 'propertyhive' ); ?></a> | |
| 317 | - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=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§ion=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§ion=availability-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a> | |
| 318 | 1148 | </td> |
| 319 | 1149 | </tr> |
| 320 | 1150 | <?php |
| 321 | 1151 | } |
| @@ -323,12 +1153,9 @@ | ||
| 323 | 1153 | else |
| 324 | 1154 | { |
| 325 | 1155 | ?> |
| 326 | 1156 | <tr> |
| 327 | - <td><?php echo __( 'No availability options found', 'propertyhive' ); ?></td> | |
| 328 | - <td class="settings"> | |
| 329 | - | |
| 330 | - </td> | |
| 1157 | + <td colspan="6"><?php echo esc_html(__( 'No availability options found', 'propertyhive' )); ?></td> | |
| 331 | 1158 | </tr> |
| 332 | 1159 | <?php |
| 333 | 1160 | } |
| 334 | 1161 | ?> |
| @@ -340,10 +1167,10 @@ | ||
| 340 | 1167 | <th scope="row" class="titledesc"> |
| 341 | 1168 | |
| 342 | 1169 | </th> |
| 343 | 1170 | <td class="forminp forminp-button"> |
| 344 | - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a> | |
| 345 | - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=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§ion=availability&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Availability', 'propertyhive' )); ?></a> | |
| 346 | 1173 | </td> |
| 347 | 1174 | </tr> |
| 348 | 1175 | <?php |
| 349 | 1176 | } |
| @@ -361,22 +1188,23 @@ | ||
| 361 | 1188 | <th scope="row" class="titledesc"> |
| 362 | 1189 | |
| 363 | 1190 | </th> |
| 364 | 1191 | <td class="forminp forminp-button"> |
| 365 | - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a> | |
| 366 | - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=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§ion=property-type&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Property Type', 'propertyhive' )); ?></a> | |
| 367 | 1194 | </td> |
| 368 | 1195 | </tr> |
| 369 | 1196 | <tr valign="top"> |
| 370 | - <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> | |
| 371 | 1198 | <td class="forminp"> |
| 372 | 1199 | <table class="ph_customfields widefat" cellspacing="0"> |
| 373 | 1200 | <thead> |
| 374 | 1201 | <tr> |
| 375 | - <th class="cb" style="width:1px;"> </th> | |
| 376 | - <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> | |
| 377 | 1204 | <?php do_action( 'propertyhive_custom_field_property_type_table_before_header_column' ); ?> |
| 378 | - <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> | |
| 379 | 1207 | <th class="settings"> </th> |
| 380 | 1208 | </tr> |
| 381 | 1209 | </thead> |
| 382 | 1210 | <tbody> |
| @@ -384,10 +1212,10 @@ | ||
| 384 | 1212 | $args = array( |
| 385 | 1213 | 'hide_empty' => false, |
| 386 | 1214 | 'parent' => 0 |
| 387 | 1215 | ); |
| 388 | - $terms = get_terms( 'property_type', $args ); | |
| 389 | - | |
| 1216 | + $terms = get_terms( array_merge( wp_parse_args( $args ), array( 'taxonomy' => 'property_type' ) ) ); | |
| 1217 | + | |
| 390 | 1218 | if ( !empty( $terms ) && !is_wp_error( $terms ) ) |
| 391 | 1219 | { |
| 392 | 1220 | foreach ($terms as $term) |
| 393 | 1221 | { |
| @@ -396,19 +1224,20 @@ | ||
| 396 | 1224 | $args = array( |
| 397 | 1225 | 'hide_empty' => false, |
| 398 | 1226 | 'parent' => $parent_term_id |
| 399 | 1227 | ); |
| 400 | - $subterms = get_terms( 'property_type', $args ); | |
| 1228 | + $subterms = get_terms( array_merge( wp_parse_args( $args ), array( 'taxonomy' => 'property_type' ) ) ); | |
| 401 | 1229 | ?> |
| 402 | 1230 | <tr> |
| 403 | - <td class="cb"><?php if ( empty( $subterms ) ) { ?><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"><?php }else{ echo ' '; } ?></td> | |
| 404 | - <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 ' '; } ?></td> | |
| 1232 | + <td class="id"><?php echo esc_html($term->term_id); ?></td> | |
| 405 | 1233 | <?php do_action( 'propertyhive_custom_field_property_type_table_before_row_column', $term->term_id ); ?> |
| 406 | - <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> | |
| 407 | 1236 | <td class="settings"> |
| 408 | - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=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§ion=property-type&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Edit', 'propertyhive' )); ?></a> | |
| 409 | 1238 | <?php if ( empty( $subterms ) ) { ?> |
| 410 | - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=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§ion=property-type-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a> | |
| 411 | 1240 | <?php } ?> |
| 412 | 1241 | </td> |
| 413 | 1242 | </tr> |
| 414 | 1243 | <?php |
| @@ -417,15 +1246,16 @@ | ||
| 417 | 1246 | foreach ($subterms as $term) |
| 418 | 1247 | { |
| 419 | 1248 | ?> |
| 420 | 1249 | <tr> |
| 421 | - <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"></td> | |
| 422 | - <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> | |
| 423 | 1252 | <?php do_action( 'propertyhive_custom_field_property_type_table_before_row_column', $term->term_id, $parent_term_id ); ?> |
| 424 | - <td class="type subtype"> - <?php echo $term->name; ?></td> | |
| 1253 | + <td class="type subtype"> - <?php echo esc_html($term->name); ?></td> | |
| 1254 | + <td class="assigned_count"><?php echo esc_html($term->count); ?></td> | |
| 425 | 1255 | <td class="settings"> |
| 426 | - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=property-type&id=' . $term->term_id ); ?>"><?php echo __( 'Edit', 'propertyhive' ); ?></a> | |
| 427 | - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=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§ion=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§ion=property-type-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a> | |
| 428 | 1258 | </td> |
| 429 | 1259 | </tr> |
| 430 | 1260 | <?php |
| 431 | 1261 | } |
| @@ -437,9 +1267,9 @@ | ||
| 437 | 1267 | else |
| 438 | 1268 | { |
| 439 | 1269 | ?> |
| 440 | 1270 | <tr> |
| 441 | - <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> | |
| 442 | 1272 | </tr> |
| 443 | 1273 | <?php |
| 444 | 1274 | } |
| 445 | 1275 | ?> |
| @@ -451,10 +1281,10 @@ | ||
| 451 | 1281 | <th scope="row" class="titledesc"> |
| 452 | 1282 | |
| 453 | 1283 | </th> |
| 454 | 1284 | <td class="forminp forminp-button"> |
| 455 | - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a> | |
| 456 | - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=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§ion=property-type&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Property Type', 'propertyhive' )); ?></a> | |
| 457 | 1287 | </td> |
| 458 | 1288 | </tr> |
| 459 | 1289 | <?php |
| 460 | 1290 | } |
| @@ -472,22 +1302,23 @@ | ||
| 472 | 1302 | <th scope="row" class="titledesc"> |
| 473 | 1303 | |
| 474 | 1304 | </th> |
| 475 | 1305 | <td class="forminp forminp-button"> |
| 476 | - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a> | |
| 477 | - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=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§ion=commercial-property-type&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Property Type', 'propertyhive' )); ?></a> | |
| 478 | 1308 | </td> |
| 479 | 1309 | </tr> |
| 480 | 1310 | <tr valign="top"> |
| 481 | - <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> | |
| 482 | 1312 | <td class="forminp"> |
| 483 | 1313 | <table class="ph_customfields widefat" cellspacing="0"> |
| 484 | 1314 | <thead> |
| 485 | 1315 | <tr> |
| 486 | - <th class="cb" style="width:1px;"> </th> | |
| 487 | - <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> | |
| 488 | 1318 | <?php do_action( 'propertyhive_custom_field_commercial_property_type_table_before_header_column' ); ?> |
| 489 | - <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> | |
| 490 | 1321 | <th class="settings"> </th> |
| 491 | 1322 | </tr> |
| 492 | 1323 | </thead> |
| 493 | 1324 | <tbody> |
| @@ -495,9 +1326,9 @@ | ||
| 495 | 1326 | $args = array( |
| 496 | 1327 | 'hide_empty' => false, |
| 497 | 1328 | 'parent' => 0 |
| 498 | 1329 | ); |
| 499 | - $terms = get_terms( 'commercial_property_type', $args ); | |
| 1330 | + $terms = get_terms( array_merge( wp_parse_args( $args ), array( 'taxonomy' => 'commercial_property_type' ) ) ); | |
| 500 | 1331 | |
| 501 | 1332 | if ( !empty( $terms ) && !is_wp_error( $terms ) ) |
| 502 | 1333 | { |
| 503 | 1334 | foreach ($terms as $term) |
| @@ -507,19 +1338,20 @@ | ||
| 507 | 1338 | $args = array( |
| 508 | 1339 | 'hide_empty' => false, |
| 509 | 1340 | 'parent' => $parent_term_id |
| 510 | 1341 | ); |
| 511 | - $subterms = get_terms( 'commercial_property_type', $args ); | |
| 1342 | + $subterms = get_terms( array_merge( wp_parse_args( $args ), array( 'taxonomy' => 'commercial_property_type' ) ) ); | |
| 512 | 1343 | ?> |
| 513 | 1344 | <tr> |
| 514 | - <td class="cb"><?php if ( empty( $subterms ) ) { ?><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"><?php }else{ echo ' '; } ?></td> | |
| 515 | - <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 ' '; } ?></td> | |
| 1346 | + <td class="id"><?php echo esc_html($term->term_id); ?></td> | |
| 516 | 1347 | <?php do_action( 'propertyhive_custom_field_commercial_property_type_table_before_row_column', $term->term_id ); ?> |
| 517 | - <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> | |
| 518 | 1350 | <td class="settings"> |
| 519 | - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=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§ion=commercial-property-type&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Edit', 'propertyhive' )); ?></a> | |
| 520 | 1352 | <?php if ( empty( $subterms ) ) { ?> |
| 521 | - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=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§ion=commercial-property-type-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a> | |
| 522 | 1354 | <?php } ?> |
| 523 | 1355 | </td> |
| 524 | 1356 | </tr> |
| 525 | 1357 | <?php |
| @@ -528,15 +1360,16 @@ | ||
| 528 | 1360 | foreach ($subterms as $term) |
| 529 | 1361 | { |
| 530 | 1362 | ?> |
| 531 | 1363 | <tr> |
| 532 | - <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"></td> | |
| 533 | - <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> | |
| 534 | 1366 | <?php do_action( 'propertyhive_custom_field_commercial_property_type_table_before_row_column', $term->term_id, $parent_term_id ); ?> |
| 535 | - <td class="type subtype"> - <?php echo $term->name; ?></td> | |
| 1367 | + <td class="type subtype"> - <?php echo esc_html($term->name); ?></td> | |
| 1368 | + <td class="assigned_count"><?php echo esc_html($term->count); ?></td> | |
| 536 | 1369 | <td class="settings"> |
| 537 | - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=commercial-property-type&id=' . $term->term_id ); ?>"><?php echo __( 'Edit', 'propertyhive' ); ?></a> | |
| 538 | - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=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§ion=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§ion=commercial-property-type-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a> | |
| 539 | 1372 | </td> |
| 540 | 1373 | </tr> |
| 541 | 1374 | <?php |
| 542 | 1375 | } |
| @@ -548,9 +1381,9 @@ | ||
| 548 | 1381 | else |
| 549 | 1382 | { |
| 550 | 1383 | ?> |
| 551 | 1384 | <tr> |
| 552 | - <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> | |
| 553 | 1386 | </tr> |
| 554 | 1387 | <?php |
| 555 | 1388 | } |
| 556 | 1389 | ?> |
| @@ -562,10 +1395,10 @@ | ||
| 562 | 1395 | <th scope="row" class="titledesc"> |
| 563 | 1396 | |
| 564 | 1397 | </th> |
| 565 | 1398 | <td class="forminp forminp-button"> |
| 566 | - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a> | |
| 567 | - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=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§ion=commercial-property-type&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Property Type', 'propertyhive' )); ?></a> | |
| 568 | 1401 | </td> |
| 569 | 1402 | </tr> |
| 570 | 1403 | <?php |
| 571 | 1404 | } |
| @@ -583,21 +1416,22 @@ | ||
| 583 | 1416 | <th scope="row" class="titledesc"> |
| 584 | 1417 | |
| 585 | 1418 | </th> |
| 586 | 1419 | <td class="forminp forminp-button"> |
| 587 | - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a> | |
| 588 | - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=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§ion=location&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Location', 'propertyhive' )); ?></a> | |
| 589 | 1422 | </td> |
| 590 | 1423 | </tr> |
| 591 | 1424 | <tr valign="top"> |
| 592 | - <th scope="row" class="titledesc"><?php _e( 'Locations', 'propertyhive' ) ?></th> | |
| 1425 | + <th scope="row" class="titledesc"><?php echo esc_html(__( 'Locations', 'propertyhive' )); ?></th> | |
| 593 | 1426 | <td class="forminp"> |
| 594 | 1427 | <table class="ph_customfields widefat" cellspacing="0"> |
| 595 | 1428 | <thead> |
| 596 | 1429 | <tr> |
| 597 | - <th class="cb" style="width:1px;"> </th> | |
| 598 | - <th class="id" style="width:45px;"><?php _e( 'ID', 'propertyhive' ); ?></th> | |
| 599 | - <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> | |
| 600 | 1434 | <th class="settings"> </th> |
| 601 | 1435 | </tr> |
| 602 | 1436 | </thead> |
| 603 | 1437 | <tbody> |
| @@ -605,9 +1439,9 @@ | ||
| 605 | 1439 | $args = array( |
| 606 | 1440 | 'hide_empty' => false, |
| 607 | 1441 | 'parent' => 0 |
| 608 | 1442 | ); |
| 609 | - $terms = get_terms( 'location', $args ); | |
| 1443 | + $terms = get_terms( array_merge( wp_parse_args( $args ), array( 'taxonomy' => 'location' ) ) ); | |
| 610 | 1444 | |
| 611 | 1445 | if ( !empty( $terms ) && !is_wp_error( $terms ) ) |
| 612 | 1446 | { |
| 613 | 1447 | foreach ($terms as $term) |
| @@ -615,18 +1449,19 @@ | ||
| 615 | 1449 | $args = array( |
| 616 | 1450 | 'hide_empty' => false, |
| 617 | 1451 | 'parent' => $term->term_id |
| 618 | 1452 | ); |
| 619 | - $subterms = get_terms( 'location', $args ); | |
| 1453 | + $subterms = get_terms( array_merge( wp_parse_args( $args ), array( 'taxonomy' => 'location' ) ) ); | |
| 620 | 1454 | ?> |
| 621 | 1455 | <tr> |
| 622 | - <td class="cb"><?php if ( empty( $subterms ) ) { ?><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"><?php }else{ echo ' '; } ?></td> | |
| 623 | - <td class="id"><?php echo $term->term_id; ?></td> | |
| 624 | - <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 ' '; } ?></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> | |
| 625 | 1460 | <td class="settings"> |
| 626 | - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=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§ion=location&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Edit', 'propertyhive' )); ?></a> | |
| 627 | 1462 | <?php if ( empty( $subterms ) ) { ?> |
| 628 | - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=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§ion=location-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a> | |
| 629 | 1464 | <?php } ?> |
| 630 | 1465 | </td> |
| 631 | 1466 | </tr> |
| 632 | 1467 | <?php |
| @@ -637,18 +1472,19 @@ | ||
| 637 | 1472 | $args = array( |
| 638 | 1473 | 'hide_empty' => false, |
| 639 | 1474 | 'parent' => $term->term_id |
| 640 | 1475 | ); |
| 641 | - $subsubterms = get_terms( 'location', $args ); | |
| 1476 | + $subsubterms = get_terms( array_merge( wp_parse_args( $args ), array( 'taxonomy' => 'location' ) ) ); | |
| 642 | 1477 | ?> |
| 643 | 1478 | <tr> |
| 644 | - <td class="cb"><?php if ( empty( $subsubterms ) ) { ?><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"><?php }else{ echo ' '; } ?></td> | |
| 645 | - <td class="id"><?php echo $term->term_id; ?></td> | |
| 646 | - <td class="type subtype"> - <?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 ' '; } ?></td> | |
| 1480 | + <td class="id"><?php echo esc_html($term->term_id); ?></td> | |
| 1481 | + <td class="type subtype"> - <?php echo esc_html($term->name); ?></td> | |
| 1482 | + <td class="assigned_count"><?php echo esc_html($term->count); ?></td> | |
| 647 | 1483 | <td class="settings"> |
| 648 | - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=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§ion=location&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Edit', 'propertyhive' )); ?></a> | |
| 649 | 1485 | <?php if ( empty( $subsubterms ) ) { ?> |
| 650 | - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=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§ion=location-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a> | |
| 651 | 1487 | <?php } ?> |
| 652 | 1488 | </td> |
| 653 | 1489 | </tr> |
| 654 | 1490 | <?php |
| @@ -657,14 +1493,15 @@ | ||
| 657 | 1493 | foreach ($subsubterms as $term) |
| 658 | 1494 | { |
| 659 | 1495 | ?> |
| 660 | 1496 | <tr> |
| 661 | - <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"></td> | |
| 662 | - <td class="id"><?php echo $term->term_id; ?></td> | |
| 663 | - <td class="type subtype"> - <?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"> - <?php echo esc_html($term->name); ?></td> | |
| 1500 | + <td class="assigned_count"><?php echo esc_html($term->count); ?></td> | |
| 664 | 1501 | <td class="settings"> |
| 665 | - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=location&id=' . $term->term_id ); ?>"><?php echo __( 'Edit', 'propertyhive' ); ?></a> | |
| 666 | - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=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§ion=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§ion=location-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a> | |
| 667 | 1504 | </td> |
| 668 | 1505 | </tr> |
| 669 | 1506 | <?php |
| 670 | 1507 | } |
| @@ -678,12 +1515,9 @@ | ||
| 678 | 1515 | else |
| 679 | 1516 | { |
| 680 | 1517 | ?> |
| 681 | 1518 | <tr> |
| 682 | - <td><?php echo __( 'No locations found', 'propertyhive' ); ?></td> | |
| 683 | - <td class="settings"> | |
| 684 | - | |
| 685 | - </td> | |
| 1519 | + <td colspan="5"><?php echo esc_html(__( 'No locations found', 'propertyhive' )); ?></td> | |
| 686 | 1520 | </tr> |
| 687 | 1521 | <?php |
| 688 | 1522 | } |
| 689 | 1523 | ?> |
| @@ -695,10 +1529,10 @@ | ||
| 695 | 1529 | <th scope="row" class="titledesc"> |
| 696 | 1530 | |
| 697 | 1531 | </th> |
| 698 | 1532 | <td class="forminp forminp-button"> |
| 699 | - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a> | |
| 700 | - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=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§ion=location&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Location', 'propertyhive' )); ?></a> | |
| 701 | 1535 | </td> |
| 702 | 1536 | </tr> |
| 703 | 1537 | <?php |
| 704 | 1538 | } |
| @@ -716,21 +1550,22 @@ | ||
| 716 | 1550 | <th scope="row" class="titledesc"> |
| 717 | 1551 | |
| 718 | 1552 | </th> |
| 719 | 1553 | <td class="forminp forminp-button"> |
| 720 | - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a> | |
| 721 | - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=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§ion=parking&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Parking', 'propertyhive' )); ?></a> | |
| 722 | 1556 | </td> |
| 723 | 1557 | </tr> |
| 724 | 1558 | <tr valign="top"> |
| 725 | - <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> | |
| 726 | 1560 | <td class="forminp"> |
| 727 | - <table class="ph_customfields widefat" cellspacing="0"> | |
| 1561 | + <table class="ph_customfields sortable-custom-field widefat" data-taxonomy="parking" cellspacing="0"> | |
| 728 | 1562 | <thead> |
| 729 | 1563 | <tr> |
| 730 | - <th class="cb" style="width:1px;"> </th> | |
| 731 | - <th class="id" style="width:45px;"><?php _e( 'ID', 'propertyhive' ); ?></th> | |
| 732 | - <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> | |
| 733 | 1568 | <th class="settings"> </th> |
| 734 | 1569 | </tr> |
| 735 | 1570 | </thead> |
| 736 | 1571 | <tbody> |
| @@ -738,22 +1573,23 @@ | ||
| 738 | 1573 | $args = array( |
| 739 | 1574 | 'hide_empty' => false, |
| 740 | 1575 | 'parent' => 0 |
| 741 | 1576 | ); |
| 742 | - $terms = get_terms( 'parking', $args ); | |
| 743 | - | |
| 1577 | + $terms = get_terms( array_merge( wp_parse_args( $args ), array( 'taxonomy' => 'parking' ) ) ); | |
| 1578 | + | |
| 744 | 1579 | if ( !empty( $terms ) && !is_wp_error( $terms ) ) |
| 745 | 1580 | { |
| 746 | 1581 | foreach ($terms as $term) |
| 747 | 1582 | { |
| 748 | 1583 | ?> |
| 749 | - <tr> | |
| 750 | - <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"></td> | |
| 751 | - <td class="id"><?php echo $term->term_id; ?></td> | |
| 752 | - <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> | |
| 753 | 1589 | <td class="settings"> |
| 754 | - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=parking&id=' . $term->term_id ); ?>"><?php echo __( 'Edit', 'propertyhive' ); ?></a> | |
| 755 | - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=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§ion=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§ion=parking-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a> | |
| 756 | 1592 | </td> |
| 757 | 1593 | </tr> |
| 758 | 1594 | <?php |
| 759 | 1595 | } |
| @@ -761,12 +1597,9 @@ | ||
| 761 | 1597 | else |
| 762 | 1598 | { |
| 763 | 1599 | ?> |
| 764 | 1600 | <tr> |
| 765 | - <td><?php echo __( 'No parking options found', 'propertyhive' ); ?></td> | |
| 766 | - <td class="settings"> | |
| 767 | - | |
| 768 | - </td> | |
| 1601 | + <td colspan="5"><?php echo esc_html(__( 'No parking options found', 'propertyhive' )); ?></td> | |
| 769 | 1602 | </tr> |
| 770 | 1603 | <?php |
| 771 | 1604 | } |
| 772 | 1605 | ?> |
| @@ -778,10 +1611,10 @@ | ||
| 778 | 1611 | <th scope="row" class="titledesc"> |
| 779 | 1612 | |
| 780 | 1613 | </th> |
| 781 | 1614 | <td class="forminp forminp-button"> |
| 782 | - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a> | |
| 783 | - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=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§ion=parking&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Parking', 'propertyhive' )); ?></a> | |
| 784 | 1617 | </td> |
| 785 | 1618 | </tr> |
| 786 | 1619 | <?php |
| 787 | 1620 | } |
| @@ -799,21 +1632,22 @@ | ||
| 799 | 1632 | <th scope="row" class="titledesc"> |
| 800 | 1633 | |
| 801 | 1634 | </th> |
| 802 | 1635 | <td class="forminp forminp-button"> |
| 803 | - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a> | |
| 804 | - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=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§ion=outside-space&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Outside Space', 'propertyhive' )); ?></a> | |
| 805 | 1638 | </td> |
| 806 | 1639 | </tr> |
| 807 | 1640 | <tr valign="top"> |
| 808 | - <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> | |
| 809 | 1642 | <td class="forminp"> |
| 810 | - <table class="ph_customfields widefat" cellspacing="0"> | |
| 1643 | + <table class="ph_customfields sortable-custom-field widefat" data-taxonomy="outside_space" cellspacing="0"> | |
| 811 | 1644 | <thead> |
| 812 | 1645 | <tr> |
| 813 | - <th class="cb" style="width:1px;"> </th> | |
| 814 | - <th class="id" style="width:45px;"><?php _e( 'ID', 'propertyhive' ); ?></th> | |
| 815 | - <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> | |
| 816 | 1650 | <th class="settings"> </th> |
| 817 | 1651 | </tr> |
| 818 | 1652 | </thead> |
| 819 | 1653 | <tbody> |
| @@ -821,9 +1655,9 @@ | ||
| 821 | 1655 | $args = array( |
| 822 | 1656 | 'hide_empty' => false, |
| 823 | 1657 | 'parent' => 0 |
| 824 | 1658 | ); |
| 825 | - $terms = get_terms( 'outside_space', $args ); | |
| 1659 | + $terms = get_terms( array_merge( wp_parse_args( $args ), array( 'taxonomy' => 'outside_space' ) ) ); | |
| 826 | 1660 | |
| 827 | 1661 | if ( !empty( $terms ) && !is_wp_error( $terms ) ) |
| 828 | 1662 | { |
| 829 | 1663 | foreach ($terms as $term) |
| @@ -828,15 +1662,16 @@ | ||
| 828 | 1662 | { |
| 829 | 1663 | foreach ($terms as $term) |
| 830 | 1664 | { |
| 831 | 1665 | ?> |
| 832 | - <tr> | |
| 833 | - <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"></td> | |
| 834 | - <td class="id"><?php echo $term->term_id; ?></td> | |
| 835 | - <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> | |
| 836 | 1671 | <td class="settings"> |
| 837 | - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=outside-space&id=' . $term->term_id ); ?>"><?php echo __( 'Edit', 'propertyhive' ); ?></a> | |
| 838 | - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=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§ion=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§ion=outside-space-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a> | |
| 839 | 1674 | </td> |
| 840 | 1675 | </tr> |
| 841 | 1676 | <?php |
| 842 | 1677 | } |
| @@ -844,12 +1679,9 @@ | ||
| 844 | 1679 | else |
| 845 | 1680 | { |
| 846 | 1681 | ?> |
| 847 | 1682 | <tr> |
| 848 | - <td><?php echo __( 'No outside spaces found', 'propertyhive' ); ?></td> | |
| 849 | - <td class="settings"> | |
| 850 | - | |
| 851 | - </td> | |
| 1683 | + <td colspan="5"><?php echo esc_html(__( 'No outside spaces found', 'propertyhive' )); ?></td> | |
| 852 | 1684 | </tr> |
| 853 | 1685 | <?php |
| 854 | 1686 | } |
| 855 | 1687 | ?> |
| @@ -861,10 +1693,10 @@ | ||
| 861 | 1693 | <th scope="row" class="titledesc"> |
| 862 | 1694 | |
| 863 | 1695 | </th> |
| 864 | 1696 | <td class="forminp forminp-button"> |
| 865 | - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a> | |
| 866 | - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=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§ion=outside-space&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Outside Space', 'propertyhive' )); ?></a> | |
| 867 | 1699 | </td> |
| 868 | 1700 | </tr> |
| 869 | 1701 | <?php |
| 870 | 1702 | } |
| @@ -882,21 +1714,22 @@ | ||
| 882 | 1714 | <th scope="row" class="titledesc"> |
| 883 | 1715 | |
| 884 | 1716 | </th> |
| 885 | 1717 | <td class="forminp forminp-button"> |
| 886 | - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a> | |
| 887 | - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=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§ion=price-qualifier&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Price Qualifier', 'propertyhive' )); ?></a> | |
| 888 | 1720 | </td> |
| 889 | 1721 | </tr> |
| 890 | 1722 | <tr valign="top"> |
| 891 | - <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> | |
| 892 | 1724 | <td class="forminp"> |
| 893 | - <table class="ph_customfields widefat" cellspacing="0"> | |
| 1725 | + <table class="ph_customfields sortable-custom-field widefat" data-taxonomy="price_qualifier" cellspacing="0"> | |
| 894 | 1726 | <thead> |
| 895 | 1727 | <tr> |
| 896 | - <th class="cb" style="width:1px;"> </th> | |
| 897 | - <th class="id" style="width:45px;"><?php _e( 'ID', 'propertyhive' ); ?></th> | |
| 898 | - <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> | |
| 899 | 1732 | <th class="settings"> </th> |
| 900 | 1733 | </tr> |
| 901 | 1734 | </thead> |
| 902 | 1735 | <tbody> |
| @@ -904,9 +1737,9 @@ | ||
| 904 | 1737 | $args = array( |
| 905 | 1738 | 'hide_empty' => false, |
| 906 | 1739 | 'parent' => 0 |
| 907 | 1740 | ); |
| 908 | - $terms = get_terms( 'price_qualifier', $args ); | |
| 1741 | + $terms = get_terms( array_merge( wp_parse_args( $args ), array( 'taxonomy' => 'price_qualifier' ) ) ); | |
| 909 | 1742 | |
| 910 | 1743 | if ( !empty( $terms ) && !is_wp_error( $terms ) ) |
| 911 | 1744 | { |
| 912 | 1745 | foreach ($terms as $term) |
| @@ -911,15 +1744,16 @@ | ||
| 911 | 1744 | { |
| 912 | 1745 | foreach ($terms as $term) |
| 913 | 1746 | { |
| 914 | 1747 | ?> |
| 915 | - <tr> | |
| 916 | - <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"></td> | |
| 917 | - <td class="id"><?php echo $term->term_id; ?></td> | |
| 918 | - <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> | |
| 919 | 1753 | <td class="settings"> |
| 920 | - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=price-qualifier&id=' . $term->term_id ); ?>"><?php echo __( 'Edit', 'propertyhive' ); ?></a> | |
| 921 | - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=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§ion=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§ion=price-qualifier-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a> | |
| 922 | 1756 | </td> |
| 923 | 1757 | </tr> |
| 924 | 1758 | <?php |
| 925 | 1759 | } |
| @@ -927,12 +1761,9 @@ | ||
| 927 | 1761 | else |
| 928 | 1762 | { |
| 929 | 1763 | ?> |
| 930 | 1764 | <tr> |
| 931 | - <td><?php echo __( 'No price qualifiers found', 'propertyhive' ); ?></td> | |
| 932 | - <td class="settings"> | |
| 933 | - | |
| 934 | - </td> | |
| 1765 | + <td colspan="5"><?php echo esc_html(__( 'No price qualifiers found', 'propertyhive' )); ?></td> | |
| 935 | 1766 | </tr> |
| 936 | 1767 | <?php |
| 937 | 1768 | } |
| 938 | 1769 | ?> |
| @@ -944,10 +1775,10 @@ | ||
| 944 | 1775 | <th scope="row" class="titledesc"> |
| 945 | 1776 | |
| 946 | 1777 | </th> |
| 947 | 1778 | <td class="forminp forminp-button"> |
| 948 | - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a> | |
| 949 | - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=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§ion=price-qualifier&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Price Qualifier', 'propertyhive' )); ?></a> | |
| 950 | 1781 | </td> |
| 951 | 1782 | </tr> |
| 952 | 1783 | <?php |
| 953 | 1784 | } |
| @@ -965,21 +1796,22 @@ | ||
| 965 | 1796 | <th scope="row" class="titledesc"> |
| 966 | 1797 | |
| 967 | 1798 | </th> |
| 968 | 1799 | <td class="forminp forminp-button"> |
| 969 | - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a> | |
| 970 | - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=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§ion=sale-by&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Sale By', 'propertyhive' )); ?></a> | |
| 971 | 1802 | </td> |
| 972 | 1803 | </tr> |
| 973 | 1804 | <tr valign="top"> |
| 974 | - <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> | |
| 975 | 1806 | <td class="forminp"> |
| 976 | - <table class="ph_customfields widefat" cellspacing="0"> | |
| 1807 | + <table class="ph_customfields sortable-custom-field widefat" data-taxonomy="sale_by" cellspacing="0"> | |
| 977 | 1808 | <thead> |
| 978 | 1809 | <tr> |
| 979 | - <th class="cb" style="width:1px;"> </th> | |
| 980 | - <th class="id" style="width:45px;"><?php _e( 'ID', 'propertyhive' ); ?></th> | |
| 981 | - <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> | |
| 982 | 1814 | <th class="settings"> </th> |
| 983 | 1815 | </tr> |
| 984 | 1816 | </thead> |
| 985 | 1817 | <tbody> |
| @@ -987,9 +1819,9 @@ | ||
| 987 | 1819 | $args = array( |
| 988 | 1820 | 'hide_empty' => false, |
| 989 | 1821 | 'parent' => 0 |
| 990 | 1822 | ); |
| 991 | - $terms = get_terms( 'sale_by', $args ); | |
| 1823 | + $terms = get_terms( array_merge( wp_parse_args( $args ), array( 'taxonomy' => 'sale_by' ) ) ); | |
| 992 | 1824 | |
| 993 | 1825 | if ( !empty( $terms ) && !is_wp_error( $terms ) ) |
| 994 | 1826 | { |
| 995 | 1827 | foreach ($terms as $term) |
| @@ -995,14 +1827,15 @@ | ||
| 995 | 1827 | foreach ($terms as $term) |
| 996 | 1828 | { |
| 997 | 1829 | ?> |
| 998 | 1830 | <tr> |
| 999 | - <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"></td> | |
| 1000 | - <td class="id"><?php echo $term->term_id; ?></td> | |
| 1001 | - <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> | |
| 1002 | 1835 | <td class="settings"> |
| 1003 | - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=sale-by&id=' . $term->term_id ); ?>"><?php echo __( 'Edit', 'propertyhive' ); ?></a> | |
| 1004 | - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=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§ion=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§ion=sale-by-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a> | |
| 1005 | 1838 | </td> |
| 1006 | 1839 | </tr> |
| 1007 | 1840 | <?php |
| 1008 | 1841 | } |
| @@ -1010,12 +1843,9 @@ | ||
| 1010 | 1843 | else |
| 1011 | 1844 | { |
| 1012 | 1845 | ?> |
| 1013 | 1846 | <tr> |
| 1014 | - <td><?php echo __( 'No sale by options found', 'propertyhive' ); ?></td> | |
| 1015 | - <td class="settings"> | |
| 1016 | - | |
| 1017 | - </td> | |
| 1847 | + <td colspan="5"><?php echo esc_html(__( 'No sale by options found', 'propertyhive' )); ?></td> | |
| 1018 | 1848 | </tr> |
| 1019 | 1849 | <?php |
| 1020 | 1850 | } |
| 1021 | 1851 | ?> |
| @@ -1027,10 +1857,10 @@ | ||
| 1027 | 1857 | <th scope="row" class="titledesc"> |
| 1028 | 1858 | |
| 1029 | 1859 | </th> |
| 1030 | 1860 | <td class="forminp forminp-button"> |
| 1031 | - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a> | |
| 1032 | - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=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§ion=sale-by&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Sale By', 'propertyhive' )); ?></a> | |
| 1033 | 1863 | </td> |
| 1034 | 1864 | </tr> |
| 1035 | 1865 | <?php |
| 1036 | 1866 | } |
| @@ -1048,21 +1878,22 @@ | ||
| 1048 | 1878 | <th scope="row" class="titledesc"> |
| 1049 | 1879 | |
| 1050 | 1880 | </th> |
| 1051 | 1881 | <td class="forminp forminp-button"> |
| 1052 | - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a> | |
| 1053 | - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=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§ion=tenure&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Tenure', 'propertyhive' )); ?></a> | |
| 1054 | 1884 | </td> |
| 1055 | 1885 | </tr> |
| 1056 | 1886 | <tr valign="top"> |
| 1057 | - <th scope="row" class="titledesc"><?php _e( 'Tenures', 'propertyhive' ) ?></th> | |
| 1887 | + <th scope="row" class="titledesc"><?php echo esc_html(__( 'Tenures', 'propertyhive' )); ?></th> | |
| 1058 | 1888 | <td class="forminp"> |
| 1059 | - <table class="ph_customfields widefat" cellspacing="0"> | |
| 1889 | + <table class="ph_customfields sortable-custom-field widefat" data-taxonomy="tenure" cellspacing="0"> | |
| 1060 | 1890 | <thead> |
| 1061 | 1891 | <tr> |
| 1062 | - <th class="cb" style="width:1px;"> </th> | |
| 1063 | - <th class="id" style="width:45px;"><?php _e( 'ID', 'propertyhive' ); ?></th> | |
| 1064 | - <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> | |
| 1065 | 1896 | <th class="settings"> </th> |
| 1066 | 1897 | </tr> |
| 1067 | 1898 | </thead> |
| 1068 | 1899 | <tbody> |
| @@ -1070,9 +1901,9 @@ | ||
| 1070 | 1901 | $args = array( |
| 1071 | 1902 | 'hide_empty' => false, |
| 1072 | 1903 | 'parent' => 0 |
| 1073 | 1904 | ); |
| 1074 | - $terms = get_terms( 'tenure', $args ); | |
| 1905 | + $terms = get_terms( array_merge( wp_parse_args( $args ), array( 'taxonomy' => 'tenure' ) ) ); | |
| 1075 | 1906 | |
| 1076 | 1907 | if ( !empty( $terms ) && !is_wp_error( $terms ) ) |
| 1077 | 1908 | { |
| 1078 | 1909 | foreach ($terms as $term) |
| @@ -1077,15 +1908,16 @@ | ||
| 1077 | 1908 | { |
| 1078 | 1909 | foreach ($terms as $term) |
| 1079 | 1910 | { |
| 1080 | 1911 | ?> |
| 1081 | - <tr> | |
| 1082 | - <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"></td> | |
| 1083 | - <td class="id"><?php echo $term->term_id; ?></td> | |
| 1084 | - <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> | |
| 1085 | 1917 | <td class="settings"> |
| 1086 | - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=tenure&id=' . $term->term_id ); ?>"><?php echo __( 'Edit', 'propertyhive' ); ?></a> | |
| 1087 | - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=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§ion=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§ion=tenure-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a> | |
| 1088 | 1920 | </td> |
| 1089 | 1921 | </tr> |
| 1090 | 1922 | <?php |
| 1091 | 1923 | } |
| @@ -1093,12 +1925,9 @@ | ||
| 1093 | 1925 | else |
| 1094 | 1926 | { |
| 1095 | 1927 | ?> |
| 1096 | 1928 | <tr> |
| 1097 | - <td><?php echo __( 'No tenure found', 'propertyhive' ); ?></td> | |
| 1098 | - <td class="settings"> | |
| 1099 | - | |
| 1100 | - </td> | |
| 1929 | + <td colspan="5"><?php echo esc_html(__( 'No tenure found', 'propertyhive' )); ?></td> | |
| 1101 | 1930 | </tr> |
| 1102 | 1931 | <?php |
| 1103 | 1932 | } |
| 1104 | 1933 | ?> |
| @@ -1110,10 +1939,10 @@ | ||
| 1110 | 1939 | <th scope="row" class="titledesc"> |
| 1111 | 1940 | |
| 1112 | 1941 | </th> |
| 1113 | 1942 | <td class="forminp forminp-button"> |
| 1114 | - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a> | |
| 1115 | - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=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§ion=tenure&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Tenure', 'propertyhive' )); ?></a> | |
| 1116 | 1945 | </td> |
| 1117 | 1946 | </tr> |
| 1118 | 1947 | <?php |
| 1119 | 1948 | } |
| @@ -1131,21 +1960,22 @@ | ||
| 1131 | 1960 | <th scope="row" class="titledesc"> |
| 1132 | 1961 | |
| 1133 | 1962 | </th> |
| 1134 | 1963 | <td class="forminp forminp-button"> |
| 1135 | - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a> | |
| 1136 | - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=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§ion=commercial-tenure&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Tenure', 'propertyhive' )); ?></a> | |
| 1137 | 1966 | </td> |
| 1138 | 1967 | </tr> |
| 1139 | 1968 | <tr valign="top"> |
| 1140 | - <th scope="row" class="titledesc"><?php _e( 'Tenures', 'propertyhive' ) ?></th> | |
| 1969 | + <th scope="row" class="titledesc"><?php echo esc_html(__( 'Tenures', 'propertyhive' )); ?></th> | |
| 1141 | 1970 | <td class="forminp"> |
| 1142 | - <table class="ph_customfields widefat" cellspacing="0"> | |
| 1971 | + <table class="ph_customfields sortable-custom-field widefat" data-taxonomy="commercial_tenure" cellspacing="0"> | |
| 1143 | 1972 | <thead> |
| 1144 | 1973 | <tr> |
| 1145 | - <th class="cb" style="width:1px;"> </th> | |
| 1146 | - <th class="id" style="width:45px;"><?php _e( 'ID', 'propertyhive' ); ?></th> | |
| 1147 | - <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> | |
| 1148 | 1978 | <th class="settings"> </th> |
| 1149 | 1979 | </tr> |
| 1150 | 1980 | </thead> |
| 1151 | 1981 | <tbody> |
| @@ -1153,9 +1983,9 @@ | ||
| 1153 | 1983 | $args = array( |
| 1154 | 1984 | 'hide_empty' => false, |
| 1155 | 1985 | 'parent' => 0 |
| 1156 | 1986 | ); |
| 1157 | - $terms = get_terms( 'commercial_tenure', $args ); | |
| 1987 | + $terms = get_terms( array_merge( wp_parse_args( $args ), array( 'taxonomy' => 'commercial_tenure' ) ) ); | |
| 1158 | 1988 | |
| 1159 | 1989 | if ( !empty( $terms ) && !is_wp_error( $terms ) ) |
| 1160 | 1990 | { |
| 1161 | 1991 | foreach ($terms as $term) |
| @@ -1160,15 +1990,16 @@ | ||
| 1160 | 1990 | { |
| 1161 | 1991 | foreach ($terms as $term) |
| 1162 | 1992 | { |
| 1163 | 1993 | ?> |
| 1164 | - <tr> | |
| 1165 | - <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"></td> | |
| 1166 | - <td class="id"><?php echo $term->term_id; ?></td> | |
| 1167 | - <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> | |
| 1168 | 1999 | <td class="settings"> |
| 1169 | - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=commercial-tenure&id=' . $term->term_id ); ?>"><?php echo __( 'Edit', 'propertyhive' ); ?></a> | |
| 1170 | - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=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§ion=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§ion=commercial-tenure-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a> | |
| 1171 | 2002 | </td> |
| 1172 | 2003 | </tr> |
| 1173 | 2004 | <?php |
| 1174 | 2005 | } |
| @@ -1176,12 +2007,9 @@ | ||
| 1176 | 2007 | else |
| 1177 | 2008 | { |
| 1178 | 2009 | ?> |
| 1179 | 2010 | <tr> |
| 1180 | - <td><?php echo __( 'No tenure found', 'propertyhive' ); ?></td> | |
| 1181 | - <td class="settings"> | |
| 1182 | - | |
| 1183 | - </td> | |
| 2011 | + <td colspan="5"><?php echo esc_html(__( 'No tenure found', 'propertyhive' )); ?></td> | |
| 1184 | 2012 | </tr> |
| 1185 | 2013 | <?php |
| 1186 | 2014 | } |
| 1187 | 2015 | ?> |
| @@ -1193,10 +2021,10 @@ | ||
| 1193 | 2021 | <th scope="row" class="titledesc"> |
| 1194 | 2022 | |
| 1195 | 2023 | </th> |
| 1196 | 2024 | <td class="forminp forminp-button"> |
| 1197 | - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a> | |
| 1198 | - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=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§ion=commercial-tenure&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Tenure', 'propertyhive' )); ?></a> | |
| 1199 | 2027 | </td> |
| 1200 | 2028 | </tr> |
| 1201 | 2029 | <?php |
| 1202 | 2030 | } |
| @@ -1214,21 +2042,22 @@ | ||
| 1214 | 2042 | <th scope="row" class="titledesc"> |
| 1215 | 2043 | |
| 1216 | 2044 | </th> |
| 1217 | 2045 | <td class="forminp forminp-button"> |
| 1218 | - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a> | |
| 1219 | - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=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§ion=furnished&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Furnished Option', 'propertyhive' )); ?></a> | |
| 1220 | 2048 | </td> |
| 1221 | 2049 | </tr> |
| 1222 | 2050 | <tr valign="top"> |
| 1223 | - <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> | |
| 1224 | 2052 | <td class="forminp"> |
| 1225 | - <table class="ph_customfields widefat" cellspacing="0"> | |
| 2053 | + <table class="ph_customfields sortable-custom-field widefat" data-taxonomy="furnished" cellspacing="0"> | |
| 1226 | 2054 | <thead> |
| 1227 | 2055 | <tr> |
| 1228 | - <th class="cb" style="width:1px;"> </th> | |
| 1229 | - <th class="id" style="width:45px;"><?php _e( 'ID', 'propertyhive' ); ?></th> | |
| 1230 | - <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> | |
| 1231 | 2060 | <th class="settings"> </th> |
| 1232 | 2061 | </tr> |
| 1233 | 2062 | </thead> |
| 1234 | 2063 | <tbody> |
| @@ -1236,9 +2065,9 @@ | ||
| 1236 | 2065 | $args = array( |
| 1237 | 2066 | 'hide_empty' => false, |
| 1238 | 2067 | 'parent' => 0 |
| 1239 | 2068 | ); |
| 1240 | - $terms = get_terms( 'furnished', $args ); | |
| 2069 | + $terms = get_terms( array_merge( wp_parse_args( $args ), array( 'taxonomy' => 'furnished' ) ) ); | |
| 1241 | 2070 | |
| 1242 | 2071 | if ( !empty( $terms ) && !is_wp_error( $terms ) ) |
| 1243 | 2072 | { |
| 1244 | 2073 | foreach ($terms as $term) |
| @@ -1243,15 +2072,16 @@ | ||
| 1243 | 2072 | { |
| 1244 | 2073 | foreach ($terms as $term) |
| 1245 | 2074 | { |
| 1246 | 2075 | ?> |
| 1247 | - <tr> | |
| 1248 | - <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"></td> | |
| 1249 | - <td class="id"><?php echo $term->term_id; ?></td> | |
| 1250 | - <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> | |
| 1251 | 2081 | <td class="settings"> |
| 1252 | - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=furnished&id=' . $term->term_id ); ?>"><?php echo __( 'Edit', 'propertyhive' ); ?></a> | |
| 1253 | - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=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§ion=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§ion=furnished-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a> | |
| 1254 | 2084 | </td> |
| 1255 | 2085 | </tr> |
| 1256 | 2086 | <?php |
| 1257 | 2087 | } |
| @@ -1259,12 +2089,9 @@ | ||
| 1259 | 2089 | else |
| 1260 | 2090 | { |
| 1261 | 2091 | ?> |
| 1262 | 2092 | <tr> |
| 1263 | - <td><?php echo __( 'No furnished options found', 'propertyhive' ); ?></td> | |
| 1264 | - <td class="settings"> | |
| 1265 | - | |
| 1266 | - </td> | |
| 2093 | + <td colspan="5"><?php echo esc_html(__( 'No furnished options found', 'propertyhive' )); ?></td> | |
| 1267 | 2094 | </tr> |
| 1268 | 2095 | <?php |
| 1269 | 2096 | } |
| 1270 | 2097 | ?> |
| @@ -1276,15 +2103,141 @@ | ||
| 1276 | 2103 | <th scope="row" class="titledesc"> |
| 1277 | 2104 | |
| 1278 | 2105 | </th> |
| 1279 | 2106 | <td class="forminp forminp-button"> |
| 1280 | - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a> | |
| 1281 | - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=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§ion=furnished&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Furnished Option', 'propertyhive' )); ?></a> | |
| 1282 | 2109 | </td> |
| 1283 | 2110 | </tr> |
| 1284 | 2111 | <?php |
| 1285 | 2112 | } |
| 1286 | 2113 | |
| 2114 | + public function custom_fields_management_key_date_type_setting() { | |
| 2115 | + ?> | |
| 2116 | + <tr valign="top"> | |
| 2117 | + <th scope="row" class="titledesc"> | |
| 2118 | + | |
| 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§ion=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;"> </th> | |
| 2133 | + <th style="width:40%;"><?php echo esc_html(__( 'Description', 'propertyhive' )); ?></th> | |
| 2134 | + <th><?php echo esc_html(__( 'Recurrence', 'propertyhive' )); ?></th> | |
| 2135 | + <th> </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§ion=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§ion=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 | + | |
| 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§ion=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 | + | |
| 1287 | 2240 | /** |
| 1288 | 2241 | * Output list of marketing flag options |
| 1289 | 2242 | * |
| 1290 | 2243 | * @access public |
| @@ -1297,21 +2250,22 @@ | ||
| 1297 | 2250 | <th scope="row" class="titledesc"> |
| 1298 | 2251 | |
| 1299 | 2252 | </th> |
| 1300 | 2253 | <td class="forminp forminp-button"> |
| 1301 | - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a> | |
| 1302 | - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=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§ion=marketing-flag&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Marketing Flag', 'propertyhive' )); ?></a> | |
| 1303 | 2256 | </td> |
| 1304 | 2257 | </tr> |
| 1305 | 2258 | <tr valign="top"> |
| 1306 | - <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> | |
| 1307 | 2260 | <td class="forminp"> |
| 1308 | - <table class="ph_customfields widefat" cellspacing="0"> | |
| 2261 | + <table class="ph_customfields sortable-custom-field widefat" data-taxonomy="marketing_flag" cellspacing="0"> | |
| 1309 | 2262 | <thead> |
| 1310 | 2263 | <tr> |
| 1311 | - <th class="cb" style="width:1px;"> </th> | |
| 1312 | - <th class="id" style="width:45px;"><?php _e( 'ID', 'propertyhive' ); ?></th> | |
| 1313 | - <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> | |
| 1314 | 2268 | <th class="settings"> </th> |
| 1315 | 2269 | </tr> |
| 1316 | 2270 | </thead> |
| 1317 | 2271 | <tbody> |
| @@ -1319,9 +2273,9 @@ | ||
| 1319 | 2273 | $args = array( |
| 1320 | 2274 | 'hide_empty' => false, |
| 1321 | 2275 | 'parent' => 0 |
| 1322 | 2276 | ); |
| 1323 | - $terms = get_terms( 'marketing_flag', $args ); | |
| 2277 | + $terms = get_terms( array_merge( wp_parse_args( $args ), array( 'taxonomy' => 'marketing_flag' ) ) ); | |
| 1324 | 2278 | |
| 1325 | 2279 | if ( !empty( $terms ) && !is_wp_error( $terms ) ) |
| 1326 | 2280 | { |
| 1327 | 2281 | foreach ($terms as $term) |
| @@ -1326,15 +2280,16 @@ | ||
| 1326 | 2280 | { |
| 1327 | 2281 | foreach ($terms as $term) |
| 1328 | 2282 | { |
| 1329 | 2283 | ?> |
| 1330 | - <tr> | |
| 1331 | - <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"></td> | |
| 1332 | - <td class="id"><?php echo $term->term_id; ?></td> | |
| 1333 | - <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> | |
| 1334 | 2289 | <td class="settings"> |
| 1335 | - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=marketing-flag&id=' . $term->term_id ); ?>"><?php echo __( 'Edit', 'propertyhive' ); ?></a> | |
| 1336 | - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=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§ion=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§ion=marketing-flag-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a> | |
| 1337 | 2292 | </td> |
| 1338 | 2293 | </tr> |
| 1339 | 2294 | <?php |
| 1340 | 2295 | } |
| @@ -1342,12 +2297,9 @@ | ||
| 1342 | 2297 | else |
| 1343 | 2298 | { |
| 1344 | 2299 | ?> |
| 1345 | 2300 | <tr> |
| 1346 | - <td><?php echo __( 'No marketing flags found', 'propertyhive' ); ?></td> | |
| 1347 | - <td class="settings"> | |
| 1348 | - | |
| 1349 | - </td> | |
| 2301 | + <td colspan="5"><?php echo esc_html(__( 'No marketing flags found', 'propertyhive' )); ?></td> | |
| 1350 | 2302 | </tr> |
| 1351 | 2303 | <?php |
| 1352 | 2304 | } |
| 1353 | 2305 | ?> |
| @@ -1359,10 +2311,10 @@ | ||
| 1359 | 2311 | <th scope="row" class="titledesc"> |
| 1360 | 2312 | |
| 1361 | 2313 | </th> |
| 1362 | 2314 | <td class="forminp forminp-button"> |
| 1363 | - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a> | |
| 1364 | - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=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§ion=marketing-flag&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Marketing Flag', 'propertyhive' )); ?></a> | |
| 1365 | 2317 | </td> |
| 1366 | 2318 | </tr> |
| 1367 | 2319 | <?php |
| 1368 | 2320 | } |
| @@ -1380,21 +2332,22 @@ | ||
| 1380 | 2332 | <th scope="row" class="titledesc"> |
| 1381 | 2333 | |
| 1382 | 2334 | </th> |
| 1383 | 2335 | <td class="forminp forminp-button"> |
| 1384 | - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a> | |
| 1385 | - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=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§ion=property-feature&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Property Feature', 'propertyhive' )); ?></a> | |
| 1386 | 2338 | </td> |
| 1387 | 2339 | </tr> |
| 1388 | 2340 | <tr valign="top"> |
| 1389 | - <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> | |
| 1390 | 2342 | <td class="forminp"> |
| 1391 | 2343 | <table class="ph_customfields widefat" cellspacing="0"> |
| 1392 | 2344 | <thead> |
| 1393 | 2345 | <tr> |
| 1394 | - <th class="cb" style="width:1px;"> </th> | |
| 1395 | - <th class="id" style="width:45px;"><?php _e( 'ID', 'propertyhive' ); ?></th> | |
| 1396 | - <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> | |
| 1397 | 2350 | <th class="settings"> </th> |
| 1398 | 2351 | </tr> |
| 1399 | 2352 | </thead> |
| 1400 | 2353 | <tbody> |
| @@ -1402,9 +2355,9 @@ | ||
| 1402 | 2355 | $args = array( |
| 1403 | 2356 | 'hide_empty' => false, |
| 1404 | 2357 | 'parent' => 0 |
| 1405 | 2358 | ); |
| 1406 | - $terms = get_terms( 'property_feature', $args ); | |
| 2359 | + $terms = get_terms( array_merge( wp_parse_args( $args ), array( 'taxonomy' => 'property_feature' ) ) ); | |
| 1407 | 2360 | |
| 1408 | 2361 | if ( !empty( $terms ) && !is_wp_error( $terms ) ) |
| 1409 | 2362 | { |
| 1410 | 2363 | foreach ($terms as $term) |
| @@ -1410,14 +2363,15 @@ | ||
| 1410 | 2363 | foreach ($terms as $term) |
| 1411 | 2364 | { |
| 1412 | 2365 | ?> |
| 1413 | 2366 | <tr> |
| 1414 | - <td class="cb"><input type="checkbox" name="term_id[]" value="<?php echo $term->term_id; ?>"></td> | |
| 1415 | - <td class="id"><?php echo $term->term_id; ?></td> | |
| 1416 | - <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> | |
| 1417 | 2371 | <td class="settings"> |
| 1418 | - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=property-feature&id=' . $term->term_id ); ?>"><?php echo __( 'Edit', 'propertyhive' ); ?></a> | |
| 1419 | - <a class="button" href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=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§ion=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§ion=property-feature-delete&id=' . $term->term_id )); ?>"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a> | |
| 1420 | 2374 | </td> |
| 1421 | 2375 | </tr> |
| 1422 | 2376 | <?php |
| 1423 | 2377 | } |
| @@ -1425,9 +2379,9 @@ | ||
| 1425 | 2379 | else |
| 1426 | 2380 | { |
| 1427 | 2381 | ?> |
| 1428 | 2382 | <tr> |
| 1429 | - <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> | |
| 1430 | 2384 | </tr> |
| 1431 | 2385 | <?php |
| 1432 | 2386 | } |
| 1433 | 2387 | ?> |
| @@ -1439,10 +2393,10 @@ | ||
| 1439 | 2393 | <th scope="row" class="titledesc"> |
| 1440 | 2394 | |
| 1441 | 2395 | </th> |
| 1442 | 2396 | <td class="forminp forminp-button"> |
| 1443 | - <a href="" class="button alignright batch-delete" disabled><?php echo __( 'Delete Selected', 'propertyhive' ); ?></a> | |
| 1444 | - <a href="<?php echo admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=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§ion=property-feature&id=' )); ?>" class="button alignright"><?php echo esc_html(__( 'Add New Property Feature', 'propertyhive' )); ?></a> | |
| 1445 | 2399 | </td> |
| 1446 | 2400 | </tr> |
| 1447 | 2401 | <?php |
| 1448 | 2402 | } |
| @@ -1454,9 +2408,10 @@ | ||
| 1454 | 2408 | * @return string |
| 1455 | 2409 | */ |
| 1456 | 2410 | public function get_custom_fields_availability_setting() |
| 1457 | 2411 | { |
| 1458 | - $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'] ) ) : '' ); | |
| 1459 | 2414 | |
| 1460 | 2415 | $taxonomy = 'availability'; |
| 1461 | 2416 | $term_name = ''; |
| 1462 | 2417 | if ($current_id != '') |
| @@ -1464,11 +2419,13 @@ | ||
| 1464 | 2419 | $term = get_term( $current_id, $taxonomy ); |
| 1465 | 2420 | $term_name = $term->name; |
| 1466 | 2421 | } |
| 1467 | 2422 | |
| 2423 | + $departments = ph_get_departments(); | |
| 2424 | + | |
| 1468 | 2425 | $args = array( |
| 1469 | 2426 | |
| 1470 | - 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' ), | |
| 1471 | 2428 | |
| 1472 | 2429 | array( |
| 1473 | 2430 | 'title' => __( 'Availability', 'propertyhive' ), |
| 1474 | 2431 | 'id' => 'availability_name', |
| @@ -1475,18 +2432,41 @@ | ||
| 1475 | 2432 | 'default' => $term_name, |
| 1476 | 2433 | 'type' => 'text', |
| 1477 | 2434 | 'desc_tip' => false, |
| 1478 | 2435 | ), |
| 2436 | + | |
| 2437 | + ); | |
| 2438 | + | |
| 2439 | + $availability_departments = get_option( 'propertyhive_availability_departments', array() ); | |
| 2440 | + | |
| 2441 | + $i = 0; | |
| 2442 | + foreach ( $departments as $key => $value ) | |
| 2443 | + { | |
| 2444 | + if ( get_option( 'propertyhive_active_departments_' . str_replace("residential-", "", $key) ) == 'yes' ) | |
| 2445 | + { | |
| 2446 | + $args[] = array( | |
| 2447 | + 'title' => __( 'Applies To', 'propertyhive' ), | |
| 2448 | + 'name' => 'department[' . $key . ']', | |
| 2449 | + 'id' => 'department_' . $key, | |
| 2450 | + //'default' => $term_name, | |
| 2451 | + 'value' => ( !isset($availability_departments[$current_id]) || in_array($key, $availability_departments[$current_id]) ? 'yes' : '' ), | |
| 2452 | + 'type' => 'checkbox', | |
| 2453 | + 'desc_tip' => false, | |
| 2454 | + 'desc' => $value, | |
| 2455 | + 'checkboxgroup' => ( $i == 0 ? 'start' : ( $i == count($departments)-1 ? 'end' : '' ) ), | |
| 2456 | + ); | |
| 2457 | + | |
| 2458 | + ++$i; | |
| 2459 | + } | |
| 2460 | + } | |
| 2461 | + | |
| 2462 | + $args[] = array( | |
| 2463 | + 'type' => 'hidden', | |
| 2464 | + 'id' => 'taxonomy', | |
| 2465 | + 'default' => $taxonomy | |
| 2466 | + ); | |
| 1479 | 2467 | |
| 1480 | - array( | |
| 1481 | - 'type' => 'hidden', | |
| 1482 | - 'id' => 'taxonomy', | |
| 1483 | - 'default' => $taxonomy | |
| 1484 | - ), | |
| 1485 | - | |
| 1486 | - array( 'type' => 'sectionend', 'id' => 'custom_field_availability_settings' ) | |
| 1487 | - | |
| 1488 | - ); | |
| 2468 | + $args[] = array( 'type' => 'sectionend', 'id' => 'custom_field_availability_settings' ); | |
| 1489 | 2469 | |
| 1490 | 2470 | return apply_filters( 'propertyhive_custom_field_availability_settings', $args ); |
| 1491 | 2471 | } |
| 1492 | 2472 | |
| @@ -1497,9 +2477,10 @@ | ||
| 1497 | 2477 | * @return string |
| 1498 | 2478 | */ |
| 1499 | 2479 | public function get_custom_fields_property_type_setting() |
| 1500 | 2480 | { |
| 1501 | - $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'] ) ) : '' ); | |
| 1502 | 2483 | |
| 1503 | 2484 | $taxonomy = 'property_type'; |
| 1504 | 2485 | $term_name = ''; |
| 1505 | 2486 | $term_parent = ''; |
| @@ -1514,11 +2495,12 @@ | ||
| 1514 | 2495 | |
| 1515 | 2496 | $args = array( |
| 1516 | 2497 | 'hide_empty' => false, |
| 1517 | 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. | |
| 1518 | 2500 | 'exclude' => array($current_id) |
| 1519 | 2501 | ); |
| 1520 | - $terms = get_terms( 'property_type', $args ); | |
| 2502 | + $terms = get_terms( array_merge( wp_parse_args( $args ), array( 'taxonomy' => 'property_type' ) ) ); | |
| 1521 | 2503 | if ( !empty( $terms ) && !is_wp_error( $terms ) ) |
| 1522 | 2504 | { |
| 1523 | 2505 | foreach ($terms as $term) |
| 1524 | 2506 | { |
| @@ -1527,9 +2509,9 @@ | ||
| 1527 | 2509 | } |
| 1528 | 2510 | |
| 1529 | 2511 | $args = array( |
| 1530 | 2512 | |
| 1531 | - 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' ), | |
| 1532 | 2514 | |
| 1533 | 2515 | array( |
| 1534 | 2516 | 'title' => __( 'Property Type', 'propertyhive' ), |
| 1535 | 2517 | 'id' => 'property_type_name', |
| @@ -1568,9 +2550,10 @@ | ||
| 1568 | 2550 | * @return string |
| 1569 | 2551 | */ |
| 1570 | 2552 | public function get_custom_fields_commercial_property_type_setting() |
| 1571 | 2553 | { |
| 1572 | - $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'] ) ) : '' ); | |
| 1573 | 2556 | |
| 1574 | 2557 | $taxonomy = 'commercial_property_type'; |
| 1575 | 2558 | $term_name = ''; |
| 1576 | 2559 | $term_parent = ''; |
| @@ -1585,11 +2568,12 @@ | ||
| 1585 | 2568 | |
| 1586 | 2569 | $args = array( |
| 1587 | 2570 | 'hide_empty' => false, |
| 1588 | 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. | |
| 1589 | 2573 | 'exclude' => array($current_id) |
| 1590 | 2574 | ); |
| 1591 | - $terms = get_terms( 'commercial_property_type', $args ); | |
| 2575 | + $terms = get_terms( array_merge( wp_parse_args( $args ), array( 'taxonomy' => 'commercial_property_type' ) ) ); | |
| 1592 | 2576 | if ( !empty( $terms ) && !is_wp_error( $terms ) ) |
| 1593 | 2577 | { |
| 1594 | 2578 | foreach ($terms as $term) |
| 1595 | 2579 | { |
| @@ -1598,9 +2582,9 @@ | ||
| 1598 | 2582 | } |
| 1599 | 2583 | |
| 1600 | 2584 | $args = array( |
| 1601 | 2585 | |
| 1602 | - 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' ), | |
| 1603 | 2587 | |
| 1604 | 2588 | array( |
| 1605 | 2589 | 'title' => __( 'Property Type', 'propertyhive' ), |
| 1606 | 2590 | 'id' => 'commercial_property_type_name', |
| @@ -1639,9 +2623,10 @@ | ||
| 1639 | 2623 | * @return string |
| 1640 | 2624 | */ |
| 1641 | 2625 | public function get_custom_fields_location_setting() |
| 1642 | 2626 | { |
| 1643 | - $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'] ) ) : '' ); | |
| 1644 | 2629 | |
| 1645 | 2630 | $taxonomy = 'location'; |
| 1646 | 2631 | $term_name = ''; |
| 1647 | 2632 | $term_parent = ''; |
| @@ -1656,11 +2641,12 @@ | ||
| 1656 | 2641 | |
| 1657 | 2642 | $args = array( |
| 1658 | 2643 | 'hide_empty' => false, |
| 1659 | 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. | |
| 1660 | 2646 | 'exclude' => array($current_id) |
| 1661 | 2647 | ); |
| 1662 | - $terms = get_terms( $taxonomy, $args ); | |
| 2648 | + $terms = get_terms( array_merge( wp_parse_args( $args ), array( 'taxonomy' => $taxonomy ) ) ); | |
| 1663 | 2649 | if ( !empty( $terms ) && !is_wp_error( $terms ) ) |
| 1664 | 2650 | { |
| 1665 | 2651 | foreach ($terms as $term) |
| 1666 | 2652 | { |
| @@ -1668,11 +2654,12 @@ | ||
| 1668 | 2654 | |
| 1669 | 2655 | $args = array( |
| 1670 | 2656 | 'hide_empty' => false, |
| 1671 | 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. | |
| 1672 | 2659 | 'exclude' => array($current_id) |
| 1673 | 2660 | ); |
| 1674 | - $terms = get_terms( $taxonomy, $args ); | |
| 2661 | + $terms = get_terms( array_merge( wp_parse_args( $args ), array( 'taxonomy' => $taxonomy ) ) ); | |
| 1675 | 2662 | if ( !empty( $terms ) && !is_wp_error( $terms ) ) |
| 1676 | 2663 | { |
| 1677 | 2664 | foreach ($terms as $term) |
| 1678 | 2665 | { |
| @@ -1683,9 +2670,9 @@ | ||
| 1683 | 2670 | } |
| 1684 | 2671 | |
| 1685 | 2672 | $args = array( |
| 1686 | 2673 | |
| 1687 | - 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' ), | |
| 1688 | 2675 | |
| 1689 | 2676 | array( |
| 1690 | 2677 | 'title' => __( 'Location', 'propertyhive' ), |
| 1691 | 2678 | 'id' => 'location_name', |
| @@ -1724,9 +2711,10 @@ | ||
| 1724 | 2711 | * @return string |
| 1725 | 2712 | */ |
| 1726 | 2713 | public function get_custom_fields_parking_setting() |
| 1727 | 2714 | { |
| 1728 | - $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'] ) ) : '' ); | |
| 1729 | 2717 | |
| 1730 | 2718 | $taxonomy = 'parking'; |
| 1731 | 2719 | $term_name = ''; |
| 1732 | 2720 | if ($current_id != '') |
| @@ -1736,9 +2724,9 @@ | ||
| 1736 | 2724 | } |
| 1737 | 2725 | |
| 1738 | 2726 | $args = array( |
| 1739 | 2727 | |
| 1740 | - 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' ), | |
| 1741 | 2729 | |
| 1742 | 2730 | array( |
| 1743 | 2731 | 'title' => __( 'Parking', 'propertyhive' ), |
| 1744 | 2732 | 'id' => 'parking_name', |
| @@ -1767,9 +2755,10 @@ | ||
| 1767 | 2755 | * @return string |
| 1768 | 2756 | */ |
| 1769 | 2757 | public function get_custom_fields_outside_space_setting() |
| 1770 | 2758 | { |
| 1771 | - $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'] ) ) : '' ); | |
| 1772 | 2761 | |
| 1773 | 2762 | $taxonomy = 'outside_space'; |
| 1774 | 2763 | $term_name = ''; |
| 1775 | 2764 | if ($current_id != '') |
| @@ -1779,9 +2768,9 @@ | ||
| 1779 | 2768 | } |
| 1780 | 2769 | |
| 1781 | 2770 | $args = array( |
| 1782 | 2771 | |
| 1783 | - 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' ), | |
| 1784 | 2773 | |
| 1785 | 2774 | array( |
| 1786 | 2775 | 'title' => __( 'Outside Space', 'propertyhive' ), |
| 1787 | 2776 | 'id' => 'outside_space_name', |
| @@ -1812,20 +2801,26 @@ | ||
| 1812 | 2801 | public function get_custom_fields_delete($current_id, $taxonomy, $taxonomy_name) |
| 1813 | 2802 | { |
| 1814 | 2803 | global $save_button_text; |
| 1815 | 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. | |
| 1816 | 2806 | $save_button_text = __( 'Delete', 'propertyhive' ); |
| 1817 | 2807 | |
| 1818 | 2808 | //$taxonomy = 'outside_space'; |
| 1819 | 2809 | //$taxonomy_name = __( 'Outside Space', 'propertyhive' ); |
| 1820 | 2810 | |
| 1821 | - 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 ) | |
| 1822 | 2814 | { |
| 1823 | 2815 | // A term has just been deleted |
| 1824 | 2816 | global $hide_save_button, $show_cancel_button, $cancel_button_href; |
| 1825 | 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. | |
| 1826 | 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. | |
| 1827 | 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. | |
| 1828 | 2823 | $cancel_button_href = admin_url( 'admin.php?page=ph-settings&tab=customfields§ion=' . str_replace("_", "-", $taxonomy) ); |
| 1829 | 2824 | |
| 1830 | 2825 | $args = array(); |
| 1831 | 2826 | |
| @@ -1872,8 +2867,9 @@ | ||
| 1872 | 2867 | $query_args = array( |
| 1873 | 2868 | 'post_type' => 'property', |
| 1874 | 2869 | 'nopaging' => true, |
| 1875 | 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. | |
| 1876 | 2872 | 'tax_query' => array( |
| 1877 | 2873 | array( |
| 1878 | 2874 | 'taxonomy' => $taxonomy, |
| 1879 | 2875 | 'field' => 'id', |
| @@ -1894,8 +2890,9 @@ | ||
| 1894 | 2890 | $query_args = array( |
| 1895 | 2891 | 'post_type' => 'contact', |
| 1896 | 2892 | 'nopaging' => true, |
| 1897 | 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. | |
| 1898 | 2895 | 'meta_query' => array( |
| 1899 | 2896 | array( |
| 1900 | 2897 | 'key' => '_contact_types', |
| 1901 | 2898 | 'value' => 'applicant', |
| @@ -1944,9 +2941,33 @@ | ||
| 1944 | 2941 | |
| 1945 | 2942 | wp_reset_postdata(); |
| 1946 | 2943 | } |
| 1947 | 2944 | |
| 1948 | - 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 ) | |
| 1949 | 2970 | { |
| 1950 | 2971 | $alternative_terms = array(); |
| 1951 | 2972 | |
| 1952 | 2973 | $alternative_terms['none'] = '-- ' . __( 'Don\'t Reassign', 'propertyhive' ) . ' --'; |
| @@ -1952,12 +2973,13 @@ | ||
| 1952 | 2973 | $alternative_terms['none'] = '-- ' . __( 'Don\'t Reassign', 'propertyhive' ) . ' --'; |
| 1953 | 2974 | |
| 1954 | 2975 | $term_args = array( |
| 1955 | 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. | |
| 1956 | 2978 | 'exclude' => $term_ids, |
| 1957 | 2979 | 'parent' => 0 |
| 1958 | 2980 | ); |
| 1959 | - $terms = get_terms( $taxonomy, $term_args ); | |
| 2981 | + $terms = get_terms( array_merge( wp_parse_args( $term_args ), array( 'taxonomy' => $taxonomy ) ) ); | |
| 1960 | 2982 | |
| 1961 | 2983 | if ( !empty( $terms ) && !is_wp_error( $terms ) ) |
| 1962 | 2984 | { |
| 1963 | 2985 | foreach ($terms as $term) |
| @@ -1965,12 +2987,13 @@ | ||
| 1965 | 2987 | $alternative_terms[$term->term_id] = $term->name; |
| 1966 | 2988 | |
| 1967 | 2989 | $term_args = array( |
| 1968 | 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. | |
| 1969 | 2992 | 'exclude' => $term_ids, |
| 1970 | 2993 | 'parent' => $term->term_id |
| 1971 | 2994 | ); |
| 1972 | - $subterms = get_terms( $taxonomy, $term_args ); | |
| 2995 | + $subterms = get_terms( array_merge( wp_parse_args( $term_args ), array( 'taxonomy' => $taxonomy ) ) ); | |
| 1973 | 2996 | |
| 1974 | 2997 | if ( !empty( $subterms ) && !is_wp_error( $subterms ) ) |
| 1975 | 2998 | { |
| 1976 | 2999 | foreach ($subterms as $term) |
| @@ -1978,12 +3001,13 @@ | ||
| 1978 | 3001 | $alternative_terms[$term->term_id] = '- ' . $term->name; |
| 1979 | 3002 | |
| 1980 | 3003 | $term_args = array( |
| 1981 | 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. | |
| 1982 | 3006 | 'exclude' => $term_ids, |
| 1983 | 3007 | 'parent' => $term->term_id |
| 1984 | 3008 | ); |
| 1985 | - $subsubterms = get_terms( $taxonomy, $term_args ); | |
| 3009 | + $subsubterms = get_terms( array_merge( wp_parse_args( $term_args ), array( 'taxonomy' => $taxonomy ) ) ); | |
| 1986 | 3010 | |
| 1987 | 3011 | if ( !empty( $subsubterms ) && !is_wp_error( $subsubterms ) ) |
| 1988 | 3012 | { |
| 1989 | 3013 | foreach ($subsubterms as $term) |
| @@ -2003,21 +3027,11 @@ | ||
| 2003 | 3027 | 'default' => '', |
| 2004 | 3028 | 'options' => $alternative_terms, |
| 2005 | 3029 | 'type' => 'select', |
| 2006 | 3030 | 'desc_tip' => false, |
| 2007 | - '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' ) | |
| 2008 | 3032 | ); |
| 2009 | 3033 | } |
| 2010 | - else | |
| 2011 | - { | |
| 2012 | - // There are properties assigned to this term | |
| 2013 | - $args[] = array( | |
| 2014 | - 'title' => __( 'Re-assign to', 'propertyhive' ), | |
| 2015 | - 'id' => 'reassign_to', | |
| 2016 | - 'type' => 'html', | |
| 2017 | - 'html' => __( 'No properties or applicants assigned to this term' , 'propertyhive' ) | |
| 2018 | - ); | |
| 2019 | - } | |
| 2020 | 3034 | |
| 2021 | 3035 | $args[] = array( 'type' => 'sectionend', 'id' => 'custom_field_' . $taxonomy . '_' . $current_id . '_delete' ); |
| 2022 | 3036 | } |
| 2023 | 3037 | } |
| @@ -2051,9 +3065,10 @@ | ||
| 2051 | 3065 | * @return string |
| 2052 | 3066 | */ |
| 2053 | 3067 | public function get_custom_fields_price_qualifier_setting() |
| 2054 | 3068 | { |
| 2055 | - $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'] ) ) : ''; | |
| 2056 | 3071 | |
| 2057 | 3072 | $taxonomy = 'price_qualifier'; |
| 2058 | 3073 | $term_name = ''; |
| 2059 | 3074 | if ($current_id != '') |
| @@ -2063,9 +3078,9 @@ | ||
| 2063 | 3078 | } |
| 2064 | 3079 | |
| 2065 | 3080 | $args = array( |
| 2066 | 3081 | |
| 2067 | - 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' ), | |
| 2068 | 3083 | |
| 2069 | 3084 | array( |
| 2070 | 3085 | 'title' => __( 'Price Qualifier', 'propertyhive' ), |
| 2071 | 3086 | 'id' => 'price_qualifier_name', |
| @@ -2094,9 +3109,10 @@ | ||
| 2094 | 3109 | * @return string |
| 2095 | 3110 | */ |
| 2096 | 3111 | public function get_custom_fields_sale_by_setting() |
| 2097 | 3112 | { |
| 2098 | - $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'] ) ) : ''; | |
| 2099 | 3115 | |
| 2100 | 3116 | $taxonomy = 'sale_by'; |
| 2101 | 3117 | $term_name = ''; |
| 2102 | 3118 | if ($current_id != '') |
| @@ -2106,9 +3122,9 @@ | ||
| 2106 | 3122 | } |
| 2107 | 3123 | |
| 2108 | 3124 | $args = array( |
| 2109 | 3125 | |
| 2110 | - 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' ), | |
| 2111 | 3127 | |
| 2112 | 3128 | array( |
| 2113 | 3129 | 'title' => __( 'Sale By', 'propertyhive' ), |
| 2114 | 3130 | 'id' => 'sale_by_name', |
| @@ -2137,9 +3153,10 @@ | ||
| 2137 | 3153 | * @return string |
| 2138 | 3154 | */ |
| 2139 | 3155 | public function get_custom_fields_tenure_setting() |
| 2140 | 3156 | { |
| 2141 | - $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'] ) ) : ''; | |
| 2142 | 3159 | |
| 2143 | 3160 | $taxonomy = 'tenure'; |
| 2144 | 3161 | $term_name = ''; |
| 2145 | 3162 | if ($current_id != '') |
| @@ -2149,9 +3166,9 @@ | ||
| 2149 | 3166 | } |
| 2150 | 3167 | |
| 2151 | 3168 | $args = array( |
| 2152 | 3169 | |
| 2153 | - 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' ), | |
| 2154 | 3171 | |
| 2155 | 3172 | array( |
| 2156 | 3173 | 'title' => __( 'Tenure', 'propertyhive' ), |
| 2157 | 3174 | 'id' => 'tenure_name', |
| @@ -2180,9 +3197,10 @@ | ||
| 2180 | 3197 | * @return string |
| 2181 | 3198 | */ |
| 2182 | 3199 | public function get_custom_fields_commercial_tenure_setting() |
| 2183 | 3200 | { |
| 2184 | - $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'] ) ) : ''; | |
| 2185 | 3203 | |
| 2186 | 3204 | $taxonomy = 'commercial_tenure'; |
| 2187 | 3205 | $term_name = ''; |
| 2188 | 3206 | if ($current_id != '') |
| @@ -2192,9 +3210,9 @@ | ||
| 2192 | 3210 | } |
| 2193 | 3211 | |
| 2194 | 3212 | $args = array( |
| 2195 | 3213 | |
| 2196 | - 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' ), | |
| 2197 | 3215 | |
| 2198 | 3216 | array( |
| 2199 | 3217 | 'title' => __( 'Tenure', 'propertyhive' ), |
| 2200 | 3218 | 'id' => 'commercial_tenure_name', |
| @@ -2223,9 +3241,10 @@ | ||
| 2223 | 3241 | * @return string |
| 2224 | 3242 | */ |
| 2225 | 3243 | public function get_custom_fields_furnished_setting() |
| 2226 | 3244 | { |
| 2227 | - $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'] ) ) : ''; | |
| 2228 | 3247 | |
| 2229 | 3248 | $taxonomy = 'furnished'; |
| 2230 | 3249 | $term_name = ''; |
| 2231 | 3250 | if ($current_id != '') |
| @@ -2235,9 +3254,9 @@ | ||
| 2235 | 3254 | } |
| 2236 | 3255 | |
| 2237 | 3256 | $args = array( |
| 2238 | 3257 | |
| 2239 | - 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' ), | |
| 2240 | 3259 | |
| 2241 | 3260 | array( |
| 2242 | 3261 | 'title' => __( 'Furnished', 'propertyhive' ), |
| 2243 | 3262 | 'id' => 'furnished_name', |
| @@ -2258,8 +3277,113 @@ | ||
| 2258 | 3277 | |
| 2259 | 3278 | return apply_filters( 'propertyhive_custom_field_furnished_settings', $args ); |
| 2260 | 3279 | } |
| 2261 | 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 | + | |
| 2262 | 3386 | /** |
| 2263 | 3387 | * Show marketing flag add/edit options |
| 2264 | 3388 | * |
| 2265 | 3389 | * @access public |
| @@ -2266,9 +3390,10 @@ | ||
| 2266 | 3390 | * @return string |
| 2267 | 3391 | */ |
| 2268 | 3392 | public function get_custom_fields_marketing_flag_setting() |
| 2269 | 3393 | { |
| 2270 | - $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'] ) ) : ''; | |
| 2271 | 3396 | |
| 2272 | 3397 | $taxonomy = 'marketing_flag'; |
| 2273 | 3398 | $term_name = ''; |
| 2274 | 3399 | if ($current_id != '') |
| @@ -2278,9 +3403,9 @@ | ||
| 2278 | 3403 | } |
| 2279 | 3404 | |
| 2280 | 3405 | $args = array( |
| 2281 | 3406 | |
| 2282 | - 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' ), | |
| 2283 | 3408 | |
| 2284 | 3409 | array( |
| 2285 | 3410 | 'title' => __( 'Marketing Flag', 'propertyhive' ), |
| 2286 | 3411 | 'id' => 'marketing_flag_name', |
| @@ -2309,9 +3434,10 @@ | ||
| 2309 | 3434 | * @return string |
| 2310 | 3435 | */ |
| 2311 | 3436 | public function get_custom_fields_property_feature_setting() |
| 2312 | 3437 | { |
| 2313 | - $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'] ) ) : ''; | |
| 2314 | 3440 | |
| 2315 | 3441 | $taxonomy = 'property_feature'; |
| 2316 | 3442 | $term_name = ''; |
| 2317 | 3443 | if ($current_id != '') |
| @@ -2321,9 +3447,9 @@ | ||
| 2321 | 3447 | } |
| 2322 | 3448 | |
| 2323 | 3449 | $args = array( |
| 2324 | 3450 | |
| 2325 | - 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' ), | |
| 2326 | 3452 | |
| 2327 | 3453 | array( |
| 2328 | 3454 | 'title' => __( 'Property Feature', 'propertyhive' ), |
| 2329 | 3455 | 'id' => 'property_feature_name', |
| @@ -2344,232 +3470,496 @@ | ||
| 2344 | 3470 | |
| 2345 | 3471 | return apply_filters( 'propertyhive_custom_field_property_feature_settings', $args ); |
| 2346 | 3472 | } |
| 2347 | 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 | + | |
| 2348 | 3619 | /** |
| 2349 | - * Save settings | |
| 3620 | + * Save settings. | |
| 2350 | 3621 | */ |
| 2351 | 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 | + | |
| 2352 | 3627 | global $current_section, $post; |
| 2353 | 3628 | |
| 2354 | - if ( $current_section != '' ) | |
| 2355 | - { | |
| 2356 | - if (isset($_REQUEST['id'])) // we're either adding or editing | |
| 2357 | - { | |
| 2358 | - $current_id = empty( $_REQUEST['id'] ) ? '' : sanitize_text_field($_REQUEST['id']); | |
| 2359 | - | |
| 2360 | - switch ($current_section) | |
| 2361 | - { | |
| 2362 | - // With heirarchy | |
| 2363 | - case "property-type": | |
| 2364 | - case "commercial-property-type": | |
| 2365 | - case "location": | |
| 2366 | - { | |
| 2367 | - // TODO: Validate (check for blank fields) | |
| 2368 | - | |
| 2369 | - if ($current_id == '') | |
| 2370 | - { | |
| 2371 | - // Adding new term | |
| 2372 | - | |
| 2373 | - // TODO: Check term doesn't exist already | |
| 2374 | - | |
| 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 ) { | |
| 2375 | 3746 | wp_insert_term( |
| 2376 | - ph_clean($_POST[ph_clean($_POST['taxonomy']) . '_name']), // the term | |
| 2377 | - 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, | |
| 2378 | 3755 | array( |
| 2379 | - 'parent' => $_POST['parent_' . ph_clean($_POST['taxonomy']) . '_id'] | |
| 3756 | + 'name' => $term_name, | |
| 3757 | + 'parent' => $parent_id, | |
| 2380 | 3758 | ) |
| 2381 | 3759 | ); |
| 2382 | - | |
| 2383 | - // TODO: Check for errors returned from wp_insert_term() | |
| 2384 | 3760 | } |
| 2385 | - else | |
| 2386 | - { | |
| 2387 | - // Editing term | |
| 2388 | - wp_update_term($current_id, ph_clean($_POST['taxonomy']), array( | |
| 2389 | - 'name' => ph_clean($_POST[ph_clean($_POST['taxonomy']).'_name']), | |
| 2390 | - 'parent' => ph_clean($_POST['parent_' . $_POST['taxonomy'] . '_id']) | |
| 2391 | - )); | |
| 2392 | - | |
| 2393 | - // 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; | |
| 2394 | 3778 | } |
| 2395 | - break; | |
| 2396 | - } | |
| 2397 | - // Without heirarchy | |
| 2398 | - case "availability": | |
| 2399 | - case "outside-space": | |
| 2400 | - case "parking": | |
| 2401 | - case "price-qualifier": | |
| 2402 | - case "sale-by": | |
| 2403 | - case "tenure": | |
| 2404 | - case "commercial-tenure": | |
| 2405 | - case "furnished": | |
| 2406 | - case "marketing-flag": | |
| 2407 | - case "property-feature": | |
| 2408 | - { | |
| 2409 | - // TODO: Validate (check for blank fields) | |
| 2410 | - | |
| 2411 | - if ($current_id == '') | |
| 2412 | - { | |
| 2413 | - // Adding new term | |
| 2414 | - | |
| 2415 | - // TODO: Check term doesn't exist already | |
| 2416 | - | |
| 2417 | - wp_insert_term( | |
| 2418 | - ph_clean($_POST[ph_clean($_POST['taxonomy']) . '_name']), // the term | |
| 2419 | - $_POST['taxonomy'] // the taxonomy | |
| 2420 | - ); | |
| 2421 | - | |
| 2422 | - // TODO: Check for errors returned from wp_insert_term() | |
| 3779 | + | |
| 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'; | |
| 3784 | + } | |
| 3785 | + } else { | |
| 3786 | + wp_update_term( absint( $current_id ), $taxonomy, array( 'name' => $term_name ) ); | |
| 2423 | 3787 | } |
| 2424 | - else | |
| 2425 | - { | |
| 2426 | - // Editing term | |
| 2427 | - wp_update_term($current_id, ph_clean($_POST['taxonomy']), array( | |
| 2428 | - 'name' => ph_clean($_POST[ph_clean($_POST['taxonomy']) . '_name']) | |
| 2429 | - )); | |
| 2430 | - | |
| 2431 | - // TODO: Check for errors returned from wp_update_term() | |
| 3788 | + | |
| 3789 | + if ( 'availability' === $current_section ) { | |
| 3790 | + $availability_departments = get_option( 'propertyhive_availability_departments', array() ); | |
| 3791 | + if ( ! is_array( $availability_departments ) ) { | |
| 3792 | + $availability_departments = array(); | |
| 3793 | + } | |
| 3794 | + | |
| 3795 | + $departments = ph_get_departments(); | |
| 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; | |
| 3801 | + } | |
| 3802 | + } | |
| 3803 | + update_option( 'propertyhive_availability_departments', $availability_departments ); | |
| 2432 | 3804 | } |
| 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 | + } | |
| 2433 | 3832 | break; |
| 2434 | - } | |
| 2435 | - case "availability-delete": | |
| 2436 | - case "property-type-delete": | |
| 2437 | - case "commercial-property-type-delete": | |
| 2438 | - case "location-delete": | |
| 2439 | - case "parking-delete": | |
| 2440 | - case "outside-space-delete": | |
| 2441 | - case "price-qualifier-delete": | |
| 2442 | - case "sale-by-delete": | |
| 2443 | - case "tenure-delete": | |
| 2444 | - case "furnished-delete": | |
| 2445 | - case "marketing-flag-delete": | |
| 2446 | - case "property-feature-delete": | |
| 2447 | - { | |
| 2448 | - if ( isset($_POST['confirm_removal']) && $_POST['confirm_removal'] == '1' ) | |
| 2449 | - { | |
| 2450 | - $term_ids = explode("-", $current_id); | |
| 2451 | 3833 | |
| 2452 | - foreach ( $term_ids as $current_id ) | |
| 2453 | - { | |
| 2454 | - // Update properties that have this taxonomy term set | |
| 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, | |
| 3863 | + ), | |
| 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 ); | |
| 3876 | + } | |
| 3877 | + } | |
| 3878 | + } | |
| 3879 | + wp_reset_postdata(); | |
| 3880 | + | |
| 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 ); | |
| 3886 | + } | |
| 3887 | + } | |
| 3888 | + | |
| 3889 | + if ( in_array( $taxonomy, array( 'property_type', 'commercial_property_type', 'location' ), true ) ) { | |
| 2455 | 3890 | $query_args = array( |
| 2456 | - 'post_type' => 'property', | |
| 2457 | - 'nopaging' => true, | |
| 3891 | + 'post_type' => 'contact', | |
| 3892 | + 'nopaging' => true, | |
| 2458 | 3893 | 'post_status' => array( 'pending', 'auto-draft', 'draft', 'private', 'publish', 'future', 'trash' ), |
| 2459 | - 'tax_query' => array( | |
| 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( | |
| 2460 | 3896 | array( |
| 2461 | - 'taxonomy' => $_POST['taxonomy'], | |
| 2462 | - 'field' => 'id', | |
| 2463 | - 'terms' => $current_id, | |
| 3897 | + 'key' => '_contact_types', | |
| 3898 | + 'value' => 'applicant', | |
| 3899 | + 'compare' => 'LIKE', | |
| 2464 | 3900 | ), |
| 2465 | 3901 | ), |
| 2466 | 3902 | ); |
| 2467 | - $property_query = new WP_Query( $query_args ); | |
| 2468 | - | |
| 2469 | - if ( $property_query->have_posts() ) | |
| 2470 | - { | |
| 2471 | - while ( $property_query->have_posts() ) | |
| 2472 | - { | |
| 2473 | - $property_query->the_post(); | |
| 2474 | - | |
| 2475 | - wp_remove_object_terms( $post->ID, $current_id, ph_clean($_POST['taxonomy']) ); | |
| 2476 | - | |
| 2477 | - // Re-assign to another term | |
| 2478 | - if ( isset($_POST['reassign_to_' . $current_id]) && ! empty( $_POST['reassign_to_' . $current_id] ) && $_POST['reassign_to_' . $current_id] != 'none' ) | |
| 2479 | - { | |
| 2480 | - $new_id = $_POST['reassign_to_' . $current_id]; | |
| 2481 | - | |
| 2482 | - wp_set_post_terms( $post->ID, $new_id, ph_clean($_POST['taxonomy']), TRUE ); | |
| 2483 | - | |
| 2484 | - // TODO: Check for WP_ERROR | |
| 3903 | + $applicant_query = new WP_Query( $query_args ); | |
| 3904 | + | |
| 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; | |
| 2485 | 3911 | } |
| 2486 | - } | |
| 2487 | - } | |
| 2488 | - | |
| 2489 | - wp_reset_postdata(); | |
| 2490 | 3912 | |
| 2491 | - if ( $_POST['taxonomy'] == 'property_type' || $_POST['taxonomy'] == 'commercial_property_type' || $_POST['taxonomy'] == 'location' ) | |
| 2492 | - { | |
| 2493 | - $query_args = array( | |
| 2494 | - 'post_type' => 'contact', | |
| 2495 | - 'nopaging' => true, | |
| 2496 | - 'post_status' => array( 'pending', 'auto-draft', 'draft', 'private', 'publish', 'future', 'trash' ), | |
| 2497 | - 'meta_query' => array( | |
| 2498 | - array( | |
| 2499 | - 'key' => '_contact_types', | |
| 2500 | - 'value' => 'applicant', | |
| 2501 | - 'compare' => 'LIKE' | |
| 2502 | - ), | |
| 2503 | - ), | |
| 2504 | - ); | |
| 2505 | - $applicant_query = new WP_Query( $query_args ); | |
| 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 | + } | |
| 2506 | 3920 | |
| 2507 | - if ( $applicant_query->have_posts() ) | |
| 2508 | - { | |
| 2509 | - while ( $applicant_query->have_posts() ) | |
| 2510 | - { | |
| 2511 | - $applicant_query->the_post(); | |
| 2512 | - | |
| 2513 | - $num_applicant_profiles = get_post_meta( get_the_ID(), '_applicant_profiles', TRUE ); | |
| 2514 | - if ( $num_applicant_profiles == '' ) | |
| 2515 | - { | |
| 2516 | - $num_applicant_profiles = 0; | |
| 2517 | - } | |
| 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 | + } | |
| 2518 | 3930 | |
| 2519 | - if ( $num_applicant_profiles > 0 ) | |
| 2520 | - { | |
| 2521 | - for ( $i = 0; $i < $num_applicant_profiles; ++$i ) | |
| 2522 | - { | |
| 2523 | - $applicant_profile = get_post_meta( get_the_ID(), '_applicant_profile_' . $i, TRUE ); | |
| 2524 | - | |
| 2525 | - 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']) ) | |
| 2526 | - { | |
| 2527 | - if (in_array($current_id, $applicant_profile[ph_clean($_POST['taxonomy']).'s'])) | |
| 2528 | - { | |
| 2529 | - // This profile has this term set | |
| 2530 | - unset($applicant_profile[ph_clean($_POST['taxonomy']).'s'][$current_id]); | |
| 2531 | - | |
| 2532 | - if ( isset($_POST['reassign_to_' . $current_id]) && ! empty( $_POST['reassign_to_' . $current_id] ) && ph_clean($_POST['reassign_to_' . $current_id]) != 'none' ) | |
| 2533 | - { | |
| 2534 | - $applicant_profile[ph_clean($_POST['taxonomy']).'s'][] = $_POST['reassign_to_' . $current_id]; | |
| 2535 | - $applicant_profile[ph_clean($_POST['taxonomy']).'s'] = array_unique($applicant_profile[ph_clean($_POST['taxonomy']).'s']); | |
| 2536 | - } | |
| 2537 | - | |
| 2538 | - $applicant_profile[ph_clean($_POST['taxonomy']).'s'] = array_values($applicant_profile[ph_clean($_POST['taxonomy']).'s']); | |
| 2539 | - | |
| 2540 | - update_post_meta( get_the_ID(), '_applicant_profile_' . $i, $applicant_profile ); | |
| 2541 | - } | |
| 2542 | - } | |
| 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; | |
| 2543 | 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 ) ); | |
| 2544 | 3940 | } |
| 2545 | 3941 | } |
| 2546 | 3942 | } |
| 2547 | 3943 | } |
| 2548 | - | |
| 2549 | 3944 | wp_reset_postdata(); |
| 3945 | + } | |
| 2550 | 3946 | |
| 2551 | - wp_delete_term( $current_id, ph_clean($_POST['taxonomy']) ); | |
| 2552 | - } | |
| 3947 | + wp_delete_term( absint( $current_id ), $taxonomy ); | |
| 2553 | 3948 | } |
| 3949 | + break; | |
| 2554 | 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 | + } | |
| 2555 | 3956 | break; |
| 2556 | - } | |
| 2557 | - default: { echo 'UNKNOWN CUSTOM FIELD'; } | |
| 2558 | 3957 | } |
| 2559 | - } | |
| 2560 | - else | |
| 2561 | - { | |
| 2562 | - // Nothing to save. Should always be an id set when editing custom fields. | |
| 2563 | - // Even blank ids dictate something is being added | |
| 2564 | - } | |
| 3958 | + break; | |
| 2565 | 3959 | } |
| 2566 | - else | |
| 2567 | - { | |
| 2568 | - // Nothing to save. Should always be a section when editing custom fields | |
| 2569 | - } | |
| 2570 | 3960 | } |
| 2571 | 3961 | } |
| 2572 | 3962 | |
| 2573 | 3963 | endif; |
| 2574 | 3964 | |
| 2575 | -return new PH_Settings_Custom_Fields(); | |
| 3965 | +return new PH_Settings_Custom_Fields(); | |