Version Description
- Tested up to WordPress 4.8.
- Requires WordPress 4.7 or higher.
- Added RTL stylesheet.
- Strengthened capability checking.
- Removed inappropriate content from h1 headings.
- Changed the default format of the export CSV.
- Introduced the flamingo_csv_value_separator and flamingo_csv_quotation filter hooks to enable customizing CSV output.
Download this release
Release Info
Developer | takayukister |
Plugin | Flamingo |
Version | 1.6 |
Comparing to | |
See all releases |
Code changes from version 1.5 to 1.6
- admin/admin.php +127 -80
- admin/css/style-rtl.css +15 -0
- admin/{style.css → css/style.css} +0 -0
- admin/edit-contact-form.php +2 -1
- admin/edit-inbound-form.php +2 -1
- admin/edit-outbound-form.php +2 -1
- admin/includes/class-contacts-list-table.php +67 -35
- admin/includes/class-inbound-messages-list-table.php +69 -40
- admin/includes/class-outbound-messages-list-table.php +41 -23
- admin/includes/meta-boxes.php +31 -20
- admin/js/script.js +13 -0
- admin/script.js +0 -7
- flamingo.php +4 -3
- includes/capabilities.php +5 -3
- includes/class-contact.php +39 -20
- includes/class-inbound-message.php +55 -28
- includes/class-outbound-message.php +27 -14
- includes/comment.php +10 -5
- includes/csv.php +19 -0
- includes/formatting.php +0 -13
- includes/user.php +12 -6
- license.txt +19 -0
- readme.txt +15 -12
admin/admin.php
CHANGED
@@ -38,7 +38,8 @@ add_filter( 'set-screen-option', 'flamingo_set_screen_options', 10, 3 );
|
|
38 |
function flamingo_set_screen_options( $result, $option, $value ) {
|
39 |
$flamingo_screens = array(
|
40 |
'toplevel_page_flamingo_per_page',
|
41 |
-
'flamingo_page_flamingo_inbound_per_page'
|
|
|
42 |
|
43 |
if ( in_array( $option, $flamingo_screens ) ) {
|
44 |
$result = $value;
|
@@ -50,58 +51,62 @@ function flamingo_set_screen_options( $result, $option, $value ) {
|
|
50 |
add_action( 'admin_enqueue_scripts', 'flamingo_admin_enqueue_scripts' );
|
51 |
|
52 |
function flamingo_admin_enqueue_scripts( $hook_suffix ) {
|
53 |
-
if ( false === strpos( $hook_suffix, 'flamingo' ) )
|
54 |
return;
|
|
|
55 |
|
56 |
wp_enqueue_style( 'flamingo-admin',
|
57 |
-
flamingo_plugin_url( 'admin/style.css' ),
|
58 |
array(), FLAMINGO_VERSION, 'all' );
|
59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
wp_enqueue_script( 'flamingo-admin',
|
61 |
-
flamingo_plugin_url( 'admin/script.js' ),
|
62 |
array( 'postbox' ), FLAMINGO_VERSION, true );
|
63 |
|
64 |
$current_screen = get_current_screen();
|
65 |
|
66 |
-
wp_localize_script( 'flamingo-admin', '
|
67 |
-
'screenId' => $current_screen->id
|
|
|
68 |
}
|
69 |
|
70 |
/* Updated Message */
|
71 |
|
72 |
-
add_action( 'flamingo_admin_updated_message',
|
|
|
73 |
|
74 |
function flamingo_admin_updated_message() {
|
75 |
-
if (
|
76 |
-
if ( 'contactupdated' == $_REQUEST['message'] )
|
77 |
-
$updated_message = esc_html( __( 'Contact updated.', 'flamingo' ) );
|
78 |
-
elseif ( 'contactdeleted' == $_REQUEST['message'] )
|
79 |
-
$updated_message = esc_html( __( 'Contact deleted.', 'flamingo' ) );
|
80 |
-
elseif ( 'inboundtrashed' == $_REQUEST['message'] )
|
81 |
-
$updated_message = esc_html( __( 'Messages trashed.', 'flamingo' ) );
|
82 |
-
elseif ( 'inbounduntrashed' == $_REQUEST['message'] )
|
83 |
-
$updated_message = esc_html( __( 'Messages restored.', 'flamingo' ) );
|
84 |
-
elseif ( 'inbounddeleted' == $_REQUEST['message'] )
|
85 |
-
$updated_message = esc_html( __( 'Messages deleted.', 'flamingo' ) );
|
86 |
-
elseif ( 'inboundspammed' == $_REQUEST['message'] )
|
87 |
-
$updated_message = esc_html( __( 'Messages got marked as spam.', 'flamingo' ) );
|
88 |
-
elseif ( 'inboundunspammed' == $_REQUEST['message'] )
|
89 |
-
$updated_message = esc_html( __( 'Messages got marked as not spam.', 'flamingo' ) );
|
90 |
-
elseif ( 'outboundupdated' == $_REQUEST['message'] )
|
91 |
-
$updated_message = esc_html( __( 'Messages updated.', 'flamingo' ) );
|
92 |
-
else
|
93 |
-
return;
|
94 |
-
} else {
|
95 |
return;
|
96 |
}
|
97 |
|
98 |
-
if (
|
99 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
}
|
101 |
|
102 |
-
|
103 |
-
<div id="message" class="
|
104 |
-
|
105 |
}
|
106 |
|
107 |
/* Contact */
|
@@ -131,10 +136,13 @@ function flamingo_load_contact_admin() {
|
|
131 |
|
132 |
$post->save();
|
133 |
|
134 |
-
$redirect_to = add_query_arg(
|
135 |
-
|
136 |
-
|
137 |
-
|
|
|
|
|
|
|
138 |
}
|
139 |
|
140 |
wp_safe_redirect( $redirect_to );
|
@@ -190,8 +198,11 @@ function flamingo_load_contact_admin() {
|
|
190 |
header( 'Content-Type: text/csv; charset=' . get_option( 'blog_charset' ) );
|
191 |
|
192 |
$labels = array(
|
193 |
-
__( 'Email', 'flamingo' ),
|
194 |
-
__( '
|
|
|
|
|
|
|
195 |
|
196 |
echo flamingo_csv_row( $labels );
|
197 |
|
@@ -199,7 +210,8 @@ function flamingo_load_contact_admin() {
|
|
199 |
'posts_per_page' => -1,
|
200 |
'orderby' => 'meta_value',
|
201 |
'order' => 'ASC',
|
202 |
-
'meta_key' => '_email'
|
|
|
203 |
|
204 |
if ( ! empty( $_GET['s'] ) ) {
|
205 |
$args['s'] = $_GET['s'];
|
@@ -228,7 +240,8 @@ function flamingo_load_contact_admin() {
|
|
228 |
$item->email,
|
229 |
$item->get_prop( 'name' ),
|
230 |
$item->get_prop( 'first_name' ),
|
231 |
-
$item->get_prop( 'last_name' )
|
|
|
232 |
|
233 |
echo "\r\n" . flamingo_csv_row( $row );
|
234 |
}
|
@@ -240,18 +253,30 @@ function flamingo_load_contact_admin() {
|
|
240 |
&& ! empty( $_REQUEST['contact_tag_id'] ) ) {
|
241 |
$redirect_to = admin_url( 'admin.php?page=flamingo_outbound' );
|
242 |
|
243 |
-
$redirect_to = add_query_arg(
|
244 |
-
|
245 |
-
|
246 |
-
|
|
|
|
|
247 |
|
248 |
wp_safe_redirect( $redirect_to );
|
249 |
exit();
|
250 |
}
|
251 |
|
252 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
253 |
|
254 |
-
if ( Flamingo_Contact::post_type == get_post_type( $post_id ) ) {
|
255 |
add_meta_box( 'submitdiv', __( 'Save', 'flamingo' ),
|
256 |
'flamingo_contact_submit_meta_box', null, 'side', 'core' );
|
257 |
|
@@ -279,11 +304,7 @@ function flamingo_load_contact_admin() {
|
|
279 |
}
|
280 |
|
281 |
function flamingo_contact_admin_page() {
|
282 |
-
|
283 |
-
$post_id = ! empty( $_REQUEST['post'] ) ? $_REQUEST['post'] : '';
|
284 |
-
|
285 |
-
if ( 'edit' == $action
|
286 |
-
&& Flamingo_Contact::post_type == get_post_type( $post_id ) ) {
|
287 |
flamingo_contact_edit_page();
|
288 |
return;
|
289 |
}
|
@@ -294,15 +315,19 @@ function flamingo_contact_admin_page() {
|
|
294 |
?>
|
295 |
<div class="wrap">
|
296 |
|
297 |
-
<h1><?php
|
298 |
echo esc_html( __( 'Flamingo Address Book', 'flamingo' ) );
|
|
|
299 |
|
|
|
300 |
if ( ! empty( $_REQUEST['s'] ) ) {
|
301 |
echo sprintf( '<span class="subtitle">'
|
302 |
. __( 'Search results for “%s”', 'flamingo' )
|
303 |
. '</span>', esc_html( $_REQUEST['s'] ) );
|
304 |
}
|
305 |
-
|
|
|
|
|
306 |
|
307 |
<?php do_action( 'flamingo_admin_updated_message' ); ?>
|
308 |
|
@@ -544,7 +569,8 @@ function flamingo_load_inbound_admin() {
|
|
544 |
$args = array(
|
545 |
'posts_per_page' => -1,
|
546 |
'orderby' => 'date',
|
547 |
-
'order' => 'DESC'
|
|
|
548 |
|
549 |
if ( ! empty( $_REQUEST['s'] ) ) {
|
550 |
$args['s'] = $_REQUEST['s'];
|
@@ -584,8 +610,9 @@ function flamingo_load_inbound_admin() {
|
|
584 |
}
|
585 |
|
586 |
$labels = array_keys( $items[0]->fields );
|
587 |
-
|
588 |
-
echo flamingo_csv_row(
|
|
|
589 |
|
590 |
foreach ( $items as $item ) {
|
591 |
$row = array();
|
@@ -602,7 +629,7 @@ function flamingo_load_inbound_admin() {
|
|
602 |
$row[] = $col;
|
603 |
}
|
604 |
|
605 |
-
$row[] = get_post_time( 'c', true, $item->id );
|
606 |
|
607 |
echo "\r\n" . flamingo_csv_row( $row );
|
608 |
}
|
@@ -610,9 +637,19 @@ function flamingo_load_inbound_admin() {
|
|
610 |
exit();
|
611 |
}
|
612 |
|
613 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
614 |
|
615 |
-
if ( Flamingo_Inbound_Message::post_type == get_post_type( $post_id ) ) {
|
616 |
add_meta_box( 'submitdiv', __( 'Save', 'flamingo' ),
|
617 |
'flamingo_inbound_submit_meta_box', null, 'side', 'core' );
|
618 |
|
@@ -633,15 +670,13 @@ function flamingo_load_inbound_admin() {
|
|
633 |
|
634 |
add_screen_option( 'per_page', array(
|
635 |
'label' => __( 'Messages', 'flamingo' ),
|
636 |
-
'default' => 20
|
|
|
637 |
}
|
638 |
}
|
639 |
|
640 |
function flamingo_inbound_admin_page() {
|
641 |
-
|
642 |
-
$post_id = ! empty( $_REQUEST['post'] ) ? $_REQUEST['post'] : '';
|
643 |
-
|
644 |
-
if ( 'edit' == $action && Flamingo_Inbound_Message::post_type == get_post_type( $post_id ) ) {
|
645 |
flamingo_inbound_edit_page();
|
646 |
return;
|
647 |
}
|
@@ -652,15 +687,19 @@ function flamingo_inbound_admin_page() {
|
|
652 |
?>
|
653 |
<div class="wrap">
|
654 |
|
655 |
-
<h1><?php
|
656 |
echo esc_html( __( 'Inbound Messages', 'flamingo' ) );
|
|
|
657 |
|
|
|
658 |
if ( ! empty( $_REQUEST['s'] ) ) {
|
659 |
echo sprintf( '<span class="subtitle">'
|
660 |
. __( 'Search results for “%s”', 'flamingo' )
|
661 |
. '</span>', esc_html( $_REQUEST['s'] ) );
|
662 |
}
|
663 |
-
|
|
|
|
|
664 |
|
665 |
<?php do_action( 'flamingo_admin_updated_message' ); ?>
|
666 |
|
@@ -679,8 +718,9 @@ function flamingo_inbound_admin_page() {
|
|
679 |
function flamingo_inbound_edit_page() {
|
680 |
$post = new Flamingo_Inbound_Message( $_REQUEST['post'] );
|
681 |
|
682 |
-
if ( empty( $post ) )
|
683 |
return;
|
|
|
684 |
|
685 |
require_once FLAMINGO_PLUGIN_DIR . '/admin/includes/meta-boxes.php';
|
686 |
|
@@ -720,10 +760,13 @@ function flamingo_load_outbound_admin() {
|
|
720 |
|
721 |
//$post->save();
|
722 |
|
723 |
-
$redirect_to = add_query_arg(
|
724 |
-
|
725 |
-
|
726 |
-
|
|
|
|
|
|
|
727 |
|
728 |
wp_safe_redirect( $redirect_to );
|
729 |
exit();
|
@@ -744,15 +787,13 @@ function flamingo_load_outbound_admin() {
|
|
744 |
|
745 |
add_screen_option( 'per_page', array(
|
746 |
'label' => __( 'Messages', 'flamingo' ),
|
747 |
-
'default' => 20
|
|
|
748 |
}
|
749 |
}
|
750 |
|
751 |
function flamingo_outbound_admin_page() {
|
752 |
-
|
753 |
-
$post_id = ! empty( $_REQUEST['post'] ) ? $_REQUEST['post'] : '';
|
754 |
-
|
755 |
-
if ( 'new' == $action ) {
|
756 |
flamingo_outbound_edit_page();
|
757 |
return;
|
758 |
}
|
@@ -763,15 +804,19 @@ function flamingo_outbound_admin_page() {
|
|
763 |
?>
|
764 |
<div class="wrap">
|
765 |
|
766 |
-
<h1><?php
|
767 |
echo esc_html( __( 'Outbound Messages', 'flamingo' ) );
|
|
|
768 |
|
|
|
769 |
if ( ! empty( $_REQUEST['s'] ) ) {
|
770 |
echo sprintf( '<span class="subtitle">'
|
771 |
. __( 'Search results for “%s”', 'flamingo' )
|
772 |
. '</span>', esc_html( $_REQUEST['s'] ) );
|
773 |
}
|
774 |
-
|
|
|
|
|
775 |
|
776 |
<?php do_action( 'flamingo_admin_updated_message' ); ?>
|
777 |
|
@@ -794,8 +839,9 @@ function flamingo_outbound_edit_page() {
|
|
794 |
if ( 'edit' == $action ) {
|
795 |
$post = new Flamingo_Outbound_Message( $_REQUEST['post'] );
|
796 |
|
797 |
-
if ( empty( $post ) )
|
798 |
return;
|
|
|
799 |
} else { // maybe 'new' == $action
|
800 |
if ( ! empty( $_REQUEST['contact_tag_id'] ) ) {
|
801 |
$tag_id = explode( ',', $_REQUEST['contact_tag_id'] );
|
@@ -803,8 +849,9 @@ function flamingo_outbound_edit_page() {
|
|
803 |
$contact_tag = get_term( $tag_id[0],
|
804 |
Flamingo_Contact::contact_tag_taxonomy );
|
805 |
|
806 |
-
if ( empty( $contact_tag ) || is_wp_error( $contact_tag ) )
|
807 |
$contact_tag = null;
|
|
|
808 |
}
|
809 |
}
|
810 |
|
38 |
function flamingo_set_screen_options( $result, $option, $value ) {
|
39 |
$flamingo_screens = array(
|
40 |
'toplevel_page_flamingo_per_page',
|
41 |
+
'flamingo_page_flamingo_inbound_per_page',
|
42 |
+
);
|
43 |
|
44 |
if ( in_array( $option, $flamingo_screens ) ) {
|
45 |
$result = $value;
|
51 |
add_action( 'admin_enqueue_scripts', 'flamingo_admin_enqueue_scripts' );
|
52 |
|
53 |
function flamingo_admin_enqueue_scripts( $hook_suffix ) {
|
54 |
+
if ( false === strpos( $hook_suffix, 'flamingo' ) ) {
|
55 |
return;
|
56 |
+
}
|
57 |
|
58 |
wp_enqueue_style( 'flamingo-admin',
|
59 |
+
flamingo_plugin_url( 'admin/css/style.css' ),
|
60 |
array(), FLAMINGO_VERSION, 'all' );
|
61 |
|
62 |
+
if ( is_rtl() ) {
|
63 |
+
wp_enqueue_style( 'flamingo-admin-rtl',
|
64 |
+
flamingo_plugin_url( 'admin/css/style-rtl.css' ),
|
65 |
+
array(), FLAMINGO_VERSION, 'all' );
|
66 |
+
}
|
67 |
+
|
68 |
wp_enqueue_script( 'flamingo-admin',
|
69 |
+
flamingo_plugin_url( 'admin/js/script.js' ),
|
70 |
array( 'postbox' ), FLAMINGO_VERSION, true );
|
71 |
|
72 |
$current_screen = get_current_screen();
|
73 |
|
74 |
+
wp_localize_script( 'flamingo-admin', 'flamingo', array(
|
75 |
+
'screenId' => $current_screen->id,
|
76 |
+
) );
|
77 |
}
|
78 |
|
79 |
/* Updated Message */
|
80 |
|
81 |
+
add_action( 'flamingo_admin_updated_message',
|
82 |
+
'flamingo_admin_updated_message' );
|
83 |
|
84 |
function flamingo_admin_updated_message() {
|
85 |
+
if ( empty( $_REQUEST['message'] ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
return;
|
87 |
}
|
88 |
|
89 |
+
if ( 'contactupdated' == $_REQUEST['message'] ) {
|
90 |
+
$message = __( 'Contact updated.', 'flamingo' );
|
91 |
+
} elseif ( 'contactdeleted' == $_REQUEST['message'] ) {
|
92 |
+
$message = __( 'Contact deleted.', 'flamingo' );
|
93 |
+
} elseif ( 'inboundtrashed' == $_REQUEST['message'] ) {
|
94 |
+
$message = __( 'Messages trashed.', 'flamingo' );
|
95 |
+
} elseif ( 'inbounduntrashed' == $_REQUEST['message'] ) {
|
96 |
+
$message = __( 'Messages restored.', 'flamingo' );
|
97 |
+
} elseif ( 'inbounddeleted' == $_REQUEST['message'] ) {
|
98 |
+
$message = __( 'Messages deleted.', 'flamingo' );
|
99 |
+
} elseif ( 'inboundspammed' == $_REQUEST['message'] ) {
|
100 |
+
$message = __( 'Messages got marked as spam.', 'flamingo' );
|
101 |
+
} elseif ( 'inboundunspammed' == $_REQUEST['message'] ) {
|
102 |
+
$message = __( 'Messages got marked as not spam.', 'flamingo' );
|
103 |
+
} elseif ( 'outboundupdated' == $_REQUEST['message'] ) {
|
104 |
+
$message = __( 'Messages updated.', 'flamingo' );
|
105 |
}
|
106 |
|
107 |
+
if ( isset( $message ) && '' !== $message ) {
|
108 |
+
echo sprintf( '<div id="message" class="notice notice-success is-dismissible"><p>%s</p></div>', esc_html( $message ) );
|
109 |
+
}
|
110 |
}
|
111 |
|
112 |
/* Contact */
|
136 |
|
137 |
$post->save();
|
138 |
|
139 |
+
$redirect_to = add_query_arg(
|
140 |
+
array(
|
141 |
+
'action' => 'edit',
|
142 |
+
'post' => $post->id,
|
143 |
+
'message' => 'contactupdated',
|
144 |
+
), $redirect_to
|
145 |
+
);
|
146 |
}
|
147 |
|
148 |
wp_safe_redirect( $redirect_to );
|
198 |
header( 'Content-Type: text/csv; charset=' . get_option( 'blog_charset' ) );
|
199 |
|
200 |
$labels = array(
|
201 |
+
__( 'Email', 'flamingo' ),
|
202 |
+
__( 'Full name', 'flamingo' ),
|
203 |
+
__( 'First name', 'flamingo' ),
|
204 |
+
__( 'Last name', 'flamingo' ),
|
205 |
+
);
|
206 |
|
207 |
echo flamingo_csv_row( $labels );
|
208 |
|
210 |
'posts_per_page' => -1,
|
211 |
'orderby' => 'meta_value',
|
212 |
'order' => 'ASC',
|
213 |
+
'meta_key' => '_email',
|
214 |
+
);
|
215 |
|
216 |
if ( ! empty( $_GET['s'] ) ) {
|
217 |
$args['s'] = $_GET['s'];
|
240 |
$item->email,
|
241 |
$item->get_prop( 'name' ),
|
242 |
$item->get_prop( 'first_name' ),
|
243 |
+
$item->get_prop( 'last_name' ),
|
244 |
+
);
|
245 |
|
246 |
echo "\r\n" . flamingo_csv_row( $row );
|
247 |
}
|
253 |
&& ! empty( $_REQUEST['contact_tag_id'] ) ) {
|
254 |
$redirect_to = admin_url( 'admin.php?page=flamingo_outbound' );
|
255 |
|
256 |
+
$redirect_to = add_query_arg(
|
257 |
+
array(
|
258 |
+
'action' => 'new',
|
259 |
+
'contact_tag_id' => absint( $_REQUEST['contact_tag_id'] ),
|
260 |
+
), $redirect_to
|
261 |
+
);
|
262 |
|
263 |
wp_safe_redirect( $redirect_to );
|
264 |
exit();
|
265 |
}
|
266 |
|
267 |
+
if ( 'edit' == $action ) {
|
268 |
+
$post_id = isset( $_REQUEST['post'] ) ? (int) $_REQUEST['post'] : 0;
|
269 |
+
|
270 |
+
if ( ! $post_id ) {
|
271 |
+
wp_safe_redirect( $redirect_to );
|
272 |
+
exit();
|
273 |
+
}
|
274 |
+
|
275 |
+
if ( ! current_user_can( 'flamingo_edit_contact', $post_id )
|
276 |
+
|| Flamingo_Contact::post_type !== get_post_type( $post_id ) ) {
|
277 |
+
wp_die( __( "You are not allowed to edit this item.", 'flamingo' ) );
|
278 |
+
}
|
279 |
|
|
|
280 |
add_meta_box( 'submitdiv', __( 'Save', 'flamingo' ),
|
281 |
'flamingo_contact_submit_meta_box', null, 'side', 'core' );
|
282 |
|
304 |
}
|
305 |
|
306 |
function flamingo_contact_admin_page() {
|
307 |
+
if ( 'edit' == flamingo_current_action() ) {
|
|
|
|
|
|
|
|
|
308 |
flamingo_contact_edit_page();
|
309 |
return;
|
310 |
}
|
315 |
?>
|
316 |
<div class="wrap">
|
317 |
|
318 |
+
<h1 class="wp-heading-inline"><?php
|
319 |
echo esc_html( __( 'Flamingo Address Book', 'flamingo' ) );
|
320 |
+
?></h1>
|
321 |
|
322 |
+
<?php
|
323 |
if ( ! empty( $_REQUEST['s'] ) ) {
|
324 |
echo sprintf( '<span class="subtitle">'
|
325 |
. __( 'Search results for “%s”', 'flamingo' )
|
326 |
. '</span>', esc_html( $_REQUEST['s'] ) );
|
327 |
}
|
328 |
+
?>
|
329 |
+
|
330 |
+
<hr class="wp-header-end">
|
331 |
|
332 |
<?php do_action( 'flamingo_admin_updated_message' ); ?>
|
333 |
|
569 |
$args = array(
|
570 |
'posts_per_page' => -1,
|
571 |
'orderby' => 'date',
|
572 |
+
'order' => 'DESC',
|
573 |
+
);
|
574 |
|
575 |
if ( ! empty( $_REQUEST['s'] ) ) {
|
576 |
$args['s'] = $_REQUEST['s'];
|
610 |
}
|
611 |
|
612 |
$labels = array_keys( $items[0]->fields );
|
613 |
+
|
614 |
+
echo flamingo_csv_row(
|
615 |
+
array_merge( $labels, array( __( 'Date', 'flamingo' ) ) ) );
|
616 |
|
617 |
foreach ( $items as $item ) {
|
618 |
$row = array();
|
629 |
$row[] = $col;
|
630 |
}
|
631 |
|
632 |
+
$row[] = get_post_time( 'c', true, $item->id ); // Date
|
633 |
|
634 |
echo "\r\n" . flamingo_csv_row( $row );
|
635 |
}
|
637 |
exit();
|
638 |
}
|
639 |
|
640 |
+
if ( 'edit' == $action ) {
|
641 |
+
$post_id = isset( $_REQUEST['post'] ) ? (int) $_REQUEST['post'] : 0;
|
642 |
+
|
643 |
+
if ( ! $post_id ) {
|
644 |
+
wp_safe_redirect( $redirect_to );
|
645 |
+
exit();
|
646 |
+
}
|
647 |
+
|
648 |
+
if ( ! current_user_can( 'flamingo_edit_inbound_message', $post_id )
|
649 |
+
|| Flamingo_Inbound_Message::post_type !== get_post_type( $post_id ) ) {
|
650 |
+
wp_die( __( "You are not allowed to edit this item.", 'flamingo' ) );
|
651 |
+
}
|
652 |
|
|
|
653 |
add_meta_box( 'submitdiv', __( 'Save', 'flamingo' ),
|
654 |
'flamingo_inbound_submit_meta_box', null, 'side', 'core' );
|
655 |
|
670 |
|
671 |
add_screen_option( 'per_page', array(
|
672 |
'label' => __( 'Messages', 'flamingo' ),
|
673 |
+
'default' => 20,
|
674 |
+
) );
|
675 |
}
|
676 |
}
|
677 |
|
678 |
function flamingo_inbound_admin_page() {
|
679 |
+
if ( 'edit' == flamingo_current_action() ) {
|
|
|
|
|
|
|
680 |
flamingo_inbound_edit_page();
|
681 |
return;
|
682 |
}
|
687 |
?>
|
688 |
<div class="wrap">
|
689 |
|
690 |
+
<h1 class="wp-heading-inline"><?php
|
691 |
echo esc_html( __( 'Inbound Messages', 'flamingo' ) );
|
692 |
+
?></h1>
|
693 |
|
694 |
+
<?php
|
695 |
if ( ! empty( $_REQUEST['s'] ) ) {
|
696 |
echo sprintf( '<span class="subtitle">'
|
697 |
. __( 'Search results for “%s”', 'flamingo' )
|
698 |
. '</span>', esc_html( $_REQUEST['s'] ) );
|
699 |
}
|
700 |
+
?>
|
701 |
+
|
702 |
+
<hr class="wp-header-end">
|
703 |
|
704 |
<?php do_action( 'flamingo_admin_updated_message' ); ?>
|
705 |
|
718 |
function flamingo_inbound_edit_page() {
|
719 |
$post = new Flamingo_Inbound_Message( $_REQUEST['post'] );
|
720 |
|
721 |
+
if ( empty( $post ) ) {
|
722 |
return;
|
723 |
+
}
|
724 |
|
725 |
require_once FLAMINGO_PLUGIN_DIR . '/admin/includes/meta-boxes.php';
|
726 |
|
760 |
|
761 |
//$post->save();
|
762 |
|
763 |
+
$redirect_to = add_query_arg(
|
764 |
+
array(
|
765 |
+
'action' => 'edit',
|
766 |
+
//'post' => $post->id,
|
767 |
+
'message' => 'outboundupdated',
|
768 |
+
), $redirect_to
|
769 |
+
);
|
770 |
|
771 |
wp_safe_redirect( $redirect_to );
|
772 |
exit();
|
787 |
|
788 |
add_screen_option( 'per_page', array(
|
789 |
'label' => __( 'Messages', 'flamingo' ),
|
790 |
+
'default' => 20,
|
791 |
+
) );
|
792 |
}
|
793 |
}
|
794 |
|
795 |
function flamingo_outbound_admin_page() {
|
796 |
+
if ( 'new' == flamingo_current_action() ) {
|
|
|
|
|
|
|
797 |
flamingo_outbound_edit_page();
|
798 |
return;
|
799 |
}
|
804 |
?>
|
805 |
<div class="wrap">
|
806 |
|
807 |
+
<h1 class="wp-heading-inline"><?php
|
808 |
echo esc_html( __( 'Outbound Messages', 'flamingo' ) );
|
809 |
+
?></h1>
|
810 |
|
811 |
+
<?php
|
812 |
if ( ! empty( $_REQUEST['s'] ) ) {
|
813 |
echo sprintf( '<span class="subtitle">'
|
814 |
. __( 'Search results for “%s”', 'flamingo' )
|
815 |
. '</span>', esc_html( $_REQUEST['s'] ) );
|
816 |
}
|
817 |
+
?>
|
818 |
+
|
819 |
+
<hr class="wp-header-end">
|
820 |
|
821 |
<?php do_action( 'flamingo_admin_updated_message' ); ?>
|
822 |
|
839 |
if ( 'edit' == $action ) {
|
840 |
$post = new Flamingo_Outbound_Message( $_REQUEST['post'] );
|
841 |
|
842 |
+
if ( empty( $post ) ) {
|
843 |
return;
|
844 |
+
}
|
845 |
} else { // maybe 'new' == $action
|
846 |
if ( ! empty( $_REQUEST['contact_tag_id'] ) ) {
|
847 |
$tag_id = explode( ',', $_REQUEST['contact_tag_id'] );
|
849 |
$contact_tag = get_term( $tag_id[0],
|
850 |
Flamingo_Contact::contact_tag_taxonomy );
|
851 |
|
852 |
+
if ( empty( $contact_tag ) || is_wp_error( $contact_tag ) ) {
|
853 |
$contact_tag = null;
|
854 |
+
}
|
855 |
}
|
856 |
}
|
857 |
|
admin/css/style-rtl.css
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
table.message-main-fields th, table.message-main-fields td {
|
2 |
+
text-align: right;
|
3 |
+
}
|
4 |
+
|
5 |
+
table.message-fields td {
|
6 |
+
padding: 4px 7px 2px 14px;
|
7 |
+
}
|
8 |
+
|
9 |
+
table.message-fields td.field-value li {
|
10 |
+
margin-right: 1em;
|
11 |
+
}
|
12 |
+
|
13 |
+
.tablenav .actions input.button {
|
14 |
+
margin: 1px 0 0 8px;
|
15 |
+
}
|
admin/{style.css → css/style.css}
RENAMED
File without changes
|
admin/edit-contact-form.php
CHANGED
@@ -1,8 +1,9 @@
|
|
1 |
<?php
|
2 |
|
3 |
// don't load directly
|
4 |
-
if ( ! defined( 'ABSPATH' ) )
|
5 |
die( '-1' );
|
|
|
6 |
|
7 |
if ( ! empty( $post->id ) ) {
|
8 |
$nonce_action = 'flamingo-update-contact_' . $post->id;
|
1 |
<?php
|
2 |
|
3 |
// don't load directly
|
4 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
5 |
die( '-1' );
|
6 |
+
}
|
7 |
|
8 |
if ( ! empty( $post->id ) ) {
|
9 |
$nonce_action = 'flamingo-update-contact_' . $post->id;
|
admin/edit-inbound-form.php
CHANGED
@@ -1,8 +1,9 @@
|
|
1 |
<?php
|
2 |
|
3 |
// don't load directly
|
4 |
-
if ( ! defined( 'ABSPATH' ) )
|
5 |
die( '-1' );
|
|
|
6 |
|
7 |
if ( ! empty( $post->id ) ) {
|
8 |
$nonce_action = 'flamingo-update-inbound_' . $post->id;
|
1 |
<?php
|
2 |
|
3 |
// don't load directly
|
4 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
5 |
die( '-1' );
|
6 |
+
}
|
7 |
|
8 |
if ( ! empty( $post->id ) ) {
|
9 |
$nonce_action = 'flamingo-update-inbound_' . $post->id;
|
admin/edit-outbound-form.php
CHANGED
@@ -1,8 +1,9 @@
|
|
1 |
<?php
|
2 |
|
3 |
// don't load directly
|
4 |
-
if ( ! defined( 'ABSPATH' ) )
|
5 |
die( '-1' );
|
|
|
6 |
|
7 |
if ( ! empty( $post->id ) ) {
|
8 |
$nonce_action = 'flamingo-update-outbound_' . $post->id;
|
1 |
<?php
|
2 |
|
3 |
// don't load directly
|
4 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
5 |
die( '-1' );
|
6 |
+
}
|
7 |
|
8 |
if ( ! empty( $post->id ) ) {
|
9 |
$nonce_action = 'flamingo-update-outbound_' . $post->id;
|
admin/includes/class-contacts-list-table.php
CHANGED
@@ -13,7 +13,8 @@ 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 Contact', 'flamingo' )
|
|
|
17 |
|
18 |
$columns = apply_filters(
|
19 |
'manage_flamingo_contact_posts_columns', $columns );
|
@@ -25,7 +26,8 @@ class Flamingo_Contacts_List_Table extends WP_List_Table {
|
|
25 |
parent::__construct( array(
|
26 |
'singular' => 'post',
|
27 |
'plural' => 'posts',
|
28 |
-
'ajax' => false
|
|
|
29 |
}
|
30 |
|
31 |
function prepare_items() {
|
@@ -39,23 +41,29 @@ class Flamingo_Contacts_List_Table extends WP_List_Table {
|
|
39 |
'offset' => ( $this->get_pagenum() - 1 ) * $per_page,
|
40 |
'orderby' => 'meta_value',
|
41 |
'order' => 'DESC',
|
42 |
-
'meta_key' => '_last_contacted'
|
|
|
43 |
|
44 |
-
if ( ! empty( $_REQUEST['s'] ) )
|
45 |
$args['s'] = $_REQUEST['s'];
|
|
|
46 |
|
47 |
if ( ! empty( $_REQUEST['orderby'] ) ) {
|
48 |
-
if ( 'email' == $_REQUEST['orderby'] )
|
49 |
$args['meta_key'] = '_email';
|
50 |
-
elseif ( 'name' == $_REQUEST['orderby'] )
|
51 |
$args['meta_key'] = '_name';
|
|
|
52 |
}
|
53 |
|
54 |
-
if ( ! empty( $_REQUEST['order'] )
|
|
|
55 |
$args['order'] = 'ASC';
|
|
|
56 |
|
57 |
-
if ( ! empty( $_REQUEST['contact_tag_id'] ) )
|
58 |
$args['contact_tag_id'] = explode( ',', $_REQUEST['contact_tag_id'] );
|
|
|
59 |
|
60 |
$this->items = Flamingo_Contact::find( $args );
|
61 |
|
@@ -65,7 +73,8 @@ class Flamingo_Contacts_List_Table extends WP_List_Table {
|
|
65 |
$this->set_pagination_args( array(
|
66 |
'total_items' => $total_items,
|
67 |
'total_pages' => $total_pages,
|
68 |
-
'per_page' => $per_page
|
|
|
69 |
}
|
70 |
|
71 |
function get_columns() {
|
@@ -76,14 +85,16 @@ class Flamingo_Contacts_List_Table extends WP_List_Table {
|
|
76 |
$columns = array(
|
77 |
'email' => array( 'email', false ),
|
78 |
'full_name' => array( 'name', false ),
|
79 |
-
'last_contacted' => array( 'last_contacted', true )
|
|
|
80 |
|
81 |
return $columns;
|
82 |
}
|
83 |
|
84 |
function get_bulk_actions() {
|
85 |
$actions = array(
|
86 |
-
'delete' => __( 'Delete', 'flamingo' )
|
|
|
87 |
|
88 |
return $actions;
|
89 |
}
|
@@ -96,8 +107,9 @@ class Flamingo_Contacts_List_Table extends WP_List_Table {
|
|
96 |
|
97 |
$term = get_term( $tag_id[0], Flamingo_Contact::contact_tag_taxonomy );
|
98 |
|
99 |
-
if ( ! empty( $term ) && ! is_wp_error( $term ) )
|
100 |
$tag = $term->term_id;
|
|
|
101 |
}
|
102 |
|
103 |
?>
|
@@ -111,7 +123,8 @@ class Flamingo_Contacts_List_Table extends WP_List_Table {
|
|
111 |
'hide_empty' => 1,
|
112 |
'hide_if_empty' => 1,
|
113 |
'orderby' => 'name',
|
114 |
-
'selected' => $tag
|
|
|
115 |
|
116 |
submit_button( __( 'Filter', 'flamingo' ),
|
117 |
'secondary', false, false, array( 'id' => 'post-query-submit' ) );
|
@@ -136,18 +149,27 @@ class Flamingo_Contacts_List_Table extends WP_List_Table {
|
|
136 |
}
|
137 |
|
138 |
function column_email( $item ) {
|
139 |
-
$
|
140 |
-
$
|
141 |
-
|
142 |
-
$
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
esc_html( $item->email ) );
|
149 |
|
150 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
}
|
152 |
|
153 |
function column_full_name( $item ) {
|
@@ -155,21 +177,25 @@ class Flamingo_Contacts_List_Table extends WP_List_Table {
|
|
155 |
}
|
156 |
|
157 |
function column_tags( $item ) {
|
158 |
-
if ( empty( $item->tags ) )
|
159 |
return __( 'No Tags', 'flamingo' );
|
|
|
160 |
|
161 |
$output = '';
|
162 |
|
163 |
foreach ( (array) $item->tags as $tag ) {
|
164 |
$term = get_term_by( 'name', $tag, Flamingo_Contact::contact_tag_taxonomy );
|
165 |
|
166 |
-
if ( empty( $term ) || is_wp_error( $term ) )
|
167 |
continue;
|
|
|
168 |
|
169 |
-
if ( $output )
|
170 |
$output .= ', ';
|
|
|
171 |
|
172 |
-
$link = admin_url(
|
|
|
173 |
|
174 |
$output .= sprintf( '<a href="%1$s" title="%2$s">%3$s</a>',
|
175 |
$link, esc_attr( $term->name ), esc_html( $term->name ) );
|
@@ -193,7 +219,8 @@ class Flamingo_Contacts_List_Table extends WP_List_Table {
|
|
193 |
'count' => true,
|
194 |
'author_email' => $item->email,
|
195 |
'status' => 'approve',
|
196 |
-
'type' => 'comment'
|
|
|
197 |
|
198 |
if ( 0 < $comment_count ) {
|
199 |
$link = sprintf( 'edit-comments.php?s=%s', urlencode( $item->email ) );
|
@@ -208,12 +235,14 @@ class Flamingo_Contacts_List_Table extends WP_List_Table {
|
|
208 |
foreach ( (array) $terms as $term ) {
|
209 |
Flamingo_Inbound_Message::find( array(
|
210 |
'channel' => $term->slug,
|
211 |
-
's' => $item->email
|
|
|
212 |
|
213 |
$count = (int) Flamingo_Inbound_Message::$found_items;
|
214 |
|
215 |
-
if ( ! $count )
|
216 |
continue;
|
|
|
217 |
|
218 |
$link = sprintf( 'admin.php?page=flamingo_inbound&channel=%1$s&s=%2$s',
|
219 |
urlencode( $term->slug ), urlencode( $item->email ) );
|
@@ -225,8 +254,9 @@ class Flamingo_Contacts_List_Table extends WP_List_Table {
|
|
225 |
|
226 |
$output = '';
|
227 |
|
228 |
-
foreach ( $history as $item )
|
229 |
$output .= '<li>' . $item . '</li>';
|
|
|
230 |
|
231 |
$output = '<ul class="contact-history">' . $output . '</ul>';
|
232 |
|
@@ -234,8 +264,9 @@ class Flamingo_Contacts_List_Table extends WP_List_Table {
|
|
234 |
}
|
235 |
|
236 |
function column_last_contacted( $item ) {
|
237 |
-
if ( empty( $item->last_contacted ) )
|
238 |
return '';
|
|
|
239 |
|
240 |
$t_time = mysql2date( __( 'Y/m/d g:i:s A', 'flamingo' ), $item->last_contacted, true );
|
241 |
$m_time = $item->last_contacted;
|
@@ -243,10 +274,11 @@ class Flamingo_Contacts_List_Table extends WP_List_Table {
|
|
243 |
|
244 |
$time_diff = time() - $time;
|
245 |
|
246 |
-
if ( $time_diff > 0 && $time_diff < 24*60*60 )
|
247 |
$h_time = sprintf( __( '%s ago', 'flamingo' ), human_time_diff( $time ) );
|
248 |
-
else
|
249 |
$h_time = mysql2date( __( 'Y/m/d', 'flamingo' ), $m_time );
|
|
|
250 |
|
251 |
return '<abbr title="' . $t_time . '">' . $h_time . '</abbr>';
|
252 |
}
|
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(
|
20 |
'manage_flamingo_contact_posts_columns', $columns );
|
26 |
parent::__construct( array(
|
27 |
'singular' => 'post',
|
28 |
'plural' => 'posts',
|
29 |
+
'ajax' => false,
|
30 |
+
) );
|
31 |
}
|
32 |
|
33 |
function prepare_items() {
|
41 |
'offset' => ( $this->get_pagenum() - 1 ) * $per_page,
|
42 |
'orderby' => 'meta_value',
|
43 |
'order' => 'DESC',
|
44 |
+
'meta_key' => '_last_contacted',
|
45 |
+
);
|
46 |
|
47 |
+
if ( ! empty( $_REQUEST['s'] ) ) {
|
48 |
$args['s'] = $_REQUEST['s'];
|
49 |
+
}
|
50 |
|
51 |
if ( ! empty( $_REQUEST['orderby'] ) ) {
|
52 |
+
if ( 'email' == $_REQUEST['orderby'] ) {
|
53 |
$args['meta_key'] = '_email';
|
54 |
+
} elseif ( 'name' == $_REQUEST['orderby'] ) {
|
55 |
$args['meta_key'] = '_name';
|
56 |
+
}
|
57 |
}
|
58 |
|
59 |
+
if ( ! empty( $_REQUEST['order'] )
|
60 |
+
&& 'asc' == strtolower( $_REQUEST['order'] ) ) {
|
61 |
$args['order'] = 'ASC';
|
62 |
+
}
|
63 |
|
64 |
+
if ( ! empty( $_REQUEST['contact_tag_id'] ) ) {
|
65 |
$args['contact_tag_id'] = explode( ',', $_REQUEST['contact_tag_id'] );
|
66 |
+
}
|
67 |
|
68 |
$this->items = Flamingo_Contact::find( $args );
|
69 |
|
73 |
$this->set_pagination_args( array(
|
74 |
'total_items' => $total_items,
|
75 |
'total_pages' => $total_pages,
|
76 |
+
'per_page' => $per_page,
|
77 |
+
) );
|
78 |
}
|
79 |
|
80 |
function get_columns() {
|
85 |
$columns = array(
|
86 |
'email' => array( 'email', false ),
|
87 |
'full_name' => array( 'name', false ),
|
88 |
+
'last_contacted' => array( 'last_contacted', true ),
|
89 |
+
);
|
90 |
|
91 |
return $columns;
|
92 |
}
|
93 |
|
94 |
function get_bulk_actions() {
|
95 |
$actions = array(
|
96 |
+
'delete' => __( 'Delete', 'flamingo' ),
|
97 |
+
);
|
98 |
|
99 |
return $actions;
|
100 |
}
|
107 |
|
108 |
$term = get_term( $tag_id[0], Flamingo_Contact::contact_tag_taxonomy );
|
109 |
|
110 |
+
if ( ! empty( $term ) && ! is_wp_error( $term ) ) {
|
111 |
$tag = $term->term_id;
|
112 |
+
}
|
113 |
}
|
114 |
|
115 |
?>
|
123 |
'hide_empty' => 1,
|
124 |
'hide_if_empty' => 1,
|
125 |
'orderby' => 'name',
|
126 |
+
'selected' => $tag,
|
127 |
+
) );
|
128 |
|
129 |
submit_button( __( 'Filter', 'flamingo' ),
|
130 |
'secondary', false, false, array( 'id' => 'post-query-submit' ) );
|
149 |
}
|
150 |
|
151 |
function column_email( $item ) {
|
152 |
+
$actions = array();
|
153 |
+
$post_id = absint( $item->id );
|
154 |
+
$base_url = admin_url( 'admin.php?page=flamingo&post=' . $post_id );
|
155 |
+
$edit_link = add_query_arg( array( 'action' => 'edit' ), $base_url );
|
156 |
+
|
157 |
+
if ( current_user_can( 'flamingo_edit_contact', $post_id ) ) {
|
158 |
+
$actions['edit'] = sprintf( '<a href="%1$s">%2$s</a>',
|
159 |
+
esc_url( $edit_link ), esc_html( __( 'Edit', 'flamingo' ) ) );
|
160 |
+
}
|
|
|
161 |
|
162 |
+
if ( current_user_can( 'flamingo_edit_contact', $post_id ) ) {
|
163 |
+
return sprintf( '<strong><a class="row-title" href="%1$s" title="%2$s">%3$s</a></strong> %4$s',
|
164 |
+
esc_url( $edit_link ),
|
165 |
+
esc_attr( sprintf( __( 'Edit “%s”', 'flamingo' ), $item->email ) ),
|
166 |
+
esc_html( $item->email ),
|
167 |
+
$this->row_actions( $actions ) );
|
168 |
+
} else {
|
169 |
+
return sprintf( '<strong>%1$s</strong> %2$s',
|
170 |
+
esc_html( $item->email ),
|
171 |
+
$this->row_actions( $actions ) );
|
172 |
+
}
|
173 |
}
|
174 |
|
175 |
function column_full_name( $item ) {
|
177 |
}
|
178 |
|
179 |
function column_tags( $item ) {
|
180 |
+
if ( empty( $item->tags ) ) {
|
181 |
return __( 'No Tags', 'flamingo' );
|
182 |
+
}
|
183 |
|
184 |
$output = '';
|
185 |
|
186 |
foreach ( (array) $item->tags as $tag ) {
|
187 |
$term = get_term_by( 'name', $tag, Flamingo_Contact::contact_tag_taxonomy );
|
188 |
|
189 |
+
if ( empty( $term ) || is_wp_error( $term ) ) {
|
190 |
continue;
|
191 |
+
}
|
192 |
|
193 |
+
if ( $output ) {
|
194 |
$output .= ', ';
|
195 |
+
}
|
196 |
|
197 |
+
$link = admin_url(
|
198 |
+
'admin.php?page=flamingo&contact_tag_id=' . $term->term_id );
|
199 |
|
200 |
$output .= sprintf( '<a href="%1$s" title="%2$s">%3$s</a>',
|
201 |
$link, esc_attr( $term->name ), esc_html( $term->name ) );
|
219 |
'count' => true,
|
220 |
'author_email' => $item->email,
|
221 |
'status' => 'approve',
|
222 |
+
'type' => 'comment',
|
223 |
+
) );
|
224 |
|
225 |
if ( 0 < $comment_count ) {
|
226 |
$link = sprintf( 'edit-comments.php?s=%s', urlencode( $item->email ) );
|
235 |
foreach ( (array) $terms as $term ) {
|
236 |
Flamingo_Inbound_Message::find( array(
|
237 |
'channel' => $term->slug,
|
238 |
+
's' => $item->email,
|
239 |
+
) );
|
240 |
|
241 |
$count = (int) Flamingo_Inbound_Message::$found_items;
|
242 |
|
243 |
+
if ( ! $count ) {
|
244 |
continue;
|
245 |
+
}
|
246 |
|
247 |
$link = sprintf( 'admin.php?page=flamingo_inbound&channel=%1$s&s=%2$s',
|
248 |
urlencode( $term->slug ), urlencode( $item->email ) );
|
254 |
|
255 |
$output = '';
|
256 |
|
257 |
+
foreach ( $history as $item ) {
|
258 |
$output .= '<li>' . $item . '</li>';
|
259 |
+
}
|
260 |
|
261 |
$output = '<ul class="contact-history">' . $output . '</ul>';
|
262 |
|
264 |
}
|
265 |
|
266 |
function column_last_contacted( $item ) {
|
267 |
+
if ( empty( $item->last_contacted ) ) {
|
268 |
return '';
|
269 |
+
}
|
270 |
|
271 |
$t_time = mysql2date( __( 'Y/m/d g:i:s A', 'flamingo' ), $item->last_contacted, true );
|
272 |
$m_time = $item->last_contacted;
|
274 |
|
275 |
$time_diff = time() - $time;
|
276 |
|
277 |
+
if ( $time_diff > 0 && $time_diff < 24*60*60 ) {
|
278 |
$h_time = sprintf( __( '%s ago', 'flamingo' ), human_time_diff( $time ) );
|
279 |
+
} else {
|
280 |
$h_time = mysql2date( __( 'Y/m/d', 'flamingo' ), $m_time );
|
281 |
+
}
|
282 |
|
283 |
return '<abbr title="' . $t_time . '">' . $h_time . '</abbr>';
|
284 |
}
|
admin/includes/class-inbound-messages-list-table.php
CHANGED
@@ -15,7 +15,8 @@ class Flamingo_Inbound_Messages_List_Table extends WP_List_Table {
|
|
15 |
'subject' => __( 'Subject', 'flamingo' ),
|
16 |
'from' => __( 'From', 'flamingo' ),
|
17 |
'channel' => __( 'Channel', 'flamingo' ),
|
18 |
-
'date' => __( 'Date', 'flamingo' )
|
|
|
19 |
|
20 |
$columns = apply_filters(
|
21 |
'manage_flamingo_inbound_posts_columns', $columns );
|
@@ -27,7 +28,8 @@ class Flamingo_Inbound_Messages_List_Table extends WP_List_Table {
|
|
27 |
parent::__construct( array(
|
28 |
'singular' => 'post',
|
29 |
'plural' => 'posts',
|
30 |
-
'ajax' => false
|
|
|
31 |
}
|
32 |
|
33 |
function prepare_items() {
|
@@ -40,7 +42,8 @@ class Flamingo_Inbound_Messages_List_Table extends WP_List_Table {
|
|
40 |
'posts_per_page' => $per_page,
|
41 |
'offset' => ( $this->get_pagenum() - 1 ) * $per_page,
|
42 |
'orderby' => 'date',
|
43 |
-
'order' => 'DESC'
|
|
|
44 |
|
45 |
if ( ! empty( $_REQUEST['s'] ) ) {
|
46 |
$args['s'] = $_REQUEST['s'];
|
@@ -56,8 +59,10 @@ class Flamingo_Inbound_Messages_List_Table extends WP_List_Table {
|
|
56 |
}
|
57 |
}
|
58 |
|
59 |
-
if ( ! empty( $_REQUEST['order'] )
|
|
|
60 |
$args['order'] = 'ASC';
|
|
|
61 |
|
62 |
if ( ! empty( $_REQUEST['m'] ) ) {
|
63 |
$args['m'] = $_REQUEST['m'];
|
@@ -89,7 +94,8 @@ class Flamingo_Inbound_Messages_List_Table extends WP_List_Table {
|
|
89 |
$this->set_pagination_args( array(
|
90 |
'total_items' => $total_items,
|
91 |
'total_pages' => $total_pages,
|
92 |
-
'per_page' => $per_page
|
|
|
93 |
}
|
94 |
|
95 |
function get_views() {
|
@@ -132,8 +138,9 @@ class Flamingo_Inbound_Messages_List_Table extends WP_List_Table {
|
|
132 |
Flamingo_Inbound_Message::find( array( 'post_status' => 'trash' ) );
|
133 |
$posts_in_trash = Flamingo_Inbound_Message::$found_items;
|
134 |
|
135 |
-
if ( empty( $posts_in_trash ) )
|
136 |
return $status_links;
|
|
|
137 |
|
138 |
$trash = sprintf(
|
139 |
_nx( 'Trash <span class="count">(%s)</span>',
|
@@ -157,7 +164,8 @@ class Flamingo_Inbound_Messages_List_Table extends WP_List_Table {
|
|
157 |
$columns = array(
|
158 |
'subject' => array( 'subject', false ),
|
159 |
'from' => array( 'from', false ),
|
160 |
-
'date' => array( 'date', true )
|
|
|
161 |
|
162 |
return $columns;
|
163 |
}
|
@@ -190,15 +198,17 @@ class Flamingo_Inbound_Messages_List_Table extends WP_List_Table {
|
|
190 |
if ( ! empty( $_REQUEST['channel_id'] ) ) {
|
191 |
$term = get_term( $_REQUEST['channel_id'], Flamingo_Inbound_Message::channel_taxonomy );
|
192 |
|
193 |
-
if ( ! empty( $term ) && ! is_wp_error( $term ) )
|
194 |
$channel = $term->term_id;
|
|
|
195 |
|
196 |
} elseif ( ! empty( $_REQUEST['channel'] ) ) {
|
197 |
$term = get_term_by( 'slug', $_REQUEST['channel'],
|
198 |
Flamingo_Inbound_Message::channel_taxonomy );
|
199 |
|
200 |
-
if ( ! empty( $term ) && ! is_wp_error( $term ) )
|
201 |
$channel = $term->term_id;
|
|
|
202 |
}
|
203 |
|
204 |
?>
|
@@ -216,12 +226,12 @@ class Flamingo_Inbound_Messages_List_Table extends WP_List_Table {
|
|
216 |
'hide_if_empty' => 1,
|
217 |
'orderby' => 'name',
|
218 |
'hierarchical' => 1,
|
219 |
-
'selected' => $channel
|
|
|
220 |
|
221 |
submit_button( __( 'Filter', 'flamingo' ),
|
222 |
'secondary', false, false, array( 'id' => 'post-query-submit' ) );
|
223 |
|
224 |
-
|
225 |
if ( ! $this->is_spam && ! $this->is_trash ) {
|
226 |
submit_button( __( 'Export', 'flamingo' ),
|
227 |
'secondary', 'export', false );
|
@@ -250,38 +260,51 @@ class Flamingo_Inbound_Messages_List_Table extends WP_List_Table {
|
|
250 |
}
|
251 |
|
252 |
function column_subject( $item ) {
|
253 |
-
if ( $this->is_trash )
|
254 |
return '<strong>' . esc_html( $item->subject ) . '</strong>';
|
|
|
255 |
|
256 |
$actions = array();
|
|
|
|
|
|
|
257 |
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
. esc_html( __( 'Edit', 'flamingo' ) ) . '</a>';
|
263 |
|
264 |
-
if ( $item->spam
|
265 |
-
|
|
|
266 |
$link = wp_nonce_url( $link,
|
267 |
-
'flamingo-unspam-inbound-message_' . $
|
268 |
-
|
269 |
-
$actions['unspam'] = '<a href="' . $link . '">'
|
270 |
-
. esc_html( __( 'Not Spam', 'flamingo' ) ) . '</a>';
|
271 |
-
} else {
|
272 |
-
$link = add_query_arg( array( 'action' => 'spam' ), $url );
|
273 |
-
$link = wp_nonce_url( $link, 'flamingo-spam-inbound-message_' . $item->id );
|
274 |
|
275 |
-
$actions['
|
276 |
-
|
277 |
}
|
278 |
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
|
|
|
|
|
|
|
|
|
|
283 |
|
284 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
285 |
}
|
286 |
|
287 |
function column_from( $item ) {
|
@@ -289,14 +312,16 @@ class Flamingo_Inbound_Messages_List_Table extends WP_List_Table {
|
|
289 |
}
|
290 |
|
291 |
function column_channel( $item ) {
|
292 |
-
if ( empty( $item->channel ) )
|
293 |
return '';
|
|
|
294 |
|
295 |
$term = get_term_by( 'slug', $item->channel,
|
296 |
Flamingo_Inbound_Message::channel_taxonomy );
|
297 |
|
298 |
-
if ( empty( $term ) || is_wp_error( $term ) )
|
299 |
return $item->channel;
|
|
|
300 |
|
301 |
$output = '';
|
302 |
|
@@ -306,8 +331,9 @@ class Flamingo_Inbound_Messages_List_Table extends WP_List_Table {
|
|
306 |
while ( $parent = array_pop( $ancestors ) ) {
|
307 |
$parent = get_term( $parent, Flamingo_Inbound_Message::channel_taxonomy );
|
308 |
|
309 |
-
if ( empty( $parent ) || is_wp_error( $parent ) )
|
310 |
continue;
|
|
|
311 |
|
312 |
$link = admin_url(
|
313 |
'admin.php?page=flamingo_inbound&channel=' . $parent->slug );
|
@@ -316,7 +342,8 @@ class Flamingo_Inbound_Messages_List_Table extends WP_List_Table {
|
|
316 |
$link, esc_attr( $parent->name ), esc_html( $parent->name ) );
|
317 |
}
|
318 |
|
319 |
-
$link = admin_url(
|
|
|
320 |
|
321 |
$output .= sprintf( '<a href="%1$s" title="%2$s">%3$s</a>',
|
322 |
$link, esc_attr( $term->name ), esc_html( $term->name ) );
|
@@ -327,8 +354,9 @@ class Flamingo_Inbound_Messages_List_Table extends WP_List_Table {
|
|
327 |
function column_date( $item ) {
|
328 |
$post = get_post( $item->id );
|
329 |
|
330 |
-
if ( ! $post )
|
331 |
return '';
|
|
|
332 |
|
333 |
$t_time = get_the_time( __( 'Y/m/d g:i:s A', 'flamingo' ), $item->id );
|
334 |
$m_time = $post->post_date;
|
@@ -336,10 +364,11 @@ class Flamingo_Inbound_Messages_List_Table extends WP_List_Table {
|
|
336 |
|
337 |
$time_diff = time() - $time;
|
338 |
|
339 |
-
if ( $time_diff > 0 && $time_diff < 24*60*60 )
|
340 |
$h_time = sprintf( __( '%s ago', 'flamingo' ), human_time_diff( $time ) );
|
341 |
-
else
|
342 |
$h_time = mysql2date( __( 'Y/m/d', 'flamingo' ), $m_time );
|
|
|
343 |
|
344 |
return '<abbr title="' . $t_time . '">' . $h_time . '</abbr>';
|
345 |
}
|
15 |
'subject' => __( 'Subject', 'flamingo' ),
|
16 |
'from' => __( 'From', 'flamingo' ),
|
17 |
'channel' => __( 'Channel', 'flamingo' ),
|
18 |
+
'date' => __( 'Date', 'flamingo' ),
|
19 |
+
);
|
20 |
|
21 |
$columns = apply_filters(
|
22 |
'manage_flamingo_inbound_posts_columns', $columns );
|
28 |
parent::__construct( array(
|
29 |
'singular' => 'post',
|
30 |
'plural' => 'posts',
|
31 |
+
'ajax' => false,
|
32 |
+
) );
|
33 |
}
|
34 |
|
35 |
function prepare_items() {
|
42 |
'posts_per_page' => $per_page,
|
43 |
'offset' => ( $this->get_pagenum() - 1 ) * $per_page,
|
44 |
'orderby' => 'date',
|
45 |
+
'order' => 'DESC',
|
46 |
+
);
|
47 |
|
48 |
if ( ! empty( $_REQUEST['s'] ) ) {
|
49 |
$args['s'] = $_REQUEST['s'];
|
59 |
}
|
60 |
}
|
61 |
|
62 |
+
if ( ! empty( $_REQUEST['order'] )
|
63 |
+
&& 'asc' == strtolower( $_REQUEST['order'] ) ) {
|
64 |
$args['order'] = 'ASC';
|
65 |
+
}
|
66 |
|
67 |
if ( ! empty( $_REQUEST['m'] ) ) {
|
68 |
$args['m'] = $_REQUEST['m'];
|
94 |
$this->set_pagination_args( array(
|
95 |
'total_items' => $total_items,
|
96 |
'total_pages' => $total_pages,
|
97 |
+
'per_page' => $per_page,
|
98 |
+
) );
|
99 |
}
|
100 |
|
101 |
function get_views() {
|
138 |
Flamingo_Inbound_Message::find( array( 'post_status' => 'trash' ) );
|
139 |
$posts_in_trash = Flamingo_Inbound_Message::$found_items;
|
140 |
|
141 |
+
if ( empty( $posts_in_trash ) ) {
|
142 |
return $status_links;
|
143 |
+
}
|
144 |
|
145 |
$trash = sprintf(
|
146 |
_nx( 'Trash <span class="count">(%s)</span>',
|
164 |
$columns = array(
|
165 |
'subject' => array( 'subject', false ),
|
166 |
'from' => array( 'from', false ),
|
167 |
+
'date' => array( 'date', true ),
|
168 |
+
);
|
169 |
|
170 |
return $columns;
|
171 |
}
|
198 |
if ( ! empty( $_REQUEST['channel_id'] ) ) {
|
199 |
$term = get_term( $_REQUEST['channel_id'], Flamingo_Inbound_Message::channel_taxonomy );
|
200 |
|
201 |
+
if ( ! empty( $term ) && ! is_wp_error( $term ) ) {
|
202 |
$channel = $term->term_id;
|
203 |
+
}
|
204 |
|
205 |
} elseif ( ! empty( $_REQUEST['channel'] ) ) {
|
206 |
$term = get_term_by( 'slug', $_REQUEST['channel'],
|
207 |
Flamingo_Inbound_Message::channel_taxonomy );
|
208 |
|
209 |
+
if ( ! empty( $term ) && ! is_wp_error( $term ) ) {
|
210 |
$channel = $term->term_id;
|
211 |
+
}
|
212 |
}
|
213 |
|
214 |
?>
|
226 |
'hide_if_empty' => 1,
|
227 |
'orderby' => 'name',
|
228 |
'hierarchical' => 1,
|
229 |
+
'selected' => $channel,
|
230 |
+
) );
|
231 |
|
232 |
submit_button( __( 'Filter', 'flamingo' ),
|
233 |
'secondary', false, false, array( 'id' => 'post-query-submit' ) );
|
234 |
|
|
|
235 |
if ( ! $this->is_spam && ! $this->is_trash ) {
|
236 |
submit_button( __( 'Export', 'flamingo' ),
|
237 |
'secondary', 'export', false );
|
260 |
}
|
261 |
|
262 |
function column_subject( $item ) {
|
263 |
+
if ( $this->is_trash ) {
|
264 |
return '<strong>' . esc_html( $item->subject ) . '</strong>';
|
265 |
+
}
|
266 |
|
267 |
$actions = array();
|
268 |
+
$post_id = absint( $item->id );
|
269 |
+
$base_url = admin_url( 'admin.php?page=flamingo_inbound&post=' . $post_id );
|
270 |
+
$edit_link = add_query_arg( array( 'action' => 'edit' ), $base_url );
|
271 |
|
272 |
+
if ( current_user_can( 'flamingo_edit_inbound_message', $post_id ) ) {
|
273 |
+
$actions['edit'] = sprintf( '<a href="%1$s">%2$s</a>',
|
274 |
+
esc_url( $edit_link ), esc_html( __( 'Edit', 'flamingo' ) ) );
|
275 |
+
}
|
|
|
276 |
|
277 |
+
if ( $item->spam
|
278 |
+
&& current_user_can( 'flamingo_unspam_inbound_message', $post_id ) ) {
|
279 |
+
$link = add_query_arg( array( 'action' => 'unspam' ), $base_url );
|
280 |
$link = wp_nonce_url( $link,
|
281 |
+
'flamingo-unspam-inbound-message_' . $post_id );
|
|
|
|
|
|
|
|
|
|
|
|
|
282 |
|
283 |
+
$actions['unspam'] = sprintf( '<a href="%1$s">%2$s</a>',
|
284 |
+
esc_url( $link ), esc_html( __( 'Not Spam', 'flamingo' ) ) );
|
285 |
}
|
286 |
|
287 |
+
if ( ! $item->spam
|
288 |
+
&& current_user_can( 'flamingo_spam_inbound_message', $post_id ) ) {
|
289 |
+
$link = add_query_arg( array( 'action' => 'spam' ), $base_url );
|
290 |
+
$link = wp_nonce_url( $link,
|
291 |
+
'flamingo-spam-inbound-message_' . $post_id );
|
292 |
+
|
293 |
+
$actions['spam'] = sprintf( '<a href="%1$s">%2$s</a>',
|
294 |
+
esc_url( $link ), esc_html( __( 'Spam', 'flamingo' ) ) );
|
295 |
+
}
|
296 |
|
297 |
+
if ( current_user_can( 'flamingo_edit_inbound_message', $post_id ) ) {
|
298 |
+
return sprintf( '<strong><a class="row-title" href="%1$s" title="%2$s">%3$s</a></strong> %4$s',
|
299 |
+
esc_url( $edit_link ),
|
300 |
+
esc_attr( sprintf( __( 'Edit “%s”', 'flamingo' ), $item->subject ) ),
|
301 |
+
esc_html( $item->subject ),
|
302 |
+
$this->row_actions( $actions ) );
|
303 |
+
} else {
|
304 |
+
return sprintf( '<strong>%1$s</strong> %2$s',
|
305 |
+
esc_html( $item->subject ),
|
306 |
+
$this->row_actions( $actions ) );
|
307 |
+
}
|
308 |
}
|
309 |
|
310 |
function column_from( $item ) {
|
312 |
}
|
313 |
|
314 |
function column_channel( $item ) {
|
315 |
+
if ( empty( $item->channel ) ) {
|
316 |
return '';
|
317 |
+
}
|
318 |
|
319 |
$term = get_term_by( 'slug', $item->channel,
|
320 |
Flamingo_Inbound_Message::channel_taxonomy );
|
321 |
|
322 |
+
if ( empty( $term ) || is_wp_error( $term ) ) {
|
323 |
return $item->channel;
|
324 |
+
}
|
325 |
|
326 |
$output = '';
|
327 |
|
331 |
while ( $parent = array_pop( $ancestors ) ) {
|
332 |
$parent = get_term( $parent, Flamingo_Inbound_Message::channel_taxonomy );
|
333 |
|
334 |
+
if ( empty( $parent ) || is_wp_error( $parent ) ) {
|
335 |
continue;
|
336 |
+
}
|
337 |
|
338 |
$link = admin_url(
|
339 |
'admin.php?page=flamingo_inbound&channel=' . $parent->slug );
|
342 |
$link, esc_attr( $parent->name ), esc_html( $parent->name ) );
|
343 |
}
|
344 |
|
345 |
+
$link = admin_url(
|
346 |
+
'admin.php?page=flamingo_inbound&channel=' . $term->slug );
|
347 |
|
348 |
$output .= sprintf( '<a href="%1$s" title="%2$s">%3$s</a>',
|
349 |
$link, esc_attr( $term->name ), esc_html( $term->name ) );
|
354 |
function column_date( $item ) {
|
355 |
$post = get_post( $item->id );
|
356 |
|
357 |
+
if ( ! $post ) {
|
358 |
return '';
|
359 |
+
}
|
360 |
|
361 |
$t_time = get_the_time( __( 'Y/m/d g:i:s A', 'flamingo' ), $item->id );
|
362 |
$m_time = $post->post_date;
|
364 |
|
365 |
$time_diff = time() - $time;
|
366 |
|
367 |
+
if ( $time_diff > 0 && $time_diff < 24*60*60 ) {
|
368 |
$h_time = sprintf( __( '%s ago', 'flamingo' ), human_time_diff( $time ) );
|
369 |
+
} else {
|
370 |
$h_time = mysql2date( __( 'Y/m/d', 'flamingo' ), $m_time );
|
371 |
+
}
|
372 |
|
373 |
return '<abbr title="' . $t_time . '">' . $h_time . '</abbr>';
|
374 |
}
|
admin/includes/class-outbound-messages-list-table.php
CHANGED
@@ -13,7 +13,8 @@ class Flamingo_Outbound_Messages_List_Table extends WP_List_Table {
|
|
13 |
'cb' => '<input type="checkbox" />',
|
14 |
'subject' => __( 'Subject', 'flamingo' ),
|
15 |
'from' => __( 'From', 'flamingo' ),
|
16 |
-
'date' => __( 'Date', 'flamingo' )
|
|
|
17 |
|
18 |
$columns = apply_filters(
|
19 |
'manage_flamingo_outbound_posts_columns', $columns );
|
@@ -25,7 +26,8 @@ class Flamingo_Outbound_Messages_List_Table extends WP_List_Table {
|
|
25 |
parent::__construct( array(
|
26 |
'singular' => 'post',
|
27 |
'plural' => 'posts',
|
28 |
-
'ajax' => false
|
|
|
29 |
}
|
30 |
|
31 |
function prepare_items() {
|
@@ -38,7 +40,8 @@ class Flamingo_Outbound_Messages_List_Table extends WP_List_Table {
|
|
38 |
'posts_per_page' => $per_page,
|
39 |
'offset' => ( $this->get_pagenum() - 1 ) * $per_page,
|
40 |
'orderby' => 'date',
|
41 |
-
'order' => 'DESC'
|
|
|
42 |
|
43 |
if ( ! empty( $_REQUEST['s'] ) ) {
|
44 |
$args['s'] = $_REQUEST['s'];
|
@@ -54,7 +57,8 @@ class Flamingo_Outbound_Messages_List_Table extends WP_List_Table {
|
|
54 |
}
|
55 |
}
|
56 |
|
57 |
-
if ( ! empty( $_REQUEST['order'] )
|
|
|
58 |
$args['order'] = 'ASC';
|
59 |
}
|
60 |
|
@@ -77,7 +81,8 @@ class Flamingo_Outbound_Messages_List_Table extends WP_List_Table {
|
|
77 |
$this->set_pagination_args( array(
|
78 |
'total_items' => $total_items,
|
79 |
'total_pages' => $total_pages,
|
80 |
-
'per_page' => $per_page
|
|
|
81 |
}
|
82 |
|
83 |
function get_views() {
|
@@ -104,8 +109,9 @@ class Flamingo_Outbound_Messages_List_Table extends WP_List_Table {
|
|
104 |
Flamingo_Outbound_Message::find( array( 'post_status' => 'trash' ) );
|
105 |
$posts_in_trash = Flamingo_Outbound_Message::$found_items;
|
106 |
|
107 |
-
if ( empty( $posts_in_trash ) )
|
108 |
return $status_links;
|
|
|
109 |
|
110 |
$trash = sprintf(
|
111 |
_nx( 'Trash <span class="count">(%s)</span>',
|
@@ -129,7 +135,8 @@ class Flamingo_Outbound_Messages_List_Table extends WP_List_Table {
|
|
129 |
$columns = array(
|
130 |
'subject' => array( 'subject', false ),
|
131 |
'from' => array( 'from', false ),
|
132 |
-
'date' => array( 'date', true )
|
|
|
133 |
|
134 |
return $columns;
|
135 |
}
|
@@ -183,23 +190,32 @@ class Flamingo_Outbound_Messages_List_Table extends WP_List_Table {
|
|
183 |
}
|
184 |
|
185 |
function column_subject( $item ) {
|
186 |
-
if ( $this->is_trash )
|
187 |
return '<strong>' . esc_html( $item->subject ) . '</strong>';
|
|
|
188 |
|
189 |
$actions = array();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
190 |
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
$
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
return '<strong>' . $a . '</strong> ' . $this->row_actions( $actions );
|
203 |
}
|
204 |
|
205 |
function column_from( $item ) {
|
@@ -209,8 +225,9 @@ class Flamingo_Outbound_Messages_List_Table extends WP_List_Table {
|
|
209 |
function column_date( $item ) {
|
210 |
$post = get_post( $item->id );
|
211 |
|
212 |
-
if ( ! $post )
|
213 |
return '';
|
|
|
214 |
|
215 |
$t_time = get_the_time( __( 'Y/m/d g:i:s A', 'flamingo' ), $item->id );
|
216 |
$m_time = $post->post_date;
|
@@ -218,10 +235,11 @@ class Flamingo_Outbound_Messages_List_Table extends WP_List_Table {
|
|
218 |
|
219 |
$time_diff = time() - $time;
|
220 |
|
221 |
-
if ( $time_diff > 0 && $time_diff < 24*60*60 )
|
222 |
$h_time = sprintf( __( '%s ago', 'flamingo' ), human_time_diff( $time ) );
|
223 |
-
else
|
224 |
$h_time = mysql2date( __( 'Y/m/d', 'flamingo' ), $m_time );
|
|
|
225 |
|
226 |
return '<abbr title="' . $t_time . '">' . $h_time . '</abbr>';
|
227 |
}
|
13 |
'cb' => '<input type="checkbox" />',
|
14 |
'subject' => __( 'Subject', 'flamingo' ),
|
15 |
'from' => __( 'From', 'flamingo' ),
|
16 |
+
'date' => __( 'Date', 'flamingo' ),
|
17 |
+
);
|
18 |
|
19 |
$columns = apply_filters(
|
20 |
'manage_flamingo_outbound_posts_columns', $columns );
|
26 |
parent::__construct( array(
|
27 |
'singular' => 'post',
|
28 |
'plural' => 'posts',
|
29 |
+
'ajax' => false,
|
30 |
+
) );
|
31 |
}
|
32 |
|
33 |
function prepare_items() {
|
40 |
'posts_per_page' => $per_page,
|
41 |
'offset' => ( $this->get_pagenum() - 1 ) * $per_page,
|
42 |
'orderby' => 'date',
|
43 |
+
'order' => 'DESC',
|
44 |
+
);
|
45 |
|
46 |
if ( ! empty( $_REQUEST['s'] ) ) {
|
47 |
$args['s'] = $_REQUEST['s'];
|
57 |
}
|
58 |
}
|
59 |
|
60 |
+
if ( ! empty( $_REQUEST['order'] )
|
61 |
+
&& 'asc' == strtolower( $_REQUEST['order'] ) ) {
|
62 |
$args['order'] = 'ASC';
|
63 |
}
|
64 |
|
81 |
$this->set_pagination_args( array(
|
82 |
'total_items' => $total_items,
|
83 |
'total_pages' => $total_pages,
|
84 |
+
'per_page' => $per_page,
|
85 |
+
) );
|
86 |
}
|
87 |
|
88 |
function get_views() {
|
109 |
Flamingo_Outbound_Message::find( array( 'post_status' => 'trash' ) );
|
110 |
$posts_in_trash = Flamingo_Outbound_Message::$found_items;
|
111 |
|
112 |
+
if ( empty( $posts_in_trash ) ) {
|
113 |
return $status_links;
|
114 |
+
}
|
115 |
|
116 |
$trash = sprintf(
|
117 |
_nx( 'Trash <span class="count">(%s)</span>',
|
135 |
$columns = array(
|
136 |
'subject' => array( 'subject', false ),
|
137 |
'from' => array( 'from', false ),
|
138 |
+
'date' => array( 'date', true ),
|
139 |
+
);
|
140 |
|
141 |
return $columns;
|
142 |
}
|
190 |
}
|
191 |
|
192 |
function column_subject( $item ) {
|
193 |
+
if ( $this->is_trash ) {
|
194 |
return '<strong>' . esc_html( $item->subject ) . '</strong>';
|
195 |
+
}
|
196 |
|
197 |
$actions = array();
|
198 |
+
$post_id = absint( $item->id );
|
199 |
+
$base_url = admin_url(
|
200 |
+
'admin.php?page=flamingo_outbound&post=' . $post_id );
|
201 |
+
$edit_link = add_query_arg( array( 'action' => 'edit' ), $base_url );
|
202 |
+
|
203 |
+
if ( current_user_can( 'flamingo_edit_outbound_message', $post_id ) ) {
|
204 |
+
$actions['edit'] = sprintf( '<a href="%1$s">%2$s</a>',
|
205 |
+
esc_url( $edit_link ), esc_html( __( 'Edit', 'flamingo' ) ) );
|
206 |
+
}
|
207 |
|
208 |
+
if ( current_user_can( 'flamingo_edit_outbound_message', $post_id ) ) {
|
209 |
+
return sprintf( '<strong><a class="row-title" href="%1$s" title="%2$s">%3$s</a></strong> %4$s',
|
210 |
+
esc_url( $edit_link ),
|
211 |
+
esc_attr( sprintf( __( 'Edit “%s”', 'flamingo' ), $item->subject ) ),
|
212 |
+
esc_html( $item->subject ),
|
213 |
+
$this->row_actions( $actions ) );
|
214 |
+
} else {
|
215 |
+
return sprintf( '<strong>%1$s</strong> %2$s',
|
216 |
+
esc_html( $item->subject ),
|
217 |
+
$this->row_actions( $actions ) );
|
218 |
+
}
|
|
|
219 |
}
|
220 |
|
221 |
function column_from( $item ) {
|
225 |
function column_date( $item ) {
|
226 |
$post = get_post( $item->id );
|
227 |
|
228 |
+
if ( ! $post ) {
|
229 |
return '';
|
230 |
+
}
|
231 |
|
232 |
$t_time = get_the_time( __( 'Y/m/d g:i:s A', 'flamingo' ), $item->id );
|
233 |
$m_time = $post->post_date;
|
235 |
|
236 |
$time_diff = time() - $time;
|
237 |
|
238 |
+
if ( $time_diff > 0 && $time_diff < 24*60*60 ) {
|
239 |
$h_time = sprintf( __( '%s ago', 'flamingo' ), human_time_diff( $time ) );
|
240 |
+
} else {
|
241 |
$h_time = mysql2date( __( 'Y/m/d', 'flamingo' ), $m_time );
|
242 |
+
}
|
243 |
|
244 |
return '<abbr title="' . $t_time . '">' . $h_time . '</abbr>';
|
245 |
}
|
admin/includes/meta-boxes.php
CHANGED
@@ -37,8 +37,9 @@ function flamingo_contact_submit_meta_box( $post ) {
|
|
37 |
function flamingo_contact_tags_meta_box( $post ) {
|
38 |
$taxonomy = get_taxonomy( Flamingo_Contact::contact_tag_taxonomy );
|
39 |
|
40 |
-
if ( ! $taxonomy )
|
41 |
return;
|
|
|
42 |
|
43 |
$tags = wp_get_post_terms( $post->id, $taxonomy->name );
|
44 |
$tag_names = $tag_ids = array();
|
@@ -57,10 +58,12 @@ function flamingo_contact_tags_meta_box( $post ) {
|
|
57 |
'order' => 'DESC',
|
58 |
'number' => 10,
|
59 |
'exclude' => $tag_ids,
|
60 |
-
'fields' => 'names'
|
|
|
61 |
|
62 |
-
if ( is_wp_error( $most_used_tags ) )
|
63 |
$most_used_tags = array();
|
|
|
64 |
|
65 |
?>
|
66 |
<div class="tagsdiv" id="<?php echo esc_attr( $taxonomy->name ); ?>">
|
@@ -78,17 +81,21 @@ function flamingo_contact_tags_meta_box( $post ) {
|
|
78 |
</p>
|
79 |
<script type='text/javascript'>
|
80 |
/* <![CDATA[ */
|
81 |
-
(function($) {
|
82 |
-
$(function() {
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
|
|
|
|
|
|
|
|
92 |
/* ]]> */
|
93 |
</script>
|
94 |
<?php endif; ?>
|
@@ -104,14 +111,16 @@ function flamingo_inbound_submit_meta_box( $post ) {
|
|
104 |
<div id="delete-action">
|
105 |
<?php
|
106 |
if ( current_user_can( 'flamingo_delete_inbound_message', $post->id ) ) {
|
107 |
-
if ( ! EMPTY_TRASH_DAYS )
|
108 |
$delete_text = __( 'Delete Permanently', 'flamingo' );
|
109 |
-
else
|
110 |
$delete_text = __( 'Move to Trash', 'flamingo' );
|
|
|
111 |
|
112 |
$delete_link = admin_url(
|
113 |
sprintf( 'admin.php?page=flamingo_inbound&post=%s&action=trash', $post->id ) );
|
114 |
-
$delete_link = wp_nonce_url( $delete_link,
|
|
|
115 |
|
116 |
?><a class="submitdelete deletion" href="<?php echo $delete_link; ?>"><?php echo esc_html( $delete_text ); ?></a><?php } ?>
|
117 |
</div>
|
@@ -222,14 +231,16 @@ function flamingo_outbound_submit_meta_box( $post ) {
|
|
222 |
<div id="delete-action">
|
223 |
<?php
|
224 |
if ( current_user_can( 'flamingo_delete_outbound_message', $post->id ) ) {
|
225 |
-
if ( ! EMPTY_TRASH_DAYS )
|
226 |
$delete_text = __( 'Delete Permanently', 'flamingo' );
|
227 |
-
else
|
228 |
$delete_text = __( 'Move to Trash', 'flamingo' );
|
|
|
229 |
|
230 |
$delete_link = admin_url(
|
231 |
sprintf( 'admin.php?page=flamingo_outbound&post=%s&action=trash', $post->id ) );
|
232 |
-
$delete_link = wp_nonce_url( $delete_link,
|
|
|
233 |
|
234 |
?><a class="submitdelete deletion" href="<?php echo $delete_link; ?>"><?php echo esc_html( $delete_text ); ?></a><?php } ?>
|
235 |
</div>
|
37 |
function flamingo_contact_tags_meta_box( $post ) {
|
38 |
$taxonomy = get_taxonomy( Flamingo_Contact::contact_tag_taxonomy );
|
39 |
|
40 |
+
if ( ! $taxonomy ) {
|
41 |
return;
|
42 |
+
}
|
43 |
|
44 |
$tags = wp_get_post_terms( $post->id, $taxonomy->name );
|
45 |
$tag_names = $tag_ids = array();
|
58 |
'order' => 'DESC',
|
59 |
'number' => 10,
|
60 |
'exclude' => $tag_ids,
|
61 |
+
'fields' => 'names',
|
62 |
+
) );
|
63 |
|
64 |
+
if ( is_wp_error( $most_used_tags ) ) {
|
65 |
$most_used_tags = array();
|
66 |
+
}
|
67 |
|
68 |
?>
|
69 |
<div class="tagsdiv" id="<?php echo esc_attr( $taxonomy->name ); ?>">
|
81 |
</p>
|
82 |
<script type='text/javascript'>
|
83 |
/* <![CDATA[ */
|
84 |
+
( function( $ ) {
|
85 |
+
$( function() {
|
86 |
+
$( 'a.append-this-to-contact-tags' ).click( function() {
|
87 |
+
var tagsinput = $( '#tax-input-<?php echo esc_js( $taxonomy->name ); ?>' );
|
88 |
+
tagsinput.val( $.trim( tagsinput.val() ) );
|
89 |
+
|
90 |
+
if ( tagsinput.val() ) {
|
91 |
+
tagsinput.val( tagsinput.val() + ', ' );
|
92 |
+
}
|
93 |
+
|
94 |
+
tagsinput.val( tagsinput.val() + $( this ).text() );
|
95 |
+
return false;
|
96 |
+
} );
|
97 |
+
} );
|
98 |
+
} )( jQuery );
|
99 |
/* ]]> */
|
100 |
</script>
|
101 |
<?php endif; ?>
|
111 |
<div id="delete-action">
|
112 |
<?php
|
113 |
if ( current_user_can( 'flamingo_delete_inbound_message', $post->id ) ) {
|
114 |
+
if ( ! EMPTY_TRASH_DAYS ) {
|
115 |
$delete_text = __( 'Delete Permanently', 'flamingo' );
|
116 |
+
} else {
|
117 |
$delete_text = __( 'Move to Trash', 'flamingo' );
|
118 |
+
}
|
119 |
|
120 |
$delete_link = admin_url(
|
121 |
sprintf( 'admin.php?page=flamingo_inbound&post=%s&action=trash', $post->id ) );
|
122 |
+
$delete_link = wp_nonce_url( $delete_link,
|
123 |
+
'flamingo-trash-inbound-message_' . $post->id );
|
124 |
|
125 |
?><a class="submitdelete deletion" href="<?php echo $delete_link; ?>"><?php echo esc_html( $delete_text ); ?></a><?php } ?>
|
126 |
</div>
|
231 |
<div id="delete-action">
|
232 |
<?php
|
233 |
if ( current_user_can( 'flamingo_delete_outbound_message', $post->id ) ) {
|
234 |
+
if ( ! EMPTY_TRASH_DAYS ) {
|
235 |
$delete_text = __( 'Delete Permanently', 'flamingo' );
|
236 |
+
} else {
|
237 |
$delete_text = __( 'Move to Trash', 'flamingo' );
|
238 |
+
}
|
239 |
|
240 |
$delete_link = admin_url(
|
241 |
sprintf( 'admin.php?page=flamingo_outbound&post=%s&action=trash', $post->id ) );
|
242 |
+
$delete_link = wp_nonce_url( $delete_link,
|
243 |
+
'flamingo-trash-outbound-message_' . $post->id );
|
244 |
|
245 |
?><a class="submitdelete deletion" href="<?php echo $delete_link; ?>"><?php echo esc_html( $delete_text ); ?></a><?php } ?>
|
246 |
</div>
|
admin/js/script.js
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
( function( $ ) {
|
2 |
+
|
3 |
+
'use strict';
|
4 |
+
|
5 |
+
if ( typeof flamingo === 'undefined' || flamingo === null ) {
|
6 |
+
return;
|
7 |
+
}
|
8 |
+
|
9 |
+
$( function() {
|
10 |
+
postboxes.add_postbox_toggles( flamingo.screenId );
|
11 |
+
} );
|
12 |
+
|
13 |
+
} )( jQuery );
|
admin/script.js
DELETED
@@ -1,7 +0,0 @@
|
|
1 |
-
(function($) {
|
2 |
-
|
3 |
-
$(function() {
|
4 |
-
postboxes.add_postbox_toggles(_flamingo.screenId);
|
5 |
-
});
|
6 |
-
|
7 |
-
})(jQuery);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
flamingo.php
CHANGED
@@ -1,14 +1,14 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: Flamingo
|
4 |
-
Description:
|
5 |
Author: Takayuki Miyoshi
|
6 |
Text Domain: flamingo
|
7 |
Domain Path: /languages/
|
8 |
-
Version: 1.
|
9 |
*/
|
10 |
|
11 |
-
define( 'FLAMINGO_VERSION', '1.
|
12 |
|
13 |
define( 'FLAMINGO_PLUGIN', __FILE__ );
|
14 |
|
@@ -27,6 +27,7 @@ define( 'FLAMINGO_PLUGIN_URL',
|
|
27 |
|
28 |
require_once FLAMINGO_PLUGIN_DIR . '/includes/functions.php';
|
29 |
require_once FLAMINGO_PLUGIN_DIR . '/includes/formatting.php';
|
|
|
30 |
require_once FLAMINGO_PLUGIN_DIR . '/includes/capabilities.php';
|
31 |
require_once FLAMINGO_PLUGIN_DIR . '/includes/class-contact.php';
|
32 |
require_once FLAMINGO_PLUGIN_DIR . '/includes/class-inbound-message.php';
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: Flamingo
|
4 |
+
Description: A trustworthy message storage plugin for Contact Form 7.
|
5 |
Author: Takayuki Miyoshi
|
6 |
Text Domain: flamingo
|
7 |
Domain Path: /languages/
|
8 |
+
Version: 1.6
|
9 |
*/
|
10 |
|
11 |
+
define( 'FLAMINGO_VERSION', '1.6' );
|
12 |
|
13 |
define( 'FLAMINGO_PLUGIN', __FILE__ );
|
14 |
|
27 |
|
28 |
require_once FLAMINGO_PLUGIN_DIR . '/includes/functions.php';
|
29 |
require_once FLAMINGO_PLUGIN_DIR . '/includes/formatting.php';
|
30 |
+
require_once FLAMINGO_PLUGIN_DIR . '/includes/csv.php';
|
31 |
require_once FLAMINGO_PLUGIN_DIR . '/includes/capabilities.php';
|
32 |
require_once FLAMINGO_PLUGIN_DIR . '/includes/class-contact.php';
|
33 |
require_once FLAMINGO_PLUGIN_DIR . '/includes/class-inbound-message.php';
|
includes/capabilities.php
CHANGED
@@ -4,17 +4,19 @@ add_filter( 'map_meta_cap', 'flamingo_map_meta_cap', 10, 4 );
|
|
4 |
|
5 |
function flamingo_map_meta_cap( $caps, $cap, $user_id, $args ) {
|
6 |
$meta_caps = array(
|
7 |
-
'flamingo_edit_contacts' => 'edit_users',
|
8 |
'flamingo_edit_contact' => 'edit_users',
|
|
|
9 |
'flamingo_delete_contact' => 'edit_users',
|
|
|
10 |
'flamingo_edit_inbound_messages' => 'edit_users',
|
11 |
'flamingo_delete_inbound_message' => 'edit_users',
|
12 |
'flamingo_delete_inbound_messages' => 'edit_users',
|
13 |
'flamingo_spam_inbound_message' => 'edit_users',
|
14 |
'flamingo_unspam_inbound_message' => 'edit_users',
|
15 |
-
'flamingo_edit_outbound_messages' => 'edit_users',
|
16 |
'flamingo_edit_outbound_message' => 'edit_users',
|
17 |
-
'
|
|
|
|
|
18 |
|
19 |
$meta_caps = apply_filters( 'flamingo_map_meta_cap', $meta_caps );
|
20 |
|
4 |
|
5 |
function flamingo_map_meta_cap( $caps, $cap, $user_id, $args ) {
|
6 |
$meta_caps = array(
|
|
|
7 |
'flamingo_edit_contact' => 'edit_users',
|
8 |
+
'flamingo_edit_contacts' => 'edit_users',
|
9 |
'flamingo_delete_contact' => 'edit_users',
|
10 |
+
'flamingo_edit_inbound_message' => 'edit_users',
|
11 |
'flamingo_edit_inbound_messages' => 'edit_users',
|
12 |
'flamingo_delete_inbound_message' => 'edit_users',
|
13 |
'flamingo_delete_inbound_messages' => 'edit_users',
|
14 |
'flamingo_spam_inbound_message' => 'edit_users',
|
15 |
'flamingo_unspam_inbound_message' => 'edit_users',
|
|
|
16 |
'flamingo_edit_outbound_message' => 'edit_users',
|
17 |
+
'flamingo_edit_outbound_messages' => 'edit_users',
|
18 |
+
'flamingo_delete_outbound_message' => 'edit_users',
|
19 |
+
);
|
20 |
|
21 |
$meta_caps = apply_filters( 'flamingo_map_meta_cap', $meta_caps );
|
22 |
|
includes/class-contact.php
CHANGED
@@ -18,17 +18,21 @@ class Flamingo_Contact {
|
|
18 |
register_post_type( self::post_type, array(
|
19 |
'labels' => array(
|
20 |
'name' => __( 'Flamingo Contacts', 'flamingo' ),
|
21 |
-
'singular_name' => __( 'Flamingo Contact', 'flamingo' )
|
|
|
22 |
'rewrite' => false,
|
23 |
-
'query_var' => false
|
|
|
24 |
|
25 |
register_taxonomy( self::contact_tag_taxonomy, self::post_type, array(
|
26 |
'labels' => array(
|
27 |
'name' => __( 'Flamingo Contact Tags', 'flamingo' ),
|
28 |
-
'singular_name' => __( 'Flamingo Contact Tag', 'flamingo' )
|
|
|
29 |
'public' => false,
|
30 |
'rewrite' => false,
|
31 |
-
'query_var' => false
|
|
|
32 |
}
|
33 |
|
34 |
public static function find( $args = '' ) {
|
@@ -41,7 +45,8 @@ class Flamingo_Contact {
|
|
41 |
'meta_value' => '',
|
42 |
'post_status' => 'any',
|
43 |
'tax_query' => array(),
|
44 |
-
'contact_tag_id' => ''
|
|
|
45 |
|
46 |
$args = wp_parse_args( $args, $defaults );
|
47 |
|
@@ -51,7 +56,8 @@ class Flamingo_Contact {
|
|
51 |
$args['tax_query'][] = array(
|
52 |
'taxonomy' => self::contact_tag_taxonomy,
|
53 |
'terms' => $args['contact_tag_id'],
|
54 |
-
'field' => 'term_id'
|
|
|
55 |
}
|
56 |
|
57 |
$q = new WP_Query();
|
@@ -61,8 +67,9 @@ class Flamingo_Contact {
|
|
61 |
|
62 |
$objs = array();
|
63 |
|
64 |
-
foreach ( (array) $posts as $post )
|
65 |
$objs[] = new self( $post );
|
|
|
66 |
|
67 |
return $objs;
|
68 |
}
|
@@ -72,10 +79,12 @@ class Flamingo_Contact {
|
|
72 |
'posts_per_page' => 1,
|
73 |
'orderby' => 'ID',
|
74 |
'meta_key' => '_email',
|
75 |
-
'meta_value' => $email
|
|
|
76 |
|
77 |
-
if ( empty( $objs ) )
|
78 |
return null;
|
|
|
79 |
|
80 |
return $objs[0];
|
81 |
}
|
@@ -84,12 +93,14 @@ class Flamingo_Contact {
|
|
84 |
$defaults = array(
|
85 |
'email' => '',
|
86 |
'name' => '',
|
87 |
-
'props' => array()
|
|
|
88 |
|
89 |
$args = wp_parse_args( $args, $defaults );
|
90 |
|
91 |
-
if ( empty( $args['email'] ) || ! is_email( $args['email'] ) )
|
92 |
return;
|
|
|
93 |
|
94 |
$obj = self::search_by_email( $args['email'] );
|
95 |
|
@@ -101,10 +112,11 @@ class Flamingo_Contact {
|
|
101 |
$obj->props = (array) $args['props'];
|
102 |
}
|
103 |
|
104 |
-
if ( ! empty( $args['last_contacted'] ) )
|
105 |
$obj->last_contacted = $args['last_contacted'];
|
106 |
-
else
|
107 |
$obj->last_contacted = current_time( 'mysql' );
|
|
|
108 |
|
109 |
$obj->save();
|
110 |
|
@@ -117,13 +129,15 @@ class Flamingo_Contact {
|
|
117 |
$this->email = get_post_meta( $post->ID, '_email', true );
|
118 |
$this->name = get_post_meta( $post->ID, '_name', true );
|
119 |
$this->props = get_post_meta( $post->ID, '_props', true );
|
120 |
-
$this->last_contacted =
|
|
|
121 |
|
122 |
$terms = wp_get_object_terms( $this->id, self::contact_tag_taxonomy );
|
123 |
|
124 |
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) {
|
125 |
-
foreach ( $terms as $term )
|
126 |
$this->tags[] = $term->name;
|
|
|
127 |
}
|
128 |
}
|
129 |
}
|
@@ -145,7 +159,8 @@ class Flamingo_Contact {
|
|
145 |
'post_status' => 'publish',
|
146 |
'post_title' => $post_title,
|
147 |
'post_name' => $post_name,
|
148 |
-
'post_content' => $post_content
|
|
|
149 |
|
150 |
$post_id = wp_insert_post( $postarr );
|
151 |
|
@@ -163,21 +178,25 @@ class Flamingo_Contact {
|
|
163 |
}
|
164 |
|
165 |
public function get_prop( $name ) {
|
166 |
-
if ( 'name' == $name )
|
167 |
return $this->name;
|
|
|
168 |
|
169 |
-
if ( isset( $this->props[$name] ) )
|
170 |
return $this->props[$name];
|
|
|
171 |
|
172 |
return '';
|
173 |
}
|
174 |
|
175 |
public function delete() {
|
176 |
-
if ( empty( $this->id ) )
|
177 |
return;
|
|
|
178 |
|
179 |
-
if ( $post = wp_delete_post( $this->id, true ) )
|
180 |
$this->id = 0;
|
|
|
181 |
|
182 |
return (bool) $post;
|
183 |
}
|
18 |
register_post_type( self::post_type, array(
|
19 |
'labels' => array(
|
20 |
'name' => __( 'Flamingo Contacts', 'flamingo' ),
|
21 |
+
'singular_name' => __( 'Flamingo Contact', 'flamingo' ),
|
22 |
+
),
|
23 |
'rewrite' => false,
|
24 |
+
'query_var' => false,
|
25 |
+
) );
|
26 |
|
27 |
register_taxonomy( self::contact_tag_taxonomy, self::post_type, array(
|
28 |
'labels' => array(
|
29 |
'name' => __( 'Flamingo Contact Tags', 'flamingo' ),
|
30 |
+
'singular_name' => __( 'Flamingo Contact Tag', 'flamingo' ),
|
31 |
+
),
|
32 |
'public' => false,
|
33 |
'rewrite' => false,
|
34 |
+
'query_var' => false,
|
35 |
+
) );
|
36 |
}
|
37 |
|
38 |
public static function find( $args = '' ) {
|
45 |
'meta_value' => '',
|
46 |
'post_status' => 'any',
|
47 |
'tax_query' => array(),
|
48 |
+
'contact_tag_id' => '',
|
49 |
+
);
|
50 |
|
51 |
$args = wp_parse_args( $args, $defaults );
|
52 |
|
56 |
$args['tax_query'][] = array(
|
57 |
'taxonomy' => self::contact_tag_taxonomy,
|
58 |
'terms' => $args['contact_tag_id'],
|
59 |
+
'field' => 'term_id',
|
60 |
+
);
|
61 |
}
|
62 |
|
63 |
$q = new WP_Query();
|
67 |
|
68 |
$objs = array();
|
69 |
|
70 |
+
foreach ( (array) $posts as $post ) {
|
71 |
$objs[] = new self( $post );
|
72 |
+
}
|
73 |
|
74 |
return $objs;
|
75 |
}
|
79 |
'posts_per_page' => 1,
|
80 |
'orderby' => 'ID',
|
81 |
'meta_key' => '_email',
|
82 |
+
'meta_value' => $email,
|
83 |
+
) );
|
84 |
|
85 |
+
if ( empty( $objs ) ) {
|
86 |
return null;
|
87 |
+
}
|
88 |
|
89 |
return $objs[0];
|
90 |
}
|
93 |
$defaults = array(
|
94 |
'email' => '',
|
95 |
'name' => '',
|
96 |
+
'props' => array(),
|
97 |
+
);
|
98 |
|
99 |
$args = wp_parse_args( $args, $defaults );
|
100 |
|
101 |
+
if ( empty( $args['email'] ) || ! is_email( $args['email'] ) ) {
|
102 |
return;
|
103 |
+
}
|
104 |
|
105 |
$obj = self::search_by_email( $args['email'] );
|
106 |
|
112 |
$obj->props = (array) $args['props'];
|
113 |
}
|
114 |
|
115 |
+
if ( ! empty( $args['last_contacted'] ) ) {
|
116 |
$obj->last_contacted = $args['last_contacted'];
|
117 |
+
} else {
|
118 |
$obj->last_contacted = current_time( 'mysql' );
|
119 |
+
}
|
120 |
|
121 |
$obj->save();
|
122 |
|
129 |
$this->email = get_post_meta( $post->ID, '_email', true );
|
130 |
$this->name = get_post_meta( $post->ID, '_name', true );
|
131 |
$this->props = get_post_meta( $post->ID, '_props', true );
|
132 |
+
$this->last_contacted =
|
133 |
+
get_post_meta( $post->ID, '_last_contacted', true );
|
134 |
|
135 |
$terms = wp_get_object_terms( $this->id, self::contact_tag_taxonomy );
|
136 |
|
137 |
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) {
|
138 |
+
foreach ( $terms as $term ) {
|
139 |
$this->tags[] = $term->name;
|
140 |
+
}
|
141 |
}
|
142 |
}
|
143 |
}
|
159 |
'post_status' => 'publish',
|
160 |
'post_title' => $post_title,
|
161 |
'post_name' => $post_name,
|
162 |
+
'post_content' => $post_content,
|
163 |
+
);
|
164 |
|
165 |
$post_id = wp_insert_post( $postarr );
|
166 |
|
178 |
}
|
179 |
|
180 |
public function get_prop( $name ) {
|
181 |
+
if ( 'name' == $name ) {
|
182 |
return $this->name;
|
183 |
+
}
|
184 |
|
185 |
+
if ( isset( $this->props[$name] ) ) {
|
186 |
return $this->props[$name];
|
187 |
+
}
|
188 |
|
189 |
return '';
|
190 |
}
|
191 |
|
192 |
public function delete() {
|
193 |
+
if ( empty( $this->id ) ) {
|
194 |
return;
|
195 |
+
}
|
196 |
|
197 |
+
if ( $post = wp_delete_post( $this->id, true ) ) {
|
198 |
$this->id = 0;
|
199 |
+
}
|
200 |
|
201 |
return (bool) $post;
|
202 |
}
|
includes/class-inbound-message.php
CHANGED
@@ -24,25 +24,30 @@ class Flamingo_Inbound_Message {
|
|
24 |
register_post_type( self::post_type, array(
|
25 |
'labels' => array(
|
26 |
'name' => __( 'Flamingo Inbound Messages', 'flamingo' ),
|
27 |
-
'singular_name' => __( 'Flamingo Inbound Message', 'flamingo' )
|
|
|
28 |
'rewrite' => false,
|
29 |
-
'query_var' => false
|
|
|
30 |
|
31 |
register_post_status( self::spam_status, array(
|
32 |
'label' => __( 'Spam', 'flamingo' ),
|
33 |
'public' => false,
|
34 |
'exclude_from_search' => true,
|
35 |
'show_in_admin_all_list' => false,
|
36 |
-
'show_in_admin_status_list' => true
|
|
|
37 |
|
38 |
register_taxonomy( self::channel_taxonomy, self::post_type, array(
|
39 |
'labels' => array(
|
40 |
'name' => __( 'Flamingo Inbound Message Channels', 'flamingo' ),
|
41 |
-
'singular_name' => __( 'Flamingo Inbound Message Channel', 'flamingo' )
|
|
|
42 |
'public' => false,
|
43 |
'hierarchical' => true,
|
44 |
'rewrite' => false,
|
45 |
-
'query_var' => false
|
|
|
46 |
}
|
47 |
|
48 |
public static function find( $args = '' ) {
|
@@ -56,7 +61,8 @@ class Flamingo_Inbound_Message {
|
|
56 |
'post_status' => 'any',
|
57 |
'tax_query' => array(),
|
58 |
'channel' => '',
|
59 |
-
'channel_id' => 0
|
|
|
60 |
|
61 |
$args = wp_parse_args( $args, $defaults );
|
62 |
|
@@ -66,14 +72,16 @@ class Flamingo_Inbound_Message {
|
|
66 |
$args['tax_query'][] = array(
|
67 |
'taxonomy' => self::channel_taxonomy,
|
68 |
'terms' => absint( $args['channel_id'] ),
|
69 |
-
'field' => 'term_id'
|
|
|
70 |
}
|
71 |
|
72 |
if ( ! empty( $args['channel'] ) ) {
|
73 |
$args['tax_query'][] = array(
|
74 |
'taxonomy' => self::channel_taxonomy,
|
75 |
'terms' => $args['channel'],
|
76 |
-
'field' => 'slug'
|
|
|
77 |
}
|
78 |
|
79 |
$q = new WP_Query();
|
@@ -95,7 +103,8 @@ class Flamingo_Inbound_Message {
|
|
95 |
'offset' => 0,
|
96 |
'channel' => '',
|
97 |
'channel_id' => 0,
|
98 |
-
|
|
|
99 |
|
100 |
self::find( $args );
|
101 |
|
@@ -112,7 +121,8 @@ class Flamingo_Inbound_Message {
|
|
112 |
'fields' => array(),
|
113 |
'meta' => array(),
|
114 |
'akismet' => array(),
|
115 |
-
'spam' => false
|
|
|
116 |
|
117 |
$args = wp_parse_args( $args, $defaults );
|
118 |
|
@@ -142,7 +152,8 @@ class Flamingo_Inbound_Message {
|
|
142 |
if ( ! empty( $post ) && ( $post = get_post( $post ) ) ) {
|
143 |
$this->id = $post->ID;
|
144 |
|
145 |
-
$this->date = get_the_time(
|
|
|
146 |
$this->subject = get_post_meta( $post->ID, '_subject', true );
|
147 |
$this->from = get_post_meta( $post->ID, '_from', true );
|
148 |
$this->from_name = get_post_meta( $post->ID, '_from_name', true );
|
@@ -165,8 +176,9 @@ class Flamingo_Inbound_Message {
|
|
165 |
|
166 |
$terms = wp_get_object_terms( $this->id, self::channel_taxonomy );
|
167 |
|
168 |
-
if ( ! empty( $terms ) && ! is_wp_error( $terms ) )
|
169 |
$this->channel = $terms[0]->slug;
|
|
|
170 |
|
171 |
if ( self::spam_status == get_post_status( $post ) ) {
|
172 |
$this->spam = true;
|
@@ -177,10 +189,11 @@ class Flamingo_Inbound_Message {
|
|
177 |
}
|
178 |
|
179 |
public function save() {
|
180 |
-
if ( ! empty( $this->subject ) )
|
181 |
$post_title = $this->subject;
|
182 |
-
else
|
183 |
$post_title = __( '(No Title)', 'flamingo' );
|
|
|
184 |
|
185 |
$fields = flamingo_array_flatten( $this->fields );
|
186 |
$fields = array_filter( array_map( 'trim', $fields ) );
|
@@ -194,7 +207,8 @@ class Flamingo_Inbound_Message {
|
|
194 |
'post_type' => self::post_type,
|
195 |
'post_status' => $post_status,
|
196 |
'post_title' => $post_title,
|
197 |
-
'post_content' => $post_content
|
|
|
198 |
|
199 |
$post_id = wp_insert_post( $postarr );
|
200 |
|
@@ -215,19 +229,23 @@ class Flamingo_Inbound_Message {
|
|
215 |
update_post_meta( $post_id, '_meta', $this->meta );
|
216 |
update_post_meta( $post_id, '_akismet', $this->akismet );
|
217 |
|
218 |
-
if ( term_exists( $this->channel, self::channel_taxonomy ) )
|
219 |
-
wp_set_object_terms( $this->id, $this->channel,
|
|
|
|
|
220 |
}
|
221 |
|
222 |
return $post_id;
|
223 |
}
|
224 |
|
225 |
public function trash() {
|
226 |
-
if ( empty( $this->id ) )
|
227 |
return;
|
|
|
228 |
|
229 |
-
if ( ! EMPTY_TRASH_DAYS )
|
230 |
return $this->delete();
|
|
|
231 |
|
232 |
$post = wp_trash_post( $this->id );
|
233 |
|
@@ -235,8 +253,9 @@ class Flamingo_Inbound_Message {
|
|
235 |
}
|
236 |
|
237 |
public function untrash() {
|
238 |
-
if ( empty( $this->id ) )
|
239 |
return;
|
|
|
240 |
|
241 |
$post = wp_untrash_post( $this->id );
|
242 |
|
@@ -244,11 +263,13 @@ class Flamingo_Inbound_Message {
|
|
244 |
}
|
245 |
|
246 |
public function delete() {
|
247 |
-
if ( empty( $this->id ) )
|
248 |
return;
|
|
|
249 |
|
250 |
-
if ( $post = wp_delete_post( $this->id, true ) )
|
251 |
$this->id = 0;
|
|
|
252 |
|
253 |
return (bool) $post;
|
254 |
}
|
@@ -265,14 +286,17 @@ class Flamingo_Inbound_Message {
|
|
265 |
}
|
266 |
|
267 |
public function akismet_submit_spam() {
|
268 |
-
if ( empty( $this->id ) || empty( $this->akismet ) )
|
269 |
return;
|
|
|
270 |
|
271 |
-
if ( isset( $this->akismet['spam'] ) && $this->akismet['spam'] )
|
272 |
return;
|
|
|
273 |
|
274 |
-
if ( empty( $this->akismet['comment'] ) )
|
275 |
return;
|
|
|
276 |
|
277 |
if ( flamingo_akismet_submit_spam( $this->akismet['comment'] ) ) {
|
278 |
$this->akismet['spam'] = true;
|
@@ -293,14 +317,17 @@ class Flamingo_Inbound_Message {
|
|
293 |
}
|
294 |
|
295 |
public function akismet_submit_ham() {
|
296 |
-
if ( empty( $this->id ) || empty( $this->akismet ) )
|
297 |
return;
|
|
|
298 |
|
299 |
-
if ( isset( $this->akismet['spam'] ) && ! $this->akismet['spam'] )
|
300 |
return;
|
|
|
301 |
|
302 |
-
if ( empty( $this->akismet['comment'] ) )
|
303 |
return;
|
|
|
304 |
|
305 |
if ( flamingo_akismet_submit_ham( $this->akismet['comment'] ) ) {
|
306 |
$this->akismet['spam'] = false;
|
24 |
register_post_type( self::post_type, array(
|
25 |
'labels' => array(
|
26 |
'name' => __( 'Flamingo Inbound Messages', 'flamingo' ),
|
27 |
+
'singular_name' => __( 'Flamingo Inbound Message', 'flamingo' ),
|
28 |
+
),
|
29 |
'rewrite' => false,
|
30 |
+
'query_var' => false,
|
31 |
+
) );
|
32 |
|
33 |
register_post_status( self::spam_status, array(
|
34 |
'label' => __( 'Spam', 'flamingo' ),
|
35 |
'public' => false,
|
36 |
'exclude_from_search' => true,
|
37 |
'show_in_admin_all_list' => false,
|
38 |
+
'show_in_admin_status_list' => true,
|
39 |
+
) );
|
40 |
|
41 |
register_taxonomy( self::channel_taxonomy, self::post_type, array(
|
42 |
'labels' => array(
|
43 |
'name' => __( 'Flamingo Inbound Message Channels', 'flamingo' ),
|
44 |
+
'singular_name' => __( 'Flamingo Inbound Message Channel', 'flamingo' ),
|
45 |
+
),
|
46 |
'public' => false,
|
47 |
'hierarchical' => true,
|
48 |
'rewrite' => false,
|
49 |
+
'query_var' => false,
|
50 |
+
) );
|
51 |
}
|
52 |
|
53 |
public static function find( $args = '' ) {
|
61 |
'post_status' => 'any',
|
62 |
'tax_query' => array(),
|
63 |
'channel' => '',
|
64 |
+
'channel_id' => 0,
|
65 |
+
);
|
66 |
|
67 |
$args = wp_parse_args( $args, $defaults );
|
68 |
|
72 |
$args['tax_query'][] = array(
|
73 |
'taxonomy' => self::channel_taxonomy,
|
74 |
'terms' => absint( $args['channel_id'] ),
|
75 |
+
'field' => 'term_id',
|
76 |
+
);
|
77 |
}
|
78 |
|
79 |
if ( ! empty( $args['channel'] ) ) {
|
80 |
$args['tax_query'][] = array(
|
81 |
'taxonomy' => self::channel_taxonomy,
|
82 |
'terms' => $args['channel'],
|
83 |
+
'field' => 'slug',
|
84 |
+
);
|
85 |
}
|
86 |
|
87 |
$q = new WP_Query();
|
103 |
'offset' => 0,
|
104 |
'channel' => '',
|
105 |
'channel_id' => 0,
|
106 |
+
'post_status' => 'publish',
|
107 |
+
) );
|
108 |
|
109 |
self::find( $args );
|
110 |
|
121 |
'fields' => array(),
|
122 |
'meta' => array(),
|
123 |
'akismet' => array(),
|
124 |
+
'spam' => false,
|
125 |
+
);
|
126 |
|
127 |
$args = wp_parse_args( $args, $defaults );
|
128 |
|
152 |
if ( ! empty( $post ) && ( $post = get_post( $post ) ) ) {
|
153 |
$this->id = $post->ID;
|
154 |
|
155 |
+
$this->date = get_the_time(
|
156 |
+
__( 'Y/m/d g:i:s A', 'flamingo' ), $this->id );
|
157 |
$this->subject = get_post_meta( $post->ID, '_subject', true );
|
158 |
$this->from = get_post_meta( $post->ID, '_from', true );
|
159 |
$this->from_name = get_post_meta( $post->ID, '_from_name', true );
|
176 |
|
177 |
$terms = wp_get_object_terms( $this->id, self::channel_taxonomy );
|
178 |
|
179 |
+
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) {
|
180 |
$this->channel = $terms[0]->slug;
|
181 |
+
}
|
182 |
|
183 |
if ( self::spam_status == get_post_status( $post ) ) {
|
184 |
$this->spam = true;
|
189 |
}
|
190 |
|
191 |
public function save() {
|
192 |
+
if ( ! empty( $this->subject ) ) {
|
193 |
$post_title = $this->subject;
|
194 |
+
} else {
|
195 |
$post_title = __( '(No Title)', 'flamingo' );
|
196 |
+
}
|
197 |
|
198 |
$fields = flamingo_array_flatten( $this->fields );
|
199 |
$fields = array_filter( array_map( 'trim', $fields ) );
|
207 |
'post_type' => self::post_type,
|
208 |
'post_status' => $post_status,
|
209 |
'post_title' => $post_title,
|
210 |
+
'post_content' => $post_content,
|
211 |
+
);
|
212 |
|
213 |
$post_id = wp_insert_post( $postarr );
|
214 |
|
229 |
update_post_meta( $post_id, '_meta', $this->meta );
|
230 |
update_post_meta( $post_id, '_akismet', $this->akismet );
|
231 |
|
232 |
+
if ( term_exists( $this->channel, self::channel_taxonomy ) ) {
|
233 |
+
wp_set_object_terms( $this->id, $this->channel,
|
234 |
+
self::channel_taxonomy );
|
235 |
+
}
|
236 |
}
|
237 |
|
238 |
return $post_id;
|
239 |
}
|
240 |
|
241 |
public function trash() {
|
242 |
+
if ( empty( $this->id ) ) {
|
243 |
return;
|
244 |
+
}
|
245 |
|
246 |
+
if ( ! EMPTY_TRASH_DAYS ) {
|
247 |
return $this->delete();
|
248 |
+
}
|
249 |
|
250 |
$post = wp_trash_post( $this->id );
|
251 |
|
253 |
}
|
254 |
|
255 |
public function untrash() {
|
256 |
+
if ( empty( $this->id ) ) {
|
257 |
return;
|
258 |
+
}
|
259 |
|
260 |
$post = wp_untrash_post( $this->id );
|
261 |
|
263 |
}
|
264 |
|
265 |
public function delete() {
|
266 |
+
if ( empty( $this->id ) ) {
|
267 |
return;
|
268 |
+
}
|
269 |
|
270 |
+
if ( $post = wp_delete_post( $this->id, true ) ) {
|
271 |
$this->id = 0;
|
272 |
+
}
|
273 |
|
274 |
return (bool) $post;
|
275 |
}
|
286 |
}
|
287 |
|
288 |
public function akismet_submit_spam() {
|
289 |
+
if ( empty( $this->id ) || empty( $this->akismet ) ) {
|
290 |
return;
|
291 |
+
}
|
292 |
|
293 |
+
if ( isset( $this->akismet['spam'] ) && $this->akismet['spam'] ) {
|
294 |
return;
|
295 |
+
}
|
296 |
|
297 |
+
if ( empty( $this->akismet['comment'] ) ) {
|
298 |
return;
|
299 |
+
}
|
300 |
|
301 |
if ( flamingo_akismet_submit_spam( $this->akismet['comment'] ) ) {
|
302 |
$this->akismet['spam'] = true;
|
317 |
}
|
318 |
|
319 |
public function akismet_submit_ham() {
|
320 |
+
if ( empty( $this->id ) || empty( $this->akismet ) ) {
|
321 |
return;
|
322 |
+
}
|
323 |
|
324 |
+
if ( isset( $this->akismet['spam'] ) && ! $this->akismet['spam'] ) {
|
325 |
return;
|
326 |
+
}
|
327 |
|
328 |
+
if ( empty( $this->akismet['comment'] ) ) {
|
329 |
return;
|
330 |
+
}
|
331 |
|
332 |
if ( flamingo_akismet_submit_ham( $this->akismet['comment'] ) ) {
|
333 |
$this->akismet['spam'] = false;
|
includes/class-outbound-message.php
CHANGED
@@ -18,9 +18,11 @@ class Flamingo_Outbound_Message {
|
|
18 |
register_post_type( self::post_type, array(
|
19 |
'labels' => array(
|
20 |
'name' => __( 'Flamingo Outbound Messages', 'flamingo' ),
|
21 |
-
'singular_name' => __( 'Flamingo Outbound Message', 'flamingo' )
|
|
|
22 |
'rewrite' => false,
|
23 |
-
'query_var' => false
|
|
|
24 |
}
|
25 |
|
26 |
public static function find( $args = '' ) {
|
@@ -32,7 +34,8 @@ class Flamingo_Outbound_Message {
|
|
32 |
'meta_key' => '',
|
33 |
'meta_value' => '',
|
34 |
'post_status' => 'any',
|
35 |
-
'tax_query' => array()
|
|
|
36 |
|
37 |
$args = wp_parse_args( $args, $defaults );
|
38 |
|
@@ -45,8 +48,9 @@ class Flamingo_Outbound_Message {
|
|
45 |
|
46 |
$objs = array();
|
47 |
|
48 |
-
foreach ( (array) $posts as $post )
|
49 |
$objs[] = new self( $post );
|
|
|
50 |
|
51 |
return $objs;
|
52 |
}
|
@@ -57,7 +61,8 @@ class Flamingo_Outbound_Message {
|
|
57 |
'from' => '',
|
58 |
'subject' => '',
|
59 |
'body' => '',
|
60 |
-
'meta' => array()
|
|
|
61 |
|
62 |
$args = wp_parse_args( $args, $defaults );
|
63 |
|
@@ -77,7 +82,8 @@ class Flamingo_Outbound_Message {
|
|
77 |
if ( ! empty( $post ) && ( $post = get_post( $post ) ) ) {
|
78 |
$this->id = $post->ID;
|
79 |
|
80 |
-
$this->date = get_the_time(
|
|
|
81 |
$this->to = get_post_meta( $post->ID, '_to', true );
|
82 |
$this->from = get_post_meta( $post->ID, '_from', true );
|
83 |
$this->subject = get_post_meta( $post->ID, '_subject', true );
|
@@ -86,10 +92,11 @@ class Flamingo_Outbound_Message {
|
|
86 |
}
|
87 |
|
88 |
public function save() {
|
89 |
-
if ( ! empty( $this->subject ) )
|
90 |
$post_title = $this->subject;
|
91 |
-
else
|
92 |
$post_title = __( '(No Title)', 'flamingo' );
|
|
|
93 |
|
94 |
$post_content = implode( "\n", array(
|
95 |
$this->to, $this->from, $this->subject, $this->body ) );
|
@@ -101,7 +108,8 @@ class Flamingo_Outbound_Message {
|
|
101 |
'post_type' => self::post_type,
|
102 |
'post_status' => $post_status,
|
103 |
'post_title' => $post_title,
|
104 |
-
'post_content' => $post_content
|
|
|
105 |
|
106 |
$post_id = wp_insert_post( $postarr );
|
107 |
|
@@ -117,11 +125,13 @@ class Flamingo_Outbound_Message {
|
|
117 |
}
|
118 |
|
119 |
public function trash() {
|
120 |
-
if ( empty( $this->id ) )
|
121 |
return;
|
|
|
122 |
|
123 |
-
if ( ! EMPTY_TRASH_DAYS )
|
124 |
return $this->delete();
|
|
|
125 |
|
126 |
$post = wp_trash_post( $this->id );
|
127 |
|
@@ -129,8 +139,9 @@ class Flamingo_Outbound_Message {
|
|
129 |
}
|
130 |
|
131 |
public function untrash() {
|
132 |
-
if ( empty( $this->id ) )
|
133 |
return;
|
|
|
134 |
|
135 |
$post = wp_untrash_post( $this->id );
|
136 |
|
@@ -138,11 +149,13 @@ class Flamingo_Outbound_Message {
|
|
138 |
}
|
139 |
|
140 |
public function delete() {
|
141 |
-
if ( empty( $this->id ) )
|
142 |
return;
|
|
|
143 |
|
144 |
-
if ( $post = wp_delete_post( $this->id, true ) )
|
145 |
$this->id = 0;
|
|
|
146 |
|
147 |
return (bool) $post;
|
148 |
}
|
18 |
register_post_type( self::post_type, array(
|
19 |
'labels' => array(
|
20 |
'name' => __( 'Flamingo Outbound Messages', 'flamingo' ),
|
21 |
+
'singular_name' => __( 'Flamingo Outbound Message', 'flamingo' ),
|
22 |
+
),
|
23 |
'rewrite' => false,
|
24 |
+
'query_var' => false,
|
25 |
+
) );
|
26 |
}
|
27 |
|
28 |
public static function find( $args = '' ) {
|
34 |
'meta_key' => '',
|
35 |
'meta_value' => '',
|
36 |
'post_status' => 'any',
|
37 |
+
'tax_query' => array(),
|
38 |
+
);
|
39 |
|
40 |
$args = wp_parse_args( $args, $defaults );
|
41 |
|
48 |
|
49 |
$objs = array();
|
50 |
|
51 |
+
foreach ( (array) $posts as $post ) {
|
52 |
$objs[] = new self( $post );
|
53 |
+
}
|
54 |
|
55 |
return $objs;
|
56 |
}
|
61 |
'from' => '',
|
62 |
'subject' => '',
|
63 |
'body' => '',
|
64 |
+
'meta' => array(),
|
65 |
+
);
|
66 |
|
67 |
$args = wp_parse_args( $args, $defaults );
|
68 |
|
82 |
if ( ! empty( $post ) && ( $post = get_post( $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 );
|
92 |
}
|
93 |
|
94 |
public function save() {
|
95 |
+
if ( ! empty( $this->subject ) ) {
|
96 |
$post_title = $this->subject;
|
97 |
+
} else {
|
98 |
$post_title = __( '(No Title)', 'flamingo' );
|
99 |
+
}
|
100 |
|
101 |
$post_content = implode( "\n", array(
|
102 |
$this->to, $this->from, $this->subject, $this->body ) );
|
108 |
'post_type' => self::post_type,
|
109 |
'post_status' => $post_status,
|
110 |
'post_title' => $post_title,
|
111 |
+
'post_content' => $post_content,
|
112 |
+
);
|
113 |
|
114 |
$post_id = wp_insert_post( $postarr );
|
115 |
|
125 |
}
|
126 |
|
127 |
public function trash() {
|
128 |
+
if ( empty( $this->id ) ) {
|
129 |
return;
|
130 |
+
}
|
131 |
|
132 |
+
if ( ! EMPTY_TRASH_DAYS ) {
|
133 |
return $this->delete();
|
134 |
+
}
|
135 |
|
136 |
$post = wp_trash_post( $this->id );
|
137 |
|
139 |
}
|
140 |
|
141 |
public function untrash() {
|
142 |
+
if ( empty( $this->id ) ) {
|
143 |
return;
|
144 |
+
}
|
145 |
|
146 |
$post = wp_untrash_post( $this->id );
|
147 |
|
149 |
}
|
150 |
|
151 |
public function delete() {
|
152 |
+
if ( empty( $this->id ) ) {
|
153 |
return;
|
154 |
+
}
|
155 |
|
156 |
+
if ( $post = wp_delete_post( $this->id, true ) ) {
|
157 |
$this->id = 0;
|
158 |
+
}
|
159 |
|
160 |
return (bool) $post;
|
161 |
}
|
includes/comment.php
CHANGED
@@ -15,10 +15,12 @@ function flamingo_insert_comment( $comment_id ) {
|
|
15 |
Flamingo_Contact::add( array(
|
16 |
'email' => $comment->comment_author_email,
|
17 |
'name' => $comment->comment_author,
|
18 |
-
'channel' => 'comment'
|
|
|
19 |
}
|
20 |
|
21 |
-
add_action( 'transition_comment_status',
|
|
|
22 |
|
23 |
function flamingo_transition_comment_status( $new_status, $old_status, $comment ) {
|
24 |
if ( 'approved' != $new_status ) {
|
@@ -31,7 +33,8 @@ function flamingo_transition_comment_status( $new_status, $old_status, $comment
|
|
31 |
Flamingo_Contact::add( array(
|
32 |
'email' => $email,
|
33 |
'name' => $name,
|
34 |
-
'channel' => 'comment'
|
|
|
35 |
}
|
36 |
|
37 |
/* Collect contact info from existing comments when activating plugin */
|
@@ -42,7 +45,8 @@ function flamingo_collect_contacts_from_comments() {
|
|
42 |
$comments = get_comments( array(
|
43 |
'status' => 'approve',
|
44 |
'type' => 'comment',
|
45 |
-
'number' => 20
|
|
|
46 |
|
47 |
foreach ( $comments as $comment ) {
|
48 |
$email = $comment->comment_author_email;
|
@@ -55,6 +59,7 @@ function flamingo_collect_contacts_from_comments() {
|
|
55 |
Flamingo_Contact::add( array(
|
56 |
'email' => $email,
|
57 |
'name' => $name,
|
58 |
-
'channel' => 'comment'
|
|
|
59 |
}
|
60 |
}
|
15 |
Flamingo_Contact::add( array(
|
16 |
'email' => $comment->comment_author_email,
|
17 |
'name' => $comment->comment_author,
|
18 |
+
'channel' => 'comment',
|
19 |
+
) );
|
20 |
}
|
21 |
|
22 |
+
add_action( 'transition_comment_status',
|
23 |
+
'flamingo_transition_comment_status', 10, 3 );
|
24 |
|
25 |
function flamingo_transition_comment_status( $new_status, $old_status, $comment ) {
|
26 |
if ( 'approved' != $new_status ) {
|
33 |
Flamingo_Contact::add( array(
|
34 |
'email' => $email,
|
35 |
'name' => $name,
|
36 |
+
'channel' => 'comment',
|
37 |
+
) );
|
38 |
}
|
39 |
|
40 |
/* Collect contact info from existing comments when activating plugin */
|
45 |
$comments = get_comments( array(
|
46 |
'status' => 'approve',
|
47 |
'type' => 'comment',
|
48 |
+
'number' => 20,
|
49 |
+
) );
|
50 |
|
51 |
foreach ( $comments as $comment ) {
|
52 |
$email = $comment->comment_author_email;
|
59 |
Flamingo_Contact::add( array(
|
60 |
'email' => $email,
|
61 |
'name' => $name,
|
62 |
+
'channel' => 'comment',
|
63 |
+
) );
|
64 |
}
|
65 |
}
|
includes/csv.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
function flamingo_csv_row( $inputs = array() ) {
|
4 |
+
$row = array();
|
5 |
+
|
6 |
+
foreach ( $inputs as $input ) {
|
7 |
+
$row[] = apply_filters( 'flamingo_csv_quotation', $input );
|
8 |
+
}
|
9 |
+
|
10 |
+
$separator = apply_filters( 'flamingo_csv_value_separator', ',' );
|
11 |
+
|
12 |
+
return implode( $separator, $row );
|
13 |
+
}
|
14 |
+
|
15 |
+
add_filter( 'flamingo_csv_quotation', 'flamingo_csv_quote' );
|
16 |
+
|
17 |
+
function flamingo_csv_quote( $input ) {
|
18 |
+
return sprintf( '"%s"', str_replace( '"', '""', $input ) );
|
19 |
+
}
|
includes/formatting.php
CHANGED
@@ -13,16 +13,3 @@ function flamingo_htmlize( $val ) {
|
|
13 |
|
14 |
return wpautop( esc_html( (string) $val ) );
|
15 |
}
|
16 |
-
|
17 |
-
function flamingo_csv_row( $inputs = array() ) {
|
18 |
-
$row = array();
|
19 |
-
|
20 |
-
foreach ( $inputs as $input ) {
|
21 |
-
$input = preg_replace( '/(?<!\r)\n/', "\r\n", $input );
|
22 |
-
$input = esc_sql( $input );
|
23 |
-
$input = sprintf( '"%s"', $input );
|
24 |
-
$row[] = $input;
|
25 |
-
}
|
26 |
-
|
27 |
-
return implode( ',', $row );
|
28 |
-
}
|
13 |
|
14 |
return wpautop( esc_html( (string) $val ) );
|
15 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/user.php
CHANGED
@@ -14,23 +14,27 @@ function flamingo_user_profile_update( $user_id ) {
|
|
14 |
|
15 |
$props = array(
|
16 |
'first_name' => $user->first_name,
|
17 |
-
'last_name' => $user->last_name
|
|
|
18 |
|
19 |
if ( ! empty( $email ) ) {
|
20 |
Flamingo_Contact::add( array(
|
21 |
'email' => $email,
|
22 |
'name' => $name,
|
23 |
'props' => $props,
|
24 |
-
'channel' => 'user'
|
|
|
25 |
}
|
26 |
}
|
27 |
|
28 |
/* Collect contact info from existing users when activating plugin */
|
29 |
-
add_action( 'activate_' . FLAMINGO_PLUGIN_BASENAME,
|
|
|
30 |
|
31 |
function flamingo_collect_contacts_from_users() {
|
32 |
$users = get_users( array(
|
33 |
-
'number' => 20
|
|
|
34 |
|
35 |
foreach ( $users as $user ) {
|
36 |
$email = $user->user_email;
|
@@ -42,12 +46,14 @@ function flamingo_collect_contacts_from_users() {
|
|
42 |
|
43 |
$props = array(
|
44 |
'first_name' => empty( $user->first_name ) ? '' : $user->first_name,
|
45 |
-
'last_name' => empty( $user->last_name ) ? '' : $user->last_name
|
|
|
46 |
|
47 |
Flamingo_Contact::add( array(
|
48 |
'email' => $email,
|
49 |
'name' => $name,
|
50 |
'props' => $props,
|
51 |
-
'channel' => 'user'
|
|
|
52 |
}
|
53 |
}
|
14 |
|
15 |
$props = array(
|
16 |
'first_name' => $user->first_name,
|
17 |
+
'last_name' => $user->last_name,
|
18 |
+
);
|
19 |
|
20 |
if ( ! empty( $email ) ) {
|
21 |
Flamingo_Contact::add( array(
|
22 |
'email' => $email,
|
23 |
'name' => $name,
|
24 |
'props' => $props,
|
25 |
+
'channel' => 'user',
|
26 |
+
) );
|
27 |
}
|
28 |
}
|
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(
|
36 |
+
'number' => 20,
|
37 |
+
) );
|
38 |
|
39 |
foreach ( $users as $user ) {
|
40 |
$email = $user->user_email;
|
46 |
|
47 |
$props = array(
|
48 |
'first_name' => empty( $user->first_name ) ? '' : $user->first_name,
|
49 |
+
'last_name' => empty( $user->last_name ) ? '' : $user->last_name,
|
50 |
+
);
|
51 |
|
52 |
Flamingo_Contact::add( array(
|
53 |
'email' => $email,
|
54 |
'name' => $name,
|
55 |
'props' => $props,
|
56 |
+
'channel' => 'user',
|
57 |
+
) );
|
58 |
}
|
59 |
}
|
license.txt
CHANGED
@@ -1,3 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
GNU GENERAL PUBLIC LICENSE
|
2 |
Version 2, June 1991
|
3 |
|
1 |
+
Flamingo - WordPress Plugin, 2012-2017 Takayuki Miyoshi
|
2 |
+
Flamingo is distributed under the terms of the GNU GPL
|
3 |
+
|
4 |
+
This program is free software; you can redistribute it and/or modify
|
5 |
+
it under the terms of the GNU General Public License as published by
|
6 |
+
the Free Software Foundation; either version 2 of the License, or
|
7 |
+
(at your option) any later version.
|
8 |
+
|
9 |
+
This program is distributed in the hope that it will be useful,
|
10 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12 |
+
GNU General Public License for more details.
|
13 |
+
|
14 |
+
You should have received a copy of the GNU General Public License
|
15 |
+
along with this program; if not, write to the Free Software
|
16 |
+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
17 |
+
|
18 |
+
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
19 |
+
|
20 |
GNU GENERAL PUBLIC LICENSE
|
21 |
Version 2, June 1991
|
22 |
|
readme.txt
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
=== Flamingo ===
|
2 |
Contributors: takayukister, megumithemes
|
3 |
Tags: bird, contact, mail, crm
|
4 |
-
Requires at least: 4.
|
5 |
-
Tested up to: 4.
|
6 |
-
Stable tag: 1.
|
7 |
License: GPLv2 or later
|
8 |
-
License URI:
|
9 |
|
10 |
A trustworthy message storage plugin for Contact Form 7.
|
11 |
|
@@ -15,7 +15,7 @@ Flamingo is a message storage plugin originally created for [Contact Form 7](htt
|
|
15 |
|
16 |
After activation of the plugin, you'll find *Flamingo* on the WordPress admin screen menu. All messages through contact forms are listed there and are searchable. With Flamingo, you are no longer need to worry about losing important messages due to mail server issues or misconfiguration in mail setup.
|
17 |
|
18 |
-
For more detailed information, please refer to the [Contact Form 7 documentation page](
|
19 |
|
20 |
== Installation ==
|
21 |
|
@@ -28,16 +28,19 @@ For more detailed information, please refer to the [Contact Form 7 documentation
|
|
28 |
|
29 |
== Changelog ==
|
30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
= 1.5 =
|
32 |
|
33 |
* Tested up to WordPress 4.7.
|
34 |
* Requires WordPress 4.5 or higher.
|
35 |
* count() method added to Flamingo_Inbound_Message class.
|
36 |
* All language files in the languages folder were removed. Translations have moved to translate.wordpress.org.
|
37 |
-
|
38 |
-
= 1.4 =
|
39 |
-
|
40 |
-
* Tested up to WordPress 4.5.1.
|
41 |
-
* Requires WordPress 4.4 or higher.
|
42 |
-
* Added "Meta" meta-box to the Inbound Message screen.
|
43 |
-
* Language packs for German, Hebrew, and Japanese are removed because those are available from translate.wordpress.org.
|
1 |
=== Flamingo ===
|
2 |
Contributors: takayukister, megumithemes
|
3 |
Tags: bird, contact, mail, crm
|
4 |
+
Requires at least: 4.7
|
5 |
+
Tested up to: 4.8
|
6 |
+
Stable tag: 1.6
|
7 |
License: GPLv2 or later
|
8 |
+
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
10 |
A trustworthy message storage plugin for Contact Form 7.
|
11 |
|
15 |
|
16 |
After activation of the plugin, you'll find *Flamingo* on the WordPress admin screen menu. All messages through contact forms are listed there and are searchable. With Flamingo, you are no longer need to worry about losing important messages due to mail server issues or misconfiguration in mail setup.
|
17 |
|
18 |
+
For more detailed information, please refer to the [Contact Form 7 documentation page](https://contactform7.com/save-submitted-messages-with-flamingo/).
|
19 |
|
20 |
== Installation ==
|
21 |
|
28 |
|
29 |
== Changelog ==
|
30 |
|
31 |
+
= 1.6 =
|
32 |
+
|
33 |
+
* Tested up to WordPress 4.8.
|
34 |
+
* Requires WordPress 4.7 or higher.
|
35 |
+
* Added RTL stylesheet.
|
36 |
+
* Strengthened capability checking.
|
37 |
+
* Removed inappropriate content from h1 headings.
|
38 |
+
* Changed the default format of the export CSV.
|
39 |
+
* Introduced the flamingo_csv_value_separator and flamingo_csv_quotation filter hooks to enable customizing CSV output.
|
40 |
+
|
41 |
= 1.5 =
|
42 |
|
43 |
* Tested up to WordPress 4.7.
|
44 |
* Requires WordPress 4.5 or higher.
|
45 |
* count() method added to Flamingo_Inbound_Message class.
|
46 |
* All language files in the languages folder were removed. Translations have moved to translate.wordpress.org.
|
|
|
|
|
|
|
|
|
|
|
|
|
|