summaryrefslogtreecommitdiff
path: root/Postman/Postman-Email-Log/PostmanEmailLogView.php
diff options
context:
space:
mode:
authoryehudah <yehudah@b8457f37-d9ea-0310-8a92-e5e31aec5664>2020-06-20 21:39:39 +0000
committeryehudah <yehudah@b8457f37-d9ea-0310-8a92-e5e31aec5664>2020-06-20 21:39:39 +0000
commit53b2035def91dc0fe6d8f68e4a34aca2acc79ec8 (patch)
tree03e818494b3390d3e7ed4aedac0a50f0b722f0a3 /Postman/Postman-Email-Log/PostmanEmailLogView.php
parent67430a4a94c041c57cb4043fcd05c85365ee17f5 (diff)
downloadPost-SMTP-53b2035def91dc0fe6d8f68e4a34aca2acc79ec8.zip
Email log improvements: Solution column, filter.
Some text clarify.
Diffstat (limited to 'Postman/Postman-Email-Log/PostmanEmailLogView.php')
-rw-r--r--Postman/Postman-Email-Log/PostmanEmailLogView.php31
1 files changed, 21 insertions, 10 deletions
diff --git a/Postman/Postman-Email-Log/PostmanEmailLogView.php b/Postman/Postman-Email-Log/PostmanEmailLogView.php
index 52cdd4d..2b06ba3 100644
--- a/Postman/Postman-Email-Log/PostmanEmailLogView.php
+++ b/Postman/Postman-Email-Log/PostmanEmailLogView.php
@@ -60,6 +60,7 @@ class PostmanEmailLogView extends WP_List_Table {
function column_default( $item, $column_name ) {
switch ( $column_name ) {
case 'sent_to' :
+ case 'solution' :
case 'date' :
case 'status' :
return $item [ $column_name ];
@@ -167,6 +168,7 @@ class PostmanEmailLogView extends WP_List_Table {
'title' => _x( 'Subject', 'What is the subject of this message?', 'post-smtp' ),
'sent_to' => __( 'Sent To', 'post-smtp' ),
'status' => __( 'Status', 'post-smtp' ),
+ 'solution' => __( 'Solution', 'post-smtp' ),
'date' => _x( 'Delivery Time', 'When was this email sent?', 'post-smtp' ),
);
return $columns;
@@ -263,13 +265,13 @@ class PostmanEmailLogView extends WP_List_Table {
* ************************************************************************
*/
function prepare_items() {
- if ( ! empty( $_POST ) && ! wp_verify_nonce( $_REQUEST['post-smtp-log'], 'post-smtp' ) )
+ if ( isset( $_REQUEST['post-smtp-log-nonce'] ) && ! wp_verify_nonce( $_REQUEST['post-smtp-log-nonce'], 'post-smtp' ) )
die( 'Security check' );
/**
* First, lets decide how many records per page to show
*/
- $per_page = isset( $_POST['postman_page_records'] ) ? absint( $_POST['postman_page_records'] ) : 10;
+ $per_page = isset( $_GET['postman_page_records'] ) ? absint( $_GET['postman_page_records'] ) : 10;
/**
* REQUIRED.
@@ -324,36 +326,36 @@ class PostmanEmailLogView extends WP_List_Table {
'suppress_filters' => true,
);
- if ( isset( $_POST['from_date'] ) && ! empty( $_POST['from_date'] ) ) {
- $from_date = sanitize_text_field( $_POST['from_date'] );
+ if ( isset( $_GET['from_date'] ) && ! empty( $_GET['from_date'] ) ) {
+ $from_date = sanitize_text_field( $_GET['from_date'] );
$args['date_query']['after'] = $from_date;
$args['date_query']['column'] = 'post_date';
$args['date_query']['inclusive'] = false;
}
- if ( isset( $_POST['to_date'] ) && ! empty( $_POST['to_date'] ) ) {
- $to_date = sanitize_text_field( $_POST['to_date'] );
+ if ( isset( $_GET['to_date'] ) && ! empty( $_GET['to_date'] ) ) {
+ $to_date = sanitize_text_field( $_GET['to_date'] );
$args['date_query']['before'] = $to_date;
$args['date_query']['column'] = 'post_date';
$args['date_query']['inclusive'] = true;
}
- if ( ! empty( $_POST['search'] ) ) {
+ if ( ! empty( $_GET['search'] ) ) {
if ( isset( $args['date_query'] ) ) {
unset( $args['date_query'] ); }
- $args['s'] = sanitize_text_field( $_POST['search'] );
+ $args['s'] = sanitize_text_field( $_GET['search'] );
}
- if ( isset( $_POST['postman_trash_all'] ) ) {
+ if ( isset( $_GET['postman_trash_all'] ) ) {
$args['posts_per_page'] = -1;
}
$posts = new WP_query( $args );
- if ( isset( $_POST['postman_trash_all'] ) ) {
+ if ( isset( $_GET['postman_trash_all'] ) && current_user_can(Postman::MANAGE_POSTMAN_CAPABILITY_LOGS ) ) {
foreach ( $posts->posts as $post ) {
wp_delete_post( $post->ID, true );
}
@@ -374,10 +376,19 @@ class PostmanEmailLogView extends WP_List_Table {
}
$meta_values = PostmanLogFields::get_instance()->get( $post->ID );
$sent_to = array_map( 'esc_html', explode( ',' , $meta_values ['to_header'] [0] ) );
+ $solution_meta = $meta_values ['solution'] [0];
+
+ if ( empty( $solution_meta ) && empty( $post->post_excerpt ) ) {
+ $solution = 'No need - Mail sent';
+ } else {
+ $solution = $solution_meta;
+ }
+
$flattenedPost = array(
// the post title must be escaped as they are displayed in the HTML output
'sent_to' => implode( ', ', $sent_to ),
'title' => esc_html( $post->post_title ),
+ 'solution' => $solution,
// the post status must be escaped as they are displayed in the HTML output
'status' => ($post->post_excerpt != null ? esc_html( $post->post_excerpt ) : __( 'Sent', 'post-smtp' )),
'date' => date( "$date_format $time_format", strtotime( $post->post_date ) ),