Version Description
- Sets the
post_date
of an inbound message based on the submission timestamp. - Allows users to search and filter messages within the Spam subgroup.
- Changes the visibility of the
$found_items
property to private and introduces thecount()
method as an alternative. - Changes the visibility of the
$id
property to private and introduces theid()
method as an alternative. - Introduces the submission result in the inbound message viewer screen.
- Stores the
posted_data_hash
value for search.
Download this release
Release Info
Developer | takayukister |
Plugin | Flamingo |
Version | 2.2 |
Comparing to | |
See all releases |
Code changes from version 2.1.1 to 2.2
- admin/admin-functions.php +5 -3
- admin/admin.php +86 -56
- admin/css/style-rtl.css +1 -1
- admin/css/style.css +2 -2
- admin/edit-contact-form.php +6 -6
- admin/edit-inbound-form.php +5 -5
- admin/edit-outbound-form.php +5 -5
- admin/includes/class-contacts-list-table.php +33 -27
- admin/includes/class-inbound-messages-list-table.php +41 -43
- admin/includes/class-outbound-messages-list-table.php +26 -29
- admin/includes/meta-boxes.php +68 -25
- admin/includes/privacy.php +7 -5
- flamingo.php +4 -7
- includes/class-contact.php +42 -6
- includes/class-inbound-message.php +85 -26
- includes/class-outbound-message.php +39 -7
- includes/comment.php +7 -3
- includes/csv.php +3 -2
- includes/functions.php +2 -2
- includes/user.php +5 -3
- readme.txt +12 -8
admin/admin-functions.php
CHANGED
@@ -2,15 +2,17 @@
|
|
2 |
|
3 |
function flamingo_current_action() {
|
4 |
if ( isset( $_REQUEST['delete_all'] )
|
5 |
-
|
6 |
return 'delete_all';
|
7 |
}
|
8 |
|
9 |
-
if ( isset( $_REQUEST['action'] )
|
|
|
10 |
return $_REQUEST['action'];
|
11 |
}
|
12 |
|
13 |
-
if ( isset( $_REQUEST['action2'] )
|
|
|
14 |
return $_REQUEST['action2'];
|
15 |
}
|
16 |
|
2 |
|
3 |
function flamingo_current_action() {
|
4 |
if ( isset( $_REQUEST['delete_all'] )
|
5 |
+
or isset( $_REQUEST['delete_all2'] ) ) {
|
6 |
return 'delete_all';
|
7 |
}
|
8 |
|
9 |
+
if ( isset( $_REQUEST['action'] )
|
10 |
+
and -1 !== $_REQUEST['action'] ) {
|
11 |
return $_REQUEST['action'];
|
12 |
}
|
13 |
|
14 |
+
if ( isset( $_REQUEST['action2'] )
|
15 |
+
and -1 !== $_REQUEST['action2'] ) {
|
16 |
return $_REQUEST['action2'];
|
17 |
}
|
18 |
|
admin/admin.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
require_once FLAMINGO_PLUGIN_DIR . '/admin/admin-functions.php';
|
4 |
require_once FLAMINGO_PLUGIN_DIR . '/admin/includes/privacy.php';
|
5 |
|
6 |
-
add_action( 'admin_menu', 'flamingo_admin_menu', 8 );
|
7 |
|
8 |
function flamingo_admin_menu() {
|
9 |
global $_wp_last_object_menu;
|
@@ -15,31 +15,47 @@ function flamingo_admin_menu() {
|
|
15 |
__( 'Flamingo', 'flamingo' ),
|
16 |
'flamingo_edit_contacts', 'flamingo',
|
17 |
'flamingo_contact_admin_page', 'dashicons-feedback',
|
18 |
-
$_wp_last_object_menu
|
|
|
19 |
|
20 |
$contact_admin = add_submenu_page( 'flamingo',
|
21 |
__( 'Flamingo Address Book', 'flamingo' ),
|
22 |
__( 'Address Book', 'flamingo' ),
|
23 |
'flamingo_edit_contacts', 'flamingo',
|
24 |
-
'flamingo_contact_admin_page'
|
|
|
25 |
|
26 |
-
add_action( 'load-' . $contact_admin, 'flamingo_load_contact_admin' );
|
27 |
|
28 |
$inbound_admin = add_submenu_page( 'flamingo',
|
29 |
__( 'Flamingo Inbound Messages', 'flamingo' ),
|
30 |
__( 'Inbound Messages', 'flamingo' ),
|
31 |
'flamingo_edit_inbound_messages', 'flamingo_inbound',
|
32 |
-
'flamingo_inbound_admin_page'
|
|
|
33 |
|
34 |
-
add_action( 'load-' . $inbound_admin, 'flamingo_load_inbound_admin' );
|
35 |
}
|
36 |
|
37 |
add_filter( 'set-screen-option', 'flamingo_set_screen_options', 10, 3 );
|
38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
function flamingo_set_screen_options( $result, $option, $value ) {
|
40 |
$flamingo_screens = array(
|
41 |
-
'
|
42 |
-
'
|
|
|
43 |
);
|
44 |
|
45 |
if ( in_array( $option, $flamingo_screens ) ) {
|
@@ -49,7 +65,7 @@ function flamingo_set_screen_options( $result, $option, $value ) {
|
|
49 |
return $result;
|
50 |
}
|
51 |
|
52 |
-
add_action( 'admin_enqueue_scripts', 'flamingo_admin_enqueue_scripts' );
|
53 |
|
54 |
function flamingo_admin_enqueue_scripts( $hook_suffix ) {
|
55 |
if ( false === strpos( $hook_suffix, 'flamingo' ) ) {
|
@@ -80,7 +96,9 @@ function flamingo_admin_enqueue_scripts( $hook_suffix ) {
|
|
80 |
/* Updated Message */
|
81 |
|
82 |
add_action( 'flamingo_admin_updated_message',
|
83 |
-
'flamingo_admin_updated_message'
|
|
|
|
|
84 |
|
85 |
function flamingo_admin_updated_message() {
|
86 |
if ( empty( $_REQUEST['message'] ) ) {
|
@@ -107,8 +125,11 @@ function flamingo_admin_updated_message() {
|
|
107 |
$message = __( 'Messages updated.', 'flamingo' );
|
108 |
}
|
109 |
|
110 |
-
if ( isset( $message )
|
111 |
-
echo sprintf(
|
|
|
|
|
|
|
112 |
}
|
113 |
}
|
114 |
|
@@ -119,15 +140,15 @@ function flamingo_load_contact_admin() {
|
|
119 |
|
120 |
$redirect_to = menu_page_url( 'flamingo', false );
|
121 |
|
122 |
-
if ( 'save' == $action
|
123 |
$post = new Flamingo_Contact( $_REQUEST['post'] );
|
124 |
|
125 |
if ( ! empty( $post ) ) {
|
126 |
-
if ( ! current_user_can( 'flamingo_edit_contact', $post->id ) ) {
|
127 |
wp_die( __( 'You are not allowed to edit this item.', 'flamingo' ) );
|
128 |
}
|
129 |
|
130 |
-
check_admin_referer( 'flamingo-update-contact_' . $post->id );
|
131 |
|
132 |
$post->props = (array) $_POST['contact'];
|
133 |
|
@@ -142,7 +163,7 @@ function flamingo_load_contact_admin() {
|
|
142 |
$redirect_to = add_query_arg(
|
143 |
array(
|
144 |
'action' => 'edit',
|
145 |
-
'post' => $post->id,
|
146 |
'message' => 'contactupdated',
|
147 |
), $redirect_to
|
148 |
);
|
@@ -152,7 +173,7 @@ function flamingo_load_contact_admin() {
|
|
152 |
exit();
|
153 |
}
|
154 |
|
155 |
-
if ( 'delete' == $action
|
156 |
if ( ! is_array( $_REQUEST['post'] ) ) {
|
157 |
check_admin_referer( 'flamingo-delete-contact_' . $_REQUEST['post'] );
|
158 |
} else {
|
@@ -168,7 +189,7 @@ function flamingo_load_contact_admin() {
|
|
168 |
continue;
|
169 |
}
|
170 |
|
171 |
-
if ( ! current_user_can( 'flamingo_delete_contact', $post->id ) ) {
|
172 |
wp_die( __( 'You are not allowed to delete this item.', 'flamingo' ) );
|
173 |
}
|
174 |
|
@@ -194,7 +215,7 @@ function flamingo_load_contact_admin() {
|
|
194 |
$sitename = sanitize_key( get_bloginfo( 'name' ) );
|
195 |
|
196 |
$filename = ( empty( $sitename ) ? '' : $sitename . '-' )
|
197 |
-
. sprintf( 'flamingo-contact-%s.csv',
|
198 |
|
199 |
header( 'Content-Description: File Transfer' );
|
200 |
header( "Content-Disposition: attachment; filename=$filename" );
|
@@ -228,7 +249,8 @@ function flamingo_load_contact_admin() {
|
|
228 |
}
|
229 |
}
|
230 |
|
231 |
-
if ( ! empty( $_GET['order'] )
|
|
|
232 |
$args['order'] = 'ASC';
|
233 |
}
|
234 |
|
@@ -253,7 +275,7 @@ function flamingo_load_contact_admin() {
|
|
253 |
}
|
254 |
|
255 |
if ( ! empty( $_GET['sendmail'] )
|
256 |
-
|
257 |
$redirect_to = menu_page_url( 'flamingo_outbound', false );
|
258 |
|
259 |
$redirect_to = add_query_arg(
|
@@ -276,7 +298,7 @@ function flamingo_load_contact_admin() {
|
|
276 |
}
|
277 |
|
278 |
if ( ! current_user_can( 'flamingo_edit_contact', $post_id )
|
279 |
-
|
280 |
wp_die( __( "You are not allowed to edit this item.", 'flamingo' ) );
|
281 |
}
|
282 |
|
@@ -298,11 +320,13 @@ function flamingo_load_contact_admin() {
|
|
298 |
$current_screen = get_current_screen();
|
299 |
|
300 |
add_filter( 'manage_' . $current_screen->id . '_columns',
|
301 |
-
array( 'Flamingo_Contacts_List_Table', 'define_columns' )
|
|
|
|
|
302 |
|
303 |
add_screen_option( 'per_page', array(
|
304 |
-
'label' => __( 'Contacts', 'flamingo' ),
|
305 |
'default' => 20,
|
|
|
306 |
) );
|
307 |
}
|
308 |
}
|
@@ -337,7 +361,7 @@ function flamingo_contact_admin_page() {
|
|
337 |
|
338 |
<form method="get" action="">
|
339 |
<input type="hidden" name="page" value="<?php echo esc_attr( $_REQUEST['page'] ); ?>" />
|
340 |
-
<?php $list_table->search_box( __( 'Search
|
341 |
<?php $list_table->display(); ?>
|
342 |
</form>
|
343 |
|
@@ -364,29 +388,29 @@ function flamingo_load_inbound_admin() {
|
|
364 |
|
365 |
$redirect_to = menu_page_url( 'flamingo_inbound', false );
|
366 |
|
367 |
-
if ( 'save' == $action
|
368 |
$post = new Flamingo_Inbound_Message( $_REQUEST['post'] );
|
369 |
|
370 |
if ( ! empty( $post ) ) {
|
371 |
-
if ( ! current_user_can( 'flamingo_edit_inbound_message', $post->id ) ) {
|
372 |
wp_die( __( 'You are not allowed to edit this item.', 'flamingo' ) );
|
373 |
}
|
374 |
|
375 |
-
check_admin_referer( 'flamingo-update-inbound_' . $post->id );
|
376 |
|
377 |
$status = isset( $_POST['inbound']['status'] )
|
378 |
? $_POST['inbound']['status'] : '';
|
379 |
|
380 |
-
if ( ! $post->spam
|
381 |
$post->spam();
|
382 |
-
} elseif ( $post->spam
|
383 |
$post->unspam();
|
384 |
}
|
385 |
|
386 |
$redirect_to = add_query_arg(
|
387 |
array(
|
388 |
'action' => 'edit',
|
389 |
-
'post' => $post->id,
|
390 |
'message' => 'inboundupdated',
|
391 |
), $redirect_to
|
392 |
);
|
@@ -396,7 +420,7 @@ function flamingo_load_inbound_admin() {
|
|
396 |
exit();
|
397 |
}
|
398 |
|
399 |
-
if ( 'trash' == $action
|
400 |
if ( ! is_array( $_REQUEST['post'] ) ) {
|
401 |
check_admin_referer(
|
402 |
'flamingo-trash-inbound-message_' . $_REQUEST['post'] );
|
@@ -414,7 +438,7 @@ function flamingo_load_inbound_admin() {
|
|
414 |
}
|
415 |
|
416 |
if ( ! current_user_can(
|
417 |
-
'flamingo_delete_inbound_message', $post->id ) ) {
|
418 |
wp_die( __( 'You are not allowed to move this item to the Trash.', 'flamingo' ) );
|
419 |
}
|
420 |
|
@@ -434,7 +458,7 @@ function flamingo_load_inbound_admin() {
|
|
434 |
exit();
|
435 |
}
|
436 |
|
437 |
-
if ( 'untrash' == $action
|
438 |
if ( ! is_array( $_REQUEST['post'] ) ) {
|
439 |
check_admin_referer(
|
440 |
'flamingo-untrash-inbound-message_' . $_REQUEST['post'] );
|
@@ -452,7 +476,7 @@ function flamingo_load_inbound_admin() {
|
|
452 |
}
|
453 |
|
454 |
if ( ! current_user_can(
|
455 |
-
'flamingo_delete_inbound_message', $post->id ) ) {
|
456 |
wp_die( __( 'You are not allowed to restore this item from the Trash.', 'flamingo' ) );
|
457 |
}
|
458 |
|
@@ -481,7 +505,7 @@ function flamingo_load_inbound_admin() {
|
|
481 |
$action = 'delete';
|
482 |
}
|
483 |
|
484 |
-
if ( 'delete' == $action
|
485 |
if ( ! is_array( $_REQUEST['post'] ) ) {
|
486 |
check_admin_referer(
|
487 |
'flamingo-delete-inbound-message_' . $_REQUEST['post'] );
|
@@ -499,7 +523,7 @@ function flamingo_load_inbound_admin() {
|
|
499 |
}
|
500 |
|
501 |
if ( ! current_user_can(
|
502 |
-
'flamingo_delete_inbound_message', $post->id ) ) {
|
503 |
wp_die( __( 'You are not allowed to delete this item.', 'flamingo' ) );
|
504 |
}
|
505 |
|
@@ -519,7 +543,7 @@ function flamingo_load_inbound_admin() {
|
|
519 |
exit();
|
520 |
}
|
521 |
|
522 |
-
if ( 'spam' == $action
|
523 |
if ( ! is_array( $_REQUEST['post'] ) ) {
|
524 |
check_admin_referer(
|
525 |
'flamingo-spam-inbound-message_' . $_REQUEST['post'] );
|
@@ -536,7 +560,7 @@ function flamingo_load_inbound_admin() {
|
|
536 |
continue;
|
537 |
}
|
538 |
|
539 |
-
if ( ! current_user_can( 'flamingo_spam_inbound_message', $post->id ) ) {
|
540 |
wp_die( __( 'You are not allowed to spam this item.', 'flamingo' ) );
|
541 |
}
|
542 |
|
@@ -554,7 +578,7 @@ function flamingo_load_inbound_admin() {
|
|
554 |
exit();
|
555 |
}
|
556 |
|
557 |
-
if ( 'unspam' == $action
|
558 |
if ( ! is_array( $_REQUEST['post'] ) ) {
|
559 |
check_admin_referer(
|
560 |
'flamingo-unspam-inbound-message_' . $_REQUEST['post'] );
|
@@ -572,7 +596,7 @@ function flamingo_load_inbound_admin() {
|
|
572 |
}
|
573 |
|
574 |
if ( ! current_user_can(
|
575 |
-
'flamingo_unspam_inbound_message', $post->id ) ) {
|
576 |
wp_die( __( 'You are not allowed to unspam this item.', 'flamingo' ) );
|
577 |
}
|
578 |
|
@@ -596,7 +620,7 @@ function flamingo_load_inbound_admin() {
|
|
596 |
$sitename = sanitize_key( get_bloginfo( 'name' ) );
|
597 |
|
598 |
$filename = ( empty( $sitename ) ? '' : $sitename . '-' )
|
599 |
-
. sprintf( 'flamingo-inbound-%s.csv',
|
600 |
|
601 |
header( 'Content-Description: File Transfer' );
|
602 |
header( "Content-Disposition: attachment; filename=$filename" );
|
@@ -623,7 +647,7 @@ function flamingo_load_inbound_admin() {
|
|
623 |
}
|
624 |
|
625 |
if ( ! empty( $_REQUEST['order'] )
|
626 |
-
|
627 |
$args['order'] = 'ASC';
|
628 |
}
|
629 |
|
@@ -665,7 +689,7 @@ function flamingo_load_inbound_admin() {
|
|
665 |
$row[] = $col;
|
666 |
}
|
667 |
|
668 |
-
$row[] = get_post_time( 'c', true, $item->id ); // Date
|
669 |
|
670 |
echo "\r\n" . flamingo_csv_row( $row );
|
671 |
}
|
@@ -682,7 +706,7 @@ function flamingo_load_inbound_admin() {
|
|
682 |
}
|
683 |
|
684 |
if ( ! current_user_can( 'flamingo_edit_inbound_message', $post_id )
|
685 |
-
|
686 |
wp_die( __( "You are not allowed to edit this item.", 'flamingo' ) );
|
687 |
}
|
688 |
|
@@ -712,17 +736,20 @@ function flamingo_load_inbound_admin() {
|
|
712 |
}
|
713 |
|
714 |
} else {
|
715 |
-
if ( ! class_exists( 'Flamingo_Inbound_Messages_List_Table' ) )
|
716 |
require_once FLAMINGO_PLUGIN_DIR . '/admin/includes/class-inbound-messages-list-table.php';
|
|
|
717 |
|
718 |
$current_screen = get_current_screen();
|
719 |
|
720 |
add_filter( 'manage_' . $current_screen->id . '_columns',
|
721 |
-
array( 'Flamingo_Inbound_Messages_List_Table', 'define_columns' )
|
|
|
|
|
722 |
|
723 |
add_screen_option( 'per_page', array(
|
724 |
-
'label' => __( 'Messages', 'flamingo' ),
|
725 |
'default' => 20,
|
|
|
726 |
) );
|
727 |
}
|
728 |
}
|
@@ -759,7 +786,8 @@ function flamingo_inbound_admin_page() {
|
|
759 |
|
760 |
<form method="get" action="">
|
761 |
<input type="hidden" name="page" value="<?php echo esc_attr( $_REQUEST['page'] ); ?>" />
|
762 |
-
<?php
|
|
|
763 |
<?php $list_table->display(); ?>
|
764 |
</form>
|
765 |
|
@@ -777,7 +805,6 @@ function flamingo_inbound_edit_page() {
|
|
777 |
require_once FLAMINGO_PLUGIN_DIR . '/admin/includes/meta-boxes.php';
|
778 |
|
779 |
include FLAMINGO_PLUGIN_DIR . '/admin/edit-inbound-form.php';
|
780 |
-
|
781 |
}
|
782 |
|
783 |
/* Outbound Messages */
|
@@ -815,7 +842,7 @@ function flamingo_load_outbound_admin() {
|
|
815 |
$redirect_to = add_query_arg(
|
816 |
array(
|
817 |
'action' => 'edit',
|
818 |
-
//'post' => $post->id,
|
819 |
'message' => 'outboundupdated',
|
820 |
), $redirect_to
|
821 |
);
|
@@ -829,17 +856,20 @@ function flamingo_load_outbound_admin() {
|
|
829 |
'flamingo_outbound_submit_meta_box', null, 'side', 'core' );
|
830 |
|
831 |
} else {
|
832 |
-
if ( ! class_exists( 'Flamingo_Outbound_Messages_List_Table' ) )
|
833 |
require_once FLAMINGO_PLUGIN_DIR . '/admin/includes/class-outbound-messages-list-table.php';
|
|
|
834 |
|
835 |
$current_screen = get_current_screen();
|
836 |
|
837 |
add_filter( 'manage_' . $current_screen->id . '_columns',
|
838 |
-
array( 'Flamingo_Outbound_Messages_List_Table', 'define_columns' )
|
|
|
|
|
839 |
|
840 |
add_screen_option( 'per_page', array(
|
841 |
-
'label' => __( 'Messages', 'flamingo' ),
|
842 |
'default' => 20,
|
|
|
843 |
) );
|
844 |
}
|
845 |
}
|
@@ -876,7 +906,7 @@ function flamingo_outbound_admin_page() {
|
|
876 |
|
877 |
<form method="get" action="">
|
878 |
<input type="hidden" name="page" value="<?php echo esc_attr( $_REQUEST['page'] ); ?>" />
|
879 |
-
<?php $list_table->search_box( __( 'Search
|
880 |
<?php $list_table->display(); ?>
|
881 |
</form>
|
882 |
|
@@ -901,7 +931,7 @@ function flamingo_outbound_edit_page() {
|
|
901 |
$contact_tag = get_term( $tag_id[0],
|
902 |
Flamingo_Contact::contact_tag_taxonomy );
|
903 |
|
904 |
-
if ( empty( $contact_tag )
|
905 |
$contact_tag = null;
|
906 |
}
|
907 |
}
|
3 |
require_once FLAMINGO_PLUGIN_DIR . '/admin/admin-functions.php';
|
4 |
require_once FLAMINGO_PLUGIN_DIR . '/admin/includes/privacy.php';
|
5 |
|
6 |
+
add_action( 'admin_menu', 'flamingo_admin_menu', 8, 0 );
|
7 |
|
8 |
function flamingo_admin_menu() {
|
9 |
global $_wp_last_object_menu;
|
15 |
__( 'Flamingo', 'flamingo' ),
|
16 |
'flamingo_edit_contacts', 'flamingo',
|
17 |
'flamingo_contact_admin_page', 'dashicons-feedback',
|
18 |
+
$_wp_last_object_menu
|
19 |
+
);
|
20 |
|
21 |
$contact_admin = add_submenu_page( 'flamingo',
|
22 |
__( 'Flamingo Address Book', 'flamingo' ),
|
23 |
__( 'Address Book', 'flamingo' ),
|
24 |
'flamingo_edit_contacts', 'flamingo',
|
25 |
+
'flamingo_contact_admin_page'
|
26 |
+
);
|
27 |
|
28 |
+
add_action( 'load-' . $contact_admin, 'flamingo_load_contact_admin', 10, 0 );
|
29 |
|
30 |
$inbound_admin = add_submenu_page( 'flamingo',
|
31 |
__( 'Flamingo Inbound Messages', 'flamingo' ),
|
32 |
__( 'Inbound Messages', 'flamingo' ),
|
33 |
'flamingo_edit_inbound_messages', 'flamingo_inbound',
|
34 |
+
'flamingo_inbound_admin_page'
|
35 |
+
);
|
36 |
|
37 |
+
add_action( 'load-' . $inbound_admin, 'flamingo_load_inbound_admin', 10, 0 );
|
38 |
}
|
39 |
|
40 |
add_filter( 'set-screen-option', 'flamingo_set_screen_options', 10, 3 );
|
41 |
|
42 |
+
add_filter( 'set_screen_option_flamingo_contacts_per_page',
|
43 |
+
'flamingo_set_screen_options', 10, 3
|
44 |
+
);
|
45 |
+
|
46 |
+
add_filter( 'set_screen_option_flamingo_inbound_messages_per_page',
|
47 |
+
'flamingo_set_screen_options', 10, 3
|
48 |
+
);
|
49 |
+
|
50 |
+
add_filter( 'set_screen_option_flamingo_outbound_messages_per_page',
|
51 |
+
'flamingo_set_screen_options', 10, 3
|
52 |
+
);
|
53 |
+
|
54 |
function flamingo_set_screen_options( $result, $option, $value ) {
|
55 |
$flamingo_screens = array(
|
56 |
+
'flamingo_contacts_per_page',
|
57 |
+
'flamingo_inbound_messages_per_page',
|
58 |
+
'flamingo_outbound_messages_per_page',
|
59 |
);
|
60 |
|
61 |
if ( in_array( $option, $flamingo_screens ) ) {
|
65 |
return $result;
|
66 |
}
|
67 |
|
68 |
+
add_action( 'admin_enqueue_scripts', 'flamingo_admin_enqueue_scripts', 10, 1 );
|
69 |
|
70 |
function flamingo_admin_enqueue_scripts( $hook_suffix ) {
|
71 |
if ( false === strpos( $hook_suffix, 'flamingo' ) ) {
|
96 |
/* Updated Message */
|
97 |
|
98 |
add_action( 'flamingo_admin_updated_message',
|
99 |
+
'flamingo_admin_updated_message',
|
100 |
+
10, 0
|
101 |
+
);
|
102 |
|
103 |
function flamingo_admin_updated_message() {
|
104 |
if ( empty( $_REQUEST['message'] ) ) {
|
125 |
$message = __( 'Messages updated.', 'flamingo' );
|
126 |
}
|
127 |
|
128 |
+
if ( isset( $message ) and '' !== $message ) {
|
129 |
+
echo sprintf(
|
130 |
+
'<div id="message" class="notice notice-success is-dismissible"><p>%s</p></div>',
|
131 |
+
esc_html( $message )
|
132 |
+
);
|
133 |
}
|
134 |
}
|
135 |
|
140 |
|
141 |
$redirect_to = menu_page_url( 'flamingo', false );
|
142 |
|
143 |
+
if ( 'save' == $action and ! empty( $_REQUEST['post'] ) ) {
|
144 |
$post = new Flamingo_Contact( $_REQUEST['post'] );
|
145 |
|
146 |
if ( ! empty( $post ) ) {
|
147 |
+
if ( ! current_user_can( 'flamingo_edit_contact', $post->id() ) ) {
|
148 |
wp_die( __( 'You are not allowed to edit this item.', 'flamingo' ) );
|
149 |
}
|
150 |
|
151 |
+
check_admin_referer( 'flamingo-update-contact_' . $post->id() );
|
152 |
|
153 |
$post->props = (array) $_POST['contact'];
|
154 |
|
163 |
$redirect_to = add_query_arg(
|
164 |
array(
|
165 |
'action' => 'edit',
|
166 |
+
'post' => $post->id(),
|
167 |
'message' => 'contactupdated',
|
168 |
), $redirect_to
|
169 |
);
|
173 |
exit();
|
174 |
}
|
175 |
|
176 |
+
if ( 'delete' == $action and ! empty( $_REQUEST['post'] ) ) {
|
177 |
if ( ! is_array( $_REQUEST['post'] ) ) {
|
178 |
check_admin_referer( 'flamingo-delete-contact_' . $_REQUEST['post'] );
|
179 |
} else {
|
189 |
continue;
|
190 |
}
|
191 |
|
192 |
+
if ( ! current_user_can( 'flamingo_delete_contact', $post->id() ) ) {
|
193 |
wp_die( __( 'You are not allowed to delete this item.', 'flamingo' ) );
|
194 |
}
|
195 |
|
215 |
$sitename = sanitize_key( get_bloginfo( 'name' ) );
|
216 |
|
217 |
$filename = ( empty( $sitename ) ? '' : $sitename . '-' )
|
218 |
+
. sprintf( 'flamingo-contact-%s.csv', wp_date( 'Y-m-d' ) );
|
219 |
|
220 |
header( 'Content-Description: File Transfer' );
|
221 |
header( "Content-Disposition: attachment; filename=$filename" );
|
249 |
}
|
250 |
}
|
251 |
|
252 |
+
if ( ! empty( $_GET['order'] )
|
253 |
+
and 'asc' == strtolower( $_GET['order'] ) ) {
|
254 |
$args['order'] = 'ASC';
|
255 |
}
|
256 |
|
275 |
}
|
276 |
|
277 |
if ( ! empty( $_GET['sendmail'] )
|
278 |
+
and ! empty( $_REQUEST['contact_tag_id'] ) ) {
|
279 |
$redirect_to = menu_page_url( 'flamingo_outbound', false );
|
280 |
|
281 |
$redirect_to = add_query_arg(
|
298 |
}
|
299 |
|
300 |
if ( ! current_user_can( 'flamingo_edit_contact', $post_id )
|
301 |
+
or Flamingo_Contact::post_type !== get_post_type( $post_id ) ) {
|
302 |
wp_die( __( "You are not allowed to edit this item.", 'flamingo' ) );
|
303 |
}
|
304 |
|
320 |
$current_screen = get_current_screen();
|
321 |
|
322 |
add_filter( 'manage_' . $current_screen->id . '_columns',
|
323 |
+
array( 'Flamingo_Contacts_List_Table', 'define_columns' ),
|
324 |
+
10, 0
|
325 |
+
);
|
326 |
|
327 |
add_screen_option( 'per_page', array(
|
|
|
328 |
'default' => 20,
|
329 |
+
'option' => 'flamingo_contacts_per_page',
|
330 |
) );
|
331 |
}
|
332 |
}
|
361 |
|
362 |
<form method="get" action="">
|
363 |
<input type="hidden" name="page" value="<?php echo esc_attr( $_REQUEST['page'] ); ?>" />
|
364 |
+
<?php $list_table->search_box( __( 'Search contacts', 'flamingo' ), 'flamingo-contact' ); ?>
|
365 |
<?php $list_table->display(); ?>
|
366 |
</form>
|
367 |
|
388 |
|
389 |
$redirect_to = menu_page_url( 'flamingo_inbound', false );
|
390 |
|
391 |
+
if ( 'save' == $action and ! empty( $_REQUEST['post'] ) ) {
|
392 |
$post = new Flamingo_Inbound_Message( $_REQUEST['post'] );
|
393 |
|
394 |
if ( ! empty( $post ) ) {
|
395 |
+
if ( ! current_user_can( 'flamingo_edit_inbound_message', $post->id() ) ) {
|
396 |
wp_die( __( 'You are not allowed to edit this item.', 'flamingo' ) );
|
397 |
}
|
398 |
|
399 |
+
check_admin_referer( 'flamingo-update-inbound_' . $post->id() );
|
400 |
|
401 |
$status = isset( $_POST['inbound']['status'] )
|
402 |
? $_POST['inbound']['status'] : '';
|
403 |
|
404 |
+
if ( ! $post->spam and 'spam' === $status ) {
|
405 |
$post->spam();
|
406 |
+
} elseif ( $post->spam and 'ham' === $status ) {
|
407 |
$post->unspam();
|
408 |
}
|
409 |
|
410 |
$redirect_to = add_query_arg(
|
411 |
array(
|
412 |
'action' => 'edit',
|
413 |
+
'post' => $post->id(),
|
414 |
'message' => 'inboundupdated',
|
415 |
), $redirect_to
|
416 |
);
|
420 |
exit();
|
421 |
}
|
422 |
|
423 |
+
if ( 'trash' == $action and ! empty( $_REQUEST['post'] ) ) {
|
424 |
if ( ! is_array( $_REQUEST['post'] ) ) {
|
425 |
check_admin_referer(
|
426 |
'flamingo-trash-inbound-message_' . $_REQUEST['post'] );
|
438 |
}
|
439 |
|
440 |
if ( ! current_user_can(
|
441 |
+
'flamingo_delete_inbound_message', $post->id() ) ) {
|
442 |
wp_die( __( 'You are not allowed to move this item to the Trash.', 'flamingo' ) );
|
443 |
}
|
444 |
|
458 |
exit();
|
459 |
}
|
460 |
|
461 |
+
if ( 'untrash' == $action and ! empty( $_REQUEST['post'] ) ) {
|
462 |
if ( ! is_array( $_REQUEST['post'] ) ) {
|
463 |
check_admin_referer(
|
464 |
'flamingo-untrash-inbound-message_' . $_REQUEST['post'] );
|
476 |
}
|
477 |
|
478 |
if ( ! current_user_can(
|
479 |
+
'flamingo_delete_inbound_message', $post->id() ) ) {
|
480 |
wp_die( __( 'You are not allowed to restore this item from the Trash.', 'flamingo' ) );
|
481 |
}
|
482 |
|
505 |
$action = 'delete';
|
506 |
}
|
507 |
|
508 |
+
if ( 'delete' == $action and ! empty( $_REQUEST['post'] ) ) {
|
509 |
if ( ! is_array( $_REQUEST['post'] ) ) {
|
510 |
check_admin_referer(
|
511 |
'flamingo-delete-inbound-message_' . $_REQUEST['post'] );
|
523 |
}
|
524 |
|
525 |
if ( ! current_user_can(
|
526 |
+
'flamingo_delete_inbound_message', $post->id() ) ) {
|
527 |
wp_die( __( 'You are not allowed to delete this item.', 'flamingo' ) );
|
528 |
}
|
529 |
|
543 |
exit();
|
544 |
}
|
545 |
|
546 |
+
if ( 'spam' == $action and ! empty( $_REQUEST['post'] ) ) {
|
547 |
if ( ! is_array( $_REQUEST['post'] ) ) {
|
548 |
check_admin_referer(
|
549 |
'flamingo-spam-inbound-message_' . $_REQUEST['post'] );
|
560 |
continue;
|
561 |
}
|
562 |
|
563 |
+
if ( ! current_user_can( 'flamingo_spam_inbound_message', $post->id() ) ) {
|
564 |
wp_die( __( 'You are not allowed to spam this item.', 'flamingo' ) );
|
565 |
}
|
566 |
|
578 |
exit();
|
579 |
}
|
580 |
|
581 |
+
if ( 'unspam' == $action and ! empty( $_REQUEST['post'] ) ) {
|
582 |
if ( ! is_array( $_REQUEST['post'] ) ) {
|
583 |
check_admin_referer(
|
584 |
'flamingo-unspam-inbound-message_' . $_REQUEST['post'] );
|
596 |
}
|
597 |
|
598 |
if ( ! current_user_can(
|
599 |
+
'flamingo_unspam_inbound_message', $post->id() ) ) {
|
600 |
wp_die( __( 'You are not allowed to unspam this item.', 'flamingo' ) );
|
601 |
}
|
602 |
|
620 |
$sitename = sanitize_key( get_bloginfo( 'name' ) );
|
621 |
|
622 |
$filename = ( empty( $sitename ) ? '' : $sitename . '-' )
|
623 |
+
. sprintf( 'flamingo-inbound-%s.csv', wp_date( 'Y-m-d' ) );
|
624 |
|
625 |
header( 'Content-Description: File Transfer' );
|
626 |
header( "Content-Disposition: attachment; filename=$filename" );
|
647 |
}
|
648 |
|
649 |
if ( ! empty( $_REQUEST['order'] )
|
650 |
+
and 'asc' == strtolower( $_REQUEST['order'] ) ) {
|
651 |
$args['order'] = 'ASC';
|
652 |
}
|
653 |
|
689 |
$row[] = $col;
|
690 |
}
|
691 |
|
692 |
+
$row[] = get_post_time( 'c', true, $item->id() ); // Date
|
693 |
|
694 |
echo "\r\n" . flamingo_csv_row( $row );
|
695 |
}
|
706 |
}
|
707 |
|
708 |
if ( ! current_user_can( 'flamingo_edit_inbound_message', $post_id )
|
709 |
+
or Flamingo_Inbound_Message::post_type !== get_post_type( $post_id ) ) {
|
710 |
wp_die( __( "You are not allowed to edit this item.", 'flamingo' ) );
|
711 |
}
|
712 |
|
736 |
}
|
737 |
|
738 |
} else {
|
739 |
+
if ( ! class_exists( 'Flamingo_Inbound_Messages_List_Table' ) ) {
|
740 |
require_once FLAMINGO_PLUGIN_DIR . '/admin/includes/class-inbound-messages-list-table.php';
|
741 |
+
}
|
742 |
|
743 |
$current_screen = get_current_screen();
|
744 |
|
745 |
add_filter( 'manage_' . $current_screen->id . '_columns',
|
746 |
+
array( 'Flamingo_Inbound_Messages_List_Table', 'define_columns' ),
|
747 |
+
10, 0
|
748 |
+
);
|
749 |
|
750 |
add_screen_option( 'per_page', array(
|
|
|
751 |
'default' => 20,
|
752 |
+
'option' => 'flamingo_inbound_messages_per_page',
|
753 |
) );
|
754 |
}
|
755 |
}
|
786 |
|
787 |
<form method="get" action="">
|
788 |
<input type="hidden" name="page" value="<?php echo esc_attr( $_REQUEST['page'] ); ?>" />
|
789 |
+
<input type="hidden" name="post_status" value="<?php echo isset( $_REQUEST['post_status'] ) ? esc_attr( $_REQUEST['post_status'] ) : ''; ?>" />
|
790 |
+
<?php $list_table->search_box( __( 'Search messages', 'flamingo' ), 'flamingo-inbound' ); ?>
|
791 |
<?php $list_table->display(); ?>
|
792 |
</form>
|
793 |
|
805 |
require_once FLAMINGO_PLUGIN_DIR . '/admin/includes/meta-boxes.php';
|
806 |
|
807 |
include FLAMINGO_PLUGIN_DIR . '/admin/edit-inbound-form.php';
|
|
|
808 |
}
|
809 |
|
810 |
/* Outbound Messages */
|
842 |
$redirect_to = add_query_arg(
|
843 |
array(
|
844 |
'action' => 'edit',
|
845 |
+
//'post' => $post->id(),
|
846 |
'message' => 'outboundupdated',
|
847 |
), $redirect_to
|
848 |
);
|
856 |
'flamingo_outbound_submit_meta_box', null, 'side', 'core' );
|
857 |
|
858 |
} else {
|
859 |
+
if ( ! class_exists( 'Flamingo_Outbound_Messages_List_Table' ) ) {
|
860 |
require_once FLAMINGO_PLUGIN_DIR . '/admin/includes/class-outbound-messages-list-table.php';
|
861 |
+
}
|
862 |
|
863 |
$current_screen = get_current_screen();
|
864 |
|
865 |
add_filter( 'manage_' . $current_screen->id . '_columns',
|
866 |
+
array( 'Flamingo_Outbound_Messages_List_Table', 'define_columns' ),
|
867 |
+
10, 0
|
868 |
+
);
|
869 |
|
870 |
add_screen_option( 'per_page', array(
|
|
|
871 |
'default' => 20,
|
872 |
+
'option' => 'flamingo_outbound_messages_per_page',
|
873 |
) );
|
874 |
}
|
875 |
}
|
906 |
|
907 |
<form method="get" action="">
|
908 |
<input type="hidden" name="page" value="<?php echo esc_attr( $_REQUEST['page'] ); ?>" />
|
909 |
+
<?php $list_table->search_box( __( 'Search messages', 'flamingo' ), 'flamingo-outbound' ); ?>
|
910 |
<?php $list_table->display(); ?>
|
911 |
</form>
|
912 |
|
931 |
$contact_tag = get_term( $tag_id[0],
|
932 |
Flamingo_Contact::contact_tag_taxonomy );
|
933 |
|
934 |
+
if ( empty( $contact_tag ) or is_wp_error( $contact_tag ) ) {
|
935 |
$contact_tag = null;
|
936 |
}
|
937 |
}
|
admin/css/style-rtl.css
CHANGED
@@ -11,7 +11,7 @@ table.message-fields td.field-value li {
|
|
11 |
}
|
12 |
|
13 |
.tablenav .actions input.button {
|
14 |
-
margin:
|
15 |
}
|
16 |
|
17 |
#misc-publishing-actions .spam-log .dashicons-before::before {
|
11 |
}
|
12 |
|
13 |
.tablenav .actions input.button {
|
14 |
+
margin: 0 0 0 8px;
|
15 |
}
|
16 |
|
17 |
#misc-publishing-actions .spam-log .dashicons-before::before {
|
admin/css/style.css
CHANGED
@@ -45,10 +45,10 @@ table.message-fields td.field-value li {
|
|
45 |
}
|
46 |
|
47 |
.tablenav .actions input.button {
|
48 |
-
margin:
|
49 |
}
|
50 |
|
51 |
-
#misc-publishing-actions .
|
52 |
position: relative;
|
53 |
top: -1px;
|
54 |
margin-left: -1px;
|
45 |
}
|
46 |
|
47 |
.tablenav .actions input.button {
|
48 |
+
margin: 0 8px 0 0;
|
49 |
}
|
50 |
|
51 |
+
#misc-publishing-actions .dashicons-before::before {
|
52 |
position: relative;
|
53 |
top: -1px;
|
54 |
margin-left: -1px;
|
admin/edit-contact-form.php
CHANGED
@@ -5,8 +5,8 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
5 |
die( '-1' );
|
6 |
}
|
7 |
|
8 |
-
if ( ! empty( $post->id ) ) {
|
9 |
-
$nonce_action = 'flamingo-update-contact_' . $post->id;
|
10 |
} else {
|
11 |
$nonce_action = 'flamingo-add-contact';
|
12 |
}
|
@@ -18,7 +18,7 @@ if ( ! empty( $post->id ) ) {
|
|
18 |
|
19 |
<?php do_action( 'flamingo_admin_updated_message', $post ); ?>
|
20 |
|
21 |
-
<form name="editcontact" id="editcontact" method="post" action="<?php echo esc_url( add_query_arg( array( 'post' => $post->id ), menu_page_url( 'flamingo', false ) ) ); ?>">
|
22 |
<?php
|
23 |
wp_nonce_field( $nonce_action );
|
24 |
wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
|
@@ -31,7 +31,7 @@ wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
|
|
31 |
<div id="post-body-content">
|
32 |
<div id="titlediv">
|
33 |
<div id="titlewrap">
|
34 |
-
<?php if ( ! empty( $post->id ) ) : ?>
|
35 |
<input type="text" name="post_title" size="30" tabindex="1" value="<?php echo esc_attr( $post->email ); ?>" id="title" disabled="disabled" />
|
36 |
<?php else : ?>
|
37 |
<label class="hide-if-no-js" style="visibility:hidden" id="title-prompt-text" for="title"><?php echo esc_html( __( 'Enter email here', 'flamingo' ) ); ?></label>
|
@@ -59,9 +59,9 @@ wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
|
|
59 |
|
60 |
</div><!-- #poststuff -->
|
61 |
|
62 |
-
<?php if ( $post->id ) : ?>
|
63 |
<input type="hidden" name="action" value="save" />
|
64 |
-
<input type="hidden" name="post" value="<?php echo (int) $post->id; ?>" />
|
65 |
<?php else: ?>
|
66 |
<input type="hidden" name="action" value="add" />
|
67 |
<?php endif; ?>
|
5 |
die( '-1' );
|
6 |
}
|
7 |
|
8 |
+
if ( ! empty( $post->id() ) ) {
|
9 |
+
$nonce_action = 'flamingo-update-contact_' . $post->id();
|
10 |
} else {
|
11 |
$nonce_action = 'flamingo-add-contact';
|
12 |
}
|
18 |
|
19 |
<?php do_action( 'flamingo_admin_updated_message', $post ); ?>
|
20 |
|
21 |
+
<form name="editcontact" id="editcontact" method="post" action="<?php echo esc_url( add_query_arg( array( 'post' => $post->id() ), menu_page_url( 'flamingo', false ) ) ); ?>">
|
22 |
<?php
|
23 |
wp_nonce_field( $nonce_action );
|
24 |
wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
|
31 |
<div id="post-body-content">
|
32 |
<div id="titlediv">
|
33 |
<div id="titlewrap">
|
34 |
+
<?php if ( ! empty( $post->id() ) ) : ?>
|
35 |
<input type="text" name="post_title" size="30" tabindex="1" value="<?php echo esc_attr( $post->email ); ?>" id="title" disabled="disabled" />
|
36 |
<?php else : ?>
|
37 |
<label class="hide-if-no-js" style="visibility:hidden" id="title-prompt-text" for="title"><?php echo esc_html( __( 'Enter email here', 'flamingo' ) ); ?></label>
|
59 |
|
60 |
</div><!-- #poststuff -->
|
61 |
|
62 |
+
<?php if ( $post->id() ) : ?>
|
63 |
<input type="hidden" name="action" value="save" />
|
64 |
+
<input type="hidden" name="post" value="<?php echo (int) $post->id(); ?>" />
|
65 |
<?php else: ?>
|
66 |
<input type="hidden" name="action" value="add" />
|
67 |
<?php endif; ?>
|
admin/edit-inbound-form.php
CHANGED
@@ -5,8 +5,8 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
5 |
die( '-1' );
|
6 |
}
|
7 |
|
8 |
-
if ( ! empty( $post->id ) ) {
|
9 |
-
$nonce_action = 'flamingo-update-inbound_' . $post->id;
|
10 |
} else {
|
11 |
$nonce_action = 'flamingo-add-inbound';
|
12 |
}
|
@@ -18,7 +18,7 @@ if ( ! empty( $post->id ) ) {
|
|
18 |
|
19 |
<?php do_action( 'flamingo_admin_updated_message', $post ); ?>
|
20 |
|
21 |
-
<form name="editinbound" id="editinbound" method="post" action="<?php echo esc_url( add_query_arg( array( 'post' => $post->id ), menu_page_url( 'flamingo_inbound', false ) ) ); ?>">
|
22 |
<?php
|
23 |
wp_nonce_field( $nonce_action );
|
24 |
wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
|
@@ -71,9 +71,9 @@ wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
|
|
71 |
|
72 |
</div><!-- #poststuff -->
|
73 |
|
74 |
-
<?php if ( $post->id ) : ?>
|
75 |
<input type="hidden" name="action" value="save" />
|
76 |
-
<input type="hidden" name="post" value="<?php echo (int) $post->id; ?>" />
|
77 |
<?php else: ?>
|
78 |
<input type="hidden" name="action" value="add" />
|
79 |
<?php endif; ?>
|
5 |
die( '-1' );
|
6 |
}
|
7 |
|
8 |
+
if ( ! empty( $post->id() ) ) {
|
9 |
+
$nonce_action = 'flamingo-update-inbound_' . $post->id();
|
10 |
} else {
|
11 |
$nonce_action = 'flamingo-add-inbound';
|
12 |
}
|
18 |
|
19 |
<?php do_action( 'flamingo_admin_updated_message', $post ); ?>
|
20 |
|
21 |
+
<form name="editinbound" id="editinbound" method="post" action="<?php echo esc_url( add_query_arg( array( 'post' => $post->id() ), menu_page_url( 'flamingo_inbound', false ) ) ); ?>">
|
22 |
<?php
|
23 |
wp_nonce_field( $nonce_action );
|
24 |
wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
|
71 |
|
72 |
</div><!-- #poststuff -->
|
73 |
|
74 |
+
<?php if ( $post->id() ) : ?>
|
75 |
<input type="hidden" name="action" value="save" />
|
76 |
+
<input type="hidden" name="post" value="<?php echo (int) $post->id(); ?>" />
|
77 |
<?php else: ?>
|
78 |
<input type="hidden" name="action" value="add" />
|
79 |
<?php endif; ?>
|
admin/edit-outbound-form.php
CHANGED
@@ -5,8 +5,8 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
5 |
die( '-1' );
|
6 |
}
|
7 |
|
8 |
-
if ( ! empty( $post->id ) ) {
|
9 |
-
$nonce_action = 'flamingo-update-outbound_' . $post->id;
|
10 |
} else {
|
11 |
$nonce_action = 'flamingo-add-outbound';
|
12 |
}
|
@@ -24,7 +24,7 @@ if ( ! empty( $post->id ) ) {
|
|
24 |
|
25 |
<?php do_action( 'flamingo_admin_updated_message', $post ); ?>
|
26 |
|
27 |
-
<form name="editoutbound" id="editoutbound" method="post" action="<?php echo esc_url( add_query_arg( array( 'post' => $post->id ), menu_page_url( 'flamingo_outbound', false ) ) ); ?>">
|
28 |
<?php
|
29 |
wp_nonce_field( $nonce_action );
|
30 |
wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
|
@@ -84,8 +84,8 @@ wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
|
|
84 |
</div><!-- #poststuff -->
|
85 |
|
86 |
<input type="hidden" name="action" value="save" />
|
87 |
-
<?php if ( ! empty( $post->id ) ) : ?>
|
88 |
-
<input type="hidden" name="post" value="<?php echo (int) $post->id; ?>" />
|
89 |
<?php endif; ?>
|
90 |
</form>
|
91 |
|
5 |
die( '-1' );
|
6 |
}
|
7 |
|
8 |
+
if ( ! empty( $post->id() ) ) {
|
9 |
+
$nonce_action = 'flamingo-update-outbound_' . $post->id();
|
10 |
} else {
|
11 |
$nonce_action = 'flamingo-add-outbound';
|
12 |
}
|
24 |
|
25 |
<?php do_action( 'flamingo_admin_updated_message', $post ); ?>
|
26 |
|
27 |
+
<form name="editoutbound" id="editoutbound" method="post" action="<?php echo esc_url( add_query_arg( array( 'post' => $post->id() ), menu_page_url( 'flamingo_outbound', false ) ) ); ?>">
|
28 |
<?php
|
29 |
wp_nonce_field( $nonce_action );
|
30 |
wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
|
84 |
</div><!-- #poststuff -->
|
85 |
|
86 |
<input type="hidden" name="action" value="save" />
|
87 |
+
<?php if ( ! empty( $post->id() ) ) : ?>
|
88 |
+
<input type="hidden" name="post" value="<?php echo (int) $post->id(); ?>" />
|
89 |
<?php endif; ?>
|
90 |
</form>
|
91 |
|
admin/includes/class-contacts-list-table.php
CHANGED
@@ -13,7 +13,7 @@ class Flamingo_Contacts_List_Table extends WP_List_Table {
|
|
13 |
'full_name' => __( 'Name', 'flamingo' ),
|
14 |
'tags' => __( 'Tags', 'flamingo' ),
|
15 |
'history' => __( 'History', 'flamingo' ),
|
16 |
-
'last_contacted' => __( 'Last
|
17 |
);
|
18 |
|
19 |
$columns = apply_filters(
|
@@ -31,8 +31,9 @@ class Flamingo_Contacts_List_Table extends WP_List_Table {
|
|
31 |
}
|
32 |
|
33 |
public function prepare_items() {
|
34 |
-
$
|
35 |
-
|
|
|
36 |
|
37 |
$args = array(
|
38 |
'posts_per_page' => $per_page,
|
@@ -55,7 +56,7 @@ class Flamingo_Contacts_List_Table extends WP_List_Table {
|
|
55 |
}
|
56 |
|
57 |
if ( ! empty( $_REQUEST['order'] )
|
58 |
-
|
59 |
$args['order'] = 'ASC';
|
60 |
}
|
61 |
|
@@ -65,7 +66,7 @@ class Flamingo_Contacts_List_Table extends WP_List_Table {
|
|
65 |
|
66 |
$this->items = Flamingo_Contact::find( $args );
|
67 |
|
68 |
-
$total_items = Flamingo_Contact
|
69 |
$total_pages = ceil( $total_items / $per_page );
|
70 |
|
71 |
$this->set_pagination_args( array(
|
@@ -136,27 +137,28 @@ class Flamingo_Contacts_List_Table extends WP_List_Table {
|
|
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 ),
|
@@ -183,13 +185,13 @@ class Flamingo_Contacts_List_Table extends WP_List_Table {
|
|
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 ),
|
@@ -206,7 +208,7 @@ class Flamingo_Contacts_List_Table extends WP_List_Table {
|
|
206 |
|
207 |
protected function column_tags( $item ) {
|
208 |
if ( empty( $item->tags ) ) {
|
209 |
-
return esc_html( __( 'No
|
210 |
}
|
211 |
|
212 |
$output = '';
|
@@ -285,7 +287,7 @@ class Flamingo_Contacts_List_Table extends WP_List_Table {
|
|
285 |
's' => $item->email,
|
286 |
) );
|
287 |
|
288 |
-
$count = (int) Flamingo_Inbound_Message
|
289 |
|
290 |
if ( ! $count ) {
|
291 |
continue;
|
@@ -322,26 +324,30 @@ class Flamingo_Contacts_List_Table extends WP_List_Table {
|
|
322 |
}
|
323 |
|
324 |
protected function column_last_contacted( $item ) {
|
325 |
-
if ( empty( $item->last_contacted )
|
|
|
326 |
return '';
|
327 |
}
|
328 |
|
329 |
-
$
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
$time_diff = time() - $time;
|
335 |
|
336 |
-
if (
|
337 |
-
|
338 |
-
} else {
|
339 |
-
$h_time = mysql2date( __( 'Y/m/d', 'flamingo' ), $m_time );
|
340 |
}
|
341 |
|
342 |
-
|
343 |
-
|
344 |
-
|
|
|
|
|
|
|
|
|
345 |
);
|
|
|
|
|
346 |
}
|
347 |
}
|
13 |
'full_name' => __( 'Name', 'flamingo' ),
|
14 |
'tags' => __( 'Tags', 'flamingo' ),
|
15 |
'history' => __( 'History', 'flamingo' ),
|
16 |
+
'last_contacted' => __( 'Last contact', 'flamingo' ),
|
17 |
);
|
18 |
|
19 |
$columns = apply_filters(
|
31 |
}
|
32 |
|
33 |
public function prepare_items() {
|
34 |
+
$per_page = $this->get_items_per_page(
|
35 |
+
'flamingo_contacts_per_page'
|
36 |
+
);
|
37 |
|
38 |
$args = array(
|
39 |
'posts_per_page' => $per_page,
|
56 |
}
|
57 |
|
58 |
if ( ! empty( $_REQUEST['order'] )
|
59 |
+
and 'asc' == strtolower( $_REQUEST['order'] ) ) {
|
60 |
$args['order'] = 'ASC';
|
61 |
}
|
62 |
|
66 |
|
67 |
$this->items = Flamingo_Contact::find( $args );
|
68 |
|
69 |
+
$total_items = Flamingo_Contact::count();
|
70 |
$total_pages = ceil( $total_items / $per_page );
|
71 |
|
72 |
$this->set_pagination_args( array(
|
137 |
|
138 |
protected function column_default( $item, $column_name ) {
|
139 |
do_action( 'manage_flamingo_contact_posts_custom_column',
|
140 |
+
$column_name, $item->id()
|
141 |
+
);
|
142 |
}
|
143 |
|
144 |
protected 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 |
|
152 |
protected function column_email( $item ) {
|
153 |
$edit_link = add_query_arg(
|
154 |
array(
|
155 |
+
'post' => $item->id(),
|
156 |
'action' => 'edit',
|
157 |
),
|
158 |
menu_page_url( 'flamingo', false )
|
159 |
);
|
160 |
|
161 |
+
if ( current_user_can( 'flamingo_edit_contact', $item->id() ) ) {
|
162 |
return sprintf(
|
163 |
'<strong><a class="row-title" href="%1$s" aria-label="%2$s">%3$s</a></strong>',
|
164 |
esc_url( $edit_link ),
|
185 |
|
186 |
$link = add_query_arg(
|
187 |
array(
|
188 |
+
'post' => $item->id(),
|
189 |
'action' => 'edit',
|
190 |
),
|
191 |
menu_page_url( 'flamingo', false )
|
192 |
);
|
193 |
|
194 |
+
if ( current_user_can( 'flamingo_edit_contact', $item->id() ) ) {
|
195 |
$actions['edit'] = sprintf(
|
196 |
'<a href="%1$s">%2$s</a>',
|
197 |
esc_url( $link ),
|
208 |
|
209 |
protected function column_tags( $item ) {
|
210 |
if ( empty( $item->tags ) ) {
|
211 |
+
return esc_html( __( 'No tags', 'flamingo' ) );
|
212 |
}
|
213 |
|
214 |
$output = '';
|
287 |
's' => $item->email,
|
288 |
) );
|
289 |
|
290 |
+
$count = (int) Flamingo_Inbound_Message::count();
|
291 |
|
292 |
if ( ! $count ) {
|
293 |
continue;
|
324 |
}
|
325 |
|
326 |
protected function column_last_contacted( $item ) {
|
327 |
+
if ( empty( $item->last_contacted )
|
328 |
+
or '0000-00-00 00:00:00' === $item->last_contacted ) {
|
329 |
return '';
|
330 |
}
|
331 |
|
332 |
+
$datetime = date_create_immutable_from_format(
|
333 |
+
'Y-m-d H:i:s',
|
334 |
+
$item->last_contacted,
|
335 |
+
wp_timezone()
|
336 |
+
);
|
|
|
337 |
|
338 |
+
if ( false === $datetime ) {
|
339 |
+
return '';
|
|
|
|
|
340 |
}
|
341 |
|
342 |
+
$t_time = sprintf(
|
343 |
+
/* translators: 1: date, 2: time */
|
344 |
+
__( '%1$s at %2$s', 'flamingo' ),
|
345 |
+
/* translators: date format, see https://www.php.net/date */
|
346 |
+
$datetime->format( __( 'Y/m/d', 'flamingo' ) ),
|
347 |
+
/* translators: time format, see https://www.php.net/date */
|
348 |
+
$datetime->format( __( 'g:i a', 'flamingo' ) )
|
349 |
);
|
350 |
+
|
351 |
+
return $t_time;
|
352 |
}
|
353 |
}
|
admin/includes/class-inbound-messages-list-table.php
CHANGED
@@ -33,8 +33,9 @@ class Flamingo_Inbound_Messages_List_Table extends WP_List_Table {
|
|
33 |
}
|
34 |
|
35 |
public function prepare_items() {
|
36 |
-
$
|
37 |
-
|
|
|
38 |
|
39 |
$args = array(
|
40 |
'posts_per_page' => $per_page,
|
@@ -86,7 +87,7 @@ class Flamingo_Inbound_Messages_List_Table extends WP_List_Table {
|
|
86 |
|
87 |
$this->items = Flamingo_Inbound_Message::find( $args );
|
88 |
|
89 |
-
$total_items = Flamingo_Inbound_Message
|
90 |
$total_pages = ceil( $total_items / $per_page );
|
91 |
|
92 |
$this->set_pagination_args( array(
|
@@ -106,7 +107,7 @@ class Flamingo_Inbound_Messages_List_Table extends WP_List_Table {
|
|
106 |
'post_status' => 'any',
|
107 |
) );
|
108 |
|
109 |
-
$posts_in_inbox = Flamingo_Inbound_Message
|
110 |
|
111 |
$inbox = sprintf(
|
112 |
_nx( 'Inbox <span class="count">(%s)</span>',
|
@@ -125,7 +126,7 @@ class Flamingo_Inbound_Messages_List_Table extends WP_List_Table {
|
|
125 |
'post_status' => Flamingo_Inbound_Message::spam_status,
|
126 |
) );
|
127 |
|
128 |
-
$posts_in_spam = Flamingo_Inbound_Message
|
129 |
|
130 |
$spam = sprintf(
|
131 |
_nx( 'Spam <span class="count">(%s)</span>',
|
@@ -150,7 +151,7 @@ class Flamingo_Inbound_Messages_List_Table extends WP_List_Table {
|
|
150 |
'post_status' => 'trash',
|
151 |
) );
|
152 |
|
153 |
-
$posts_in_trash = Flamingo_Inbound_Message
|
154 |
|
155 |
if ( empty( $posts_in_trash ) ) {
|
156 |
return $status_links;
|
@@ -199,15 +200,15 @@ class Flamingo_Inbound_Messages_List_Table extends WP_List_Table {
|
|
199 |
}
|
200 |
|
201 |
if ( $this->is_trash or ! EMPTY_TRASH_DAYS ) {
|
202 |
-
$actions['delete'] = __( 'Delete
|
203 |
} else {
|
204 |
-
$actions['trash'] = __( 'Move to
|
205 |
}
|
206 |
|
207 |
if ( $this->is_spam ) {
|
208 |
-
$actions['unspam'] = __( 'Not
|
209 |
} else {
|
210 |
-
$actions['spam'] = __( 'Mark as
|
211 |
}
|
212 |
|
213 |
return $actions;
|
@@ -245,8 +246,8 @@ class Flamingo_Inbound_Messages_List_Table extends WP_List_Table {
|
|
245 |
'taxonomy' => Flamingo_Inbound_Message::channel_taxonomy,
|
246 |
'name' => 'channel_id',
|
247 |
'show_option_all' => __( 'View all channels', 'flamingo' ),
|
248 |
-
'show_count' =>
|
249 |
-
'hide_empty' =>
|
250 |
'hide_if_empty' => 1,
|
251 |
'orderby' => 'name',
|
252 |
'hierarchical' => 1,
|
@@ -264,7 +265,7 @@ class Flamingo_Inbound_Messages_List_Table extends WP_List_Table {
|
|
264 |
|
265 |
if ( $this->is_trash
|
266 |
and current_user_can( 'flamingo_delete_inbound_messages' ) ) {
|
267 |
-
submit_button( __( 'Empty
|
268 |
'button-secondary apply', 'delete_all', false );
|
269 |
}
|
270 |
?>
|
@@ -274,14 +275,15 @@ class Flamingo_Inbound_Messages_List_Table extends WP_List_Table {
|
|
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 |
|
@@ -290,10 +292,10 @@ class Flamingo_Inbound_Messages_List_Table extends WP_List_Table {
|
|
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 )
|
@@ -322,10 +324,10 @@ class Flamingo_Inbound_Messages_List_Table extends WP_List_Table {
|
|
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 )
|
@@ -338,36 +340,38 @@ class Flamingo_Inbound_Messages_List_Table extends WP_List_Table {
|
|
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
|
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 ),
|
@@ -437,27 +441,21 @@ class Flamingo_Inbound_Messages_List_Table extends WP_List_Table {
|
|
437 |
}
|
438 |
|
439 |
protected function column_date( $item ) {
|
440 |
-
$
|
441 |
|
442 |
-
if (
|
443 |
return '';
|
444 |
}
|
445 |
|
446 |
-
$t_time =
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
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 |
}
|
33 |
}
|
34 |
|
35 |
public function prepare_items() {
|
36 |
+
$per_page = $this->get_items_per_page(
|
37 |
+
'flamingo_inbound_messages_per_page'
|
38 |
+
);
|
39 |
|
40 |
$args = array(
|
41 |
'posts_per_page' => $per_page,
|
87 |
|
88 |
$this->items = Flamingo_Inbound_Message::find( $args );
|
89 |
|
90 |
+
$total_items = Flamingo_Inbound_Message::count();
|
91 |
$total_pages = ceil( $total_items / $per_page );
|
92 |
|
93 |
$this->set_pagination_args( array(
|
107 |
'post_status' => 'any',
|
108 |
) );
|
109 |
|
110 |
+
$posts_in_inbox = Flamingo_Inbound_Message::count();
|
111 |
|
112 |
$inbox = sprintf(
|
113 |
_nx( 'Inbox <span class="count">(%s)</span>',
|
126 |
'post_status' => Flamingo_Inbound_Message::spam_status,
|
127 |
) );
|
128 |
|
129 |
+
$posts_in_spam = Flamingo_Inbound_Message::count();
|
130 |
|
131 |
$spam = sprintf(
|
132 |
_nx( 'Spam <span class="count">(%s)</span>',
|
151 |
'post_status' => 'trash',
|
152 |
) );
|
153 |
|
154 |
+
$posts_in_trash = Flamingo_Inbound_Message::count();
|
155 |
|
156 |
if ( empty( $posts_in_trash ) ) {
|
157 |
return $status_links;
|
200 |
}
|
201 |
|
202 |
if ( $this->is_trash or ! EMPTY_TRASH_DAYS ) {
|
203 |
+
$actions['delete'] = __( 'Delete permanently', 'flamingo' );
|
204 |
} else {
|
205 |
+
$actions['trash'] = __( 'Move to trash', 'flamingo' );
|
206 |
}
|
207 |
|
208 |
if ( $this->is_spam ) {
|
209 |
+
$actions['unspam'] = __( 'Not spam', 'flamingo' );
|
210 |
} else {
|
211 |
+
$actions['spam'] = __( 'Mark as spam', 'flamingo' );
|
212 |
}
|
213 |
|
214 |
return $actions;
|
246 |
'taxonomy' => Flamingo_Inbound_Message::channel_taxonomy,
|
247 |
'name' => 'channel_id',
|
248 |
'show_option_all' => __( 'View all channels', 'flamingo' ),
|
249 |
+
'show_count' => 0,
|
250 |
+
'hide_empty' => 1,
|
251 |
'hide_if_empty' => 1,
|
252 |
'orderby' => 'name',
|
253 |
'hierarchical' => 1,
|
265 |
|
266 |
if ( $this->is_trash
|
267 |
and current_user_can( 'flamingo_delete_inbound_messages' ) ) {
|
268 |
+
submit_button( __( 'Empty trash', 'flamingo' ),
|
269 |
'button-secondary apply', 'delete_all', false );
|
270 |
}
|
271 |
?>
|
275 |
|
276 |
protected function column_default( $item, $column_name ) {
|
277 |
do_action( 'manage_flamingo_inbound_posts_custom_column',
|
278 |
+
$column_name, $item->id()
|
279 |
+
);
|
280 |
}
|
281 |
|
282 |
protected function column_cb( $item ) {
|
283 |
return sprintf(
|
284 |
'<input type="checkbox" name="%1$s[]" value="%2$s" />',
|
285 |
$this->_args['singular'],
|
286 |
+
$item->id()
|
287 |
);
|
288 |
}
|
289 |
|
292 |
return sprintf( '<strong>%s</strong>', esc_html( $item->subject ) );
|
293 |
}
|
294 |
|
295 |
+
if ( current_user_can( 'flamingo_edit_inbound_message', $item->id() ) ) {
|
296 |
$edit_link = add_query_arg(
|
297 |
array(
|
298 |
+
'post' => $item->id(),
|
299 |
'action' => 'edit',
|
300 |
),
|
301 |
menu_page_url( 'flamingo_inbound', false )
|
324 |
|
325 |
$actions = array();
|
326 |
|
327 |
+
if ( current_user_can( 'flamingo_edit_inbound_message', $item->id() ) ) {
|
328 |
$link = add_query_arg(
|
329 |
array(
|
330 |
+
'post' => $item->id(),
|
331 |
'action' => 'edit',
|
332 |
),
|
333 |
menu_page_url( 'flamingo_inbound', false )
|
340 |
}
|
341 |
|
342 |
if ( $item->spam
|
343 |
+
and current_user_can( 'flamingo_unspam_inbound_message', $item->id() ) ) {
|
344 |
$link = add_query_arg(
|
345 |
array(
|
346 |
+
'post' => $item->id(),
|
347 |
'action' => 'unspam',
|
348 |
),
|
349 |
menu_page_url( 'flamingo_inbound', false )
|
350 |
);
|
351 |
|
352 |
$link = wp_nonce_url( $link,
|
353 |
+
'flamingo-unspam-inbound-message_' . $item->id()
|
354 |
+
);
|
355 |
|
356 |
$actions['unspam'] = sprintf( '<a href="%1$s">%2$s</a>',
|
357 |
esc_url( $link ),
|
358 |
+
esc_html( __( 'Not spam', 'flamingo' ) )
|
359 |
);
|
360 |
}
|
361 |
|
362 |
if ( ! $item->spam
|
363 |
+
and current_user_can( 'flamingo_spam_inbound_message', $item->id() ) ) {
|
364 |
$link = add_query_arg(
|
365 |
array(
|
366 |
+
'post' => $item->id(),
|
367 |
'action' => 'spam',
|
368 |
),
|
369 |
menu_page_url( 'flamingo_inbound', false )
|
370 |
);
|
371 |
|
372 |
$link = wp_nonce_url( $link,
|
373 |
+
'flamingo-spam-inbound-message_' . $item->id()
|
374 |
+
);
|
375 |
|
376 |
$actions['spam'] = sprintf( '<a href="%1$s">%2$s</a>',
|
377 |
esc_url( $link ),
|
441 |
}
|
442 |
|
443 |
protected function column_date( $item ) {
|
444 |
+
$datetime = get_post_datetime( $item->id() );
|
445 |
|
446 |
+
if ( false === $datetime ) {
|
447 |
return '';
|
448 |
}
|
449 |
|
450 |
+
$t_time = sprintf(
|
451 |
+
/* translators: 1: date, 2: time */
|
452 |
+
__( '%1$s at %2$s', 'flamingo' ),
|
453 |
+
/* translators: date format, see https://www.php.net/date */
|
454 |
+
$datetime->format( __( 'Y/m/d', 'flamingo' ) ),
|
455 |
+
/* translators: time format, see https://www.php.net/date */
|
456 |
+
$datetime->format( __( 'g:i a', 'flamingo' ) )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
457 |
);
|
458 |
+
|
459 |
+
return $t_time;
|
460 |
}
|
461 |
}
|
admin/includes/class-outbound-messages-list-table.php
CHANGED
@@ -31,8 +31,9 @@ class Flamingo_Outbound_Messages_List_Table extends WP_List_Table {
|
|
31 |
}
|
32 |
|
33 |
public function prepare_items() {
|
34 |
-
$
|
35 |
-
|
|
|
36 |
|
37 |
$args = array(
|
38 |
'posts_per_page' => $per_page,
|
@@ -56,7 +57,7 @@ class Flamingo_Outbound_Messages_List_Table extends WP_List_Table {
|
|
56 |
}
|
57 |
|
58 |
if ( ! empty( $_REQUEST['order'] )
|
59 |
-
|
60 |
$args['order'] = 'ASC';
|
61 |
}
|
62 |
|
@@ -73,7 +74,7 @@ class Flamingo_Outbound_Messages_List_Table extends WP_List_Table {
|
|
73 |
|
74 |
$this->items = Flamingo_Outbound_Message::find( $args );
|
75 |
|
76 |
-
$total_items = Flamingo_Outbound_Message
|
77 |
$total_pages = ceil( $total_items / $per_page );
|
78 |
|
79 |
$this->set_pagination_args( array(
|
@@ -90,7 +91,7 @@ class Flamingo_Outbound_Messages_List_Table extends WP_List_Table {
|
|
90 |
|
91 |
// Inbox
|
92 |
Flamingo_Outbound_Message::find( array( 'post_status' => 'any' ) );
|
93 |
-
$posts_in_inbox = Flamingo_Outbound_Message
|
94 |
|
95 |
$inbox = sprintf(
|
96 |
_nx( 'Inbox <span class="count">(%s)</span>',
|
@@ -105,7 +106,7 @@ class Flamingo_Outbound_Messages_List_Table extends WP_List_Table {
|
|
105 |
|
106 |
// Trash
|
107 |
Flamingo_Outbound_Message::find( array( 'post_status' => 'trash' ) );
|
108 |
-
$posts_in_trash = Flamingo_Outbound_Message
|
109 |
|
110 |
if ( empty( $posts_in_trash ) ) {
|
111 |
return $status_links;
|
@@ -152,9 +153,9 @@ class Flamingo_Outbound_Messages_List_Table extends WP_List_Table {
|
|
152 |
}
|
153 |
|
154 |
if ( $this->is_trash or ! EMPTY_TRASH_DAYS ) {
|
155 |
-
$actions['delete'] = __( 'Delete
|
156 |
} else {
|
157 |
-
$actions['trash'] = __( 'Move to
|
158 |
}
|
159 |
|
160 |
return $actions;
|
@@ -173,7 +174,7 @@ class Flamingo_Outbound_Messages_List_Table extends WP_List_Table {
|
|
173 |
|
174 |
if ( $this->is_trash
|
175 |
and current_user_can( 'flamingo_delete_outbound_messages' ) ) {
|
176 |
-
submit_button( __( 'Empty
|
177 |
'button-secondary apply', 'delete_all', false );
|
178 |
}
|
179 |
?>
|
@@ -183,14 +184,16 @@ class Flamingo_Outbound_Messages_List_Table extends WP_List_Table {
|
|
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 ) {
|
@@ -199,7 +202,7 @@ class Flamingo_Outbound_Messages_List_Table extends WP_List_Table {
|
|
199 |
}
|
200 |
|
201 |
$actions = array();
|
202 |
-
$post_id = absint( $item->id );
|
203 |
|
204 |
$edit_link = add_query_arg(
|
205 |
array(
|
@@ -232,27 +235,21 @@ class Flamingo_Outbound_Messages_List_Table extends WP_List_Table {
|
|
232 |
}
|
233 |
|
234 |
protected function column_date( $item ) {
|
235 |
-
$
|
236 |
|
237 |
-
if (
|
238 |
return '';
|
239 |
}
|
240 |
|
241 |
-
$t_time =
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
$h_time = sprintf( __( '%s ago', 'flamingo' ), human_time_diff( $time ) );
|
249 |
-
} else {
|
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 |
}
|
31 |
}
|
32 |
|
33 |
public function prepare_items() {
|
34 |
+
$per_page = $this->get_items_per_page(
|
35 |
+
'flamingo_outbound_messages_per_page'
|
36 |
+
);
|
37 |
|
38 |
$args = array(
|
39 |
'posts_per_page' => $per_page,
|
57 |
}
|
58 |
|
59 |
if ( ! empty( $_REQUEST['order'] )
|
60 |
+
and 'asc' == strtolower( $_REQUEST['order'] ) ) {
|
61 |
$args['order'] = 'ASC';
|
62 |
}
|
63 |
|
74 |
|
75 |
$this->items = Flamingo_Outbound_Message::find( $args );
|
76 |
|
77 |
+
$total_items = Flamingo_Outbound_Message::count();
|
78 |
$total_pages = ceil( $total_items / $per_page );
|
79 |
|
80 |
$this->set_pagination_args( array(
|
91 |
|
92 |
// Inbox
|
93 |
Flamingo_Outbound_Message::find( array( 'post_status' => 'any' ) );
|
94 |
+
$posts_in_inbox = Flamingo_Outbound_Message::count();
|
95 |
|
96 |
$inbox = sprintf(
|
97 |
_nx( 'Inbox <span class="count">(%s)</span>',
|
106 |
|
107 |
// Trash
|
108 |
Flamingo_Outbound_Message::find( array( 'post_status' => 'trash' ) );
|
109 |
+
$posts_in_trash = Flamingo_Outbound_Message::count();
|
110 |
|
111 |
if ( empty( $posts_in_trash ) ) {
|
112 |
return $status_links;
|
153 |
}
|
154 |
|
155 |
if ( $this->is_trash or ! EMPTY_TRASH_DAYS ) {
|
156 |
+
$actions['delete'] = __( 'Delete permanently', 'flamingo' );
|
157 |
} else {
|
158 |
+
$actions['trash'] = __( 'Move to trash', 'flamingo' );
|
159 |
}
|
160 |
|
161 |
return $actions;
|
174 |
|
175 |
if ( $this->is_trash
|
176 |
and current_user_can( 'flamingo_delete_outbound_messages' ) ) {
|
177 |
+
submit_button( __( 'Empty trash', 'flamingo' ),
|
178 |
'button-secondary apply', 'delete_all', false );
|
179 |
}
|
180 |
?>
|
184 |
|
185 |
protected function column_default( $item, $column_name ) {
|
186 |
do_action( 'manage_flamingo_outbound_posts_custom_column',
|
187 |
+
$column_name, $item->id()
|
188 |
+
);
|
189 |
}
|
190 |
|
191 |
protected function column_cb( $item ) {
|
192 |
return sprintf(
|
193 |
'<input type="checkbox" name="%1$s[]" value="%2$s" />',
|
194 |
$this->_args['singular'],
|
195 |
+
$item->id()
|
196 |
+
);
|
197 |
}
|
198 |
|
199 |
protected function column_subject( $item ) {
|
202 |
}
|
203 |
|
204 |
$actions = array();
|
205 |
+
$post_id = absint( $item->id() );
|
206 |
|
207 |
$edit_link = add_query_arg(
|
208 |
array(
|
235 |
}
|
236 |
|
237 |
protected function column_date( $item ) {
|
238 |
+
$datetime = get_post_datetime( $item->id() );
|
239 |
|
240 |
+
if ( false === $datetime ) {
|
241 |
return '';
|
242 |
}
|
243 |
|
244 |
+
$t_time = sprintf(
|
245 |
+
/* translators: 1: date, 2: time */
|
246 |
+
__( '%1$s at %2$s', 'flamingo' ),
|
247 |
+
/* translators: date format, see https://www.php.net/date */
|
248 |
+
$datetime->format( __( 'Y/m/d', 'flamingo' ) ),
|
249 |
+
/* translators: time format, see https://www.php.net/date */
|
250 |
+
$datetime->format( __( 'g:i a', 'flamingo' ) )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
251 |
);
|
252 |
+
|
253 |
+
return $t_time;
|
254 |
}
|
255 |
}
|
admin/includes/meta-boxes.php
CHANGED
@@ -7,28 +7,31 @@ function flamingo_contact_submit_meta_box( $post ) {
|
|
7 |
|
8 |
<div id="delete-action">
|
9 |
<?php
|
10 |
-
if ( current_user_can( 'flamingo_delete_contact', $post->id ) ) {
|
11 |
$delete_text = __( 'Delete', 'flamingo' );
|
12 |
|
13 |
$delete_link = add_query_arg(
|
14 |
array(
|
15 |
-
'post' => $post->id,
|
16 |
'action' => 'delete',
|
17 |
),
|
18 |
menu_page_url( 'flamingo', false )
|
19 |
);
|
20 |
|
21 |
-
$delete_link = wp_nonce_url(
|
|
|
|
|
|
|
22 |
|
23 |
-
?><a class="submitdelete deletion" href="<?php echo esc_url( $delete_link ); ?>" onclick="if (confirm('<?php echo esc_js( sprintf( __( "You are about to delete this contact '%s'\n 'Cancel' to stop, 'OK' to delete." ), $post->email ) ); ?>')) {return true;} return false;"><?php echo esc_html( $delete_text ); ?></a><?php } ?>
|
24 |
</div>
|
25 |
|
26 |
<div id="publishing-action">
|
27 |
<span class="spinner"></span>
|
28 |
-
<?php if ( ! empty( $post->id ) ) : ?>
|
29 |
-
<input name="save" type="submit" class="button-primary" id="publish" tabindex="4" accesskey="p" value="<?php echo esc_attr( __( 'Update
|
30 |
<?php else : ?>
|
31 |
-
<input name="save" type="submit" class="button-primary" id="publish" tabindex="4" accesskey="p" value="<?php echo esc_attr( __( 'Add
|
32 |
<?php endif; ?>
|
33 |
</div>
|
34 |
|
@@ -47,10 +50,10 @@ function flamingo_contact_tags_meta_box( $post ) {
|
|
47 |
return;
|
48 |
}
|
49 |
|
50 |
-
$tags = wp_get_post_terms( $post->id, $taxonomy->name );
|
51 |
$tag_names = $tag_ids = array();
|
52 |
|
53 |
-
if ( ! empty( $tags )
|
54 |
foreach( $tags as $tag ) {
|
55 |
$tag_names[] = $tag->name;
|
56 |
$tag_ids[] = $tag->term_id;
|
@@ -117,21 +120,57 @@ function flamingo_inbound_submit_meta_box( $post ) {
|
|
117 |
<fieldset class="misc-pub-section" id="comment-status-radio">
|
118 |
<legend class="screen-reader-text"><?php echo esc_html( __( 'Inbound message status', 'flamingo' ) ); ?></legend>
|
119 |
<label><input type="radio"<?php checked( $post->spam, true ); ?> name="inbound[status]" value="spam" /><?php echo esc_html( __( 'Spam', 'flamingo' ) ); ?></label><br />
|
120 |
-
<label><input type="radio"<?php checked( $post->spam, false ); ?> name="inbound[status]" value="ham" /><?php echo esc_html( __( 'Not
|
121 |
</fieldset>
|
122 |
|
123 |
<div class="misc-pub-section curtime misc-pub-curtime">
|
124 |
<span id="timestamp">
|
125 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
echo sprintf(
|
127 |
/* translators: %s: message submission date */
|
128 |
esc_html( __( 'Submitted on: %s', 'flamingo' ) ),
|
129 |
-
'<b>' . esc_html( $
|
130 |
);
|
131 |
?>
|
132 |
</span>
|
133 |
</div>
|
134 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
if ( ! empty( $post->spam_log ) ) {
|
136 |
echo '<div class="misc-pub-section spam-log">', "\n";
|
137 |
|
@@ -165,23 +204,25 @@ function flamingo_inbound_submit_meta_box( $post ) {
|
|
165 |
<div id="major-publishing-actions">
|
166 |
<div id="delete-action">
|
167 |
<?php
|
168 |
-
if ( current_user_can( 'flamingo_delete_inbound_message', $post->id ) ) {
|
169 |
if ( ! EMPTY_TRASH_DAYS ) {
|
170 |
-
$delete_text = __( 'Delete
|
171 |
} else {
|
172 |
-
$delete_text = __( 'Move to
|
173 |
}
|
174 |
|
175 |
$delete_link = add_query_arg(
|
176 |
array(
|
177 |
-
'post' => $post->id,
|
178 |
'action' => 'trash',
|
179 |
),
|
180 |
menu_page_url( 'flamingo_inbound', false )
|
181 |
);
|
182 |
|
183 |
-
$delete_link = wp_nonce_url(
|
184 |
-
|
|
|
|
|
185 |
|
186 |
echo sprintf( '<a href="%1$s" class="submitdelete deletion">%2$s</a>',
|
187 |
esc_url( $delete_link ),
|
@@ -312,7 +353,7 @@ function flamingo_outbound_submit_meta_box( $post ) {
|
|
312 |
|
313 |
<div id="minor-publishing-actions">
|
314 |
<div id="save-action">
|
315 |
-
<?php if ( $initial
|
316 |
<input type="submit" name="save" id="save-post" value="<?php echo esc_attr( __( 'Save Draft', 'flamingo' ) ); ?>" class="button" />
|
317 |
<span class="spinner"></span>
|
318 |
<?php endif; ?>
|
@@ -331,23 +372,25 @@ function flamingo_outbound_submit_meta_box( $post ) {
|
|
331 |
<?php if ( ! $initial ) : ?>
|
332 |
<div id="delete-action">
|
333 |
<?php
|
334 |
-
if ( current_user_can( 'flamingo_delete_outbound_message', $post->id ) ) {
|
335 |
if ( ! EMPTY_TRASH_DAYS ) {
|
336 |
-
$delete_text = __( 'Delete
|
337 |
} else {
|
338 |
-
$delete_text = __( 'Move to
|
339 |
}
|
340 |
|
341 |
$delete_link = add_query_arg(
|
342 |
array(
|
343 |
-
'post' => $post->id,
|
344 |
'action' => 'trash',
|
345 |
),
|
346 |
menu_page_url( 'flamingo_outbound', false )
|
347 |
);
|
348 |
|
349 |
-
$delete_link = wp_nonce_url(
|
350 |
-
|
|
|
|
|
351 |
|
352 |
?><a class="submitdelete deletion" href="<?php echo esc_url( $delete_link ); ?>"><?php echo esc_html( $delete_text ); ?></a><?php } ?>
|
353 |
</div>
|
@@ -355,7 +398,7 @@ function flamingo_outbound_submit_meta_box( $post ) {
|
|
355 |
|
356 |
<div id="publishing-action">
|
357 |
<span class="spinner"></span>
|
358 |
-
<input name="send" type="submit" class="button-primary" id="publish" tabindex="4" accesskey="p" value="<?php echo esc_attr( __( 'Send
|
359 |
</div>
|
360 |
|
361 |
<div class="clear"></div>
|
7 |
|
8 |
<div id="delete-action">
|
9 |
<?php
|
10 |
+
if ( current_user_can( 'flamingo_delete_contact', $post->id() ) ) {
|
11 |
$delete_text = __( 'Delete', 'flamingo' );
|
12 |
|
13 |
$delete_link = add_query_arg(
|
14 |
array(
|
15 |
+
'post' => $post->id(),
|
16 |
'action' => 'delete',
|
17 |
),
|
18 |
menu_page_url( 'flamingo', false )
|
19 |
);
|
20 |
|
21 |
+
$delete_link = wp_nonce_url(
|
22 |
+
$delete_link,
|
23 |
+
'flamingo-delete-contact_' . $post->id()
|
24 |
+
);
|
25 |
|
26 |
+
?><a class="submitdelete deletion" href="<?php echo esc_url( $delete_link ); ?>" onclick="if (confirm('<?php echo esc_js( sprintf( __( "You are about to delete this contact '%s'\n 'Cancel' to stop, 'OK' to delete.", 'flamingo' ), $post->email ) ); ?>')) {return true;} return false;"><?php echo esc_html( $delete_text ); ?></a><?php } ?>
|
27 |
</div>
|
28 |
|
29 |
<div id="publishing-action">
|
30 |
<span class="spinner"></span>
|
31 |
+
<?php if ( ! empty( $post->id() ) ) : ?>
|
32 |
+
<input name="save" type="submit" class="button-primary" id="publish" tabindex="4" accesskey="p" value="<?php echo esc_attr( __( 'Update contact', 'flamingo' ) ); ?>" />
|
33 |
<?php else : ?>
|
34 |
+
<input name="save" type="submit" class="button-primary" id="publish" tabindex="4" accesskey="p" value="<?php echo esc_attr( __( 'Add contact', 'flamingo' ) ); ?>" />
|
35 |
<?php endif; ?>
|
36 |
</div>
|
37 |
|
50 |
return;
|
51 |
}
|
52 |
|
53 |
+
$tags = wp_get_post_terms( $post->id(), $taxonomy->name );
|
54 |
$tag_names = $tag_ids = array();
|
55 |
|
56 |
+
if ( ! empty( $tags ) and ! is_wp_error( $tags ) ) {
|
57 |
foreach( $tags as $tag ) {
|
58 |
$tag_names[] = $tag->name;
|
59 |
$tag_ids[] = $tag->term_id;
|
120 |
<fieldset class="misc-pub-section" id="comment-status-radio">
|
121 |
<legend class="screen-reader-text"><?php echo esc_html( __( 'Inbound message status', 'flamingo' ) ); ?></legend>
|
122 |
<label><input type="radio"<?php checked( $post->spam, true ); ?> name="inbound[status]" value="spam" /><?php echo esc_html( __( 'Spam', 'flamingo' ) ); ?></label><br />
|
123 |
+
<label><input type="radio"<?php checked( $post->spam, false ); ?> name="inbound[status]" value="ham" /><?php echo esc_html( __( 'Not spam', 'flamingo' ) ); ?></label>
|
124 |
</fieldset>
|
125 |
|
126 |
<div class="misc-pub-section curtime misc-pub-curtime">
|
127 |
<span id="timestamp">
|
128 |
<?php
|
129 |
+
$submitted_timestamp = get_post_timestamp( $post->id() );
|
130 |
+
|
131 |
+
$submitted_on = sprintf(
|
132 |
+
/* translators: Publish box date string. 1: Date, 2: Time. */
|
133 |
+
__( '%1$s at %2$s', 'flamingo' ),
|
134 |
+
wp_date(
|
135 |
+
/* translators: Publish box date format, see https://www.php.net/date */
|
136 |
+
_x( 'M j, Y', 'publish box date format', 'flamingo' ),
|
137 |
+
$submitted_timestamp
|
138 |
+
),
|
139 |
+
wp_date(
|
140 |
+
/* translators: Publish box time format, see https://www.php.net/date */
|
141 |
+
_x( 'H:i', 'publish box time format', 'flamingo' ),
|
142 |
+
$submitted_timestamp
|
143 |
+
)
|
144 |
+
);
|
145 |
+
|
146 |
echo sprintf(
|
147 |
/* translators: %s: message submission date */
|
148 |
esc_html( __( 'Submitted on: %s', 'flamingo' ) ),
|
149 |
+
'<b>' . esc_html( $submitted_on ) . '</b>'
|
150 |
);
|
151 |
?>
|
152 |
</span>
|
153 |
</div>
|
154 |
<?php
|
155 |
+
if ( ! empty( $post->submission_status ) ) {
|
156 |
+
echo '<div class="misc-pub-section submission-status">', "\n";
|
157 |
+
|
158 |
+
$submission_status = sprintf(
|
159 |
+
/* translators: %s: Result of the submission. */
|
160 |
+
esc_html( __( 'Submission result: %s', 'flamingo' ) ),
|
161 |
+
sprintf( '<b>%s</b>', esc_html( $post->submission_status ) )
|
162 |
+
);
|
163 |
+
|
164 |
+
echo sprintf(
|
165 |
+
'<span class="dashicons-before %1$s"> %2$s</span>',
|
166 |
+
in_array( $post->submission_status, array( 'mail_failed', 'spam' ) )
|
167 |
+
? 'dashicons-no' : 'dashicons-yes',
|
168 |
+
$submission_status
|
169 |
+
);
|
170 |
+
|
171 |
+
echo '</div>', "\n";
|
172 |
+
}
|
173 |
+
|
174 |
if ( ! empty( $post->spam_log ) ) {
|
175 |
echo '<div class="misc-pub-section spam-log">', "\n";
|
176 |
|
204 |
<div id="major-publishing-actions">
|
205 |
<div id="delete-action">
|
206 |
<?php
|
207 |
+
if ( current_user_can( 'flamingo_delete_inbound_message', $post->id() ) ) {
|
208 |
if ( ! EMPTY_TRASH_DAYS ) {
|
209 |
+
$delete_text = __( 'Delete permanently', 'flamingo' );
|
210 |
} else {
|
211 |
+
$delete_text = __( 'Move to trash', 'flamingo' );
|
212 |
}
|
213 |
|
214 |
$delete_link = add_query_arg(
|
215 |
array(
|
216 |
+
'post' => $post->id(),
|
217 |
'action' => 'trash',
|
218 |
),
|
219 |
menu_page_url( 'flamingo_inbound', false )
|
220 |
);
|
221 |
|
222 |
+
$delete_link = wp_nonce_url(
|
223 |
+
$delete_link,
|
224 |
+
'flamingo-trash-inbound-message_' . $post->id()
|
225 |
+
);
|
226 |
|
227 |
echo sprintf( '<a href="%1$s" class="submitdelete deletion">%2$s</a>',
|
228 |
esc_url( $delete_link ),
|
353 |
|
354 |
<div id="minor-publishing-actions">
|
355 |
<div id="save-action">
|
356 |
+
<?php if ( $initial or 'publish' != $post->post_status ) : ?>
|
357 |
<input type="submit" name="save" id="save-post" value="<?php echo esc_attr( __( 'Save Draft', 'flamingo' ) ); ?>" class="button" />
|
358 |
<span class="spinner"></span>
|
359 |
<?php endif; ?>
|
372 |
<?php if ( ! $initial ) : ?>
|
373 |
<div id="delete-action">
|
374 |
<?php
|
375 |
+
if ( current_user_can( 'flamingo_delete_outbound_message', $post->id() ) ) {
|
376 |
if ( ! EMPTY_TRASH_DAYS ) {
|
377 |
+
$delete_text = __( 'Delete permanently', 'flamingo' );
|
378 |
} else {
|
379 |
+
$delete_text = __( 'Move to trash', 'flamingo' );
|
380 |
}
|
381 |
|
382 |
$delete_link = add_query_arg(
|
383 |
array(
|
384 |
+
'post' => $post->id(),
|
385 |
'action' => 'trash',
|
386 |
),
|
387 |
menu_page_url( 'flamingo_outbound', false )
|
388 |
);
|
389 |
|
390 |
+
$delete_link = wp_nonce_url(
|
391 |
+
$delete_link,
|
392 |
+
'flamingo-trash-outbound-message_' . $post->id()
|
393 |
+
);
|
394 |
|
395 |
?><a class="submitdelete deletion" href="<?php echo esc_url( $delete_link ); ?>"><?php echo esc_html( $delete_text ); ?></a><?php } ?>
|
396 |
</div>
|
398 |
|
399 |
<div id="publishing-action">
|
400 |
<span class="spinner"></span>
|
401 |
+
<input name="send" type="submit" class="button-primary" id="publish" tabindex="4" accesskey="p" value="<?php echo esc_attr( __( 'Send message', 'flamingo' ) ); ?>" />
|
402 |
</div>
|
403 |
|
404 |
<div class="clear"></div>
|
admin/includes/privacy.php
CHANGED
@@ -1,7 +1,9 @@
|
|
1 |
<?php
|
2 |
|
3 |
add_filter( 'wp_privacy_personal_data_erasers',
|
4 |
-
'flamingo_privacy_register_personal_data_erasers',
|
|
|
|
|
5 |
|
6 |
function flamingo_privacy_register_personal_data_erasers( $erasers ) {
|
7 |
return array_merge( (array) $erasers, array(
|
@@ -31,7 +33,7 @@ function flamingo_privacy_contact_eraser( $email_address, $page = 1 ) {
|
|
31 |
$messages = array();
|
32 |
|
33 |
foreach ( (array) $posts as $post ) {
|
34 |
-
if ( ! current_user_can( 'flamingo_delete_contact', $post->id ) ) {
|
35 |
$items_retained = true;
|
36 |
|
37 |
$messages = array(
|
@@ -48,7 +50,7 @@ function flamingo_privacy_contact_eraser( $email_address, $page = 1 ) {
|
|
48 |
}
|
49 |
}
|
50 |
|
51 |
-
$done = Flamingo_Contact
|
52 |
|
53 |
return array(
|
54 |
'items_removed' => $items_removed,
|
@@ -73,7 +75,7 @@ function flamingo_privacy_inbound_eraser( $email_address, $page = 1 ) {
|
|
73 |
$messages = array();
|
74 |
|
75 |
foreach ( (array) $posts as $post ) {
|
76 |
-
if ( ! current_user_can( 'flamingo_delete_inbound_message', $post->id ) ) {
|
77 |
$items_retained = true;
|
78 |
|
79 |
$messages = array(
|
@@ -90,7 +92,7 @@ function flamingo_privacy_inbound_eraser( $email_address, $page = 1 ) {
|
|
90 |
}
|
91 |
}
|
92 |
|
93 |
-
$done = Flamingo_Inbound_Message
|
94 |
|
95 |
return array(
|
96 |
'items_removed' => $items_removed,
|
1 |
<?php
|
2 |
|
3 |
add_filter( 'wp_privacy_personal_data_erasers',
|
4 |
+
'flamingo_privacy_register_personal_data_erasers',
|
5 |
+
10, 1
|
6 |
+
);
|
7 |
|
8 |
function flamingo_privacy_register_personal_data_erasers( $erasers ) {
|
9 |
return array_merge( (array) $erasers, array(
|
33 |
$messages = array();
|
34 |
|
35 |
foreach ( (array) $posts as $post ) {
|
36 |
+
if ( ! current_user_can( 'flamingo_delete_contact', $post->id() ) ) {
|
37 |
$items_retained = true;
|
38 |
|
39 |
$messages = array(
|
50 |
}
|
51 |
}
|
52 |
|
53 |
+
$done = Flamingo_Contact::count() < $number;
|
54 |
|
55 |
return array(
|
56 |
'items_removed' => $items_removed,
|
75 |
$messages = array();
|
76 |
|
77 |
foreach ( (array) $posts as $post ) {
|
78 |
+
if ( ! current_user_can( 'flamingo_delete_inbound_message', $post->id() ) ) {
|
79 |
$items_retained = true;
|
80 |
|
81 |
$messages = array(
|
92 |
}
|
93 |
}
|
94 |
|
95 |
+
$done = Flamingo_Inbound_Message::count() < $number;
|
96 |
|
97 |
return array(
|
98 |
'items_removed' => $items_removed,
|
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: 2.
|
9 |
*/
|
10 |
|
11 |
-
define( 'FLAMINGO_VERSION', '2.
|
12 |
|
13 |
define( 'FLAMINGO_PLUGIN', __FILE__ );
|
14 |
|
@@ -47,10 +47,7 @@ if ( is_admin() ) {
|
|
47 |
|
48 |
/* Init */
|
49 |
|
50 |
-
add_action( 'init',
|
51 |
-
|
52 |
-
function flamingo_init() {
|
53 |
-
|
54 |
/* L10N */
|
55 |
load_plugin_textdomain( 'flamingo', false, 'flamingo/languages' );
|
56 |
|
@@ -60,4 +57,4 @@ function flamingo_init() {
|
|
60 |
Flamingo_Outbound_Message::register_post_type();
|
61 |
|
62 |
do_action( 'flamingo_init' );
|
63 |
-
}
|
5 |
Author: Takayuki Miyoshi
|
6 |
Text Domain: flamingo
|
7 |
Domain Path: /languages/
|
8 |
+
Version: 2.2
|
9 |
*/
|
10 |
|
11 |
+
define( 'FLAMINGO_VERSION', '2.2' );
|
12 |
|
13 |
define( 'FLAMINGO_PLUGIN', __FILE__ );
|
14 |
|
47 |
|
48 |
/* Init */
|
49 |
|
50 |
+
add_action( 'init', function() {
|
|
|
|
|
|
|
51 |
/* L10N */
|
52 |
load_plugin_textdomain( 'flamingo', false, 'flamingo/languages' );
|
53 |
|
57 |
Flamingo_Outbound_Message::register_post_type();
|
58 |
|
59 |
do_action( 'flamingo_init' );
|
60 |
+
}, 10, 0 );
|
includes/class-contact.php
CHANGED
@@ -5,9 +5,9 @@ class Flamingo_Contact {
|
|
5 |
const post_type = 'flamingo_contact';
|
6 |
const contact_tag_taxonomy = 'flamingo_contact_tag';
|
7 |
|
8 |
-
|
9 |
|
10 |
-
|
11 |
public $email;
|
12 |
public $name;
|
13 |
public $props = array();
|
@@ -74,6 +74,19 @@ class Flamingo_Contact {
|
|
74 |
return $objs;
|
75 |
}
|
76 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
public static function search_by_email( $email ) {
|
78 |
$objs = self::find( array(
|
79 |
'posts_per_page' => 1,
|
@@ -99,7 +112,7 @@ class Flamingo_Contact {
|
|
99 |
$args = apply_filters( 'flamingo_add_contact',
|
100 |
wp_parse_args( $args, $defaults ) );
|
101 |
|
102 |
-
if ( empty( $args['email'] )
|
103 |
return;
|
104 |
}
|
105 |
|
@@ -116,7 +129,7 @@ class Flamingo_Contact {
|
|
116 |
if ( ! empty( $args['last_contacted'] ) ) {
|
117 |
$obj->last_contacted = $args['last_contacted'];
|
118 |
} else {
|
119 |
-
$obj->last_contacted =
|
120 |
}
|
121 |
|
122 |
$obj->save();
|
@@ -125,7 +138,7 @@ class Flamingo_Contact {
|
|
125 |
}
|
126 |
|
127 |
public function __construct( $post = null ) {
|
128 |
-
if ( ! empty( $post )
|
129 |
$this->id = $post->ID;
|
130 |
$this->email = get_post_meta( $post->ID, '_email', true );
|
131 |
$this->name = get_post_meta( $post->ID, '_name', true );
|
@@ -135,7 +148,7 @@ class Flamingo_Contact {
|
|
135 |
|
136 |
$terms = wp_get_object_terms( $this->id, self::contact_tag_taxonomy );
|
137 |
|
138 |
-
if ( ! empty( $terms )
|
139 |
foreach ( $terms as $term ) {
|
140 |
$this->tags[] = $term->name;
|
141 |
}
|
@@ -143,6 +156,29 @@ class Flamingo_Contact {
|
|
143 |
}
|
144 |
}
|
145 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
public function save() {
|
147 |
$post_title = $this->email;
|
148 |
$post_name = strtr( $this->email, '@', '-' );
|
5 |
const post_type = 'flamingo_contact';
|
6 |
const contact_tag_taxonomy = 'flamingo_contact_tag';
|
7 |
|
8 |
+
private static $found_items = 0;
|
9 |
|
10 |
+
private $id;
|
11 |
public $email;
|
12 |
public $name;
|
13 |
public $props = array();
|
74 |
return $objs;
|
75 |
}
|
76 |
|
77 |
+
public static function count( $args = '' ) {
|
78 |
+
if ( $args ) {
|
79 |
+
$args = wp_parse_args( $args, array(
|
80 |
+
'offset' => 0,
|
81 |
+
'post_status' => 'publish',
|
82 |
+
) );
|
83 |
+
|
84 |
+
self::find( $args );
|
85 |
+
}
|
86 |
+
|
87 |
+
return absint( self::$found_items );
|
88 |
+
}
|
89 |
+
|
90 |
public static function search_by_email( $email ) {
|
91 |
$objs = self::find( array(
|
92 |
'posts_per_page' => 1,
|
112 |
$args = apply_filters( 'flamingo_add_contact',
|
113 |
wp_parse_args( $args, $defaults ) );
|
114 |
|
115 |
+
if ( empty( $args['email'] ) or ! is_email( $args['email'] ) ) {
|
116 |
return;
|
117 |
}
|
118 |
|
129 |
if ( ! empty( $args['last_contacted'] ) ) {
|
130 |
$obj->last_contacted = $args['last_contacted'];
|
131 |
} else {
|
132 |
+
$obj->last_contacted = wp_date( 'Y-m-d H:i:s' );
|
133 |
}
|
134 |
|
135 |
$obj->save();
|
138 |
}
|
139 |
|
140 |
public function __construct( $post = null ) {
|
141 |
+
if ( ! empty( $post ) and $post = get_post( $post ) ) {
|
142 |
$this->id = $post->ID;
|
143 |
$this->email = get_post_meta( $post->ID, '_email', true );
|
144 |
$this->name = get_post_meta( $post->ID, '_name', true );
|
148 |
|
149 |
$terms = wp_get_object_terms( $this->id, self::contact_tag_taxonomy );
|
150 |
|
151 |
+
if ( ! empty( $terms ) and ! is_wp_error( $terms ) ) {
|
152 |
foreach ( $terms as $term ) {
|
153 |
$this->tags[] = $term->name;
|
154 |
}
|
156 |
}
|
157 |
}
|
158 |
|
159 |
+
public function __get( $name ) {
|
160 |
+
/* translators: 1: Property, 2: Version, 3: Class, 4: Method. */
|
161 |
+
$message = __( 'The visibility of the %1$s property has been changed in %2$s. Now the property may only be accessed by the %3$s class. You can use the %4$s method instead.', 'flamingo' );
|
162 |
+
|
163 |
+
if ( 'id' == $name ) {
|
164 |
+
if ( WP_DEBUG ) {
|
165 |
+
trigger_error( sprintf(
|
166 |
+
$message,
|
167 |
+
sprintf( '<code>%s</code>', 'id' ),
|
168 |
+
esc_html( __( 'Flamingo 2.2', 'flamingo' ) ),
|
169 |
+
sprintf( '<code>%s</code>', self::class ),
|
170 |
+
sprintf( '<code>%s</code>', 'id()' )
|
171 |
+
) );
|
172 |
+
}
|
173 |
+
|
174 |
+
return $this->id;
|
175 |
+
}
|
176 |
+
}
|
177 |
+
|
178 |
+
public function id() {
|
179 |
+
return $this->id;
|
180 |
+
}
|
181 |
+
|
182 |
public function save() {
|
183 |
$post_title = $this->email;
|
184 |
$post_name = strtr( $this->email, '@', '-' );
|
includes/class-inbound-message.php
CHANGED
@@ -6,11 +6,11 @@ class Flamingo_Inbound_Message {
|
|
6 |
const spam_status = 'flamingo-spam';
|
7 |
const channel_taxonomy = 'flamingo_inbound_channel';
|
8 |
|
9 |
-
|
10 |
|
11 |
-
|
12 |
public $channel;
|
13 |
-
public $
|
14 |
public $subject;
|
15 |
public $from;
|
16 |
public $from_name;
|
@@ -22,6 +22,8 @@ class Flamingo_Inbound_Message {
|
|
22 |
public $spam;
|
23 |
public $spam_log;
|
24 |
public $consent;
|
|
|
|
|
25 |
|
26 |
public static function register_post_type() {
|
27 |
register_post_type( self::post_type, array(
|
@@ -65,6 +67,7 @@ class Flamingo_Inbound_Message {
|
|
65 |
'tax_query' => array(),
|
66 |
'channel' => '',
|
67 |
'channel_id' => 0,
|
|
|
68 |
);
|
69 |
|
70 |
$args = wp_parse_args( $args, $defaults );
|
@@ -87,6 +90,13 @@ class Flamingo_Inbound_Message {
|
|
87 |
);
|
88 |
}
|
89 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
$q = new WP_Query();
|
91 |
$posts = $q->query( $args );
|
92 |
|
@@ -102,14 +112,16 @@ class Flamingo_Inbound_Message {
|
|
102 |
}
|
103 |
|
104 |
public static function count( $args = '' ) {
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
|
|
|
|
113 |
|
114 |
return absint( self::$found_items );
|
115 |
}
|
@@ -117,6 +129,7 @@ class Flamingo_Inbound_Message {
|
|
117 |
public static function add( $args = '' ) {
|
118 |
$defaults = array(
|
119 |
'channel' => '',
|
|
|
120 |
'subject' => '',
|
121 |
'from' => '',
|
122 |
'from_name' => '',
|
@@ -128,14 +141,18 @@ class Flamingo_Inbound_Message {
|
|
128 |
'spam' => false,
|
129 |
'spam_log' => array(),
|
130 |
'consent' => array(),
|
|
|
|
|
131 |
);
|
132 |
|
133 |
$args = apply_filters( 'flamingo_add_inbound',
|
134 |
-
wp_parse_args( $args, $defaults )
|
|
|
135 |
|
136 |
$obj = new self();
|
137 |
|
138 |
$obj->channel = $args['channel'];
|
|
|
139 |
$obj->subject = $args['subject'];
|
140 |
$obj->from = $args['from'];
|
141 |
$obj->from_name = $args['from_name'];
|
@@ -148,18 +165,22 @@ class Flamingo_Inbound_Message {
|
|
148 |
$obj->spam_log = $args['spam_log'];
|
149 |
$obj->consent = $args['consent'];
|
150 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
$obj->save();
|
152 |
|
153 |
return $obj;
|
154 |
}
|
155 |
|
156 |
public function __construct( $post = null ) {
|
157 |
-
if ( ! empty( $post )
|
158 |
$this->id = $post->ID;
|
159 |
-
|
160 |
-
$this->date = get_the_time(
|
161 |
-
/* translators: date format, see https://php.net/date */
|
162 |
-
__( 'M j, Y @ H:i', 'flamingo' ), $this->id );
|
163 |
$this->subject = get_post_meta( $post->ID, '_subject', true );
|
164 |
$this->from = get_post_meta( $post->ID, '_from', true );
|
165 |
$this->from_name = get_post_meta( $post->ID, '_from_name', true );
|
@@ -177,6 +198,10 @@ class Flamingo_Inbound_Message {
|
|
177 |
}
|
178 |
}
|
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 );
|
@@ -185,7 +210,7 @@ class Flamingo_Inbound_Message {
|
|
185 |
|
186 |
$terms = wp_get_object_terms( $this->id, self::channel_taxonomy );
|
187 |
|
188 |
-
if ( ! empty( $terms )
|
189 |
$this->channel = $terms[0]->slug;
|
190 |
}
|
191 |
|
@@ -194,9 +219,34 @@ class Flamingo_Inbound_Message {
|
|
194 |
} else {
|
195 |
$this->spam = isset( $this->akismet['spam'] ) && $this->akismet['spam'];
|
196 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
197 |
}
|
198 |
}
|
199 |
|
|
|
|
|
|
|
|
|
200 |
public function save() {
|
201 |
if ( ! empty( $this->subject ) ) {
|
202 |
$post_title = $this->subject;
|
@@ -205,9 +255,9 @@ class Flamingo_Inbound_Message {
|
|
205 |
}
|
206 |
|
207 |
$post_content = array_merge(
|
208 |
-
$this->fields,
|
209 |
-
$this->consent,
|
210 |
-
$this->meta
|
211 |
);
|
212 |
|
213 |
$post_content = flamingo_array_flatten( $post_content );
|
@@ -225,12 +275,16 @@ class Flamingo_Inbound_Message {
|
|
225 |
'post_date' => $this->get_post_date(),
|
226 |
);
|
227 |
|
|
|
|
|
|
|
|
|
228 |
$post_id = wp_insert_post( $postarr );
|
229 |
|
230 |
if ( $post_id ) {
|
231 |
$this->id = $post_id;
|
232 |
|
233 |
-
if ( $post_status
|
234 |
|
235 |
// set spam meta time for later use to trash
|
236 |
update_post_meta( $post_id, '_spam_meta_time', time() );
|
@@ -240,6 +294,10 @@ class Flamingo_Inbound_Message {
|
|
240 |
delete_post_meta( $post_id, '_spam_meta_time' );
|
241 |
}
|
242 |
|
|
|
|
|
|
|
|
|
243 |
update_post_meta( $post_id, '_subject', $this->subject );
|
244 |
update_post_meta( $post_id, '_from', $this->from );
|
245 |
update_post_meta( $post_id, '_from_name', $this->from_name );
|
@@ -257,6 +315,7 @@ class Flamingo_Inbound_Message {
|
|
257 |
update_post_meta( $post_id, '_recaptcha', $this->recaptcha );
|
258 |
update_post_meta( $post_id, '_spam_log', $this->spam_log );
|
259 |
update_post_meta( $post_id, '_consent', $this->consent );
|
|
|
260 |
|
261 |
if ( term_exists( $this->channel, self::channel_taxonomy ) ) {
|
262 |
wp_set_object_terms( $this->id, $this->channel,
|
@@ -348,11 +407,11 @@ class Flamingo_Inbound_Message {
|
|
348 |
}
|
349 |
|
350 |
public function akismet_submit_spam() {
|
351 |
-
if ( empty( $this->id )
|
352 |
return;
|
353 |
}
|
354 |
|
355 |
-
if ( isset( $this->akismet['spam'] )
|
356 |
return;
|
357 |
}
|
358 |
|
@@ -379,11 +438,11 @@ class Flamingo_Inbound_Message {
|
|
379 |
}
|
380 |
|
381 |
public function akismet_submit_ham() {
|
382 |
-
if ( empty( $this->id )
|
383 |
return;
|
384 |
}
|
385 |
|
386 |
-
if ( isset( $this->akismet['spam'] )
|
387 |
return;
|
388 |
}
|
389 |
|
6 |
const spam_status = 'flamingo-spam';
|
7 |
const channel_taxonomy = 'flamingo_inbound_channel';
|
8 |
|
9 |
+
private static $found_items = 0;
|
10 |
|
11 |
+
private $id;
|
12 |
public $channel;
|
13 |
+
public $submission_status;
|
14 |
public $subject;
|
15 |
public $from;
|
16 |
public $from_name;
|
22 |
public $spam;
|
23 |
public $spam_log;
|
24 |
public $consent;
|
25 |
+
private $timestamp = null;
|
26 |
+
private $hash = null;
|
27 |
|
28 |
public static function register_post_type() {
|
29 |
register_post_type( self::post_type, array(
|
67 |
'tax_query' => array(),
|
68 |
'channel' => '',
|
69 |
'channel_id' => 0,
|
70 |
+
'hash' => '',
|
71 |
);
|
72 |
|
73 |
$args = wp_parse_args( $args, $defaults );
|
90 |
);
|
91 |
}
|
92 |
|
93 |
+
if ( ! empty( $args['hash'] ) ) {
|
94 |
+
$args['meta_query'][] = array(
|
95 |
+
'key' => '_hash',
|
96 |
+
'value' => $args['hash'],
|
97 |
+
);
|
98 |
+
}
|
99 |
+
|
100 |
$q = new WP_Query();
|
101 |
$posts = $q->query( $args );
|
102 |
|
112 |
}
|
113 |
|
114 |
public static function count( $args = '' ) {
|
115 |
+
if ( $args ) {
|
116 |
+
$args = wp_parse_args( $args, array(
|
117 |
+
'offset' => 0,
|
118 |
+
'channel' => '',
|
119 |
+
'channel_id' => 0,
|
120 |
+
'post_status' => 'publish',
|
121 |
+
) );
|
122 |
+
|
123 |
+
self::find( $args );
|
124 |
+
}
|
125 |
|
126 |
return absint( self::$found_items );
|
127 |
}
|
129 |
public static function add( $args = '' ) {
|
130 |
$defaults = array(
|
131 |
'channel' => '',
|
132 |
+
'status' => '',
|
133 |
'subject' => '',
|
134 |
'from' => '',
|
135 |
'from_name' => '',
|
141 |
'spam' => false,
|
142 |
'spam_log' => array(),
|
143 |
'consent' => array(),
|
144 |
+
'timestamp' => null,
|
145 |
+
'posted_data_hash' => null,
|
146 |
);
|
147 |
|
148 |
$args = apply_filters( 'flamingo_add_inbound',
|
149 |
+
wp_parse_args( $args, $defaults )
|
150 |
+
);
|
151 |
|
152 |
$obj = new self();
|
153 |
|
154 |
$obj->channel = $args['channel'];
|
155 |
+
$obj->submission_status = $args['status'];
|
156 |
$obj->subject = $args['subject'];
|
157 |
$obj->from = $args['from'];
|
158 |
$obj->from_name = $args['from_name'];
|
165 |
$obj->spam_log = $args['spam_log'];
|
166 |
$obj->consent = $args['consent'];
|
167 |
|
168 |
+
if ( $args['timestamp'] ) {
|
169 |
+
$obj->timestamp = $args['timestamp'];
|
170 |
+
}
|
171 |
+
|
172 |
+
if ( $args['posted_data_hash'] ) {
|
173 |
+
$obj->hash = $args['posted_data_hash'];
|
174 |
+
}
|
175 |
+
|
176 |
$obj->save();
|
177 |
|
178 |
return $obj;
|
179 |
}
|
180 |
|
181 |
public function __construct( $post = null ) {
|
182 |
+
if ( ! empty( $post ) and $post = get_post( $post ) ) {
|
183 |
$this->id = $post->ID;
|
|
|
|
|
|
|
|
|
184 |
$this->subject = get_post_meta( $post->ID, '_subject', true );
|
185 |
$this->from = get_post_meta( $post->ID, '_from', true );
|
186 |
$this->from_name = get_post_meta( $post->ID, '_from_name', true );
|
198 |
}
|
199 |
}
|
200 |
|
201 |
+
$this->submission_status = get_post_meta( $post->ID,
|
202 |
+
'_submission_status', true
|
203 |
+
);
|
204 |
+
|
205 |
$this->meta = get_post_meta( $post->ID, '_meta', true );
|
206 |
$this->akismet = get_post_meta( $post->ID, '_akismet', true );
|
207 |
$this->recaptcha = get_post_meta( $post->ID, '_recaptcha', true );
|
210 |
|
211 |
$terms = wp_get_object_terms( $this->id, self::channel_taxonomy );
|
212 |
|
213 |
+
if ( ! empty( $terms ) and ! is_wp_error( $terms ) ) {
|
214 |
$this->channel = $terms[0]->slug;
|
215 |
}
|
216 |
|
219 |
} else {
|
220 |
$this->spam = isset( $this->akismet['spam'] ) && $this->akismet['spam'];
|
221 |
}
|
222 |
+
|
223 |
+
$this->hash = get_post_meta( $post->ID, '_hash', true );
|
224 |
+
}
|
225 |
+
}
|
226 |
+
|
227 |
+
public function __get( $name ) {
|
228 |
+
/* translators: 1: Property, 2: Version, 3: Class, 4: Method. */
|
229 |
+
$message = __( 'The visibility of the %1$s property has been changed in %2$s. Now the property may only be accessed by the %3$s class. You can use the %4$s method instead.', 'flamingo' );
|
230 |
+
|
231 |
+
if ( 'id' == $name ) {
|
232 |
+
if ( WP_DEBUG ) {
|
233 |
+
trigger_error( sprintf(
|
234 |
+
$message,
|
235 |
+
sprintf( '<code>%s</code>', 'id' ),
|
236 |
+
esc_html( __( 'Flamingo 2.2', 'flamingo' ) ),
|
237 |
+
sprintf( '<code>%s</code>', self::class ),
|
238 |
+
sprintf( '<code>%s</code>', 'id()' )
|
239 |
+
) );
|
240 |
+
}
|
241 |
+
|
242 |
+
return $this->id;
|
243 |
}
|
244 |
}
|
245 |
|
246 |
+
public function id() {
|
247 |
+
return $this->id;
|
248 |
+
}
|
249 |
+
|
250 |
public function save() {
|
251 |
if ( ! empty( $this->subject ) ) {
|
252 |
$post_title = $this->subject;
|
255 |
}
|
256 |
|
257 |
$post_content = array_merge(
|
258 |
+
(array) $this->fields,
|
259 |
+
(array) $this->consent,
|
260 |
+
(array) $this->meta
|
261 |
);
|
262 |
|
263 |
$post_content = flamingo_array_flatten( $post_content );
|
275 |
'post_date' => $this->get_post_date(),
|
276 |
);
|
277 |
|
278 |
+
if ( $this->timestamp ) {
|
279 |
+
$postarr['post_date'] = wp_date( 'Y-m-d H:i:s', $this->timestamp );
|
280 |
+
}
|
281 |
+
|
282 |
$post_id = wp_insert_post( $postarr );
|
283 |
|
284 |
if ( $post_id ) {
|
285 |
$this->id = $post_id;
|
286 |
|
287 |
+
if ( $post_status === self::spam_status ) {
|
288 |
|
289 |
// set spam meta time for later use to trash
|
290 |
update_post_meta( $post_id, '_spam_meta_time', time() );
|
294 |
delete_post_meta( $post_id, '_spam_meta_time' );
|
295 |
}
|
296 |
|
297 |
+
update_post_meta( $post_id, '_submission_status',
|
298 |
+
$this->submission_status
|
299 |
+
);
|
300 |
+
|
301 |
update_post_meta( $post_id, '_subject', $this->subject );
|
302 |
update_post_meta( $post_id, '_from', $this->from );
|
303 |
update_post_meta( $post_id, '_from_name', $this->from_name );
|
315 |
update_post_meta( $post_id, '_recaptcha', $this->recaptcha );
|
316 |
update_post_meta( $post_id, '_spam_log', $this->spam_log );
|
317 |
update_post_meta( $post_id, '_consent', $this->consent );
|
318 |
+
update_post_meta( $post_id, '_hash', $this->hash );
|
319 |
|
320 |
if ( term_exists( $this->channel, self::channel_taxonomy ) ) {
|
321 |
wp_set_object_terms( $this->id, $this->channel,
|
407 |
}
|
408 |
|
409 |
public function akismet_submit_spam() {
|
410 |
+
if ( empty( $this->id ) or empty( $this->akismet ) ) {
|
411 |
return;
|
412 |
}
|
413 |
|
414 |
+
if ( isset( $this->akismet['spam'] ) and $this->akismet['spam'] ) {
|
415 |
return;
|
416 |
}
|
417 |
|
438 |
}
|
439 |
|
440 |
public function akismet_submit_ham() {
|
441 |
+
if ( empty( $this->id ) or empty( $this->akismet ) ) {
|
442 |
return;
|
443 |
}
|
444 |
|
445 |
+
if ( isset( $this->akismet['spam'] ) and ! $this->akismet['spam'] ) {
|
446 |
return;
|
447 |
}
|
448 |
|
includes/class-outbound-message.php
CHANGED
@@ -4,10 +4,9 @@ class Flamingo_Outbound_Message {
|
|
4 |
|
5 |
const post_type = 'flamingo_outbound';
|
6 |
|
7 |
-
|
8 |
|
9 |
-
|
10 |
-
public $date;
|
11 |
public $to;
|
12 |
public $from;
|
13 |
public $subject;
|
@@ -55,6 +54,19 @@ class Flamingo_Outbound_Message {
|
|
55 |
return $objs;
|
56 |
}
|
57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
public static function add( $args = '' ) {
|
59 |
$defaults = array(
|
60 |
'to' => '',
|
@@ -79,11 +91,8 @@ class Flamingo_Outbound_Message {
|
|
79 |
}
|
80 |
|
81 |
public function __construct( $post = null ) {
|
82 |
-
if ( ! empty( $post )
|
83 |
$this->id = $post->ID;
|
84 |
-
|
85 |
-
$this->date = get_the_time(
|
86 |
-
__( 'Y/m/d g:i:s A', 'flamingo' ), $this->id );
|
87 |
$this->to = get_post_meta( $post->ID, '_to', true );
|
88 |
$this->from = get_post_meta( $post->ID, '_from', true );
|
89 |
$this->subject = get_post_meta( $post->ID, '_subject', true );
|
@@ -91,6 +100,29 @@ class Flamingo_Outbound_Message {
|
|
91 |
}
|
92 |
}
|
93 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
public function save() {
|
95 |
if ( ! empty( $this->subject ) ) {
|
96 |
$post_title = $this->subject;
|
4 |
|
5 |
const post_type = 'flamingo_outbound';
|
6 |
|
7 |
+
private static $found_items = 0;
|
8 |
|
9 |
+
private $id;
|
|
|
10 |
public $to;
|
11 |
public $from;
|
12 |
public $subject;
|
54 |
return $objs;
|
55 |
}
|
56 |
|
57 |
+
public static function count( $args = '' ) {
|
58 |
+
if ( $args ) {
|
59 |
+
$args = wp_parse_args( $args, array(
|
60 |
+
'offset' => 0,
|
61 |
+
'post_status' => 'publish',
|
62 |
+
) );
|
63 |
+
|
64 |
+
self::find( $args );
|
65 |
+
}
|
66 |
+
|
67 |
+
return absint( self::$found_items );
|
68 |
+
}
|
69 |
+
|
70 |
public static function add( $args = '' ) {
|
71 |
$defaults = array(
|
72 |
'to' => '',
|
91 |
}
|
92 |
|
93 |
public function __construct( $post = null ) {
|
94 |
+
if ( ! empty( $post ) and $post = get_post( $post ) ) {
|
95 |
$this->id = $post->ID;
|
|
|
|
|
|
|
96 |
$this->to = get_post_meta( $post->ID, '_to', true );
|
97 |
$this->from = get_post_meta( $post->ID, '_from', true );
|
98 |
$this->subject = get_post_meta( $post->ID, '_subject', true );
|
100 |
}
|
101 |
}
|
102 |
|
103 |
+
public function __get( $name ) {
|
104 |
+
/* translators: 1: Property, 2: Version, 3: Class, 4: Method. */
|
105 |
+
$message = __( 'The visibility of the %1$s property has been changed in %2$s. Now the property may only be accessed by the %3$s class. You can use the %4$s method instead.', 'flamingo' );
|
106 |
+
|
107 |
+
if ( 'id' == $name ) {
|
108 |
+
if ( WP_DEBUG ) {
|
109 |
+
trigger_error( sprintf(
|
110 |
+
$message,
|
111 |
+
sprintf( '<code>%s</code>', 'id' ),
|
112 |
+
esc_html( __( 'Flamingo 2.2', 'flamingo' ) ),
|
113 |
+
sprintf( '<code>%s</code>', self::class ),
|
114 |
+
sprintf( '<code>%s</code>', 'id()' )
|
115 |
+
) );
|
116 |
+
}
|
117 |
+
|
118 |
+
return $this->id;
|
119 |
+
}
|
120 |
+
}
|
121 |
+
|
122 |
+
public function id() {
|
123 |
+
return $this->id;
|
124 |
+
}
|
125 |
+
|
126 |
public function save() {
|
127 |
if ( ! empty( $this->subject ) ) {
|
128 |
$post_title = $this->subject;
|
includes/comment.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
** Module for WordPress comment.
|
4 |
**/
|
5 |
|
6 |
-
add_action( 'wp_insert_comment', 'flamingo_insert_comment' );
|
7 |
|
8 |
function flamingo_insert_comment( $comment_id ) {
|
9 |
$comment = get_comment( $comment_id );
|
@@ -20,7 +20,9 @@ function flamingo_insert_comment( $comment_id ) {
|
|
20 |
}
|
21 |
|
22 |
add_action( 'transition_comment_status',
|
23 |
-
'flamingo_transition_comment_status',
|
|
|
|
|
24 |
|
25 |
function flamingo_transition_comment_status( $new_status, $old_status, $comment ) {
|
26 |
if ( 'approved' != $new_status ) {
|
@@ -39,7 +41,9 @@ function flamingo_transition_comment_status( $new_status, $old_status, $comment
|
|
39 |
|
40 |
/* Collect contact info from existing comments when activating plugin */
|
41 |
add_action( 'activate_' . FLAMINGO_PLUGIN_BASENAME,
|
42 |
-
'flamingo_collect_contacts_from_comments'
|
|
|
|
|
43 |
|
44 |
function flamingo_collect_contacts_from_comments() {
|
45 |
$comments = get_comments( array(
|
3 |
** Module for WordPress comment.
|
4 |
**/
|
5 |
|
6 |
+
add_action( 'wp_insert_comment', 'flamingo_insert_comment', 10, 1 );
|
7 |
|
8 |
function flamingo_insert_comment( $comment_id ) {
|
9 |
$comment = get_comment( $comment_id );
|
20 |
}
|
21 |
|
22 |
add_action( 'transition_comment_status',
|
23 |
+
'flamingo_transition_comment_status',
|
24 |
+
10, 3
|
25 |
+
);
|
26 |
|
27 |
function flamingo_transition_comment_status( $new_status, $old_status, $comment ) {
|
28 |
if ( 'approved' != $new_status ) {
|
41 |
|
42 |
/* Collect contact info from existing comments when activating plugin */
|
43 |
add_action( 'activate_' . FLAMINGO_PLUGIN_BASENAME,
|
44 |
+
'flamingo_collect_contacts_from_comments',
|
45 |
+
10, 0
|
46 |
+
);
|
47 |
|
48 |
function flamingo_collect_contacts_from_comments() {
|
49 |
$comments = get_comments( array(
|
includes/csv.php
CHANGED
@@ -12,7 +12,7 @@ function flamingo_csv_row( $inputs = array() ) {
|
|
12 |
return implode( $separator, $row );
|
13 |
}
|
14 |
|
15 |
-
add_filter( 'flamingo_csv_quotation', 'flamingo_csv_quote' );
|
16 |
|
17 |
function flamingo_csv_quote( $input ) {
|
18 |
$prefix = apply_filters( 'flamingo_csv_field_prefix', '', $input );
|
@@ -24,7 +24,8 @@ function flamingo_csv_quote( $input ) {
|
|
24 |
/*
|
25 |
* https://contactform7.com/2020/01/15/heads-up-about-spreadsheet-vulnerabilities/
|
26 |
*/
|
27 |
-
add_filter( 'flamingo_csv_field_prefix',
|
|
|
28 |
10, 2
|
29 |
);
|
30 |
|
12 |
return implode( $separator, $row );
|
13 |
}
|
14 |
|
15 |
+
add_filter( 'flamingo_csv_quotation', 'flamingo_csv_quote', 10, 1 );
|
16 |
|
17 |
function flamingo_csv_quote( $input ) {
|
18 |
$prefix = apply_filters( 'flamingo_csv_field_prefix', '', $input );
|
24 |
/*
|
25 |
* https://contactform7.com/2020/01/15/heads-up-about-spreadsheet-vulnerabilities/
|
26 |
*/
|
27 |
+
add_filter( 'flamingo_csv_field_prefix',
|
28 |
+
'flamingo_csv_field_prefix_text',
|
29 |
10, 2
|
30 |
);
|
31 |
|
includes/functions.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
function flamingo_plugin_url( $path = '' ) {
|
4 |
$url = plugins_url( $path, FLAMINGO_PLUGIN );
|
5 |
|
6 |
-
if ( is_ssl()
|
7 |
$url = 'https:' . substr( $url, 5 );
|
8 |
}
|
9 |
|
@@ -52,7 +52,7 @@ function flamingo_schedule_move_trash() {
|
|
52 |
if ( $post->trash() ) {
|
53 |
|
54 |
// delete spam meta time to stop trashing in cron job
|
55 |
-
delete_post_meta( $post->id, '_spam_meta_time' );
|
56 |
}
|
57 |
|
58 |
}
|
3 |
function flamingo_plugin_url( $path = '' ) {
|
4 |
$url = plugins_url( $path, FLAMINGO_PLUGIN );
|
5 |
|
6 |
+
if ( is_ssl() and 'http:' == substr( $url, 0, 5 ) ) {
|
7 |
$url = 'https:' . substr( $url, 5 );
|
8 |
}
|
9 |
|
52 |
if ( $post->trash() ) {
|
53 |
|
54 |
// delete spam meta time to stop trashing in cron job
|
55 |
+
delete_post_meta( $post->id(), '_spam_meta_time' );
|
56 |
}
|
57 |
|
58 |
}
|
includes/user.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
** Module for WordPress user.
|
4 |
**/
|
5 |
|
6 |
-
add_action( 'profile_update', 'flamingo_user_profile_update' );
|
7 |
-
add_action( 'user_register', 'flamingo_user_profile_update' );
|
8 |
|
9 |
function flamingo_user_profile_update( $user_id ) {
|
10 |
$user = new WP_User( $user_id );
|
@@ -29,7 +29,9 @@ function flamingo_user_profile_update( $user_id ) {
|
|
29 |
|
30 |
/* Collect contact info from existing users when activating plugin */
|
31 |
add_action( 'activate_' . FLAMINGO_PLUGIN_BASENAME,
|
32 |
-
'flamingo_collect_contacts_from_users'
|
|
|
|
|
33 |
|
34 |
function flamingo_collect_contacts_from_users() {
|
35 |
$users = get_users( array(
|
3 |
** Module for WordPress user.
|
4 |
**/
|
5 |
|
6 |
+
add_action( 'profile_update', 'flamingo_user_profile_update', 10, 1 );
|
7 |
+
add_action( 'user_register', 'flamingo_user_profile_update', 10, 1 );
|
8 |
|
9 |
function flamingo_user_profile_update( $user_id ) {
|
10 |
$user = new WP_User( $user_id );
|
29 |
|
30 |
/* Collect contact info from existing users when activating plugin */
|
31 |
add_action( 'activate_' . FLAMINGO_PLUGIN_BASENAME,
|
32 |
+
'flamingo_collect_contacts_from_users',
|
33 |
+
10, 0
|
34 |
+
);
|
35 |
|
36 |
function flamingo_collect_contacts_from_users() {
|
37 |
$users = get_users( array(
|
readme.txt
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
=== Flamingo ===
|
2 |
Contributors: takayukister, megumithemes, itpixelz
|
3 |
Tags: bird, contact, mail, crm
|
4 |
-
Requires at least: 5.
|
5 |
-
Tested up to: 5.
|
6 |
-
Stable tag: 2.
|
7 |
License: GPLv2 or later
|
8 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
@@ -32,6 +32,15 @@ This plugin stores submission data collected through contact forms, which may in
|
|
32 |
|
33 |
== Changelog ==
|
34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
= 2.1.1 =
|
36 |
|
37 |
* Security enhancement, CSV: Prefixes a field when its value begins with `=`, `+`, `-`, or `@`. See https://contactform7.com/2020/01/15/heads-up-about-spreadsheet-vulnerabilities/ for details.
|
@@ -41,8 +50,3 @@ This plugin stores submission data collected through contact forms, which may in
|
|
41 |
|
42 |
* UI improvements in displaying JSON reCAPTCHA logs in the Inbound Message editor page.
|
43 |
* Moves to trash automatically after every 30 days of the creation of spam messages.
|
44 |
-
|
45 |
-
= 2.0 =
|
46 |
-
|
47 |
-
* Displays spam logs in the Inbound Message editor page.
|
48 |
-
* Displays reCAPTCHA logs in the Inbound Message editor page.
|
1 |
=== Flamingo ===
|
2 |
Contributors: takayukister, megumithemes, itpixelz
|
3 |
Tags: bird, contact, mail, crm
|
4 |
+
Requires at least: 5.4
|
5 |
+
Tested up to: 5.5
|
6 |
+
Stable tag: 2.2
|
7 |
License: GPLv2 or later
|
8 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
32 |
|
33 |
== Changelog ==
|
34 |
|
35 |
+
= 2.2 =
|
36 |
+
|
37 |
+
* Sets the `post_date` of an inbound message based on the submission timestamp.
|
38 |
+
* Allows users to search and filter messages within the Spam subgroup.
|
39 |
+
* Changes the visibility of the `$found_items` property to private and introduces the `count()` method as an alternative.
|
40 |
+
* Changes the visibility of the `$id` property to private and introduces the `id()` method as an alternative.
|
41 |
+
* Introduces the submission result in the inbound message viewer screen.
|
42 |
+
* Stores the `posted_data_hash` value for search.
|
43 |
+
|
44 |
= 2.1.1 =
|
45 |
|
46 |
* Security enhancement, CSV: Prefixes a field when its value begins with `=`, `+`, `-`, or `@`. See https://contactform7.com/2020/01/15/heads-up-about-spreadsheet-vulnerabilities/ for details.
|
50 |
|
51 |
* UI improvements in displaying JSON reCAPTCHA logs in the Inbound Message editor page.
|
52 |
* Moves to trash automatically after every 30 days of the creation of spam messages.
|
|
|
|
|
|
|
|
|
|