@@ -75,7 +75,25 @@ public function admin_pages() {
75
75
* Admin listing menu callback
76
76
*/
77
77
public function display_cbxwpemaillogger_listing_page () {
78
- include ( cbxwpemaillogger_locate_template ('admin/cbxwpemaillogger-logs.php ' ) );
78
+ $ view = isset ($ _REQUEST ['view ' ])? esc_attr ($ _REQUEST ['view ' ]) : 'list ' ;
79
+
80
+
81
+ if ($ view == 'list ' ){
82
+ include ( cbxwpemaillogger_locate_template ('admin/cbxwpemaillogger-logs.php ' ) );
83
+ }
84
+ /*else if($view == 'body'){
85
+ $log_id = isset($_REQUEST['log_id'])? intval($_REQUEST['log_id']) : 0;
86
+ $item = CBXWPEmailLoggerHelper::SingleLog($log_id);
87
+ include( cbxwpemaillogger_locate_template('admin/cbxwpemaillogger-body.php') );
88
+ }*/
89
+ else {
90
+ $ log_id = isset ($ _REQUEST ['log_id ' ])? intval ($ _REQUEST ['log_id ' ]) : 0 ;
91
+
92
+ $ item = CBXWPEmailLoggerHelper::SingleLog ($ log_id );
93
+
94
+ include ( cbxwpemaillogger_locate_template ('admin/cbxwpemaillogger-log.php ' ) );
95
+ }
96
+
79
97
}//end method display_cbxwpemaillogger_listing_page
80
98
81
99
/**
@@ -150,6 +168,7 @@ public function enqueue_scripts( $hook ) {
150
168
151
169
wp_localize_script ( 'cbxwpemaillogger ' , 'cbxwpemaillogger_dashboard ' , apply_filters ( 'cbxwpemaillogger_js_vars ' , $ cbxwpemaillogger_js_vars ) );
152
170
171
+ add_thickbox ();
153
172
154
173
wp_enqueue_script ( 'jquery ' );
155
174
wp_enqueue_script ( 'ply ' );
@@ -177,6 +196,8 @@ public function insert_log( $atts ) {
177
196
178
197
$ subject = isset ( $ atts ['subject ' ] ) ? $ atts ['subject ' ] : '' ;
179
198
$ body = isset ( $ atts ['message ' ] ) ? $ atts ['message ' ] : ( isset ( $ atts ['html ' ] ) ? $ atts ['html ' ] : '' );
199
+ //$htm
200
+
180
201
$ headers = isset ( $ atts ['headers ' ] ) ? $ atts ['headers ' ] : array ();
181
202
$ attachments = isset ( $ atts ['attachments ' ] ) ? $ atts ['attachments ' ] : array ();
182
203
@@ -468,7 +489,7 @@ public function email_log_delete(){
468
489
check_ajax_referer ( 'cbxwpemaillogger ' ,
469
490
'security ' );
470
491
471
- if ( is_user_logged_in () ) {
492
+ if ( is_user_logged_in () && user_can ( get_current_user_id (), ' manage_options ' ) ) {
472
493
$ id = isset ( $ _POST ['id ' ] ) ? intval ( $ _POST ['id ' ] ) : 0 ;
473
494
474
495
if ( $ id > 0 ) {
@@ -506,4 +527,71 @@ public function email_log_delete(){
506
527
wp_send_json ( $ return );
507
528
508
529
}//end method email_log_delete
530
+
531
+ /**
532
+ * Email log delete ajax handle
533
+ */
534
+ public function email_resend (){
535
+ check_ajax_referer ( 'cbxwpemaillogger ' ,
536
+ 'security ' );
537
+
538
+ if ( is_user_logged_in () && user_can ( get_current_user_id (),'manage_options ' ) ) {
539
+ $ id = isset ( $ _POST ['id ' ] ) ? intval ( $ _POST ['id ' ] ) : 0 ;
540
+
541
+ if ( $ id > 0 ) {
542
+ global $ wpdb ;
543
+
544
+
545
+ $ item = CBXWPEmailLoggerHelper::SingleLog ($ id );
546
+
547
+ $ email_data = maybe_unserialize ( $ item ['email_data ' ] );
548
+
549
+ $ atts = isset ($ email_data ['atts ' ])? $ email_data ['atts ' ]: array ();
550
+
551
+
552
+
553
+ if (is_array ($ atts ) && sizeof ($ atts ) > 0 ){
554
+
555
+ //write_log($atts);
556
+
557
+ list ($ to , $ subject , $ message , $ headers , $ attachments ) = array_values ($ atts );
558
+
559
+ $ report = wp_mail ($ to , $ subject , $ message , $ headers , $ attachments );
560
+
561
+ if ($ report ){
562
+ $ return = array (
563
+ 'message ' => esc_html__ ( 'Email ReSend and Successfully sent. ' ,
564
+ 'cbxwpemaillogger ' ),
565
+ 'success ' => 1 ,
566
+
567
+ );
568
+ }
569
+ else {
570
+ $ return = array (
571
+ 'message ' => esc_html__ ( 'Email ReSend but failed. ' ,
572
+ 'cbxwpemaillogger ' ),
573
+ 'success ' => 1 ,
574
+
575
+ );
576
+ }
577
+
578
+
579
+
580
+ wp_send_json ( $ return );
581
+ }
582
+
583
+ }
584
+ }
585
+
586
+ $ return = array (
587
+ 'message ' => esc_html__ ( 'Failed to send or not enough access to send ' ,
588
+ 'cbxwpemaillogger ' ),
589
+ 'success ' => 0 ,
590
+
591
+ );
592
+
593
+ wp_send_json ( $ return );
594
+
595
+ }//end method email_resend
596
+
509
597
}//end class CBXWPEmailLogger_Admin
0 commit comments