← All changes
|
includes/admin/views/html-management-dates-meta-box.php
+41
-6
2.2.5
→
2.3.1
View file →
| @@ -2,18 +2,23 @@ | ||
| 2 | 2 | if ( ! defined( 'ABSPATH' ) ) { |
| 3 | 3 | exit; |
| 4 | 4 | } |
| 5 | 5 | |
| 6 | - $key_date_type_terms = get_terms( 'management_key_date_type', array( | |
| 6 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. | |
| 7 | + $key_date_type_terms = get_terms( array_merge( wp_parse_args( array( | |
| 7 | 8 | 'hide_empty' => false, |
| 8 | 9 | 'parent' => 0 |
| 9 | - ) ); | |
| 10 | + ) ), array( 'taxonomy' => 'management_key_date_type' ) ) ); | |
| 10 | 11 | |
| 12 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. | |
| 11 | 13 | $recurrence_rules = get_option( 'propertyhive_key_date_type', array() ); |
| 14 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. | |
| 12 | 15 | $recurrence_rules = is_array( $recurrence_rules ) ? $recurrence_rules : array(); |
| 13 | 16 | |
| 17 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. | |
| 14 | 18 | $parent_post_type = get_post_type( $post_id ); |
| 15 | 19 | |
| 20 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. | |
| 16 | 21 | $meta_query = array(); |
| 17 | 22 | |
| 18 | 23 | switch ( $parent_post_type ) |
| 19 | 24 | { |
| @@ -18,8 +23,9 @@ | ||
| 18 | 23 | switch ( $parent_post_type ) |
| 19 | 24 | { |
| 20 | 25 | case 'property' : |
| 21 | 26 | { |
| 27 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. | |
| 22 | 28 | $meta_query = array( |
| 23 | 29 | array( |
| 24 | 30 | 'key' => '_property_id', |
| 25 | 31 | 'value' => $post_id, |
| @@ -32,9 +38,11 @@ | ||
| 32 | 38 | break; |
| 33 | 39 | } |
| 34 | 40 | case 'tenancy' : |
| 35 | 41 | { |
| 42 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. | |
| 36 | 43 | $parent_property_id = get_post_meta( $post_id, '_property_id', true ); |
| 44 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. | |
| 37 | 45 | $meta_query = array( |
| 38 | 46 | array( |
| 39 | 47 | 'relation' => 'OR', |
| 40 | 48 | array( |
| @@ -56,8 +64,9 @@ | ||
| 56 | 64 | switch ( $selected_status ) |
| 57 | 65 | { |
| 58 | 66 | case 'upcoming_and_overdue': |
| 59 | 67 | { |
| 68 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. | |
| 60 | 69 | $meta_query[] = array( |
| 61 | 70 | 'key' => '_key_date_status', |
| 62 | 71 | 'value' => array('pending', 'booked'), |
| 63 | 72 | 'compare' => 'IN' |
| @@ -62,9 +71,11 @@ | ||
| 62 | 71 | 'value' => array('pending', 'booked'), |
| 63 | 72 | 'compare' => 'IN' |
| 64 | 73 | ); |
| 65 | 74 | |
| 75 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. | |
| 66 | 76 | $upcoming_threshold = new DateTime('+ ' . apply_filters( 'propertyhive_key_date_upcoming_days', 7 ) . ' DAYS'); |
| 77 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. | |
| 67 | 78 | $meta_query[] = array( |
| 68 | 79 | 'key' => '_date_due', |
| 69 | 80 | 'value' => $upcoming_threshold->format('Y-m-d'), |
| 70 | 81 | 'type' => 'date', |
| @@ -73,8 +84,9 @@ | ||
| 73 | 84 | break; |
| 74 | 85 | } |
| 75 | 86 | case 'overdue': |
| 76 | 87 | { |
| 88 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. | |
| 77 | 89 | $meta_query[] = array( |
| 78 | 90 | 'key' => '_key_date_status', |
| 79 | 91 | 'value' => array('pending', 'booked'), |
| 80 | 92 | 'compare' => 'IN' |
| @@ -79,11 +91,12 @@ | ||
| 79 | 91 | 'value' => array('pending', 'booked'), |
| 80 | 92 | 'compare' => 'IN' |
| 81 | 93 | ); |
| 82 | 94 | |
| 95 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. | |
| 83 | 96 | $meta_query[] = array( |
| 84 | 97 | 'key' => '_date_due', |
| 85 | - 'value' => date('Y-m-d'), | |
| 98 | + 'value' => gmdate('Y-m-d'), | |
| 86 | 99 | 'type' => 'date', |
| 87 | 100 | 'compare' => '<', |
| 88 | 101 | ); |
| 89 | 102 | break; |
| @@ -89,8 +102,9 @@ | ||
| 89 | 102 | break; |
| 90 | 103 | } |
| 91 | 104 | default: |
| 92 | 105 | { |
| 106 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. | |
| 93 | 107 | $meta_query[] = array( |
| 94 | 108 | 'key' => '_key_date_status', |
| 95 | 109 | 'value' => $selected_status, |
| 96 | 110 | ); |
| @@ -100,8 +114,9 @@ | ||
| 100 | 114 | } |
| 101 | 115 | |
| 102 | 116 | if ( isset($selected_type_id) && !empty($selected_type_id) ) |
| 103 | 117 | { |
| 118 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. | |
| 104 | 119 | $meta_query[] = array( |
| 105 | 120 | 'key' => '_key_date_type_id', |
| 106 | 121 | 'value' => $selected_type_id, |
| 107 | 122 | ); |
| @@ -106,13 +121,16 @@ | ||
| 106 | 121 | 'value' => $selected_type_id, |
| 107 | 122 | ); |
| 108 | 123 | } |
| 109 | 124 | |
| 125 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. | |
| 110 | 126 | $key_dates = get_posts(array ( |
| 111 | 127 | 'post_type' => 'key_date', |
| 112 | 128 | 'nopaging' => true, |
| 129 | + // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query -- The complete management-date grid selects records by existing property/tenancy relationships and date/status metadata. | |
| 113 | 130 | 'meta_query' => $meta_query, |
| 114 | 131 | 'orderby' => 'meta_value', |
| 132 | + // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key -- Management dates are ordered by their stored due date to preserve the grid's chronological behavior. | |
| 115 | 133 | 'meta_key' => '_date_due', |
| 116 | 134 | 'order' => 'DESC', |
| 117 | 135 | |
| 118 | 136 | )); |
| @@ -126,14 +144,18 @@ | ||
| 126 | 144 | <option value=""><?php echo esc_html(__( 'All Types', 'propertyhive' )); ?></option> |
| 127 | 145 | <?php |
| 128 | 146 | if ( !empty( $key_date_type_terms ) && !is_wp_error( $key_date_type_terms ) ) |
| 129 | 147 | { |
| 148 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. | |
| 130 | 149 | foreach ($key_date_type_terms as $key_date_type_term) |
| 131 | 150 | { |
| 151 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. | |
| 132 | 152 | $recurrence_type = isset($recurrence_rules[$key_date_type_term->term_id]) ? $recurrence_rules[$key_date_type_term->term_id]['recurrence_type'] : ''; |
| 133 | 153 | if ( $parent_post_type == 'tenancy' || ( $parent_post_type == 'property' && $recurrence_type == 'property_management' ) ) |
| 134 | 154 | { |
| 155 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. | |
| 135 | 156 | $selected = ( isset($selected_type_id) && $selected_type_id == $key_date_type_term->term_id ) ? ' selected' : ''; |
| 157 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- The selected fragment is only the fixed literal ' selected' or an empty string; option name/value are escaped. | |
| 136 | 158 | echo '<option value="' . esc_attr($key_date_type_term->term_id) . '"' . $selected . '>' . esc_html($key_date_type_term->name) . '</option>'; |
| 137 | 159 | } |
| 138 | 160 | } |
| 139 | 161 | } |
| @@ -188,15 +210,17 @@ | ||
| 188 | 210 | <tbody id="the-list"> |
| 189 | 211 | <?php |
| 190 | 212 | if ( count($key_dates) > 0 ) |
| 191 | 213 | { |
| 214 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. | |
| 192 | 215 | foreach ( $key_dates as $key_date_post ) |
| 193 | 216 | { |
| 217 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. | |
| 194 | 218 | $key_date = new PH_Key_Date( $key_date_post ); |
| 195 | 219 | ?> |
| 196 | 220 | <tr id="post-<?php echo (int)$key_date_post->ID; ?>" class="post-<?php echo esc_attr($key_date_post->ID); ?> key-date-row"> |
| 197 | 221 | <td class="description column-description" data-colname="Description"> |
| 198 | - <div class="cell-main-content"><?php echo $key_date->description(); ?></div> | |
| 222 | + <div class="cell-main-content"><?php echo esc_html( $key_date->description() ); ?></div> | |
| 199 | 223 | <div class="row-actions"> |
| 200 | 224 | <span class="inline hide-if-no-js"> |
| 201 | 225 | <button type="button" id="<?php echo esc_attr($key_date_post->ID); ?>" class="button-link meta-box-quick-edit"> |
| 202 | 226 | Quick Edit |
| @@ -214,15 +238,18 @@ | ||
| 214 | 238 | </td> |
| 215 | 239 | <td class="tenants column-tenants" data-colname="Tenants"> |
| 216 | 240 | <div class="cell-main-content"> |
| 217 | 241 | <?php |
| 242 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. | |
| 218 | 243 | $tenants = ''; |
| 219 | 244 | if ( !empty($key_date->tenancy_id) ) |
| 220 | 245 | { |
| 246 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. | |
| 221 | 247 | $tenancy = $key_date->tenancy(); |
| 248 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. | |
| 222 | 249 | $tenants = $tenancy->get_tenants(false, true); |
| 223 | 250 | } |
| 224 | - echo !empty($tenants) ? $tenants : '-'; | |
| 251 | + echo !empty($tenants) ? wp_kses_post( $tenants ) : '-'; | |
| 225 | 252 | ?> |
| 226 | 253 | </div> |
| 227 | 254 | </td> |
| 228 | 255 | <td class="date_due column-date_due" data-colname="Date Due"> |
| @@ -228,12 +255,14 @@ | ||
| 228 | 255 | <td class="date_due column-date_due" data-colname="Date Due"> |
| 229 | 256 | <?php |
| 230 | 257 | if ( $key_date->date_due()->format( 'H:i' ) == '00:00' ) |
| 231 | 258 | { |
| 259 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. | |
| 232 | 260 | $date_format = 'jS F Y'; |
| 233 | 261 | } |
| 234 | 262 | else |
| 235 | 263 | { |
| 264 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. | |
| 236 | 265 | $date_format = 'H:i jS F Y'; |
| 237 | 266 | } |
| 238 | 267 | ?> |
| 239 | 268 | <div class="cell-main-content"><?php echo esc_html($key_date->date_due()->format( $date_format )); ?></div> |
| @@ -289,10 +318,12 @@ | ||
| 289 | 318 | <option value="">Select Type</option> |
| 290 | 319 | <?php |
| 291 | 320 | if ( !empty( $key_date_type_terms ) && !is_wp_error( $key_date_type_terms ) ) |
| 292 | 321 | { |
| 322 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. | |
| 293 | 323 | foreach ($key_date_type_terms as $key_date_type_term) |
| 294 | 324 | { |
| 325 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. | |
| 295 | 326 | $recurrence_type = isset($recurrence_rules[$key_date_type_term->term_id]) ? $recurrence_rules[$key_date_type_term->term_id]['recurrence_type'] : ''; |
| 296 | 327 | if ( $parent_post_type == 'tenancy' || ( $parent_post_type == 'property' && $recurrence_type == 'property_management' ) ) |
| 297 | 328 | { |
| 298 | 329 | echo '<option value="' . esc_attr($key_date_type_term->term_id) . '">' . esc_html($key_date_type_term->name) . '</option>'; |
| @@ -307,14 +338,16 @@ | ||
| 307 | 338 | <input type="text" id="_add_key_date_description" name="_add_key_date_description" value="" class="short"> |
| 308 | 339 | </p> |
| 309 | 340 | <p class="form-field _add_key_date_due_field"> |
| 310 | 341 | <label for="_add_key_date_due"><?php echo esc_html(__('Date Due', 'propertyhive')); ?></label> |
| 311 | - <input type="date" class="small" name="_add_key_date_due" id="_add_key_date_due" value="<?php echo esc_attr(date("Y-m-d")); ?>" placeholder=""> | |
| 342 | + <input type="date" class="small" name="_add_key_date_due" id="_add_key_date_due" value="<?php echo esc_attr(gmdate("Y-m-d")); ?>" placeholder=""> | |
| 312 | 343 | |
| 313 | 344 | <select id="_add_key_date_due_hours" name="_add_key_date_due_hours" class="select short" style="width:55px">'; |
| 314 | 345 | <?php |
| 346 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. | |
| 315 | 347 | for ( $i = 0; $i < 23; ++$i ) |
| 316 | 348 | { |
| 349 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. | |
| 317 | 350 | $j = str_pad($i, 2, '0', STR_PAD_LEFT); |
| 318 | 351 | echo '<option value="' . esc_attr($j) . '">' . esc_html($j) . '</option>'; |
| 319 | 352 | } |
| 320 | 353 | ?> |
| @@ -321,10 +354,12 @@ | ||
| 321 | 354 | </select> |
| 322 | 355 | : |
| 323 | 356 | <select id="_add_key_date_due_minutes" name="_add_key_date_due_minutes" class="select short" style="width:55px"> |
| 324 | 357 | <?php |
| 358 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. | |
| 325 | 359 | for ( $i = 0; $i < 60; $i+=5 ) |
| 326 | 360 | { |
| 361 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. | |
| 327 | 362 | $j = str_pad($i, 2, '0', STR_PAD_LEFT); |
| 328 | 363 | echo '<option value="' . esc_attr($j) . '">' . esc_html($j) . '</option>'; |
| 329 | 364 | } |
| 330 | 365 | ?> |