PluginProbe ʕ •ᴥ•ʔ
Check & Log Email – Easy Email Testing & Mail logging / 1.0.9
Check & Log Email – Easy Email Testing & Mail logging v1.0.9
2.0.15 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 2.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.13.1 2.0.13.2 2.0.14 2.0.2 2.0.3 2.0.4 2.0.5 2.0.5.1 2.0.6 2.0.7 2.0.8 2.0.9 trunk 0.5.7 0.6.0 0.6.1 0.6.2 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.12.1 1.0.13 1.0.13.1 1.0.2 1.0.3
check-email / include / Util / helper.php
check-email / include / Util Last commit date
Check_Email_Header_Parser.php 2 years ago helper.php 2 years ago
helper.php
157 lines
1 <?php namespace CheckEmail\Util;
2
3 defined( 'ABSPATH' ) || exit; // Exit if accessed directly.
4
5 function sanitize_email( $email, $multiple = true ) {
6 $emails = explode( ',', $email );
7 if ( ! $multiple ) {
8 $emails = array_slice( $emails, 0, 1 );
9 }
10
11 $cleaned_emails = array_map( __NAMESPACE__ . '\\wpchill_sanitize_check_email_with_name', $emails );
12
13 return implode( ', ', $cleaned_emails );
14 }
15
16 function wpchill_sanitize_check_email_with_name( $string ) {
17 $string = trim( $string );
18
19 $bracket_pos = strpos( $string, '<' );
20 if ( false !== $bracket_pos ) {
21 if ( $bracket_pos > 0 ) {
22 $name = substr( $string, 0, $bracket_pos );
23 $name = trim( $name );
24
25 $email = substr( $string, $bracket_pos + 1 );
26 $email = str_replace( '>', '', $email );
27
28 return sanitize_text_field( $name ) . ' <' . \sanitize_email( $email ) . '>';
29 }
30 }
31
32 return \sanitize_email( $string );
33 }
34
35 function wp_chill_check_email_is_admin_non_ajax() {
36 if ( function_exists( 'wp_doing_ajax' ) && wp_doing_ajax() ) {
37 return false;
38 }
39
40 if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
41 return false;
42 }
43
44 return is_admin();
45 }
46
47 function wp_chill_check_email_array_checked( $values, $current ) {
48 if ( ! is_array( $values ) ) {
49 return;
50 }
51
52 if ( in_array( $current, $values, true ) ) {
53 echo "checked='checked'";
54 }
55 }
56
57 function wp_chill_check_email_get_dismiss_icon() {
58 return <<<EOT
59 <span class="dashicons dashicons-dismiss"></span>
60 EOT;
61 }
62
63 function wp_chill_check_email_get_confirm_icon() {
64 return <<<EOT
65 <span class="dashicons dashicons-yes-alt"></span>
66 EOT;
67
68 }
69
70 function wp_chill_check_email_stringify( $may_be_array, $delimiter = ',' ) {
71 if ( ! is_array( $may_be_array ) ) {
72 return (string) $may_be_array;
73 }else{
74 if( isset( $may_be_array[0] ) && is_object( $may_be_array[0] ) && is_a( $may_be_array[0], 'PostmanEmailAddress' ) ){
75 return (string) $may_be_array[0]->getEmail();
76 }
77 }
78
79 return implode( $delimiter, $may_be_array );
80 }
81
82 function wp_chill_check_email_get_user_defined_date_format() {
83 return sprintf( '%1$s %2$s', get_option( 'date_format', 'Y-m-d' ), get_option( 'time_format', 'g:i a' ) );
84 }
85
86 function wp_chill_check_email_array_get( $array, $key, $default = null ) {
87 return isset( $array[ $key ] ) ? $array[ $key ] : $default;
88 }
89
90 function wp_chill_check_email_advanced_search_term( $term ) {
91 if ( ! is_string( $term ) ) {
92 return false;
93 }
94
95 $predicates = wp_chill_check_email_get_advanced_search_term_predicates( $term );
96
97 return ! empty( $predicates );
98 }
99
100 function wp_chill_check_email_get_advanced_search_term_predicates( $term ) {
101 if ( ! is_string( $term ) ) {
102 return array();
103 }
104
105 $predicates = explode( ' ', $term );
106 $predicates_organized = array();
107
108 foreach ( $predicates as $predicate ) {
109 $is_match = preg_match( '/(id|email|to|cc|bcc|reply-to):(.*)$/', $predicate, $matches );
110 if ( 1 === $is_match ) {
111 $predicates_organized[ $matches[1] ] = $matches[2];
112 }
113 }
114
115 return $predicates_organized;
116 }
117
118 function wp_chill_check_email_get_advanced_search_url() {
119 $admin_url = get_admin_url( null, 'admin.php?page=check-email-logs' );
120
121 return add_query_arg( 'check_email_as', 1, $admin_url );
122 }
123
124 function wp_chill_check_email_get_column_label_by_db_column( $db_column ) {
125 return wp_chill_check_email_get_column_label( $db_column );
126 }
127
128 function wp_chill_check_email_get_column_label( $column_name ) {
129 $labels = wp_chill_check_email_get_column_label_map();
130
131 if ( ! array_key_exists( $column_name, $labels ) ) {
132 return $column_name;
133 }
134
135 return $labels[ $column_name ];
136 }
137
138 function wp_chill_check_email_get_column_label_map() {
139 $labels = array(
140 'id' => esc_html__( 'ID', 'check-email' ),
141 'to_email' => esc_html__( 'To', 'check-email' ),
142 'from_email' => esc_html__( 'From', 'check-email' ),
143 'subject' => esc_html__( 'Subject', 'check-email' ),
144 'message' => esc_html__( 'Message', 'check-email' ),
145 'attachments' => esc_html__( 'Attachment', 'check-email' ),
146 'sent_date' => esc_html__( 'Sent at', 'check-email' ),
147 'from' => esc_html__( 'From', 'check-email' ),
148 'cc' => esc_html__( 'CC', 'check-email' ),
149 'bcc' => esc_html__( 'BCC', 'check-email' ),
150 'reply_to' => esc_html__( 'Reply To', 'check-email' ),
151 'ip_address' => esc_html__( 'IP Address', 'check-email' ),
152 'result' => esc_html__( 'Sent Status', 'check-email' ),
153 );
154
155 return apply_filters( 'check_email_db_column_labels', $labels );
156 }
157