| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; |
| 4 |
} |
| 5 |
|
| 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 |
$meta_query = array( |
| 8 |
array( |
| 9 |
'relation' => 'OR', |
| 10 |
array( |
| 11 |
'key' => '_contact_id', |
| 12 |
'value' => $post_id, |
| 13 |
), |
| 14 |
), |
| 15 |
); |
| 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. |
| 18 |
$contact_email_address = get_post_meta( $post_id, '_email_address', TRUE ); |
| 19 |
if ( !empty($contact_email_address) ) |
| 20 |
{ |
| 21 |
// 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 |
$meta_query[0][] = array( |
| 23 |
'key' => 'email', |
| 24 |
'value' => $contact_email_address, |
| 25 |
); |
| 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. |
| 28 |
$meta_query[0][] = array( |
| 29 |
'key' => 'email_address', |
| 30 |
'value' => $contact_email_address, |
| 31 |
); |
| 32 |
} |
| 33 |
|
| 34 |
if ( isset($selected_status) && !empty($selected_status) ) |
| 35 |
{ |
| 36 |
// 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 |
$meta_query[] = array( |
| 38 |
'key' => '_status', |
| 39 |
'value' => $selected_status, |
| 40 |
); |
| 41 |
} |
| 42 |
|
| 43 |
// 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. |
| 44 |
$args = array( |
| 45 |
'post_type' => 'enquiry', |
| 46 |
'nopaging' => true, |
| 47 |
// phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query -- Required relationship/status metadata restricts this grid to the selected contact; retain existing result and status-filter semantics. |
| 48 |
'meta_query' => $meta_query, |
| 49 |
); |
| 50 |
// 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. |
| 51 |
$enquiries_query = new WP_Query( $args ); |
| 52 |
// 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. |
| 53 |
$enquiries_count = $enquiries_query->found_posts; |
| 54 |
|
| 55 |
// 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. |
| 56 |
$columns = array( |
| 57 |
'date_time' => __( 'Date', 'propertyhive' ) . ' / ' . __( 'Time', 'propertyhive' ), |
| 58 |
'subject' => __( 'Subject', 'propertyhive' ), |
| 59 |
'status' => __( 'Status', 'propertyhive' ), |
| 60 |
'negotiator' => __( 'Negotiator', 'propertyhive' ), |
| 61 |
'office' => __( 'Office', 'propertyhive' ), |
| 62 |
); |
| 63 |
|
| 64 |
// 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. |
| 65 |
$columns = apply_filters( 'propertyhive_contact_enquiries_columns', $columns ); |
| 66 |
?> |
| 67 |
|
| 68 |
<div class="tablenav top"> |
| 69 |
<div class="alignleft actions"> |
| 70 |
<select name="_status" id="_enquiry_status_filter"> |
| 71 |
<option value=""><?php echo esc_html(__( 'All Statuses', 'propertyhive' )); ?></option> |
| 72 |
<?php |
| 73 |
// 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. |
| 74 |
$enquiry_statuses = ph_get_enquiry_statuses(); |
| 75 |
|
| 76 |
// 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 |
foreach ( $enquiry_statuses as $status => $display_status ) |
| 78 |
{ |
| 79 |
?> |
| 80 |
<option value="<?php echo esc_attr($status); ?>" <?php selected( $status, $selected_status ); ?>><?php echo esc_html($display_status); ?></option> |
| 81 |
<?php |
| 82 |
} |
| 83 |
?> |
| 84 |
</select> |
| 85 |
<input type="button" name="filter_action" id="filter-contact-enquiries-grid" class="button" value="Filter"> |
| 86 |
</div> |
| 87 |
<div class='tablenav-pages one-page'> |
| 88 |
<span class="displaying-num"><?php echo esc_html($enquiries_count); ?> item<?php echo $enquiries_count != 1 ? 's' : ''; ?></span> |
| 89 |
</div> |
| 90 |
<br class="clear" /> |
| 91 |
</div> |
| 92 |
<table class="wp-list-table widefat fixed striped posts"> |
| 93 |
<thead> |
| 94 |
<tr> |
| 95 |
<?php |
| 96 |
// 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. |
| 97 |
$column_i = 0; |
| 98 |
// 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. |
| 99 |
foreach ( $columns as $column_key => $column ) |
| 100 |
{ |
| 101 |
?> |
| 102 |
<th scope="col" id='<?php echo esc_attr($column_key); ?>' class='manage-column column-<?php echo esc_attr($column_key); echo ($column_i == 0 ? ' column-primary' : ''); ?>'><?php echo esc_html($column); ?></th> |
| 103 |
<?php |
| 104 |
++$column_i; |
| 105 |
} |
| 106 |
?> |
| 107 |
</tr> |
| 108 |
</thead> |
| 109 |
<tbody id="the-list"> |
| 110 |
<?php |
| 111 |
if ( $enquiries_query->have_posts() ) |
| 112 |
{ |
| 113 |
while ( $enquiries_query->have_posts() ) |
| 114 |
{ |
| 115 |
$enquiries_query->the_post(); |
| 116 |
// 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. |
| 117 |
$the_enquiry = new PH_Enquiry( get_the_ID() ); |
| 118 |
|
| 119 |
// 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. |
| 120 |
$edit_link = get_edit_post_link( get_the_ID() ); |
| 121 |
|
| 122 |
// 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. |
| 123 |
$column_data = array( |
| 124 |
'date_time' => '<a href="' . esc_url($edit_link) . '" target="' . esc_attr(apply_filters('propertyhive_subgrid_link_target', '')) . '">' . esc_html(get_the_time( 'jS M Y H:i' )) . '</a>', |
| 125 |
'subject' => esc_html(get_the_title()), |
| 126 |
'status' => esc_html(ucfirst( $the_enquiry->status )), |
| 127 |
'negotiator' => wp_kses($the_enquiry->get_negotiator(), array( 'em' => array() )), |
| 128 |
'office' => esc_html($the_enquiry->get_office()), |
| 129 |
); |
| 130 |
|
| 131 |
// 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 |
$row_classes = array( 'status-' . $the_enquiry->_status ); |
| 133 |
// 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. |
| 134 |
$row_classes = apply_filters( 'propertyhive_contact_enquiries_row_classes', $row_classes, get_the_ID(), $the_enquiry ); |
| 135 |
// 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. |
| 136 |
$row_classes = is_array($row_classes) ? array_map( 'sanitize_html_class', array_map( 'strtolower', $row_classes ) ) : array(); |
| 137 |
?> |
| 138 |
<tr class="<?php echo esc_attr(implode(" ", $row_classes)); ?>" > |
| 139 |
<?php |
| 140 |
// 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. |
| 141 |
$column_i = 0; |
| 142 |
// 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. |
| 143 |
foreach ( $columns as $column_key => $column ) |
| 144 |
{ |
| 145 |
echo '<td class="' . esc_attr($column_key) . ' column-' . esc_attr($column_key) . ($column_i == 0 ? ' column-primary' : '') . '" data-colname="' . esc_attr($column) . '">'; |
| 146 |
|
| 147 |
if ( isset( $column_data[$column_key] ) ) |
| 148 |
{ |
| 149 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Core cells are escaped HTML assembled above or by the reviewed PH model formatters; preserve trusted PHP contact-detail filter markup and links. |
| 150 |
echo $column_data[$column_key]; |
| 151 |
} |
| 152 |
|
| 153 |
do_action( 'propertyhive_contact_enquiries_custom_column', $column_key ); |
| 154 |
|
| 155 |
if ( $column_i == 0 ) { echo '<button type="button" class="toggle-row"><span class="screen-reader-text">' . esc_html(__('Show more details', 'propertyhive' )) . '</span></button>'; } |
| 156 |
|
| 157 |
echo '</td>'; |
| 158 |
++$column_i; |
| 159 |
} |
| 160 |
?> |
| 161 |
</tr> |
| 162 |
<?php |
| 163 |
} |
| 164 |
} |
| 165 |
else |
| 166 |
{ |
| 167 |
?> |
| 168 |
<tr class="no-items"> |
| 169 |
<td class="colspanchange" colspan="<?php echo count($columns); ?>"><?php echo esc_html(__( 'No enquiries found', 'propertyhive' )); ?></td> |
| 170 |
</tr> |
| 171 |
<?php |
| 172 |
} |
| 173 |
wp_reset_postdata(); |
| 174 |
?> |
| 175 |
</tbody> |
| 176 |
</table> |