-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpepro-cf7-sms.php
More file actions
1646 lines (1570 loc) · 79.7 KB
/
pepro-cf7-sms.php
File metadata and controls
1646 lines (1570 loc) · 79.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/*
Plugin Name: PeproDev CF7 SMS Notifier
Description: Send SMS notifications to Users and Admins upon Contact Form 7 Submission
Contributors: amirhosseinhpv, peprodev
Tags: wordpress contact form, cf7 database, contact form 7, contact form 7 notifier, cf7 sms, contact form 7 sms
Author: Pepro Dev. Group
Developer: Amirhosseinhpv
Author URI: https://pepro.dev/
Developer URI: https://hpv.im/
Plugin URI: https://pepro.dev/cf7-database/
Version: 1.1.0
Stable tag: 1.1.0
Requires at least: 5.0
Tested up to: 5.9
Requires PHP: 5.6
WC requires at least: 4.0
WC tested up to: 4.2.0
Text Domain: cf7sms
Domain Path: /languages
Copyright: (c) 2020 Pepro Dev. Group, All rights reserved.
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
*/
defined("ABSPATH") or die("CF7 Database :: Unauthorized Access!");
if (!class_exists("PeproContactformse7enSMS_Notifier")) {
class PeproContactformse7enSMS_Notifier
{
private static $_instance = null;
public $td;
public $url;
public $version;
public $title;
public $title_w;
public $db_slug;
private $plugin_dir;
private $plugin_url;
private $assets_url;
private $plugin_basename;
private $plugin_file;
private $deactivateURI;
private $deactivateICON;
private $versionICON;
private $authorICON;
private $settingICON;
private $db_table = null;
private $manage_links = array();
private $meta_links = array();
/**
* @method __construct
* @version 1.0.0
* @since 1.0.0
* @license https://pepro.dev/license Pepro.dev License
*/
public function __construct()
{
global $wpdb;
$this->td = "cf7sms";
self::$_instance = $this;
$this->db_slug = $this->td;
$this->db_table = $wpdb->prefix . $this->db_slug;
$this->plugin_dir = plugin_dir_path(__FILE__);
$this->plugin_url = plugins_url("", __FILE__);
$this->assets_url = plugins_url("/assets/", __FILE__);
$this->plugin_basename = plugin_basename(__FILE__);
$this->url = admin_url("admin.php?page={$this->db_slug}");
$this->plugin_file = __FILE__;
$this->version = "1.1.0";
$this->deactivateURI = null;
$this->deactivateICON = '<span style="font-size: larger; line-height: 1rem; display: inline; vertical-align: text-top;" class="dashicons dashicons-dismiss" aria-hidden="true"></span> ';
$this->versionICON = '<span style="font-size: larger; line-height: 1rem; display: inline; vertical-align: text-top;" class="dashicons dashicons-admin-plugins" aria-hidden="true"></span> ';
$this->authorICON = '<span style="font-size: larger; line-height: 1rem; display: inline; vertical-align: text-top;" class="dashicons dashicons-admin-users" aria-hidden="true"></span> ';
$this->settingURL = '<span style="display: inline;float: none;padding: 0;" class="dashicons dashicons-admin-settings dashicons-small" aria-hidden="true"></span> ';
$this->submitionURL = '<span style="display: inline;float: none;padding: 0;" class="dashicons dashicons-images-alt dashicons-small" aria-hidden="true"></span> ';
$this->title = __("CF7 SMS Notifier", $this->td);
$this->title_s = __("CF7 SMS", $this->td);
$this->title_w = sprintf(__("%2\$s ver. %1\$s", $this->td), $this->version, $this->title);
$this->APIKey = $this->read_opt("{$this->db_slug}-user_api_key");
$this->SecretKey = $this->read_opt("{$this->db_slug}-user_secret_key");
$this->APIURL = "https://ws.sms.ir/";
$this->LineNumber = $this->read_opt("{$this->db_slug}-line_number");
add_action( "init", array($this, 'init_plugin'));
add_filter( "wpcf7_sendnormalsms", array($this, "send_normal_sms"),10, 2 );
add_filter( "wpcf7_sendultrafastsms", array($this, "send_ultrafast_sms"),10, 1 );
add_action( "wpcf7_mail_sent", array($this, "cf7sms_before_send_mail_hook") );
// add_action( "wpcf7_before_send_mail", array($this, "cf7sms_before_send_mail_hook") );
add_filter( "wpcf7_editor_panels", array($this, "cf7sms_editor_panel"), 10, 1 );
add_action( "wpcf7_after_save", array($this, "cf7sms_save_formdata") );
}
/**
* Init Plugin
*
* @method init_plugin
* @version 1.0.0
* @since 1.0.0
* @license https://pepro.dev/license Pepro.dev License
*/
public function init_plugin()
{
add_filter("plugin_action_links_{$this->plugin_basename}", array($this, 'plugins_row_links'));
add_action("plugin_row_meta", array( $this, 'plugin_row_meta' ), 10, 2);
add_action("admin_menu", array($this, 'admin_menu'));
add_action("admin_init", array($this, 'admin_init'));
add_action("admin_enqueue_scripts", array($this, 'admin_enqueue_scripts'));
add_action("wp_ajax_nopriv_cf7sms_{$this->td}", array($this, 'handel_ajax_req'));
add_action("wp_ajax_cf7sms_{$this->td}", array($this, 'handel_ajax_req'));
$this->CreateDatabase(); // always check if table exist or not
}
/**
* contact form 7 edit cf7 setting tabs hook
*
* @method cf7sms_editor_panel
* @param array $panels
* @return array $panels with added data
* @version 1.0.0
* @since 1.0.0
* @license https://pepro.dev/license Pepro.dev License
*/
public function cf7sms_editor_panel($panels)
{
$panels['pepro_cf7sms'] = array(
'title' => __("SMS Notification",$this->td),
'callback' => array($this,'cf7sms_editor_panel_html')
);
return $panels;
}
/**
* contact form 7 setting tab, callback html handler
*
* @method cf7sms_editor_panel_html
* @param array $args
* @return string html data of setting page
* @version 1.0.0
* @since 1.0.0
* @license https://pepro.dev/license Pepro.dev License
*/
public function cf7sms_editor_panel_html($args)
{
$this->update_footer_info();
$cf7sms = get_option( "pepro_cf7sms_{$args->id}" , array());
wp_enqueue_style( $this->td, "{$this->assets_url}css/cf7_edit_screen.css");
wp_enqueue_script( $this->td, "{$this->assets_url}js/cf7_edit_screen.js", array("jquery"));
?>
<div class="pepro_cf7sms_panel">
<h2><?=$this->title;?></h2>
<div class="cf7sms_setting_section">
<p>
<input type="checkbox" class="cf7smscheckbox" id="pepro_cf7sms_active_sms_admin" name="pepro_cf7sms[active_sms_admin]" value="1" <?=checked(1,(isset($cf7sms['active_sms_admin']) ? $cf7sms['active_sms_admin']:"0"), false );?> />
<label for="pepro_cf7sms_active_sms_admin"><?=__("Activate SMS Notification for Administrators",$this->td);?></label>
</p>
<p class="extra">
<label for="pepro_cf7sms_admin_sms_mobile"><?=__("Administrators Mobile:",$this->td);?></label>
<input type="text" id="pepro_cf7sms_admin_sms_mobile" name="pepro_cf7sms[admin_sms_mobile]" style="width: 100%;" placeholder="<?=esc_attr__("Enter Administrators mobiles number (Comma separated, with no spaces between)",$this->td);?>" title="<?=esc_attr__("Enter Administrators mobiles number (Comma separated, with no spaces between)",$this->td);?>" value="<?=(isset($cf7sms['admin_sms_mobile']) ? esc_attr( $cf7sms['admin_sms_mobile'] ):"");?>" />
</p>
<p class="extra">
<label for="pepro_cf7sms_admin_sms_text"><?=__("SMS Body:",$this->td);?></label>
<textarea id="pepro_cf7sms_admin_sms_text" name="pepro_cf7sms[admin_sms_text]" style="width: 100%;" row="8"
placeholder="<?=esc_attr__("Enter SMS text, you can use Contact Form 7 short tags just like what you've entered as Email body in Mail tab",$this->td);?>"
title="<?=esc_attr__("Enter SMS text, you can use Contact Form 7 short tags just like what you've entered as Email body in Mail tab",$this->td);?>" ><?=
(isset($cf7sms['admin_sms_text']) ? esc_attr( $cf7sms['admin_sms_text'] ):"");
?></textarea>
</p>
<p class="extra">
<input type="checkbox" id="pepro_cf7sms_active_sms_admin_fast" name="pepro_cf7sms[active_sms_admin_fast]" value="1" <?=checked(1,(isset($cf7sms['active_sms_admin_fast']) ? $cf7sms['active_sms_admin_fast']:"0"), false );?> />
<label for="pepro_cf7sms_active_sms_admin_fast"><?=__("Use Ultra-fast SMS sending feature",$this->td);?></label>
</p>
<p class="extra">
<label for="pepro_cf7sms_active_sms_admin_fast_id"><?=__("Ultra-fast Template ID:",$this->td);?></label>
<input type="text" id="pepro_cf7sms_active_sms_admin_fast_id" name="pepro_cf7sms[active_sms_admin_fastID]" style="width: 100%;"
placeholder="<?=esc_attr__("Enter Ultra-fast Template ID",$this->td);?>"
title="<?=esc_attr__("Enter Ultra-fast Template ID",$this->td);?>" value="<?=(isset($cf7sms['active_sms_admin_fastID']) ? esc_attr( $cf7sms['active_sms_admin_fastID'] ):"");?>" />
</p>
<p class="extra">
<label for="pepro_cf7sms_active_sms_admin_fast_ids"><?=__("Ultra-fast Template Params:",$this->td);?></label>
<input type="text" id="pepro_cf7sms_active_sms_admin_fast_ids" name="pepro_cf7sms[active_sms_admin_fastIDparam]" style="width: 100%;"
placeholder="<?=esc_attr__("Enter Ultra-fast Template Parameters (Comma separated, with no spaces between)",$this->td);?>"
title="<?=esc_attr__("Enter Ultra-fast Template Parameters (Comma separated, with no spaces between)",$this->td);?>" value="<?=(isset($cf7sms['active_sms_admin_fastIDparam']) ? esc_attr( $cf7sms['active_sms_admin_fastIDparam'] ):"");?>" />
</p>
</div>
<div class="cf7sms_setting_section">
<p>
<input type="checkbox" class="cf7smscheckbox" id="pepro_cf7sms_active_sms_user" name="pepro_cf7sms[active_sms_user]" value="1" <?=checked(1,(isset($cf7sms['active_sms_user']) ? $cf7sms['active_sms_user']:"0"), false );?> />
<label for="pepro_cf7sms_active_sms_user"><?=__("Activate SMS Notification for Submitter",$this->td);?></label>
</p>
<p class="extra">
<label for="pepro_cf7sms_user_sms_mobile"><?=__("Submitter Mobile Field:",$this->td);?></label>
<input type="text" id="pepro_cf7sms_user_sms_mobile" name="pepro_cf7sms[user_sms_mobile]" style="width: 100%;"
placeholder="<?=esc_attr__("Enter the mobile field you set for submitter. e.g. your-phone",$this->td);?>"
title="<?=esc_attr__("Enter the mobile field you set for submitter. e.g. your-phone",$this->td);?>" value="<?=(isset($cf7sms['user_sms_mobile']) ? esc_attr( $cf7sms['user_sms_mobile'] ):"");?>" />
</p>
<p class="extra">
<label for="pepro_cf7sms_user_sms_text"><?=__("SMS Body:",$this->td);?></label>
<textarea id="pepro_cf7sms_user_sms_text" name="pepro_cf7sms[user_sms_text]" style="width: 100%;" row="8"
placeholder="<?=esc_attr__("Enter SMS text, you can use Contact Form 7 short tags just like what you've entered as Email body in Mail tab",$this->td);?>"
title="<?=esc_attr__("Enter SMS text, you can use Contact Form 7 short tags just like what you've entered as Email body in Mail tab",$this->td);?>" ><?=
(isset($cf7sms['user_sms_text']) ? esc_attr( $cf7sms['user_sms_text'] ):"");
?></textarea>
</p>
<p class="extra">
<input type="checkbox" id="pepro_cf7sms_active_sms_user_fast" name="pepro_cf7sms[active_sms_user_fast]" value="1" <?=checked(1,(isset($cf7sms['active_sms_user_fast']) ? $cf7sms['active_sms_user_fast']:"0"), false );?> />
<label for="pepro_cf7sms_active_sms_user_fast"><?=__("Use Ultra-fast SMS sending feature",$this->td);?></label>
</p>
<p class="extra">
<label for="pepro_cf7sms_active_sms_user_fast_id"><?=__("Ultra-fast Template ID:",$this->td);?></label>
<input type="text" id="pepro_cf7sms_active_sms_user_fast_id" name="pepro_cf7sms[active_sms_user_fastID]" style="width: 100%;"
placeholder="<?=esc_attr__("Enter Ultra-fast Template ID",$this->td);?>"
title="<?=esc_attr__("Enter Ultra-fast Template ID",$this->td);?>" value="<?=(isset($cf7sms['active_sms_user_fastID']) ? esc_attr( $cf7sms['active_sms_user_fastID'] ):"");?>" />
</p>
<p class="extra">
<label for="pepro_cf7sms_active_sms_user_fast_ids"><?=__("Ultra-fast Template Params:",$this->td);?></label>
<input type="text" id="pepro_cf7sms_active_sms_user_fast_ids" name="pepro_cf7sms[active_sms_user_fastIDparam]" style="width: 100%;"
placeholder="<?=esc_attr__("Enter Ultra-fast Template Parameters (Comma separated, with no spaces between)",$this->td);?>"
title="<?=esc_attr__("Enter Ultra-fast Template Parameters (Comma separated, with no spaces between)",$this->td);?>" value="<?=(isset($cf7sms['active_sms_user_fastIDparam']) ? esc_attr( $cf7sms['active_sms_user_fastIDparam'] ):"");?>" />
</p>
</div>
</div>
<?php
}
/**
* contact form 7 save custom setting tab's data
*
* @method cf7sms_save_formdata
* @param array $args
* @version 1.0.0
* @since 1.0.0
* @license https://pepro.dev/license Pepro.dev License
*/
public function cf7sms_save_formdata($args)
{
if (!empty($_POST)){
$data = array();
foreach ($_POST['pepro_cf7sms'] as $key => $value) {
$data[sanitize_text_field( $key )] = sanitize_textarea_field( $value );
}
update_option( "pepro_cf7sms_{$args->id}", $data);
}
}
/**
* hook to cf7 send sms
*
* @method cf7sms_before_send_mail_hook
* @param array $form_to_DBs
* @version 1.0.0
* @since 1.0.0
* @license https://pepro.dev/license Pepro.dev License
*/
public function cf7sms_before_send_mail_hook( $form_to_DBs )
{
$form_to_DB = WPCF7_Submission::get_instance();
if ( $form_to_DB ) {
$formData = $form_to_DB->get_posted_data();
$subject = isset($formData['your-subject']) ? $formData['your-subject'] : "";
$name = isset($formData['your-name']) ? $formData['your-name'] : "";
$email = isset($formData['your-email']) ? $formData['your-email'] : "";
$form_id = $form_to_DBs->id();
$cf7sms = get_option( "pepro_cf7sms_{$form_id}" , array());
$reciever = isset($formData[$cf7sms["user_sms_mobile"]]) ? $formData[$cf7sms["user_sms_mobile"]] : (isset($formData['your-phone'])?$formData['your-phone']:"");
$extra_info = "";foreach ($formData as $key => $value) {
$extra_info .= "$key: $value\r\n";
};
$msgbodyAdmin = $cf7sms["admin_sms_text"];
$msgbodyUser = $cf7sms["user_sms_text"];
foreach ($formData as $key => $value) {
$msgbodyAdmin = str_replace("[$key]", $value, $msgbodyAdmin);
$msgbodyUser = str_replace("[$key]", $value, $msgbodyUser);
}
$contactform = "* {$form_to_DBs->title()} *";
// check if ADMIN Notification is set to <ON>
if (isset($cf7sms["active_sms_admin"]) && "1" == $cf7sms["active_sms_admin"]){
$formData["_sentforadmin_or_user"] = "YES";
// yes, now send sms to admin
if (isset($cf7sms["admin_sms_mobile"]) && !empty($cf7sms["admin_sms_mobile"])){
// admin mobile is okay | send ultrafast or normal?
$MobileNumbers = explode(",",$cf7sms["admin_sms_mobile"]);
$MobileNumbers = array_filter($MobileNumbers,function($var){return (int) trim($var);});
if (isset($cf7sms["active_sms_admin_fast"]) && 1 == $cf7sms["active_sms_admin_fast"]){
// send ultrafast
if (isset($cf7sms["active_sms_admin_fastID"]) && !empty($cf7sms["active_sms_admin_fastID"])){
$msgbodyAdmin = "ULTRAFAST";
if (isset($cf7sms["active_sms_admin_fastIDparam"]) && !empty($cf7sms["active_sms_admin_fastIDparam"])){
$reqired_params = explode(",",$cf7sms["active_sms_admin_fastIDparam"]);
$reqired_params = array_filter($reqired_params,function($var){return trim($var);});
$ParameterArray = array();
foreach ($formData as $key => $value) {
if (in_array($key, $reqired_params)){
array_push($ParameterArray,array( "Parameter" => "$key", "ParameterValue" => "$value" ));
}
}
foreach ($MobileNumbers as $ue) {
$status = $this->send_ultrafast_sms_org(
array(
"ParameterArray" => $ParameterArray,
"Mobile" => $ue,
"TemplateId" => $cf7sms["active_sms_admin_fastID"]
)
);
}
if ("your verification code is sent" == $status){
$status = 100;
}
}else{
$status = __("Ultra-fast Template Params missing.",$this->td);
}
}else{
$status = __("Ultra-fast Template ID missing.",$this->td);
}
}
else{
// ultrafast is not set or it's Template ID is missing, so let's send normal SMS to admin numbers
$status = $this->send_normal_sms_org($MobileNumbers,array($msgbodyAdmin));
}
$this->save_submition($form_id, implode(", ", $MobileNumbers), ($status===true?100:$status), $msgbodyAdmin, serialize($formData));
}
else{
// admin mobile is not set
$this->save_submition($form_id, __("No admin mobile is set to recieve SMS",$this->td), "400", $msgbodyAdmin, serialize($formData));
}
}
// check if user Notification is set to <ON>
if (isset($cf7sms["active_sms_user"]) && "1" == $cf7sms["active_sms_user"]){
$formData["_sentforadmin_or_user"] = "NO";
// yes, now send sms to user
if (isset($cf7sms["user_sms_mobile"]) && !empty($cf7sms["user_sms_mobile"])){
// user mobile is okay | send ultrafast or normal?
$MobileNumbers = (int) trim($formData[$cf7sms["user_sms_mobile"]]);
if (isset($cf7sms["active_sms_user_fast"]) && 1 == $cf7sms["active_sms_user_fast"]){
// send ultrafast
if (isset($cf7sms["active_sms_user_fastID"]) && !empty($cf7sms["active_sms_user_fastID"])){
$msgbodyUser = "ULTRAFAST";
if (isset($cf7sms["active_sms_user_fastIDparam"]) && !empty($cf7sms["active_sms_user_fastIDparam"])){
$reqired_params = explode(",",$cf7sms["active_sms_user_fastIDparam"]);
$reqired_params = array_filter($reqired_params,function($var){return trim($var);});
$ParameterArray = array();
foreach ($formData as $key => $value) {
if (in_array($key, $reqired_params)){
array_push($ParameterArray,array( "Parameter" => "$key", "ParameterValue" => "$value" ));
}
}
$status = $this->send_ultrafast_sms_org(
array(
"ParameterArray" => $ParameterArray,
"Mobile" => $MobileNumbers,
"TemplateId" => $cf7sms["active_sms_user_fastID"]
)
);
if ("your verification code is sent" == $status){
$status = 100;
}
}else{
$status = __("Ultra-fast Template Params missing.",$this->td);
}
}else{
$status = __("Ultra-fast Template ID missing.",$this->td);
}
}
else{
// ultrafast is not set or it's Template ID is missing, so let's send normal SMS to user numbers
$status = $this->send_normal_sms_org(array($MobileNumbers),array($msgbodyUser));
}
$this->save_submition($form_id, implode(", ", (array) $MobileNumbers), ($status===true?100:$status), $msgbodyUser, serialize($formData));
}
else{
// user mobile is not set
$this->save_submition($form_id, __("No user mobile is set to recieve SMS",$this->td), "400", $msgbodyUser, serialize($formData));
}
}
}
return $form_to_DBs;
}
/**
* Get Plugin Setting Options
*
* @method get_setting_options
* @return array plugin settings
* @version 1.0.0
* @since 1.0.0
* @license https://pepro.dev/license Pepro.dev License
*/
public function get_setting_options()
{
return array(
array(
"name" => "{$this->db_slug}_general",
"data" => array(
"{$this->db_slug}-clearunistall" => "no",
"{$this->db_slug}-cleardbunistall" => "no",
"{$this->db_slug}-user_secret_key" => "",
"{$this->db_slug}-user_api_key" => "",
"{$this->db_slug}-line_number" => "30002101000338",
)
),
);
}
/**
* wp get_meta_link hool
*
* @method get_meta_links
* @return array meta_link
* @version 1.0.0
* @since 1.0.0
* @license https://pepro.dev/license Pepro.dev License
*/
public function get_meta_links()
{
if (!empty($this->meta_links)) {return $this->meta_links;
}
$this->meta_links = array(
'support' => array(
'title' => __('Support', $this->td),
'description' => __('Support', $this->td),
'icon' => 'dashicons-admin-site',
'target' => '_blank',
'url' => "mailto:support@pepro.dev?subject={$this->title}",
),
);
return $this->meta_links;
}
/**
* wp get_manage_links hool
*
* @method get_manage_links
* @return array get_manage_links
* @version 1.0.0
* @since 1.0.0
* @license https://pepro.dev/license Pepro.dev License
*/
public function get_manage_links()
{
if (!empty($this->manage_links)) {return $this->manage_links; }
$this->manage_links = array(
$this->settingURL . __("Settings", $this->td) => "$this->url-setting",
$this->submitionURL . __("Sent SMS Log", $this->td) => $this->url,
);
return $this->manage_links;
}
/**
* Activation Hook
*
* @method activation_hook
* @version 1.0.0
* @since 1.0.0
* @license https://pepro.dev/license Pepro.dev License
*/
public static function activation_hook()
{
(new PeproContactformse7enSMS_Notifier)->CreateDatabase();
}
/**
* Deactivation Hook
*
* @method deactivation_hook
* @version 1.0.0
* @since 1.0.0
* @license https://pepro.dev/license Pepro.dev License
*/
public static function deactivation_hook()
{
}
/**
* Uninstall Hook
*
* @method uninstall_hook
* @version 1.0.0
* @since 1.0.0
* @license https://pepro.dev/license Pepro.dev License
*/
public static function uninstall_hook()
{
$ppa = new PeproContactformse7enSMS_Notifier;
$dbClear = get_option("{$ppa->db_slug}-cleardbunistall", "no") === "yes" ? $ppa->DropDatabase() : null;
if (get_option("{$ppa->db_slug}-clearunistall", "no") === "yes") {
$PeproContactformse7enSMS_Notifier_class_options = $ppa->get_setting_options();
foreach ($PeproContactformse7enSMS_Notifier_class_options as $options) {
$opparent = $options["name"];
foreach ($options["data"] as $optname => $optvalue) {
unregister_setting($opparent, $optname);
delete_option($optname);
}
}
}
}
/**
* Create Database Scheme
*
* @method CreateDatabase
* @version 1.0.0
* @since 1.0.0
* @license https://pepro.dev/license Pepro.dev License
*/
public function CreateDatabase()
{
global $wpdb;
$charset_collate = $wpdb->get_charset_collate();
$tbl = $this->db_table;
if ($wpdb->get_var("SHOW TABLES LIKE '". $tbl ."'") != $tbl ) {
$sql = "CREATE TABLE `$tbl` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`date_created` DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL,
`form_id` VARCHAR(512),
`reciever` VARCHAR(320),
`status` VARCHAR(320),
`msgbody` TEXT,
`extra_info` TEXT,
PRIMARY KEY id (id)
) $charset_collate;";
if(!function_exists('dbDelta')) {include_once ABSPATH . 'wp-admin/includes/upgrade.php';
}
dbDelta($sql);
// error_log("$tbl Created");
}else{
// error_log("$tbl Already Exist");
}
}
/**
* Clear Database
*
* @method DropDatabase
* @version 1.0.0
* @since 1.0.0
* @license https://pepro.dev/license Pepro.dev License
*/
public function DropDatabase()
{
global $wpdb;
$wpdb->query("DROP TABLE IF EXISTS {$this->db_table}");
}
/**
* Update Footer Info to Developer info
*
* @method update_footer_info
* @version 1.0.0
* @since 1.0.0
* @license https://pepro.dev/license Pepro.dev License
*/
private function update_footer_info()
{
add_filter(
'admin_footer_text', function () {
return sprintf(_x("Thanks for using %s products", "footer-copyright", $this->td), "<b><a href='https://pepro.dev/' target='_blank' >".__("Pepro Dev", $this->td)."</a></b>");
}, 11
);
add_filter(
'update_footer', function () {
return sprintf(_x("%s — Version %s", "footer-copyright", $this->td), $this->title, $this->version);
}, 11
);
echo "<style>
#footer-left b a::before {
content: '';
background: url('{$this->assets_url}images/peprodev.svg') no-repeat;
background-position-x: center;
background-position-y: center;
background-size: contain;
width: 60px;
height: 40px;
display: inline-block;
pointer-events: none;
position: absolute;
-webkit-margin-before: calc(-60px + 1rem);
margin-block-start: calc(-60px + 1rem);
-webkit-filter: opacity(0.0);
filter: opacity(0.0);
transition: all 0.3s ease-in-out;
}
#footer-left b a:hover::before {
-webkit-filter: opacity(1.0);
filter: opacity(1.0);
transition: all 0.3s ease-in-out;
}
</style>";
}
/**
* callback for ajax requesets
*
* @method handel_ajax_req
* @return json ajax response
* @version 1.0.0
* @since 1.0.0
* @license https://pepro.dev/license Pepro.dev License
*/
public function handel_ajax_req()
{
if (wp_doing_ajax() && $_POST['action'] == "cf7sms_{$this->td}") {
if (!wp_verify_nonce( $_POST["nonce"], $this->td)){
wp_send_json_error( array("msg"=>__("Unauthorized Access!",$this->td)));
}
if (isset($_POST["wparam"]) && "delete_item" == trim($_POST["wparam"]) && !empty($_POST["lparam"])) {
global $wpdb;
$id = (int) trim($_POST["lparam"]);
$del = $wpdb->delete( $this->db_table , array( 'ID' => $id ) );
if (false !== $del){
wp_send_json_success( array( "msg" => sprintf(__("Submition ID %s Successfully Deleted.",$this->td),$id ) ) );
}else{
wp_send_json_error( array( "msg" => sprintf(__("Error Deleting Submition ID %s.",$this->td),$id ) ) );
}
}
if (isset($_POST["wparam"]) && "clear_db_cf7" == trim($_POST["wparam"]) && !empty($_POST["lparam"])) {
global $wpdb;
$id = (int) trim($_POST["lparam"]);
$del = $wpdb->delete( $this->db_table , array( 'extra_info' => $id ) );
if (false !== $del){
wp_send_json_success( array( "msg" => sprintf(__("All data regarding Contact form %s (ID %s) were Successfully Deleted.",$this->td), get_the_title($id), $id ) ) );
}else{
wp_send_json_error( array( "msg" => sprintf(__("Error Deleting Contact form %s (ID %s) data from database.",$this->td), get_the_title($id), $id ) ) );
}
}
if (isset($_POST["wparam"]) && "clear_db" == trim($_POST["wparam"])) {
global $wpdb;
$del = $wpdb->query("TRUNCATE TABLE `$this->db_table`");
if (false !== $del){
wp_send_json_success( array( "msg" => sprintf(__("Database Successfully Cleared.",$this->td),$id ) ) );
}else{
wp_send_json_error( array( "msg" => sprintf(__("Error Clearing Database.",$this->td),$id ) ) );
}
}
die();
}
}
/**
* Add Admin Menu
*
* @method admin_menu
* @version 1.0.0
* @since 1.0.0
* @license https://pepro.dev/license Pepro.dev License
*/
public function admin_menu()
{
add_menu_page(
$this->title_w,
$this->title_s,
"manage_options",
$this->db_slug,
array($this,'db_container'),
"{$this->assets_url}images/peprodev.svg",
81
);
$menu_title = __("Setting", $this->td);
add_submenu_page($this->db_slug,$this->title_w, $menu_title, "manage_options", "{$this->db_slug}-setting", array($this,'help_container'));
}
/**
* setting page html callback data
*
* @method help_container
* @param string $hook
* @return string callback html
* @version 1.0.0
* @since 1.0.0
* @license https://pepro.dev/license Pepro.dev License
*/
public function help_container($hook)
{
ob_start();
$this->update_footer_info();
$input_number = ' dir="ltr" lang="en-US" min="0" step="1" ';
$input_english = ' dir="ltr" lang="en-US" ';
$input_required = ' required ';
wp_enqueue_style("jQconfirm");
wp_enqueue_script("jQconfirm");
wp_enqueue_style("fontawesome","https://use.fontawesome.com/releases/v5.13.1/css/all.css", array(), '5.13.1', 'all');
wp_enqueue_style("{$this->db_slug}", "{$this->assets_url}css/backend.css");
wp_enqueue_script("{$this->db_slug}", "{$this->assets_url}js/backend.js", array('jquery'), null, true);
wp_localize_script("{$this->db_slug}", "_i18n", $this->localize_script());
is_rtl() AND wp_add_inline_style("{$this->db_slug}", ".form-table th {}#wpfooter, #wpbody-content *:not(.dashicons ), #wpbody-content input:not([dir=ltr]), #wpbody-content textarea:not([dir=ltr]), h1.had, .caqpde>b.fa{ font-family: bodyfont, roboto, Tahoma; }");
echo "<h1 class='had'>".$this->title_w."</h1><div class=\"wrap\">";
echo '<form method="post" action="options.php">';
settings_fields("{$this->db_slug}_general");
if (isset($_REQUEST["settings-updated"]) && $_REQUEST["settings-updated"] == "true") { echo '<div id="message" class="updated notice is-dismissible"><p>' . _x("Settings saved successfully.", "setting-general", $this->td) . "</p></div>"; }
echo '<br><table class="form-table"><tbody>';
$this->print_setting_input("{$this->db_slug}-user_secret_key", _x("User Security Key","setting-general", $this->td), $input_required, "text");
$this->print_setting_input("{$this->db_slug}-user_api_key", _x("User API Key","setting-general", $this->td), $input_required, "text");
$this->print_setting_input("{$this->db_slug}-line_number", _x("Line Number","setting-general", $this->td), $input_required, "text");
$this->print_setting_select("{$this->db_slug}-clearunistall", _x("Clear Configurations on Unistall","setting-general", $this->td),array("yes" =>_x("Yes","settings-general",$this->td), "no" => _x("No","settings-general",$this->td)));
$this->print_setting_select("{$this->db_slug}-cleardbunistall", _x("Clear Database Data on Unistall","setting-general", $this->td),array("yes" =>_x("Yes","settings-general",$this->td), "no" => _x("No","settings-general",$this->td)));
echo '</tbody></table><div class="submtCC">';
submit_button(__("Save setting", $this->td), "primary submt", "submit", false);
echo "<a class='button button-primary submt' id='emptyDbNow' href='#'>"._x("Empty Database", "setting-general", $this->td)."</a>";
echo "</form></div></div>";
$tcona = ob_get_contents();
ob_end_clean();
print $tcona;
}
/**
* localize js script
*
* @method localize_script
* @return array i18n array
* @version 1.0.0
* @since 1.0.0
* @license https://pepro.dev/license Pepro.dev License
*/
public function localize_script()
{
$currentTimestamp = current_time( "timestamp");
$currentDate = date_i18n( get_option('date_format'),$currentTimestamp);
$currentTime = date_i18n( get_option('time_format'),$currentTimestamp);
return array(
"td" => "cf7sms_{$this->td}",
"ajax" => admin_url("admin-ajax.php"),
"home" => home_url(),
"nonce" => wp_create_nonce($this->td),
"title" => _x("Select image file", "wc-setting-js", $this->td),
"btntext" => _x("Use this image", "wc-setting-js", $this->td),
"clear" => _x("Clear", "wc-setting-js", $this->td),
"currentlogo" => _x("Current preview", "wc-setting-js", $this->td),
"selectbtn" => _x("Select image", "wc-setting-js", $this->td),
"tr_submit" => _x("Submit","js-string",$this->td),
"tr_today" => _x("Today","js-string",$this->td),
"errorTxt" => _x("Error", "wc-setting-js", $this->td),
"cancelTtl" => _x("Canceled", "wc-setting-js", $this->td),
"confirmTxt" => _x("Confirm", "wc-setting-js", $this->td),
"successTtl" => _x("Success", "wc-setting-js", $this->td),
"submitTxt" => _x("Submit", "wc-setting-js", $this->td),
"okTxt" => _x("Okay", "wc-setting-js", $this->td),
"txtYes" => _x("Yes", "wc-setting-js", $this->td),
"txtNop" => _x("No", "wc-setting-js", $this->td),
"cancelbTn" => _x("Cancel", "wc-setting-js", $this->td),
"sendTxt" => _x("Send to all", "wc-setting-js", $this->td),
"closeTxt" => _x("Close", "wc-setting-js", $this->td),
"deleteConfirmTitle" => _x("Delete Submition", "wc-setting-js", $this->td),
"deleteConfirmation" => _x("Are you sure you want to delete submition ID %s ? This cannot be undone.", "wc-setting-js", $this->td),
"clearDBConfirmation" => _x("Are you sure you want to clear all data from database? This cannot be undone.", "wc-setting-js", $this->td),
"clearDBConfirmatio2" => _x("Are you sure you want to clear all Current Contact form data from database? This cannot be undone.", "wc-setting-js", $this->td),
"clearDBConfTitle" => _x("Clear Database", "wc-setting-js", $this->td),
"str1" => sprintf(_x("Contact Form 7 SMS Log Exported via %s", "wc-setting-js", $this->td),"$this->title_w"),
"str2" => sprintf(_x("CF7 SMS Log Export", "wc-setting-js", $this->td),$this->title_w),
"str3" => sprintf(_x("Exported at %s @ %s", "wc-setting-js", $this->td),$currentDate,$currentTime),
"str4" => "Pepro-cf7Notifier-". date_i18n("YmdHis",current_time( "timestamp")),
"str5" => sprintf(_x("Exported via %s — Export Date: %s @ %s — Developed by Pepro Dev Team ( https://pepro.dev/ )", "wc-setting-js", $this->td),$this->title_w,$currentDate,$currentTime),
"str6" => "Pepro CF7 Notifier",
"tbl1" => _x("No data available in table", "data-table", $this->td),
"tbl2" => _x("Showing _START_ to _END_ of _TOTAL_ entries", "data-table", $this->td),
"tbl3" => _x("Showing 0 to 0 of 0 entries", "data-table", $this->td),
"tbl4" => _x("(filtered from _MAX_ total entries)", "data-table", $this->td),
"tbl5" => _x("Show _MENU_ entries", "data-table", $this->td),
"tbl6" => _x("Loading...", "data-table", $this->td),
"tbl7" => _x("Processing...", "data-table", $this->td),
"tbl8" => _x("Search:", "data-table", $this->td),
"tbl9" => _x("No matching records found", "data-table", $this->td),
"tbl10" => _x("First", "data-table", $this->td),
"tbl11" => _x("Last", "data-table", $this->td),
"tbl12" => _x("Next", "data-table", $this->td),
"tbl13" => _x("Previous", "data-table", $this->td),
"tbl14" => _x(": activate to sort column ascending", "data-table", $this->td),
"tbl15" => _x(": activate to sort column descending", "data-table", $this->td),
"tbl16" => _x("Copy to clipboard", "data-table", $this->td),
"tbl17" => _x("Print", "data-table", $this->td),
"tbl18" => _x("Export CSV", "data-table", $this->td),
"tbl19" => _x("Export Excel", "data-table", $this->td),
"tbl20" => _x("Export PDF", "data-table", $this->td),
);
}
/**
* callback html for list of data saved in database
*
* @method db_container
* @return string html data
* @version 1.0.0
* @since 1.0.0
* @license https://pepro.dev/license Pepro.dev License
*/
public function db_container()
{
ob_start();
$s = true;
for ($i=0; $i < 2; $i++) {
$s = !$s;
$this->update_footer_info();
$now = current_time('timestamp');
$randomnum = random_int( 15740, 68414866 );
$form_id = 114;
$reciever = "9118629342";
$msgbody = "Lorem $randomnum ipsum dolor $randomnum sit amet, consectetur $randomnum adipisicing $randomnum elit, sed do eiusmod $randomnum tempor";
$status = "100";
$extra_info = serialize(array(
"your-subject" => "Subj.$randomnum",
"your-name" => "Name.$randomnum",
"your-email" => "use$randomnum@gmail.com",
"your-mobile" => "$randomnum/$randomnum/$randomnum",
));
// $this->save_submition($form_id, $reciever, $status, ($s ? $msgbody : "ULTRAFAST"), $extra_info);
}
wp_enqueue_style("{$this->db_slug}", "{$this->assets_url}css/backend.css");
wp_enqueue_style("datatable");
wp_enqueue_style("SrchHighlt");
wp_enqueue_style("jQconfirm");
wp_enqueue_style("fontawesome","https://use.fontawesome.com/releases/v5.13.1/css/all.css", array(), '5.13.1', 'all');
wp_enqueue_script("jQconfirm");
wp_enqueue_script("datatable");
wp_enqueue_script("highlight.js");
wp_enqueue_script("SrchHighlt");
/* needs for PDF export function word properly but due to not supporting utf-8 we ignore these*/
// wp_enqueue_script( "s1", "https://cdn.datatables.net/buttons/1.6.2/js/dataTables.buttons.min.js", array("jquery"), false);
// wp_enqueue_script( "s1", "https://cdn.datatables.net/buttons/1.6.2/js/buttons.flash.min.js", array("jquery"), false);
// wp_enqueue_script( "s2", "https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js", array("jquery"), false);
// wp_enqueue_script( "s3", "https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js", array("jquery"), false);
// wp_enqueue_script( "s4", "https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js", array("jquery"), false);
// wp_enqueue_script( "s5", "https://cdn.datatables.net/buttons/1.6.2/js/buttons.html5.min.js", array("jquery"), false);
// wp_enqueue_script( "s6", "https://cdn.datatables.net/buttons/1.6.2/js/buttons.print.min.js", array("jquery"), false);
wp_enqueue_script("{$this->db_slug}", "{$this->assets_url}/js/backend.js", array('jquery'), null, true);
wp_localize_script("{$this->db_slug}", "_i18n", $this->localize_script());
$this->print_table_style();
is_rtl() AND wp_add_inline_style("{$this->db_slug}", ".form-table th {}#wpfooter, #wpbody-content *:not(.dashicons ), #wpbody-content input:not([dir=ltr]), #wpbody-content textarea:not([dir=ltr]), h1.had, .caqpde>b.fa{ font-family: bodyfont, roboto, Tahoma; }");
global $wpdb;
$table = $this->db_table;
$post_per_page = isset($_GET['per_page']) ? abs((int) $_GET['per_page']) : 100;
$page = isset($_GET['num']) ? abs((int) $_GET['num']) : 1;
$offset = ( $page * $post_per_page ) - $post_per_page;
$title = $this->title;
echo "<h1 class='had'>$title</h1>";
$total = $wpdb->get_var("SELECT COUNT(1) FROM $table AS combined_table");
$res_obj = $wpdb->get_results("SELECT * FROM $table ORDER BY `date_created` DESC LIMIT {$offset}, {$post_per_page}");
$items_per_page_selceter =
"<select id='itemsperpagedisplay' name='per_page' style='width:auto !important; margin: 0 0 0 .5rem; float: right;' title='" . __("Items per page", $this->td) . "' >
<option value='50' " . selected(100, $post_per_page, false) . ">".sprintf(_x("Show %s items per page", "items_per_page", $this->td), 50)."</option>
<option value='100' " . selected(100, $post_per_page, false) . ">".sprintf(_x("Show %s items per page", "items_per_page", $this->td), 100)."</option>
<option value='200' " . selected(200, $post_per_page, false) . ">".sprintf(_x("Show %s items per page", "items_per_page", $this->td), 200)."</option>
<option value='300' " . selected(300, $post_per_page, false) . ">".sprintf(_x("Show %s items per page", "items_per_page", $this->td), 300)."</option>
<option value='400' " . selected(500, $post_per_page, false) . ">".sprintf(_x("Show %s items per page", "items_per_page", $this->td), 400)."</option>
<option value='500' " . selected(500, $post_per_page, false) . ">".sprintf(_x("Show %s items per page", "items_per_page", $this->td), 500)."</option>
<option value='600' " . selected(500, $post_per_page, false) . ">".sprintf(_x("Show %s items per page", "items_per_page", $this->td), 600)."</option>
<option value='700' " . selected(500, $post_per_page, false) . ">".sprintf(_x("Show %s items per page", "items_per_page", $this->td), 700)."</option>
<option value='800' " . selected(500, $post_per_page, false) . ">".sprintf(_x("Show %s items per page", "items_per_page", $this->td), 800)."</option>
<option value='900' " . selected(500, $post_per_page, false) . ">".sprintf(_x("Show %s items per page", "items_per_page", $this->td), 900)."</option>
<option value='1000' " . selected(1000, $post_per_page, false) . ">".sprintf(_x("Show %s items per page", "items_per_page", $this->td), 1000)."</option>
<option disabled>-----------------</option>
<option value='$total' " . selected($total, $post_per_page, false) . ">".sprintf(_n( "Show your only saved submition", "Show all %s items at once", $total, $this->td ), $total)."</option>
</select>";
?>
<div class="wrap">
<form action="<?php echo admin_url("admin.php?page=cf7sms");?>" id='mainform' >
<input type="hidden" name="page" value="cf7sms" />
<input type="hidden" name="num" value="<?=$page;?>" />
<?php
// form_id
// reciever
// status
// msgbody
// extra_info
if (!empty($wpdb->num_rows)) {
$header = array(
"_sharp_id" => __('ID',$this->td) ,
"date_created" => __('Date Created',$this->td) ,
"_cf7_formid" => __('Contact Form',$this->td) ,
"your-subject" => __('Subject',$this->td) ,
"email" => __('From',$this->td) ,
"reciever" => __('Reciever',$this->td) ,
"status" => __('Status',$this->td) ,
"msgbody" => __('Message Body',$this->td) ,
"utltrafast" => __('Ultra-fast Send',$this->td) ,
"foradmin" => __('Sent to Admin/Submitter',$this->td) ,
);
// foreach ( $res_obj as $obj ){
// $data_array = unserialize($obj->extra_info);
// unset($data_array["your-subject"]);
// unset($data_array["your-name"]);
// unset($data_array["your-email"]);
// foreach ( $data_array as $key => $value) {
// // $header[$key] = $key;
// }
// }
$header["action"] = __('Action',$this->td);
$header = array_unique($header);
echo "
<p><b>". sprintf(_n( "Your very first saved submition is showing below", "%s Saved SMS Log found", $total, $this->td ), $total) . "</b> {$items_per_page_selceter}</p>
<table border=\"1\" id=\"exported_data\" class=\"exported_data\">
<thead>
<tr>";
foreach ($header as $key => $value) {
$extraClass = "";
if (in_array($key, apply_filters( "pepro_cf7sms_hide_col_from_export", array("action","_sharp_id")))){
$extraClass = "noExport";
}
echo "<th class='th-{$key} $extraClass'>{$value}</th>";
}
echo "
</tr>
</thead>
<tbody>";
foreach ( $res_obj as $obj ){
$data_array = unserialize($obj->extra_info);
echo "<tr class=\"item_{$obj->id} status_$obj->status ".("ULTRAFAST" == $obj->msgbody ? "ULTRAFAST" : "NORMAL")." \">";
foreach ($header as $key => $value) {
switch ($key) {
case '_sharp_id':
$val = $obj->id;
break;
case 'reciever':
$val = $obj->reciever;
break;
case 'status':
$val = $this->read_status($obj->status);
break;
case 'foradmin':
$val = ("YES" == $data_array['_sentforadmin_or_user'])? __("Administrators",$this->td) : __("Submitter",$this->td);
break;
case 'msgbody':
$val = $obj->msgbody;
break;
case 'utltrafast':
$val = ("ULTRAFAST" == $obj->msgbody ? __("YES",$this->td): __("NO",$this->td)) ;
break;
case '_cf7_formid':
$val = "<a target='_blank' href='".admin_url("admin.php?page=wpcf7&post={$obj->form_id}&action=edit")."'>".get_the_title($obj->form_id)." ".sprintf(_x("(ID #%s)","cf7-name-suffix",$this->td),$obj->form_id)."</a>";
break;
case 'date_created':
$val = "<p>". date_i18n( get_option('date_format'), strtotime($obj->date_created) ) . "</p><p>" . date_i18n( get_option('time_format'), strtotime($obj->date_created) )."</p>";
break;
case 'email':
$name = (isset($data_array['your-name'])?$data_array['your-name']:"");
$email = (isset($data_array['your-email'])?"<{$data_array['your-email']}>":"");
$val = "{$name} $email";
break;
case 'action':
$val = "<a href='javascript:;' title='".esc_attr__("Delete this specific submition", $this->td)."' class=\"button delete_item\" data-lid='{$obj->id}' ><span class='dashicons dashicons-trash'></span></a>
<span class='spinner loading_{$obj->id}'></span>";
break;
default:
$val = nl2br(esc_html($data_array[$key]));
break;
}
echo "<td class='item_{$key} itd_{$obj->id}'>{$val}</th>";
}
echo "</tr>";
}
echo "</tbody>";
echo "</table>";
echo '<div class="pagination" style="margin-top: 1.5rem;display: block;">';
echo paginate_links(
array(
'base' => add_query_arg('num', '%#%'),
'format' => '',
'show_all' => false,
'mid_size' => 2,
'end_size' => 2,
'prev_text' => '<span class="button button-primary">' . __('< Previous',$this->td) . "</span>",
'next_text' => '<span class="button button-primary">' . __('Next >',$this->td) . "</span>",
'total' => ceil($total / $post_per_page),
'current' => $page,
'before_page_number' => '<span class="button">',
'after_page_number' => "</span>",
'type' => 'list'
)
);
echo "</div>";
}
else{