diff options
Diffstat (limited to 'Postman/Postman-Email-Log')
-rw-r--r-- | Postman/Postman-Email-Log/PostmanEmailLogController.php | 20 | ||||
-rw-r--r-- | Postman/Postman-Email-Log/PostmanEmailLogService.php | 10 | ||||
-rw-r--r-- | Postman/Postman-Email-Log/PostmanEmailLogView.php | 16 |
3 files changed, 36 insertions, 10 deletions
diff --git a/Postman/Postman-Email-Log/PostmanEmailLogController.php b/Postman/Postman-Email-Log/PostmanEmailLogController.php index efb19ae..447b6dc 100644 --- a/Postman/Postman-Email-Log/PostmanEmailLogController.php +++ b/Postman/Postman-Email-Log/PostmanEmailLogController.php @@ -363,7 +363,7 @@ class PostmanEmailLogController { ?> <form id="postman-email-log-filter" method="post"> - <div id="email-log-filter"> + <div id="email-log-filter" class="postman-log-row"> <div class="form-control"> <label for="from_date"><?php _e( 'From Date', Postman::TEXT_DOMAIN ); ?></label> <input id="from_date" class="email-log-date" value="<?php echo $from_date; ?>" type="text" name="from_date" placeholder="<?php _e( 'From Date', Postman::TEXT_DOMAIN ); ?>"> @@ -378,11 +378,21 @@ class PostmanEmailLogController { </div> <div class="form-control"> <button type="submit" name="filter" class="button button-primary"><?php _e( 'Filter', Postman::TEXT_DOMAIN ); ?></button> + </div> + </div> + <div id="postman-log-actions"> + <div class="postman-log-row postman-no-sep"> + <label id="postman_page_records"><?php _e( 'Number of records per page', Postman::TEXT_DOMAIN ); ?></label> + <select id="postman_page_records" name="postman_page_records"> + <option value="10">10</option> + <option value="25">25</option> + <option value="50">50</option> + <option value="75">75</option> + <option value="100">100</option> + </select> + <label id="postman-log-trash-all"><?php _e( 'Trash all records', Postman::TEXT_DOMAIN ); ?></label> + <button type="submit" id="postman_trash_all" name="postman_trash_all" class="button button-primary"><?php _e( 'Trash All', Postman::TEXT_DOMAIN ); ?></button> </div> - - <div class="form-control"> - <!-- <button type="submit" name="export_email_logs" class="button button-primary">Export To CSV</button> --> - </div> </div> <div class="error">Please notice: when you select a date for example 11/20/2017, behind the scene the query select <b>11/20/2017 00:00:00</b>.<br>So if you searching for an email arrived that day at any hour you need to select 11/20/2017 as the <b>From Date</b> and 11/21/2017 as the <b>To Date</b>.</div> </form> diff --git a/Postman/Postman-Email-Log/PostmanEmailLogService.php b/Postman/Postman-Email-Log/PostmanEmailLogService.php index 5f57ed8..6c0784b 100644 --- a/Postman/Postman-Email-Log/PostmanEmailLogService.php +++ b/Postman/Postman-Email-Log/PostmanEmailLogService.php @@ -234,10 +234,10 @@ if ( ! class_exists( 'PostmanEmailLogPurger' ) ) { * * @return unknown */ - function __construct() { + function __construct( $args = array() ) { $this->logger = new PostmanLogger( get_class( $this ) ); - $args = array( - 'posts_per_page' => 1000, + $defaults = array( + 'posts_per_page' => -1, 'offset' => 0, 'category' => '', 'category_name' => '', @@ -253,7 +253,9 @@ if ( ! class_exists( 'PostmanEmailLogPurger' ) ) { 'post_status' => 'private', 'suppress_filters' => true, ); - $this->posts = get_posts( $args ); + $args = wp_parse_args( $args, $defaults ); + $query = new WP_Query( $args ); + $this->posts = $query->posts; } /** diff --git a/Postman/Postman-Email-Log/PostmanEmailLogView.php b/Postman/Postman-Email-Log/PostmanEmailLogView.php index fe0fdfe..1d8c4b1 100644 --- a/Postman/Postman-Email-Log/PostmanEmailLogView.php +++ b/Postman/Postman-Email-Log/PostmanEmailLogView.php @@ -305,8 +305,10 @@ class PostmanEmailLogView extends WP_List_Table { * be able to use your precisely-queried data immediately. */ $data = array(); + $posts_per_page = absint( $_POST['postman_page_records'] ); + $args = array( - 'posts_per_page' => 1000, + 'posts_per_page' => $posts_per_page, 'offset' => 0, 'orderby' => 'date', 'order' => 'DESC', @@ -339,7 +341,19 @@ class PostmanEmailLogView extends WP_List_Table { $args['s'] = sanitize_text_field( $_POST['search'] ); } + if ( isset( $_POST['postman_trash_all'] ) ) { + $args['posts_per_page'] = -1; + } $posts = new WP_query( $args ); + + if ( isset( $_POST['postman_trash_all'] ) ) { + foreach ( $posts->posts as $post ) { + wp_delete_post( $post->ID, true ); + } + + $posts->posts = array(); + } + $date_format = get_option( 'date_format' ); $time_format = get_option( 'time_format' ); |