Flamingo - Version 2.0

Version Description

  • Displays spam logs in the Inbound Message editor page.
  • Displays reCAPTCHA logs in the Inbound Message editor page.
Download this release

Release Info

Developer takayukister
Plugin Icon 128x128 Flamingo
Version 2.0
Comparing to
See all releases

Code changes from version 1.9 to 2.0

admin/admin.php CHANGED
@@ -701,6 +701,11 @@ function flamingo_load_inbound_admin() {
701
  'flamingo_inbound_consent_meta_box', null, 'normal', 'core' );
702
  }
703
 
 
 
 
 
 
704
  if ( ! empty( $post->meta ) ) {
705
  add_meta_box( 'inboundmetadiv', __( 'Meta', 'flamingo' ),
706
  'flamingo_inbound_meta_meta_box', null, 'normal', 'core' );
701
  'flamingo_inbound_consent_meta_box', null, 'normal', 'core' );
702
  }
703
 
704
+ if ( ! empty( $post->recaptcha ) ) {
705
+ add_meta_box( 'inboundrecaptchadiv', __( 'reCAPTCHA', 'flamingo' ),
706
+ 'flamingo_inbound_recaptcha_meta_box', null, 'normal', 'core' );
707
+ }
708
+
709
  if ( ! empty( $post->meta ) ) {
710
  add_meta_box( 'inboundmetadiv', __( 'Meta', 'flamingo' ),
711
  'flamingo_inbound_meta_meta_box', null, 'normal', 'core' );
admin/css/style-rtl.css CHANGED
@@ -13,3 +13,8 @@ table.message-fields td.field-value li {
13
  .tablenav .actions input.button {
14
  margin: 1px 0 0 8px;
15
  }
 
 
 
 
 
13
  .tablenav .actions input.button {
14
  margin: 1px 0 0 8px;
15
  }
16
+
17
+ #misc-publishing-actions .spam-log .dashicons-before::before {
18
+ margin: 0 -1px 0 0;
19
+ padding: 0 0 0 3px;
20
+ }
admin/css/style.css CHANGED
@@ -47,3 +47,12 @@ table.message-fields td.field-value li {
47
  .tablenav .actions input.button {
48
  margin: 1px 8px 0 0;
49
  }
 
 
 
 
 
 
 
 
 
47
  .tablenav .actions input.button {
48
  margin: 1px 8px 0 0;
49
  }
50
+
51
+ #misc-publishing-actions .spam-log .dashicons-before::before {
52
+ position: relative;
53
+ top: -1px;
54
+ margin-left: -1px;
55
+ padding-right: 3px;
56
+ vertical-align: top;
57
+ color: #82878c;
58
+ }
admin/includes/class-contacts-list-table.php CHANGED
@@ -22,7 +22,7 @@ class Flamingo_Contacts_List_Table extends WP_List_Table {
22
  return $columns;
23
  }
24
 
25
- function __construct() {
26
  parent::__construct( array(
27
  'singular' => 'post',
28
  'plural' => 'posts',
@@ -30,12 +30,10 @@ class Flamingo_Contacts_List_Table extends WP_List_Table {
30
  ) );
31
  }
32
 
33
- function prepare_items() {
34
  $current_screen = get_current_screen();
35
  $per_page = $this->get_items_per_page( $current_screen->id . '_per_page' );
36
 
37
- $this->_column_headers = $this->get_column_info();
38
-
39
  $args = array(
40
  'posts_per_page' => $per_page,
41
  'offset' => ( $this->get_pagenum() - 1 ) * $per_page,
@@ -77,11 +75,11 @@ class Flamingo_Contacts_List_Table extends WP_List_Table {
77
  ) );
78
  }
79
 
80
- function get_columns() {
81
  return get_column_headers( get_current_screen() );
82
  }
83
 
84
- function get_sortable_columns() {
85
  $columns = array(
86
  'email' => array( 'email', false ),
87
  'full_name' => array( 'name', false ),
@@ -91,7 +89,7 @@ class Flamingo_Contacts_List_Table extends WP_List_Table {
91
  return $columns;
92
  }
93
 
94
- function get_bulk_actions() {
95
  $actions = array(
96
  'delete' => __( 'Delete', 'flamingo' ),
97
  );
@@ -99,7 +97,7 @@ class Flamingo_Contacts_List_Table extends WP_List_Table {
99
  return $actions;
100
  }
101
 
102
- function extra_tablenav( $which ) {
103
  $tag = 0;
104
 
105
  if ( ! empty( $_REQUEST['contact_tag_id'] ) ) {
@@ -107,7 +105,7 @@ class Flamingo_Contacts_List_Table extends WP_List_Table {
107
 
108
  $term = get_term( $tag_id[0], Flamingo_Contact::contact_tag_taxonomy );
109
 
110
- if ( ! empty( $term ) && ! is_wp_error( $term ) ) {
111
  $tag = $term->term_id;
112
  }
113
  }
@@ -136,63 +134,88 @@ class Flamingo_Contacts_List_Table extends WP_List_Table {
136
  <?php
137
  }
138
 
139
- function column_default( $item, $column_name ) {
140
  do_action( 'manage_flamingo_contact_posts_custom_column',
141
  $column_name, $item->id );
142
  }
143
 
144
- function column_cb( $item ) {
145
  return sprintf(
146
  '<input type="checkbox" name="%1$s[]" value="%2$s" />',
147
  $this->_args['singular'],
148
- $item->id );
 
149
  }
150
 
151
- function column_email( $item ) {
152
- $actions = array();
153
- $post_id = absint( $item->id );
154
-
155
  $edit_link = add_query_arg(
156
  array(
157
- 'post' => $post_id,
158
  'action' => 'edit',
159
  ),
160
  menu_page_url( 'flamingo', false )
161
  );
162
 
163
- if ( current_user_can( 'flamingo_edit_contact', $post_id ) ) {
164
- $actions['edit'] = sprintf( '<a href="%1$s">%2$s</a>',
165
- esc_url( $edit_link ), esc_html( __( 'Edit', 'flamingo' ) ) );
166
- }
167
-
168
- if ( current_user_can( 'flamingo_edit_contact', $post_id ) ) {
169
- return sprintf( '<strong><a class="row-title" href="%1$s" aria-label="%2$s">%3$s</a></strong> %4$s',
170
  esc_url( $edit_link ),
171
- esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;', 'flamingo' ), $item->email ) ),
172
- esc_html( $item->email ),
173
- $this->row_actions( $actions ) );
 
 
 
174
  } else {
175
- return sprintf( '<strong>%1$s</strong> %2$s',
176
- esc_html( $item->email ),
177
- $this->row_actions( $actions ) );
 
178
  }
179
  }
180
 
181
- function column_full_name( $item ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
182
  return esc_html( $item->name );
183
  }
184
 
185
- function column_tags( $item ) {
186
  if ( empty( $item->tags ) ) {
187
- return __( 'No Tags', 'flamingo' );
188
  }
189
 
190
  $output = '';
191
 
192
  foreach ( (array) $item->tags as $tag ) {
193
- $term = get_term_by( 'name', $tag, Flamingo_Contact::contact_tag_taxonomy );
 
194
 
195
- if ( empty( $term ) || is_wp_error( $term ) ) {
196
  continue;
197
  }
198
 
@@ -217,14 +240,18 @@ class Flamingo_Contacts_List_Table extends WP_List_Table {
217
  return $output;
218
  }
219
 
220
- function column_history( $item ) {
221
  $history = array();
222
 
223
  // User
224
  if ( $user = get_user_by( 'email', $item->email ) ) {
225
  $link = sprintf( 'user-edit.php?user_id=%d', $user->ID );
226
- $history[] = '<a href="' . admin_url( $link ) . '">'
227
- . esc_html( __( 'User', 'flamingo' ) ) . '</a>';
 
 
 
 
228
  }
229
 
230
  // Comment
@@ -237,14 +264,21 @@ class Flamingo_Contacts_List_Table extends WP_List_Table {
237
 
238
  if ( 0 < $comment_count ) {
239
  $link = sprintf( 'edit-comments.php?s=%s', urlencode( $item->email ) );
240
- $history[] = '<a href="' . admin_url( $link ) . '">'
241
- . sprintf( __( 'Comment (%d)', 'flamingo' ), $comment_count ) . '</a>';
 
 
 
 
 
 
 
242
  }
243
 
244
  // Contact channels
245
  $terms = get_terms( Flamingo_Inbound_Message::channel_taxonomy );
246
 
247
- if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) {
248
  foreach ( (array) $terms as $term ) {
249
  Flamingo_Inbound_Message::find( array(
250
  'channel' => $term->slug,
@@ -265,43 +299,49 @@ class Flamingo_Contacts_List_Table extends WP_List_Table {
265
  menu_page_url( 'flamingo_inbound', false )
266
  );
267
 
268
- $history[] = '<a href="' . esc_url( $link ) . '">'
269
- /* translators: 1: contact channel name, 2: contact count */
270
- . sprintf( _x( '%1$s (%2$d)', 'contact history', 'flamingo' ),
 
 
271
  $term->name,
272
- $count )
273
- . '</a>';
 
 
274
  }
275
  }
276
 
277
  $output = '';
278
 
279
  foreach ( $history as $item ) {
280
- $output .= '<li>' . $item . '</li>';
281
  }
282
 
283
- $output = '<ul class="contact-history">' . $output . '</ul>';
284
-
285
- return $output;
286
  }
287
 
288
- function column_last_contacted( $item ) {
289
  if ( empty( $item->last_contacted ) ) {
290
  return '';
291
  }
292
 
293
  $t_time = mysql2date( __( 'Y/m/d g:i:s A', 'flamingo' ), $item->last_contacted, true );
294
  $m_time = $item->last_contacted;
295
- $time = mysql2date( 'G', $item->last_contacted ) - get_option( 'gmt_offset' ) * 3600;
 
296
 
297
  $time_diff = time() - $time;
298
 
299
- if ( $time_diff > 0 && $time_diff < 24*60*60 ) {
300
  $h_time = sprintf( __( '%s ago', 'flamingo' ), human_time_diff( $time ) );
301
  } else {
302
  $h_time = mysql2date( __( 'Y/m/d', 'flamingo' ), $m_time );
303
  }
304
 
305
- return '<abbr aria-label="' . $t_time . '">' . $h_time . '</abbr>';
 
 
 
306
  }
307
  }
22
  return $columns;
23
  }
24
 
25
+ public function __construct() {
26
  parent::__construct( array(
27
  'singular' => 'post',
28
  'plural' => 'posts',
30
  ) );
31
  }
32
 
33
+ public function prepare_items() {
34
  $current_screen = get_current_screen();
35
  $per_page = $this->get_items_per_page( $current_screen->id . '_per_page' );
36
 
 
 
37
  $args = array(
38
  'posts_per_page' => $per_page,
39
  'offset' => ( $this->get_pagenum() - 1 ) * $per_page,
75
  ) );
76
  }
77
 
78
+ public function get_columns() {
79
  return get_column_headers( get_current_screen() );
80
  }
81
 
82
+ protected function get_sortable_columns() {
83
  $columns = array(
84
  'email' => array( 'email', false ),
85
  'full_name' => array( 'name', false ),
89
  return $columns;
90
  }
91
 
92
+ protected function get_bulk_actions() {
93
  $actions = array(
94
  'delete' => __( 'Delete', 'flamingo' ),
95
  );
97
  return $actions;
98
  }
99
 
100
+ protected function extra_tablenav( $which ) {
101
  $tag = 0;
102
 
103
  if ( ! empty( $_REQUEST['contact_tag_id'] ) ) {
105
 
106
  $term = get_term( $tag_id[0], Flamingo_Contact::contact_tag_taxonomy );
107
 
108
+ if ( ! empty( $term ) and ! is_wp_error( $term ) ) {
109
  $tag = $term->term_id;
110
  }
111
  }
134
  <?php
135
  }
136
 
137
+ protected function column_default( $item, $column_name ) {
138
  do_action( 'manage_flamingo_contact_posts_custom_column',
139
  $column_name, $item->id );
140
  }
141
 
142
+ protected function column_cb( $item ) {
143
  return sprintf(
144
  '<input type="checkbox" name="%1$s[]" value="%2$s" />',
145
  $this->_args['singular'],
146
+ $item->id
147
+ );
148
  }
149
 
150
+ protected function column_email( $item ) {
 
 
 
151
  $edit_link = add_query_arg(
152
  array(
153
+ 'post' => $item->id,
154
  'action' => 'edit',
155
  ),
156
  menu_page_url( 'flamingo', false )
157
  );
158
 
159
+ if ( current_user_can( 'flamingo_edit_contact', $item->id ) ) {
160
+ return sprintf(
161
+ '<strong><a class="row-title" href="%1$s" aria-label="%2$s">%3$s</a></strong>',
 
 
 
 
162
  esc_url( $edit_link ),
163
+ esc_attr( sprintf(
164
+ __( 'Edit &#8220;%s&#8221;', 'flamingo' ),
165
+ $item->email
166
+ ) ),
167
+ esc_html( $item->email )
168
+ );
169
  } else {
170
+ return sprintf(
171
+ '<strong>%1$s</strong>',
172
+ esc_html( $item->email )
173
+ );
174
  }
175
  }
176
 
177
+ protected function handle_row_actions( $item, $column_name, $primary ) {
178
+ if ( $column_name !== $primary ) {
179
+ return '';
180
+ }
181
+
182
+ $actions = array();
183
+
184
+ $link = add_query_arg(
185
+ array(
186
+ 'post' => $item->id,
187
+ 'action' => 'edit',
188
+ ),
189
+ menu_page_url( 'flamingo', false )
190
+ );
191
+
192
+ if ( current_user_can( 'flamingo_edit_contact', $item->id ) ) {
193
+ $actions['edit'] = sprintf(
194
+ '<a href="%1$s">%2$s</a>',
195
+ esc_url( $link ),
196
+ esc_html( __( 'Edit', 'flamingo' ) )
197
+ );
198
+ }
199
+
200
+ return $this->row_actions( $actions );
201
+ }
202
+
203
+ protected function column_full_name( $item ) {
204
  return esc_html( $item->name );
205
  }
206
 
207
+ protected function column_tags( $item ) {
208
  if ( empty( $item->tags ) ) {
209
+ return esc_html( __( 'No Tags', 'flamingo' ) );
210
  }
211
 
212
  $output = '';
213
 
214
  foreach ( (array) $item->tags as $tag ) {
215
+ $term = get_term_by( 'name', $tag,
216
+ Flamingo_Contact::contact_tag_taxonomy );
217
 
218
+ if ( empty( $term ) or is_wp_error( $term ) ) {
219
  continue;
220
  }
221
 
240
  return $output;
241
  }
242
 
243
+ protected function column_history( $item ) {
244
  $history = array();
245
 
246
  // User
247
  if ( $user = get_user_by( 'email', $item->email ) ) {
248
  $link = sprintf( 'user-edit.php?user_id=%d', $user->ID );
249
+
250
+ $history[] = sprintf(
251
+ '<a href="%2$s">%1$s</a>',
252
+ esc_html( __( 'User', 'flamingo' ) ),
253
+ admin_url( $link )
254
+ );
255
  }
256
 
257
  // Comment
264
 
265
  if ( 0 < $comment_count ) {
266
  $link = sprintf( 'edit-comments.php?s=%s', urlencode( $item->email ) );
267
+
268
+ $history[] = sprintf(
269
+ '<a href="%2$s">%1$s</a>',
270
+ esc_html( sprintf(
271
+ __( 'Comment (%d)', 'flamingo' ),
272
+ $comment_count
273
+ ) ),
274
+ admin_url( $link )
275
+ );
276
  }
277
 
278
  // Contact channels
279
  $terms = get_terms( Flamingo_Inbound_Message::channel_taxonomy );
280
 
281
+ if ( ! empty( $terms ) and ! is_wp_error( $terms ) ) {
282
  foreach ( (array) $terms as $term ) {
283
  Flamingo_Inbound_Message::find( array(
284
  'channel' => $term->slug,
299
  menu_page_url( 'flamingo_inbound', false )
300
  );
301
 
302
+ $history[] = sprintf(
303
+ '<a href="%2$s">%1$s</a>',
304
+ esc_html( sprintf(
305
+ /* translators: 1: contact channel name, 2: contact count */
306
+ _x( '%1$s (%2$d)', 'contact history', 'flamingo' ),
307
  $term->name,
308
+ $count
309
+ ) ),
310
+ esc_url( $link )
311
+ );
312
  }
313
  }
314
 
315
  $output = '';
316
 
317
  foreach ( $history as $item ) {
318
+ $output .= sprintf( '<li>%s</li>', $item );
319
  }
320
 
321
+ return sprintf( '<ul class="contact-history">%s</ul>', $output );
 
 
322
  }
323
 
324
+ protected function column_last_contacted( $item ) {
325
  if ( empty( $item->last_contacted ) ) {
326
  return '';
327
  }
328
 
329
  $t_time = mysql2date( __( 'Y/m/d g:i:s A', 'flamingo' ), $item->last_contacted, true );
330
  $m_time = $item->last_contacted;
331
+ $time = mysql2date( 'G', $item->last_contacted )
332
+ - get_option( 'gmt_offset' ) * 3600;
333
 
334
  $time_diff = time() - $time;
335
 
336
+ if ( $time_diff > 0 and $time_diff < 24*60*60 ) {
337
  $h_time = sprintf( __( '%s ago', 'flamingo' ), human_time_diff( $time ) );
338
  } else {
339
  $h_time = mysql2date( __( 'Y/m/d', 'flamingo' ), $m_time );
340
  }
341
 
342
+ return sprintf( '<abbr aria-label="%2$s">%1$s</abbr>',
343
+ esc_html( $h_time ),
344
+ esc_attr( $t_time )
345
+ );
346
  }
347
  }
admin/includes/class-inbound-messages-list-table.php CHANGED
@@ -24,7 +24,7 @@ class Flamingo_Inbound_Messages_List_Table extends WP_List_Table {
24
  return $columns;
25
  }
26
 
27
- function __construct() {
28
  parent::__construct( array(
29
  'singular' => 'post',
30
  'plural' => 'posts',
@@ -32,12 +32,10 @@ class Flamingo_Inbound_Messages_List_Table extends WP_List_Table {
32
  ) );
33
  }
34
 
35
- function prepare_items() {
36
  $current_screen = get_current_screen();
37
  $per_page = $this->get_items_per_page( $current_screen->id . '_per_page' );
38
 
39
- $this->_column_headers = $this->get_column_info();
40
-
41
  $args = array(
42
  'posts_per_page' => $per_page,
43
  'offset' => ( $this->get_pagenum() - 1 ) * $per_page,
@@ -60,7 +58,7 @@ class Flamingo_Inbound_Messages_List_Table extends WP_List_Table {
60
  }
61
 
62
  if ( ! empty( $_REQUEST['order'] )
63
- && 'asc' == strtolower( $_REQUEST['order'] ) ) {
64
  $args['order'] = 'ASC';
65
  }
66
 
@@ -98,20 +96,24 @@ class Flamingo_Inbound_Messages_List_Table extends WP_List_Table {
98
  ) );
99
  }
100
 
101
- function get_views() {
102
  $status_links = array();
103
  $post_status = empty( $_REQUEST['post_status'] )
104
  ? '' : $_REQUEST['post_status'];
105
 
106
  // Inbox
107
- Flamingo_Inbound_Message::find( array( 'post_status' => 'any' ) );
 
 
 
108
  $posts_in_inbox = Flamingo_Inbound_Message::$found_items;
109
 
110
  $inbox = sprintf(
111
  _nx( 'Inbox <span class="count">(%s)</span>',
112
  'Inbox <span class="count">(%s)</span>',
113
  $posts_in_inbox, 'posts', 'flamingo' ),
114
- number_format_i18n( $posts_in_inbox ) );
 
115
 
116
  $status_links['inbox'] = sprintf( '<a href="%1$s"%2$s>%3$s</a>',
117
  menu_page_url( 'flamingo_inbound', false ),
@@ -120,14 +122,17 @@ class Flamingo_Inbound_Messages_List_Table extends WP_List_Table {
120
 
121
  // Spam
122
  Flamingo_Inbound_Message::find( array(
123
- 'post_status' => Flamingo_Inbound_Message::spam_status ) );
 
 
124
  $posts_in_spam = Flamingo_Inbound_Message::$found_items;
125
 
126
  $spam = sprintf(
127
  _nx( 'Spam <span class="count">(%s)</span>',
128
  'Spam <span class="count">(%s)</span>',
129
  $posts_in_spam, 'posts', 'flamingo' ),
130
- number_format_i18n( $posts_in_spam ) );
 
131
 
132
  $status_links['spam'] = sprintf( '<a href="%1$s"%2$s>%3$s</a>',
133
  esc_url( add_query_arg(
@@ -141,7 +146,10 @@ class Flamingo_Inbound_Messages_List_Table extends WP_List_Table {
141
  );
142
 
143
  // Trash
144
- Flamingo_Inbound_Message::find( array( 'post_status' => 'trash' ) );
 
 
 
145
  $posts_in_trash = Flamingo_Inbound_Message::$found_items;
146
 
147
  if ( empty( $posts_in_trash ) ) {
@@ -152,7 +160,8 @@ class Flamingo_Inbound_Messages_List_Table extends WP_List_Table {
152
  _nx( 'Trash <span class="count">(%s)</span>',
153
  'Trash <span class="count">(%s)</span>',
154
  $posts_in_trash, 'posts', 'flamingo' ),
155
- number_format_i18n( $posts_in_trash ) );
 
156
 
157
  $status_links['trash'] = sprintf( '<a href="%1$s"%2$s>%3$s</a>',
158
  esc_url( add_query_arg(
@@ -162,16 +171,17 @@ class Flamingo_Inbound_Messages_List_Table extends WP_List_Table {
162
  menu_page_url( 'flamingo_inbound', false )
163
  ) ),
164
  'trash' == $post_status ? ' class="current"' : '',
165
- $trash );
 
166
 
167
  return $status_links;
168
  }
169
 
170
- function get_columns() {
171
  return get_column_headers( get_current_screen() );
172
  }
173
 
174
- function get_sortable_columns() {
175
  $columns = array(
176
  'subject' => array( 'subject', false ),
177
  'from' => array( 'from', false ),
@@ -181,14 +191,14 @@ class Flamingo_Inbound_Messages_List_Table extends WP_List_Table {
181
  return $columns;
182
  }
183
 
184
- function get_bulk_actions() {
185
  $actions = array();
186
 
187
  if ( $this->is_trash ) {
188
  $actions['untrash'] = __( 'Restore', 'flamingo' );
189
  }
190
 
191
- if ( $this->is_trash || ! EMPTY_TRASH_DAYS ) {
192
  $actions['delete'] = __( 'Delete Permanently', 'flamingo' );
193
  } else {
194
  $actions['trash'] = __( 'Move to Trash', 'flamingo' );
@@ -203,21 +213,24 @@ class Flamingo_Inbound_Messages_List_Table extends WP_List_Table {
203
  return $actions;
204
  }
205
 
206
- function extra_tablenav( $which ) {
207
  $channel = 0;
208
 
209
  if ( ! empty( $_REQUEST['channel_id'] ) ) {
210
- $term = get_term( $_REQUEST['channel_id'], Flamingo_Inbound_Message::channel_taxonomy );
 
 
211
 
212
- if ( ! empty( $term ) && ! is_wp_error( $term ) ) {
213
  $channel = $term->term_id;
214
  }
215
 
216
  } elseif ( ! empty( $_REQUEST['channel'] ) ) {
217
  $term = get_term_by( 'slug', $_REQUEST['channel'],
218
- Flamingo_Inbound_Message::channel_taxonomy );
 
219
 
220
- if ( ! empty( $term ) && ! is_wp_error( $term ) ) {
221
  $channel = $term->term_id;
222
  }
223
  }
@@ -243,13 +256,14 @@ class Flamingo_Inbound_Messages_List_Table extends WP_List_Table {
243
  submit_button( __( 'Filter', 'flamingo' ),
244
  'secondary', false, false, array( 'id' => 'post-query-submit' ) );
245
 
246
- if ( ! $this->is_spam && ! $this->is_trash ) {
247
  submit_button( __( 'Export', 'flamingo' ),
248
  'secondary', 'export', false );
249
  }
250
  }
251
 
252
- if ( $this->is_trash && current_user_can( 'flamingo_delete_inbound_messages' ) ) {
 
253
  submit_button( __( 'Empty Trash', 'flamingo' ),
254
  'button-secondary apply', 'delete_all', false );
255
  }
@@ -258,78 +272,117 @@ class Flamingo_Inbound_Messages_List_Table extends WP_List_Table {
258
  <?php
259
  }
260
 
261
- function column_default( $item, $column_name ) {
262
  do_action( 'manage_flamingo_inbound_posts_custom_column',
263
  $column_name, $item->id );
264
  }
265
 
266
- function column_cb( $item ) {
267
  return sprintf(
268
  '<input type="checkbox" name="%1$s[]" value="%2$s" />',
269
  $this->_args['singular'],
270
- $item->id );
 
271
  }
272
 
273
- function column_subject( $item ) {
274
  if ( $this->is_trash ) {
275
- return '<strong>' . esc_html( $item->subject ) . '</strong>';
276
  }
277
 
278
- $actions = array();
279
- $post_id = absint( $item->id );
 
 
 
 
 
 
280
 
281
- $base_url = add_query_arg(
282
- array(
283
- 'post' => $post_id,
284
- ),
285
- menu_page_url( 'flamingo_inbound', false )
 
 
 
 
 
 
 
 
286
  );
 
287
 
288
- $edit_link = add_query_arg( array( 'action' => 'edit' ), $base_url );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
289
 
290
- if ( current_user_can( 'flamingo_edit_inbound_message', $post_id ) ) {
291
  $actions['edit'] = sprintf( '<a href="%1$s">%2$s</a>',
292
- esc_url( $edit_link ), esc_html( __( 'View', 'flamingo' ) ) );
 
 
293
  }
294
 
295
  if ( $item->spam
296
- && current_user_can( 'flamingo_unspam_inbound_message', $post_id ) ) {
297
- $link = add_query_arg( array( 'action' => 'unspam' ), $base_url );
 
 
 
 
 
 
 
298
  $link = wp_nonce_url( $link,
299
- 'flamingo-unspam-inbound-message_' . $post_id );
300
 
301
  $actions['unspam'] = sprintf( '<a href="%1$s">%2$s</a>',
302
- esc_url( $link ), esc_html( __( 'Not Spam', 'flamingo' ) ) );
 
 
303
  }
304
 
305
  if ( ! $item->spam
306
- && current_user_can( 'flamingo_spam_inbound_message', $post_id ) ) {
307
- $link = add_query_arg( array( 'action' => 'spam' ), $base_url );
 
 
 
 
 
 
 
308
  $link = wp_nonce_url( $link,
309
- 'flamingo-spam-inbound-message_' . $post_id );
310
 
311
  $actions['spam'] = sprintf( '<a href="%1$s">%2$s</a>',
312
- esc_url( $link ), esc_html( __( 'Spam', 'flamingo' ) ) );
 
 
313
  }
314
 
315
- if ( current_user_can( 'flamingo_edit_inbound_message', $post_id ) ) {
316
- return sprintf( '<strong><a class="row-title" href="%1$s" aria-label="%2$s">%3$s</a></strong> %4$s',
317
- esc_url( $edit_link ),
318
- esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;', 'flamingo' ), $item->subject ) ),
319
- esc_html( $item->subject ),
320
- $this->row_actions( $actions ) );
321
- } else {
322
- return sprintf( '<strong>%1$s</strong> %2$s',
323
- esc_html( $item->subject ),
324
- $this->row_actions( $actions ) );
325
- }
326
  }
327
 
328
- function column_from( $item ) {
329
  return esc_html( $item->from );
330
  }
331
 
332
- function column_channel( $item ) {
333
  if ( empty( $item->channel ) ) {
334
  return '';
335
  }
@@ -337,7 +390,7 @@ class Flamingo_Inbound_Messages_List_Table extends WP_List_Table {
337
  $term = get_term_by( 'slug', $item->channel,
338
  Flamingo_Inbound_Message::channel_taxonomy );
339
 
340
- if ( empty( $term ) || is_wp_error( $term ) ) {
341
  return $item->channel;
342
  }
343
 
@@ -349,7 +402,7 @@ class Flamingo_Inbound_Messages_List_Table extends WP_List_Table {
349
  while ( $parent = array_pop( $ancestors ) ) {
350
  $parent = get_term( $parent, Flamingo_Inbound_Message::channel_taxonomy );
351
 
352
- if ( empty( $parent ) || is_wp_error( $parent ) ) {
353
  continue;
354
  }
355
 
@@ -383,7 +436,7 @@ class Flamingo_Inbound_Messages_List_Table extends WP_List_Table {
383
  return $output;
384
  }
385
 
386
- function column_date( $item ) {
387
  $post = get_post( $item->id );
388
 
389
  if ( ! $post ) {
@@ -396,12 +449,15 @@ class Flamingo_Inbound_Messages_List_Table extends WP_List_Table {
396
 
397
  $time_diff = time() - $time;
398
 
399
- if ( $time_diff > 0 && $time_diff < 24*60*60 ) {
400
  $h_time = sprintf( __( '%s ago', 'flamingo' ), human_time_diff( $time ) );
401
  } else {
402
  $h_time = mysql2date( __( 'Y/m/d', 'flamingo' ), $m_time );
403
  }
404
 
405
- return '<abbr aria-label="' . $t_time . '">' . $h_time . '</abbr>';
 
 
 
406
  }
407
  }
24
  return $columns;
25
  }
26
 
27
+ public function __construct() {
28
  parent::__construct( array(
29
  'singular' => 'post',
30
  'plural' => 'posts',
32
  ) );
33
  }
34
 
35
+ public function prepare_items() {
36
  $current_screen = get_current_screen();
37
  $per_page = $this->get_items_per_page( $current_screen->id . '_per_page' );
38
 
 
 
39
  $args = array(
40
  'posts_per_page' => $per_page,
41
  'offset' => ( $this->get_pagenum() - 1 ) * $per_page,
58
  }
59
 
60
  if ( ! empty( $_REQUEST['order'] )
61
+ and 'asc' == strtolower( $_REQUEST['order'] ) ) {
62
  $args['order'] = 'ASC';
63
  }
64
 
96
  ) );
97
  }
98
 
99
+ protected function get_views() {
100
  $status_links = array();
101
  $post_status = empty( $_REQUEST['post_status'] )
102
  ? '' : $_REQUEST['post_status'];
103
 
104
  // Inbox
105
+ Flamingo_Inbound_Message::find( array(
106
+ 'post_status' => 'any',
107
+ ) );
108
+
109
  $posts_in_inbox = Flamingo_Inbound_Message::$found_items;
110
 
111
  $inbox = sprintf(
112
  _nx( 'Inbox <span class="count">(%s)</span>',
113
  'Inbox <span class="count">(%s)</span>',
114
  $posts_in_inbox, 'posts', 'flamingo' ),
115
+ number_format_i18n( $posts_in_inbox )
116
+ );
117
 
118
  $status_links['inbox'] = sprintf( '<a href="%1$s"%2$s>%3$s</a>',
119
  menu_page_url( 'flamingo_inbound', false ),
122
 
123
  // Spam
124
  Flamingo_Inbound_Message::find( array(
125
+ 'post_status' => Flamingo_Inbound_Message::spam_status,
126
+ ) );
127
+
128
  $posts_in_spam = Flamingo_Inbound_Message::$found_items;
129
 
130
  $spam = sprintf(
131
  _nx( 'Spam <span class="count">(%s)</span>',
132
  'Spam <span class="count">(%s)</span>',
133
  $posts_in_spam, 'posts', 'flamingo' ),
134
+ number_format_i18n( $posts_in_spam )
135
+ );
136
 
137
  $status_links['spam'] = sprintf( '<a href="%1$s"%2$s>%3$s</a>',
138
  esc_url( add_query_arg(
146
  );
147
 
148
  // Trash
149
+ Flamingo_Inbound_Message::find( array(
150
+ 'post_status' => 'trash',
151
+ ) );
152
+
153
  $posts_in_trash = Flamingo_Inbound_Message::$found_items;
154
 
155
  if ( empty( $posts_in_trash ) ) {
160
  _nx( 'Trash <span class="count">(%s)</span>',
161
  'Trash <span class="count">(%s)</span>',
162
  $posts_in_trash, 'posts', 'flamingo' ),
163
+ number_format_i18n( $posts_in_trash )
164
+ );
165
 
166
  $status_links['trash'] = sprintf( '<a href="%1$s"%2$s>%3$s</a>',
167
  esc_url( add_query_arg(
171
  menu_page_url( 'flamingo_inbound', false )
172
  ) ),
173
  'trash' == $post_status ? ' class="current"' : '',
174
+ $trash
175
+ );
176
 
177
  return $status_links;
178
  }
179
 
180
+ public function get_columns() {
181
  return get_column_headers( get_current_screen() );
182
  }
183
 
184
+ protected function get_sortable_columns() {
185
  $columns = array(
186
  'subject' => array( 'subject', false ),
187
  'from' => array( 'from', false ),
191
  return $columns;
192
  }
193
 
194
+ protected function get_bulk_actions() {
195
  $actions = array();
196
 
197
  if ( $this->is_trash ) {
198
  $actions['untrash'] = __( 'Restore', 'flamingo' );
199
  }
200
 
201
+ if ( $this->is_trash or ! EMPTY_TRASH_DAYS ) {
202
  $actions['delete'] = __( 'Delete Permanently', 'flamingo' );
203
  } else {
204
  $actions['trash'] = __( 'Move to Trash', 'flamingo' );
213
  return $actions;
214
  }
215
 
216
+ protected function extra_tablenav( $which ) {
217
  $channel = 0;
218
 
219
  if ( ! empty( $_REQUEST['channel_id'] ) ) {
220
+ $term = get_term( $_REQUEST['channel_id'],
221
+ Flamingo_Inbound_Message::channel_taxonomy
222
+ );
223
 
224
+ if ( ! empty( $term ) and ! is_wp_error( $term ) ) {
225
  $channel = $term->term_id;
226
  }
227
 
228
  } elseif ( ! empty( $_REQUEST['channel'] ) ) {
229
  $term = get_term_by( 'slug', $_REQUEST['channel'],
230
+ Flamingo_Inbound_Message::channel_taxonomy
231
+ );
232
 
233
+ if ( ! empty( $term ) and ! is_wp_error( $term ) ) {
234
  $channel = $term->term_id;
235
  }
236
  }
256
  submit_button( __( 'Filter', 'flamingo' ),
257
  'secondary', false, false, array( 'id' => 'post-query-submit' ) );
258
 
259
+ if ( ! $this->is_spam and ! $this->is_trash ) {
260
  submit_button( __( 'Export', 'flamingo' ),
261
  'secondary', 'export', false );
262
  }
263
  }
264
 
265
+ if ( $this->is_trash
266
+ and current_user_can( 'flamingo_delete_inbound_messages' ) ) {
267
  submit_button( __( 'Empty Trash', 'flamingo' ),
268
  'button-secondary apply', 'delete_all', false );
269
  }
272
  <?php
273
  }
274
 
275
+ protected function column_default( $item, $column_name ) {
276
  do_action( 'manage_flamingo_inbound_posts_custom_column',
277
  $column_name, $item->id );
278
  }
279
 
280
+ protected function column_cb( $item ) {
281
  return sprintf(
282
  '<input type="checkbox" name="%1$s[]" value="%2$s" />',
283
  $this->_args['singular'],
284
+ $item->id
285
+ );
286
  }
287
 
288
+ protected function column_subject( $item ) {
289
  if ( $this->is_trash ) {
290
+ return sprintf( '<strong>%s</strong>', esc_html( $item->subject ) );
291
  }
292
 
293
+ if ( current_user_can( 'flamingo_edit_inbound_message', $item->id ) ) {
294
+ $edit_link = add_query_arg(
295
+ array(
296
+ 'post' => $item->id,
297
+ 'action' => 'edit',
298
+ ),
299
+ menu_page_url( 'flamingo_inbound', false )
300
+ );
301
 
302
+ return sprintf(
303
+ '<strong><a class="row-title" href="%1$s" aria-label="%2$s">%3$s</a></strong>',
304
+ esc_url( $edit_link ),
305
+ esc_attr( sprintf(
306
+ __( 'Edit &#8220;%s&#8221;', 'flamingo' ),
307
+ $item->subject
308
+ ) ),
309
+ esc_html( $item->subject )
310
+ );
311
+ }
312
+
313
+ return sprintf( '<strong>%1$s</strong>',
314
+ esc_html( $item->subject )
315
  );
316
+ }
317
 
318
+ protected function handle_row_actions( $item, $column_name, $primary ) {
319
+ if ( $column_name !== $primary ) {
320
+ return '';
321
+ }
322
+
323
+ $actions = array();
324
+
325
+ if ( current_user_can( 'flamingo_edit_inbound_message', $item->id ) ) {
326
+ $link = add_query_arg(
327
+ array(
328
+ 'post' => $item->id,
329
+ 'action' => 'edit',
330
+ ),
331
+ menu_page_url( 'flamingo_inbound', false )
332
+ );
333
 
 
334
  $actions['edit'] = sprintf( '<a href="%1$s">%2$s</a>',
335
+ esc_url( $link ),
336
+ esc_html( __( 'View', 'flamingo' ) )
337
+ );
338
  }
339
 
340
  if ( $item->spam
341
+ and current_user_can( 'flamingo_unspam_inbound_message', $item->id ) ) {
342
+ $link = add_query_arg(
343
+ array(
344
+ 'post' => $item->id,
345
+ 'action' => 'unspam',
346
+ ),
347
+ menu_page_url( 'flamingo_inbound', false )
348
+ );
349
+
350
  $link = wp_nonce_url( $link,
351
+ 'flamingo-unspam-inbound-message_' . $item->id );
352
 
353
  $actions['unspam'] = sprintf( '<a href="%1$s">%2$s</a>',
354
+ esc_url( $link ),
355
+ esc_html( __( 'Not Spam', 'flamingo' ) )
356
+ );
357
  }
358
 
359
  if ( ! $item->spam
360
+ and current_user_can( 'flamingo_spam_inbound_message', $item->id ) ) {
361
+ $link = add_query_arg(
362
+ array(
363
+ 'post' => $item->id,
364
+ 'action' => 'spam',
365
+ ),
366
+ menu_page_url( 'flamingo_inbound', false )
367
+ );
368
+
369
  $link = wp_nonce_url( $link,
370
+ 'flamingo-spam-inbound-message_' . $item->id );
371
 
372
  $actions['spam'] = sprintf( '<a href="%1$s">%2$s</a>',
373
+ esc_url( $link ),
374
+ esc_html( __( 'Spam', 'flamingo' ) )
375
+ );
376
  }
377
 
378
+ return $this->row_actions( $actions );
 
 
 
 
 
 
 
 
 
 
379
  }
380
 
381
+ protected function column_from( $item ) {
382
  return esc_html( $item->from );
383
  }
384
 
385
+ protected function column_channel( $item ) {
386
  if ( empty( $item->channel ) ) {
387
  return '';
388
  }
390
  $term = get_term_by( 'slug', $item->channel,
391
  Flamingo_Inbound_Message::channel_taxonomy );
392
 
393
+ if ( empty( $term ) or is_wp_error( $term ) ) {
394
  return $item->channel;
395
  }
396
 
402
  while ( $parent = array_pop( $ancestors ) ) {
403
  $parent = get_term( $parent, Flamingo_Inbound_Message::channel_taxonomy );
404
 
405
+ if ( empty( $parent ) or is_wp_error( $parent ) ) {
406
  continue;
407
  }
408
 
436
  return $output;
437
  }
438
 
439
+ protected function column_date( $item ) {
440
  $post = get_post( $item->id );
441
 
442
  if ( ! $post ) {
449
 
450
  $time_diff = time() - $time;
451
 
452
+ if ( $time_diff > 0 and $time_diff < 24*60*60 ) {
453
  $h_time = sprintf( __( '%s ago', 'flamingo' ), human_time_diff( $time ) );
454
  } else {
455
  $h_time = mysql2date( __( 'Y/m/d', 'flamingo' ), $m_time );
456
  }
457
 
458
+ return sprintf( '<abbr aria-label="%2$s">%1$s</abbr>',
459
+ esc_html( $h_time ),
460
+ esc_attr( $t_time )
461
+ );
462
  }
463
  }
admin/includes/class-outbound-messages-list-table.php CHANGED
@@ -22,7 +22,7 @@ class Flamingo_Outbound_Messages_List_Table extends WP_List_Table {
22
  return $columns;
23
  }
24
 
25
- function __construct() {
26
  parent::__construct( array(
27
  'singular' => 'post',
28
  'plural' => 'posts',
@@ -30,12 +30,10 @@ class Flamingo_Outbound_Messages_List_Table extends WP_List_Table {
30
  ) );
31
  }
32
 
33
- function prepare_items() {
34
  $current_screen = get_current_screen();
35
  $per_page = $this->get_items_per_page( $current_screen->id . '_per_page' );
36
 
37
- $this->_column_headers = $this->get_column_info();
38
-
39
  $args = array(
40
  'posts_per_page' => $per_page,
41
  'offset' => ( $this->get_pagenum() - 1 ) * $per_page,
@@ -85,7 +83,7 @@ class Flamingo_Outbound_Messages_List_Table extends WP_List_Table {
85
  ) );
86
  }
87
 
88
- function get_views() {
89
  $status_links = array();
90
  $post_status = empty( $_REQUEST['post_status'] )
91
  ? '' : $_REQUEST['post_status'];
@@ -132,11 +130,11 @@ class Flamingo_Outbound_Messages_List_Table extends WP_List_Table {
132
  return $status_links;
133
  }
134
 
135
- function get_columns() {
136
  return get_column_headers( get_current_screen() );
137
  }
138
 
139
- function get_sortable_columns() {
140
  $columns = array(
141
  'subject' => array( 'subject', false ),
142
  'from' => array( 'from', false ),
@@ -146,14 +144,14 @@ class Flamingo_Outbound_Messages_List_Table extends WP_List_Table {
146
  return $columns;
147
  }
148
 
149
- function get_bulk_actions() {
150
  $actions = array();
151
 
152
  if ( $this->is_trash ) {
153
  $actions['untrash'] = __( 'Restore', 'flamingo' );
154
  }
155
 
156
- if ( $this->is_trash || ! EMPTY_TRASH_DAYS ) {
157
  $actions['delete'] = __( 'Delete Permanently', 'flamingo' );
158
  } else {
159
  $actions['trash'] = __( 'Move to Trash', 'flamingo' );
@@ -162,7 +160,7 @@ class Flamingo_Outbound_Messages_List_Table extends WP_List_Table {
162
  return $actions;
163
  }
164
 
165
- function extra_tablenav( $which ) {
166
  ?>
167
  <div class="alignleft actions">
168
  <?php
@@ -173,7 +171,8 @@ class Flamingo_Outbound_Messages_List_Table extends WP_List_Table {
173
  'secondary', false, false, array( 'id' => 'post-query-submit' ) );
174
  }
175
 
176
- if ( $this->is_trash && current_user_can( 'flamingo_delete_outbound_messages' ) ) {
 
177
  submit_button( __( 'Empty Trash', 'flamingo' ),
178
  'button-secondary apply', 'delete_all', false );
179
  }
@@ -182,19 +181,19 @@ class Flamingo_Outbound_Messages_List_Table extends WP_List_Table {
182
  <?php
183
  }
184
 
185
- function column_default( $item, $column_name ) {
186
  do_action( 'manage_flamingo_outbound_posts_custom_column',
187
  $column_name, $item->id );
188
  }
189
 
190
- function column_cb( $item ) {
191
  return sprintf(
192
  '<input type="checkbox" name="%1$s[]" value="%2$s" />',
193
  $this->_args['singular'],
194
  $item->id );
195
  }
196
 
197
- function column_subject( $item ) {
198
  if ( $this->is_trash ) {
199
  return '<strong>' . esc_html( $item->subject ) . '</strong>';
200
  }
@@ -228,11 +227,11 @@ class Flamingo_Outbound_Messages_List_Table extends WP_List_Table {
228
  }
229
  }
230
 
231
- function column_from( $item ) {
232
  return esc_html( $item->from );
233
  }
234
 
235
- function column_date( $item ) {
236
  $post = get_post( $item->id );
237
 
238
  if ( ! $post ) {
@@ -251,6 +250,9 @@ class Flamingo_Outbound_Messages_List_Table extends WP_List_Table {
251
  $h_time = mysql2date( __( 'Y/m/d', 'flamingo' ), $m_time );
252
  }
253
 
254
- return '<abbr aria-label="' . $t_time . '">' . $h_time . '</abbr>';
 
 
 
255
  }
256
  }
22
  return $columns;
23
  }
24
 
25
+ public function __construct() {
26
  parent::__construct( array(
27
  'singular' => 'post',
28
  'plural' => 'posts',
30
  ) );
31
  }
32
 
33
+ public function prepare_items() {
34
  $current_screen = get_current_screen();
35
  $per_page = $this->get_items_per_page( $current_screen->id . '_per_page' );
36
 
 
 
37
  $args = array(
38
  'posts_per_page' => $per_page,
39
  'offset' => ( $this->get_pagenum() - 1 ) * $per_page,
83
  ) );
84
  }
85
 
86
+ protected function get_views() {
87
  $status_links = array();
88
  $post_status = empty( $_REQUEST['post_status'] )
89
  ? '' : $_REQUEST['post_status'];
130
  return $status_links;
131
  }
132
 
133
+ public function get_columns() {
134
  return get_column_headers( get_current_screen() );
135
  }
136
 
137
+ protected function get_sortable_columns() {
138
  $columns = array(
139
  'subject' => array( 'subject', false ),
140
  'from' => array( 'from', false ),
144
  return $columns;
145
  }
146
 
147
+ protected function get_bulk_actions() {
148
  $actions = array();
149
 
150
  if ( $this->is_trash ) {
151
  $actions['untrash'] = __( 'Restore', 'flamingo' );
152
  }
153
 
154
+ if ( $this->is_trash or ! EMPTY_TRASH_DAYS ) {
155
  $actions['delete'] = __( 'Delete Permanently', 'flamingo' );
156
  } else {
157
  $actions['trash'] = __( 'Move to Trash', 'flamingo' );
160
  return $actions;
161
  }
162
 
163
+ protected function extra_tablenav( $which ) {
164
  ?>
165
  <div class="alignleft actions">
166
  <?php
171
  'secondary', false, false, array( 'id' => 'post-query-submit' ) );
172
  }
173
 
174
+ if ( $this->is_trash
175
+ and current_user_can( 'flamingo_delete_outbound_messages' ) ) {
176
  submit_button( __( 'Empty Trash', 'flamingo' ),
177
  'button-secondary apply', 'delete_all', false );
178
  }
181
  <?php
182
  }
183
 
184
+ protected function column_default( $item, $column_name ) {
185
  do_action( 'manage_flamingo_outbound_posts_custom_column',
186
  $column_name, $item->id );
187
  }
188
 
189
+ protected function column_cb( $item ) {
190
  return sprintf(
191
  '<input type="checkbox" name="%1$s[]" value="%2$s" />',
192
  $this->_args['singular'],
193
  $item->id );
194
  }
195
 
196
+ protected function column_subject( $item ) {
197
  if ( $this->is_trash ) {
198
  return '<strong>' . esc_html( $item->subject ) . '</strong>';
199
  }
227
  }
228
  }
229
 
230
+ protected function column_from( $item ) {
231
  return esc_html( $item->from );
232
  }
233
 
234
+ protected function column_date( $item ) {
235
  $post = get_post( $item->id );
236
 
237
  if ( ! $post ) {
250
  $h_time = mysql2date( __( 'Y/m/d', 'flamingo' ), $m_time );
251
  }
252
 
253
+ return sprintf( '<abbr aria-label="%2$s">%1$s</abbr>',
254
+ esc_html( $h_time ),
255
+ esc_attr( $t_time )
256
+ );
257
  }
258
  }
admin/includes/meta-boxes.php CHANGED
@@ -131,6 +131,32 @@ function flamingo_inbound_submit_meta_box( $post ) {
131
  ?>
132
  </span>
133
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
  </div><!-- #misc-publishing-actions -->
135
 
136
  <div class="clear"></div>
@@ -242,6 +268,23 @@ function flamingo_inbound_consent_meta_box( $post ) {
242
  <?php
243
  }
244
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
245
  function flamingo_inbound_meta_meta_box( $post ) {
246
  ?>
247
  <table class="widefat message-fields striped">
131
  ?>
132
  </span>
133
  </div>
134
+ <?php
135
+ if ( ! empty( $post->spam_log ) ) {
136
+ echo '<div class="misc-pub-section spam-log">', "\n";
137
+
138
+ foreach ( (array) $post->spam_log as $log ) {
139
+ $agent = isset( $log['agent'] ) ? trim( $log['agent'] ) : '';
140
+ $reason = isset( $log['reason'] ) ? trim( $log['reason'] ) : '';
141
+
142
+ if ( '' !== $reason ) {
143
+ $reason = sprintf(
144
+ /* translators: %s: reason why this message is regarded as spam */
145
+ __( 'Spam log: %s', 'flamingo' ),
146
+ $reason
147
+ );
148
+
149
+ echo sprintf(
150
+ '<span class="dashicons-before dashicons-shield %1$s"> %2$s</span>',
151
+ esc_attr( $agent ),
152
+ esc_html( $reason )
153
+ );
154
+ }
155
+ }
156
+
157
+ echo '</div>', "\n";
158
+ }
159
+ ?>
160
  </div><!-- #misc-publishing-actions -->
161
 
162
  <div class="clear"></div>
268
  <?php
269
  }
270
 
271
+ function flamingo_inbound_recaptcha_meta_box( $post ) {
272
+ ?>
273
+ <table class="widefat message-fields striped">
274
+ <tbody>
275
+
276
+ <?php foreach ( (array) $post->recaptcha as $key => $value ) : ?>
277
+ <tr>
278
+ <td class="field-title"><?php echo esc_html( $key ); ?></td>
279
+ <td class="field-value"><?php echo esc_html( json_encode( $value ) ); ?></td>
280
+ </tr>
281
+ <?php endforeach; ?>
282
+
283
+ </tbody>
284
+ </table>
285
+ <?php
286
+ }
287
+
288
  function flamingo_inbound_meta_meta_box( $post ) {
289
  ?>
290
  <table class="widefat message-fields striped">
flamingo.php CHANGED
@@ -5,10 +5,10 @@ Description: A trustworthy message storage plugin for Contact Form 7.
5
  Author: Takayuki Miyoshi
6
  Text Domain: flamingo
7
  Domain Path: /languages/
8
- Version: 1.9
9
  */
10
 
11
- define( 'FLAMINGO_VERSION', '1.9' );
12
 
13
  define( 'FLAMINGO_PLUGIN', __FILE__ );
14
 
5
  Author: Takayuki Miyoshi
6
  Text Domain: flamingo
7
  Domain Path: /languages/
8
+ Version: 2.0
9
  */
10
 
11
+ define( 'FLAMINGO_VERSION', '2.0' );
12
 
13
  define( 'FLAMINGO_PLUGIN', __FILE__ );
14
 
includes/class-inbound-message.php CHANGED
@@ -18,7 +18,9 @@ class Flamingo_Inbound_Message {
18
  public $fields;
19
  public $meta;
20
  public $akismet;
 
21
  public $spam;
 
22
  public $consent;
23
 
24
  public static function register_post_type() {
@@ -122,7 +124,9 @@ class Flamingo_Inbound_Message {
122
  'fields' => array(),
123
  'meta' => array(),
124
  'akismet' => array(),
 
125
  'spam' => false,
 
126
  'consent' => array(),
127
  );
128
 
@@ -139,14 +143,11 @@ class Flamingo_Inbound_Message {
139
  $obj->fields = $args['fields'];
140
  $obj->meta = $args['meta'];
141
  $obj->akismet = $args['akismet'];
 
 
 
142
  $obj->consent = $args['consent'];
143
 
144
- if ( $args['spam'] ) {
145
- $obj->spam = true;
146
- } else {
147
- $obj->spam = isset( $obj->akismet['spam'] ) && $obj->akismet['spam'];
148
- }
149
-
150
  $obj->save();
151
 
152
  return $obj;
@@ -178,6 +179,8 @@ class Flamingo_Inbound_Message {
178
 
179
  $this->meta = get_post_meta( $post->ID, '_meta', true );
180
  $this->akismet = get_post_meta( $post->ID, '_akismet', true );
 
 
181
  $this->consent = get_post_meta( $post->ID, '_consent', true );
182
 
183
  $terms = wp_get_object_terms( $this->id, self::channel_taxonomy );
@@ -219,6 +222,7 @@ class Flamingo_Inbound_Message {
219
  'post_status' => $post_status,
220
  'post_title' => $post_title,
221
  'post_content' => $post_content,
 
222
  );
223
 
224
  $post_id = wp_insert_post( $postarr );
@@ -239,6 +243,8 @@ class Flamingo_Inbound_Message {
239
  update_post_meta( $post_id, '_fields', $this->fields );
240
  update_post_meta( $post_id, '_meta', $this->meta );
241
  update_post_meta( $post_id, '_akismet', $this->akismet );
 
 
242
  update_post_meta( $post_id, '_consent', $this->consent );
243
 
244
  if ( term_exists( $this->channel, self::channel_taxonomy ) ) {
@@ -250,6 +256,20 @@ class Flamingo_Inbound_Message {
250
  return $post_id;
251
  }
252
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
253
  public function trash() {
254
  if ( empty( $this->id ) ) {
255
  return;
@@ -294,6 +314,25 @@ class Flamingo_Inbound_Message {
294
  $this->akismet_submit_spam();
295
  $this->spam = true;
296
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
297
  return $this->save();
298
  }
299
 
18
  public $fields;
19
  public $meta;
20
  public $akismet;
21
+ public $recaptcha;
22
  public $spam;
23
+ public $spam_log;
24
  public $consent;
25
 
26
  public static function register_post_type() {
124
  'fields' => array(),
125
  'meta' => array(),
126
  'akismet' => array(),
127
+ 'recaptcha' => array(),
128
  'spam' => false,
129
+ 'spam_log' => array(),
130
  'consent' => array(),
131
  );
132
 
143
  $obj->fields = $args['fields'];
144
  $obj->meta = $args['meta'];
145
  $obj->akismet = $args['akismet'];
146
+ $obj->recaptcha = $args['recaptcha'];
147
+ $obj->spam = $args['spam'];
148
+ $obj->spam_log = $args['spam_log'];
149
  $obj->consent = $args['consent'];
150
 
 
 
 
 
 
 
151
  $obj->save();
152
 
153
  return $obj;
179
 
180
  $this->meta = get_post_meta( $post->ID, '_meta', true );
181
  $this->akismet = get_post_meta( $post->ID, '_akismet', true );
182
+ $this->recaptcha = get_post_meta( $post->ID, '_recaptcha', true );
183
+ $this->spam_log = get_post_meta( $post->ID, '_spam_log', true );
184
  $this->consent = get_post_meta( $post->ID, '_consent', true );
185
 
186
  $terms = wp_get_object_terms( $this->id, self::channel_taxonomy );
222
  'post_status' => $post_status,
223
  'post_title' => $post_title,
224
  'post_content' => $post_content,
225
+ 'post_date' => $this->get_post_date(),
226
  );
227
 
228
  $post_id = wp_insert_post( $postarr );
243
  update_post_meta( $post_id, '_fields', $this->fields );
244
  update_post_meta( $post_id, '_meta', $this->meta );
245
  update_post_meta( $post_id, '_akismet', $this->akismet );
246
+ update_post_meta( $post_id, '_recaptcha', $this->recaptcha );
247
+ update_post_meta( $post_id, '_spam_log', $this->spam_log );
248
  update_post_meta( $post_id, '_consent', $this->consent );
249
 
250
  if ( term_exists( $this->channel, self::channel_taxonomy ) ) {
256
  return $post_id;
257
  }
258
 
259
+ private function get_post_date() {
260
+ if ( empty( $this->id ) ) {
261
+ return false;
262
+ }
263
+
264
+ $post = get_post( $this->id );
265
+
266
+ if ( ! $post ) {
267
+ return false;
268
+ }
269
+
270
+ return $post->post_date;
271
+ }
272
+
273
  public function trash() {
274
  if ( empty( $this->id ) ) {
275
  return;
314
  $this->akismet_submit_spam();
315
  $this->spam = true;
316
 
317
+ $user_name = get_user_option( 'user_login' );
318
+
319
+ if ( false === $user_name ) {
320
+ $user_name = __( 'Unknown', 'flamingo' );
321
+ }
322
+
323
+ if ( empty( $this->spam_log ) ) {
324
+ $this->spam_log = array();
325
+ }
326
+
327
+ $this->spam_log[] = array(
328
+ 'agent' => 'flamingo',
329
+ 'reason' => sprintf(
330
+ /* translators: %s: WordPress user name */
331
+ __( '%s has marked this message as spam.', 'flamingo' ),
332
+ $user_name
333
+ ),
334
+ );
335
+
336
  return $this->save();
337
  }
338
 
license.txt CHANGED
@@ -1,4 +1,4 @@
1
- Flamingo - WordPress Plugin, 2012-2018 Takayuki Miyoshi
2
  Flamingo is distributed under the terms of the GNU GPL
3
 
4
  This program is free software; you can redistribute it and/or modify
1
+ Flamingo - WordPress Plugin, 2012-2019 Takayuki Miyoshi
2
  Flamingo is distributed under the terms of the GNU GPL
3
 
4
  This program is free software; you can redistribute it and/or modify
readme.txt CHANGED
@@ -1,9 +1,9 @@
1
  === Flamingo ===
2
  Contributors: takayukister, megumithemes
3
  Tags: bird, contact, mail, crm
4
- Requires at least: 4.9
5
- Tested up to: 4.9
6
- Stable tag: 1.9
7
  License: GPLv2 or later
8
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -32,13 +32,13 @@ This plugin stores submission data collected through contact forms, which may in
32
 
33
  == Changelog ==
34
 
 
 
 
 
 
35
  = 1.9 =
36
 
37
  * The admin screen UI has been updated.
38
  * Enables to search Inbound Messages by keywords used in the Consent and Meta sections.
39
  * Introduces personal data eraser for Address Book and Inbound Messages data.
40
-
41
- = 1.8 =
42
-
43
- * Remove support for outdated Akismet APIs.
44
- * Take consent data through an inbound message.
1
  === Flamingo ===
2
  Contributors: takayukister, megumithemes
3
  Tags: bird, contact, mail, crm
4
+ Requires at least: 5.0
5
+ Tested up to: 5.2
6
+ Stable tag: 2.0
7
  License: GPLv2 or later
8
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
9
 
32
 
33
  == Changelog ==
34
 
35
+ = 2.0 =
36
+
37
+ * Displays spam logs in the Inbound Message editor page.
38
+ * Displays reCAPTCHA logs in the Inbound Message editor page.
39
+
40
  = 1.9 =
41
 
42
  * The admin screen UI has been updated.
43
  * Enables to search Inbound Messages by keywords used in the Consent and Meta sections.
44
  * Introduces personal data eraser for Address Book and Inbound Messages data.