PluginProbe
Property Hive / 2.3.0
Property Hive v2.3.0
2.3.0 2.2.6 2.2.5 2.2.4 2.2.3 2.2.2 1.4.46 1.4.47 1.4.48 1.4.49 1.4.5 1.4.50 1.4.51 1.4.52 1.4.53 1.4.54 1.4.55 1.4.56 1.4.57 1.4.58 1.4.59 1.4.6 1.4.60 1.4.61 1.4.62 All 260 releases
propertyhive / includes / admin / views / html-display-notes.php

html-display-notes.php in Property Hive 2.3.0, at includes/admin/views/html-display-notes.php

461 lines 29.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit; // Exit if accessed directly
5 }
6
7 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only display mode; parent CRM renderer enforces access, and note mutations verify their own nonce.
8 $propertyhive_has_pinned_filter = isset( $_POST['pinned'] );
9 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only display filter, with a scalar integer conversion.
10 $propertyhive_pinned_only = $propertyhive_has_pinned_filter && is_scalar( $_POST['pinned'] ) && 1 === (int) $_POST['pinned'];
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.
13 $args = array(
14 'post_id' => (int)$post->ID,
15 'type' => 'propertyhive_note',
16 // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query -- Notes use the existing serialized related_to comment metadata to include cross-record relationships.
17 'meta_query' => array(
18 array(
19 'key' => 'related_to',
20 'value' => '"' . (int)$post->ID . '"',
21 'compare' => 'LIKE',
22 ),
23 )
24 );
25
26 if ( $propertyhive_pinned_only )
27 {
28 // 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.
29 $args['search'] = '"pinned";s:1:"1"';
30 }
31
32 // 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.
33 $notes = get_comments( $args );
34
35 // 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 $pinned_notes = array();
37 // 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.
38 $unpinned_notes = array();
39
40 if ( !empty($notes) )
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.
43 foreach( $notes as $note )
44 {
45 // 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.
46 $comment_content = @unserialize($note->comment_content, ['allowed_classes' => false]);
47
48 if ( $comment_content === false )
49 {
50 continue;
51 }
52
53 // 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.
54 $note_body = 'Unknown note type';
55 switch ( $comment_content['note_type'] )
56 {
57 case "mailout":
58 {
59 if ( isset($comment_content['method']) && $comment_content['method'] == 'email' && isset($comment_content['email_log_id']) )
60 {
61 // 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.
62 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching,WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable. Prepared single-row lookup in the plugin email queue; show current delivery status changed asynchronously by the mail worker.
63 $email_log = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}ph_email_log WHERE email_id = %d", (int) $comment_content['email_log_id'] ) );
64
65 if ( null !== $email_log )
66 {
67 // 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.
68 $next_cron_run = '';
69 // 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.
70 $email_status = '';
71 // 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.
72 $note_suffix = '';
73 switch ($email_log->status) {
74 case '':
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.
76 $next_cron_run = $next_cron_run ?: propertyhive_human_time_difference( wp_next_scheduled( 'propertyhive_process_email_log' ) );
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.
78 $email_status = __( 'queued', 'propertyhive' );
79 // 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.
80 $note_suffix = '<em>(' . __( 'Due to be sent', 'propertyhive' ) . ' ' . $next_cron_run . ')</em>';
81 break;
82 case 'fail1':
83 case 'fail2':
84 // 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.
85 $email_status = '<b>' . __( 'failed', 'propertyhive' ) . '</b>';
86 break;
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.
89 $note_body = '';
90 if ($section == 'property')
91 {
92 // 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 $note_body .= 'Included in ' . $email_status . ' email mailout to ' . get_the_title($email_log->contact_id) . '. ' . $note_suffix;
94 }
95 elseif ($section == 'contact')
96 {
97 // 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.
98 $property_ids = @unserialize($email_log->property_ids, ['allowed_classes' => false]);
99 if ( $property_ids !== false )
100 {
101 // 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.
102 $note_body .= count($property_ids) . ' propert' . ( (count($property_ids) != 1) ? 'ies' : 'y' ) . ' included in ' . $email_status . ' email mailout. ' . $note_suffix;
103 }
104 }
105 // 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.
106 $note_body .= ' <a href="' . wp_nonce_url( admin_url('?view_propertyhive_email=' . $comment_content['email_log_id'] . '&email_id=' . $comment_content['email_log_id'] ), 'view-email' ) . '" target="_blank">View Mailout</a>';
107 }
108 else
109 {
110 // 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.
111 $keep_logs_days = (string)apply_filters( 'propertyhive_keep_email_logs_days', '3650' ); // 10 years
112
113 // Revert back to 3650 days if anything other than numbers has been passed
114 // This prevent SQL injection and errors
115 if ( !preg_match("/^\d+$/", $keep_logs_days) )
116 {
117 // 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.
118 $keep_logs_days = '3650';
119 }
120
121 // 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.
122 $note_body = 'The details of the email have since been deleted as we remove details of emails sent more then ' . $keep_logs_days . ' days ago';
123 }
124 }
125 break;
126 }
127 case "action":
128 {
129 switch ( $comment_content['action'] )
130 {
131 case "property_price_change":
132 {
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 $note_body = $comment_content['action'] . '<br>From: ' . $comment_content['original_value'] . '<br>To: ' . $comment_content['new_value'];
135 break;
136 }
137 case "property_availability_change":
138 {
139 // 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.
140 $note_body = $comment_content['action'] . '<br>From: ' . $comment_content['original_value'] . '<br>To: ' . $comment_content['new_value'];
141 break;
142 }
143 case "viewing_booked":
144 {
145 // 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.
146 $note_body = '<a href="' . get_edit_post_link($comment_content['viewing_id']) . '">Viewing</a> booked';
147 if ( isset($comment_content['property_id']) )
148 {
149 // 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.
150 $property = new PH_Property((int)$comment_content['property_id']);
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.
152 $note_body .= ' on <a href="' . get_edit_post_link($comment_content['property_id']) . '">' . $property->get_formatted_full_address() . '</a>';
153 }
154 break;
155 }
156 case "added_to_viewing":
157 {
158 // 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.
159 $note_body = 'Added to <a href="' . get_edit_post_link($comment_content['viewing_id']) . '">viewing</a>';
160 if ( isset($comment_content['property_id']) )
161 {
162 // 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.
163 $property = new PH_Property((int)$comment_content['property_id']);
164 // 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.
165 $note_body .= ' on <a href="' . get_edit_post_link($comment_content['property_id']) . '">' . $property->get_formatted_full_address() . '</a>';
166 }
167 break;
168 }
169 case "tenancy_booked":
170 {
171 // 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.
172 $note_body = '<a href="' . get_edit_post_link($comment_content['tenancy_id']) . '">Tenancy</a> created';
173 if ( isset($comment_content['property_id']) )
174 {
175 // 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.
176 $property = new PH_Property((int)$comment_content['property_id']);
177 // 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.
178 $note_body .= ' on <a href="' . get_edit_post_link($comment_content['property_id']) . '">' . $property->get_formatted_full_address() . '</a>';
179 }
180 break;
181 }
182 case "added_to_tenancy":
183 {
184 // 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.
185 $note_body = 'Added to <a href="' . get_edit_post_link($comment_content['tenancy_id']) . '">tenancy</a>';
186 if ( isset($comment_content['property_id']) )
187 {
188 // 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.
189 $property = new PH_Property((int)$comment_content['property_id']);
190 // 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.
191 $note_body .= ' on <a href="' . get_edit_post_link($comment_content['property_id']) . '">' . $property->get_formatted_full_address() . '</a>';
192 }
193 break;
194 }
195 case "removed_from_tenancy":
196 {
197 if (isset($comment_content['tenancy_id']))
198 {
199 // 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.
200 $note_body = 'Removed from <a href="' . get_edit_post_link($comment_content['tenancy_id']) . '">tenancy</a>';
201 }
202 else
203 {
204 // 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.
205 $note_body = '<a href="' . get_edit_post_link($comment_content['contact_id']) . '">' . get_the_title($comment_content['contact_id']) . '</a> removed from tenancy';
206 }
207 break;
208 }
209 default:
210 {
211 // 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.
212 $note_body = $comment_content['action'];
213 break;
214 }
215 }
216 break;
217 }
218 case "note":
219 {
220 // 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 $note_body = $comment_content['note'];
222
223 // Regular expression pattern to match {{mention-ID|NAME}} or {{mention-ID}}
224 // 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.
225 $pattern = '/\{\{mention-(\d+)(?:\|([^}]*))?\}\}/';
226
227 // Callback function to replace the mentions with HTML links
228 // 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.
229 $callback = function($matches)
230 {
231 $post_id = $matches[1];
232 $title = isset($matches[2]) ? $matches[2] : '';
233 $edit_url = get_edit_post_link($post_id);
234 $post_title = get_the_title($post_id);
235 if ( get_post_type($post_id) == 'property' )
236 {
237 $property = new PH_Property((int)$post_id);
238 $post_title = $property->get_formatted_full_address();
239 }
240
241 // If the post exists, create the link
242 if ( $edit_url && $post_title )
243 {
244 return '<a href="' . esc_url($edit_url) . '">' . esc_html($post_title) . '</a>';
245 }
246 else
247 {
248 if ( !empty($title) )
249 {
250 return $title;
251 }
252 else
253 {
254 return '{{mention-' . $post_id . '}}';
255 }
256 }
257 };
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.
260 $note_body = preg_replace_callback($pattern, $callback, $note_body);
261
262 /*$pattern = '/\{\{mention-(\d+)(\|.*)?\}\}/';
263 $replacement = function($matches) {
264 $post_id = $matches[1];
265 $title = trim(trim($matches[2], '|'));
266 $edit_url = get_edit_post_link($post_id);
267 $post_title = get_the_title($post_id);
268 if ( get_post_type($post_id) == 'property' )
269 {
270 $property = new PH_Property((int)$post_id);
271 $post_title = $property->get_formatted_full_address();
272 }
273
274 // If the post exists, create the link
275 if ( $edit_url && $post_title )
276 {
277 return '<a href="' . esc_url($edit_url) . '">' . esc_html($post_title) . '</a>';
278 }
279 else
280 {
281 if ( !empty($title) )
282 {
283 return $title;
284 }
285 else
286 {
287 return '{{mention-' . $post_id . '}}';
288 }
289 }
290 };
291 $note_body = preg_replace_callback($pattern, $replacement, $note_body);*/
292
293 // 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.
294 $note_body = nl2br($note_body);
295
296 break;
297 }
298 case "unsubscribe":
299 {
300 // 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.
301 $note_body = 'Contact unsubscribed themselves from emails';
302 break;
303 }
304 case "status_change": // Believe this is only used by maintenance jobs add on
305 {
306 // 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.
307 $note_body = 'Status changed from ' . $comment_content['previous_status'] . ' to ' . $comment_content['new_status'];
308 break;
309 }
310 default:
311 {
312 // 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.
313 $note_body = apply_filters( 'propertyhive_note_body', $note_body, $note );
314 }
315 }
316 // 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 $note_content = array(
318 'id' => $note->comment_ID,
319 'post_id' => $note->comment_post_ID,
320 'type' => $comment_content['note_type'],
321 'author' => $note->comment_author,
322 'body' => $note_body,
323 'timestamp' => strtotime($note->comment_date),
324 'internal' => true,
325 'pinned' => ( isset($comment_content['pinned']) && $comment_content['pinned'] == '1' ) ? '1' : '0',
326 );
327
328 if ( $note_content['pinned'] == '1' )
329 {
330 // 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.
331 $pinned_notes[] = $note_content;
332 }
333 else
334 {
335 // 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.
336 $unpinned_notes[] = $note_content;
337 }
338 }
339 }
340
341 // 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.
342 $note_output = array_merge($pinned_notes, $unpinned_notes);
343
344 if ($section != 'enquiry')
345 {
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.
347 $note_output = apply_filters( 'propertyhive_notes', $note_output, $post );
348 // 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.
349 $note_output = apply_filters( 'propertyhive_' . $section . '_notes', $note_output, $post );
350 }
351 ?>
352 <ul class="record_notes" style="max-height:300px; overflow-y:auto">
353 <?php
354 if ( !empty($note_output) )
355 {
356 // 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.
357 foreach ( $note_output as $key => $note )
358 {
359 // Set pinned parameter for any notes added by third party plugins
360 if ( !isset($note['pinned']) )
361 {
362 // 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.
363 $note_output[$key]['pinned'] = 0;
364 }
365 }
366
367 // 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.
368 $datetime_format = get_option('date_format')." \a\\t ".get_option('time_format');
369
370 // order by date desc. Older PHP versions don't support array_column so just can't order for them
371 if ( function_exists('array_column') )
372 {
373 // 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.
374 $pinned = array_column($note_output, 'pinned');
375 // 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.
376 $timestamp = array_column($note_output, 'timestamp');
377
378 array_multisort($pinned, SORT_DESC,
379 $timestamp, SORT_DESC,
380 $note_output);
381 }
382
383 // 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.
384 foreach ( $note_output as $note )
385 {
386 // 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.
387 $note_classes = array( 'note' );
388
389 // 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.
390 $note_classes[] = 'note-type-' . $note['type'];
391 ?>
392 <li rel="<?php echo absint( $note['id'] ) ; ?>" class="<?php echo esc_attr(implode( ' ', $note_classes )); ?>">
393 <div class="note_content<?php echo ($note['pinned'] == '1') ? ' pinned' : '' ?>">
394 <?php echo wp_kses_post( $note['body'] ); ?>
395 </div>
396 <p class="meta">
397 <abbr class="exact-date" title="<?php echo esc_attr(gmdate("Y-m-d H:i:s", $note['timestamp'])); ?>">
398 <?php
399
400 // 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.
401 $time_diff = current_time( 'timestamp', 1 ) - $note['timestamp'];
402
403 if ($time_diff > 86400) {
404 echo esc_html(gmdate( $datetime_format, $note['timestamp'] ));
405 } else {
406 /* translators: %s: Elapsed time. */
407 printf( esc_html__( '%s ago', 'propertyhive' ), esc_html( human_time_diff( $note['timestamp'], current_time( 'timestamp', 1 ) ) ) );
408 }
409 ?>
410 </abbr>
411 <?php
412 if ( !empty($note['author']) && $note['author'] !== 'Property Hive' )
413 {
414 printf(
415 /* translators: %s: author name */
416 esc_html__( 'by %s', 'propertyhive' ),
417 esc_html($note['author'])
418 );
419 }
420 ?>
421
422 <a href="#" data-section="<?php echo esc_attr($section); ?>" class="toggle_note_pinned"><?php echo ( $note['pinned'] == '0' ? esc_html__( 'Pin To Top', 'propertyhive' ) : esc_html__( 'Unpin', 'propertyhive' ) ); ?></a>
423
424 <?php if ( $note['type'] == 'note' ) { ?><a href="#" data-section="<?php echo esc_attr($section); ?>" class="delete_note"><?php echo esc_html(__( 'Delete', 'propertyhive' )); ?></a><?php } ?>
425 <?php
426 if ( $post->ID != $note['post_id'] )
427 {
428 echo '<br>';
429 $post_type_object = get_post_type_object( get_post_type( $note['post_id'] ) );
430 // 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.
431 $post_type_label = $post_type_object ? $post_type_object->labels->singular_name : get_post_type( $note['post_id'] );
432
433 printf(
434 /* translators: %s: linked post type label, for example "Property" */
435 esc_html__( 'Note originally entered on %s', 'propertyhive' ),
436 '<a href="' . esc_url( get_edit_post_link( $note['post_id'] ) ) . '" style="color:inherit;">' . esc_html( $post_type_label ) . '</a>'
437 );
438 }
439 ?>
440 </p>
441 </li>
442 <?php
443 }
444 }
445 ?>
446 <li id="no_notes" style="text-align:center;<?php echo (!empty($note_output)) ? 'display:none;' : ''; ?>"><?php if ( $propertyhive_pinned_only ) { echo esc_html(__( 'There are no pinned notes to display', 'propertyhive' )); }else{ echo esc_html(__( 'There are no notes to display', 'propertyhive' )); } ?></li>
447 </ul>
448
449 <?php if ( ! $propertyhive_has_pinned_filter ) { ?>
450 <div class="add_note">
451 <h4><?php esc_html_e( 'Add Note', 'propertyhive' ); ?></h4>
452 <p>
453 <textarea type="text" name="note" id="add_note" class="input-text" cols="20" rows="6" placeholder="Enter your note<?php if ( apply_filters('propertyhive_disable_notes_mention', false) === false ) { ?><br>Type <code style='background:#f9f9f9; border:1px solid #DDD; padding:0 2px; border-radius:5px; vertical-align:middle'>@</code> to tag a contact and property<?php } ?>"></textarea>
454 <br>
455 <input type="checkbox" name="pinned" id="pinned" value="1"> <?php echo esc_html(__( 'Pin Note', 'propertyhive' )); ?>
456 </p>
457 <p>
458 <a href="#" class="add_note button-primary" data-section="<?php echo esc_attr($section); ?>"><?php echo esc_html(__( 'Save Note', 'propertyhive' )); ?></a>
459 </p>
460 </div>
461 <?php } ?>