PluginProbe ʕ •ᴥ•ʔ
WP Mail SMTP by WPForms – The Most Popular SMTP and Email Log Plugin / 4.9.0
WP Mail SMTP by WPForms – The Most Popular SMTP and Email Log Plugin v4.9.0
4.9.0 0.9.6 1.0.0 1.0.1 1.0.2 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.5.0 1.5.1 1.5.2 1.6.0 1.6.2 1.7.0 1.7.1 1.8.0 1.8.1 1.9.0 2.0.0 2.0.1 2.1.1 2.2.1 2.3.1 2.4.0 2.5.0 2.5.1 2.6.0 2.7.0 2.8.0 2.9.0 3.0.1 3.0.2 3.0.3 3.1.0 3.10.0 3.11.0 3.11.1 3.2.0 3.2.1 3.3.0 3.4.0 3.5.0 3.5.1 3.5.2 3.6.1 3.7.0 3.8.0 3.8.2 3.9.0 4.0.1 4.1.0 4.1.1 4.2.0 4.3.0 4.4.0 4.5.0 4.6.0 4.7.0 4.7.1 4.8.0 trunk 0.10.0 0.10.1 0.11.1 0.11.2 0.3.1 0.3.2 0.4 0.4.1 0.4.2 0.5.0 0.5.1 0.5.2 0.6 0.7 0.8 0.8.2 0.8.3 0.8.4 0.8.5 0.8.6 0.8.7 0.9.0 0.9.1 0.9.2 0.9.3 0.9.4 0.9.5
wp-mail-smtp / src / Debug.php
wp-mail-smtp / src Last commit date
Abilities 6 days ago Admin 6 days ago Compatibility 6 days ago Helpers 6 days ago Integrations 6 days ago Providers 6 days ago Queue 6 days ago Reports 6 days ago Tasks 6 days ago TestEmail 6 days ago UsageTracking 6 days ago WPCLI 6 days ago AbstractConnection.php 6 days ago Conflicts.php 6 days ago Connect.php 6 days ago Connection.php 6 days ago ConnectionInterface.php 6 days ago ConnectionsManager.php 6 days ago Core.php 6 days ago DBRepair.php 6 days ago Debug.php 6 days ago EmailSendingDebug.php 6 days ago Geo.php 6 days ago MailCatcher.php 6 days ago MailCatcherInterface.php 6 days ago MailCatcherTrait.php 6 days ago MailCatcherV6.php 6 days ago Migration.php 6 days ago MigrationAbstract.php 6 days ago Migrations.php 6 days ago OptimizedEmailSending.php 6 days ago Options.php 6 days ago Processor.php 6 days ago SiteHealth.php 6 days ago Upgrade.php 6 days ago Uploads.php 6 days ago WP.php 6 days ago WPMailArgs.php 6 days ago WPMailInitiator.php 6 days ago
Debug.php
208 lines
1 <?php
2
3 namespace WPMailSMTP;
4
5 use WPMailSMTP\Admin\DebugEvents\DebugEvents;
6 use WPMailSMTP\Helpers\Helpers;
7
8 /**
9 * Class Debug — legacy global "last error" message bag.
10 *
11 * The plugin no longer reads from this bag. For diagnostic logging, use
12 * {@see DebugEvents::add()}. For tracking the current email-sending failure
13 * state per connection (the data the EmailSendingErrors banner renders), use
14 * {@see EmailSendingDebug}.
15 *
16 * @since 1.2.0
17 * @deprecated {VERSION}
18 */
19 class Debug {
20
21 /**
22 * Key for options table where all messages will be saved to.
23 *
24 * @since 1.2.0
25 */
26 const OPTION_KEY = 'wp_mail_smtp_debug';
27
28 /**
29 * Hold the cached error messages.
30 *
31 * @since 3.0.0
32 *
33 * @var array
34 */
35 private static $cached_messages;
36
37 /**
38 * Save unique debug message to a debug log.
39 * Adds one more to a list, at the end.
40 *
41 * Use {@see DebugEvents::add()} directly. The legacy bag this method
42 * writes to has no remaining readers in the plugin.
43 *
44 * @since 1.2.0
45 * @since 3.0.0 Start saving the Debug Event IDs, instead of error messages.
46 * @since 3.5.0 Returns Event ID.
47 * @deprecated {VERSION}
48 *
49 * @param mixed $message An array or string error message.
50 *
51 * @return bool|int
52 */
53 public static function set( $message ) {
54
55 if ( empty( $message ) ) {
56 return false;
57 }
58
59 self::clear_cache();
60
61 // Log the error message to the Debug Events.
62 $event_id = DebugEvents::add( $message );
63
64 $all = self::get_raw();
65
66 if ( ! empty( $event_id ) ) {
67 array_push( $all, $event_id );
68 } else {
69 if ( ! is_string( $message ) ) {
70 $message = wp_json_encode( $message );
71 } else {
72 $message = wp_strip_all_tags( $message, false );
73 }
74
75 array_push( $all, $message );
76 }
77
78 update_option( self::OPTION_KEY, array_unique( $all ), false );
79
80 return $event_id;
81 }
82
83 /**
84 * Remove all messages for a debug log.
85 *
86 * The plugin no longer reads from this bag, so clearing it is a no-op for
87 * in-plugin behavior. For per-connection send failure state, use
88 * {@see EmailSendingDebug::clear()}.
89 *
90 * @since 1.2.0
91 * @deprecated {VERSION}
92 */
93 public static function clear() {
94
95 self::clear_cache();
96
97 update_option( self::OPTION_KEY, [], false );
98 }
99
100 /**
101 * Clear cached error messages.
102 *
103 * @since 3.0.0
104 */
105 private static function clear_cache() {
106
107 self::$cached_messages = null;
108 }
109
110 /**
111 * Get the raw DB debug option values.
112 *
113 * @since 3.0.0
114 */
115 private static function get_raw() {
116
117 $all = get_option( self::OPTION_KEY, [] );
118
119 if ( ! is_array( $all ) ) {
120 $all = (array) $all;
121 }
122
123 return $all;
124 }
125
126 /**
127 * Retrieve all messages from a debug log.
128 *
129 * For diagnostic event history, use {@see DebugEvents::get_debug_messages()}.
130 * For per-connection send failure state, use {@see EmailSendingDebug::get()}.
131 *
132 * @since 1.2.0
133 * @deprecated {VERSION}
134 *
135 * @return array
136 */
137 public static function get() {
138
139 if ( isset( self::$cached_messages ) ) {
140 return self::$cached_messages;
141 }
142
143 $all = self::get_raw();
144
145 if ( empty( $all ) ) {
146 self::$cached_messages = [];
147
148 return [];
149 }
150
151 $event_ids = [];
152 $old_messages = [];
153
154 foreach ( $all as $item ) {
155 if ( is_int( $item ) ) {
156 $event_ids[] = (int) $item;
157 } else {
158 $old_messages[] = $item;
159 }
160 }
161
162 $event_messages = DebugEvents::get_debug_messages( $event_ids );
163 self::$cached_messages = array_unique( array_merge( $old_messages, $event_messages ) );
164
165 return self::$cached_messages;
166 }
167
168 /**
169 * Get the last message that was saved to a debug log.
170 *
171 * For per-connection send failure state, use {@see EmailSendingDebug::get()}
172 * keyed by connection id and read the `error_message` field.
173 *
174 * @since 1.2.0
175 * @deprecated {VERSION}
176 *
177 * @return string
178 */
179 public static function get_last() {
180
181 $all = self::get();
182
183 if ( ! empty( $all ) && is_array( $all ) ) {
184 return (string) end( $all );
185 }
186
187 return '';
188 }
189
190 /**
191 * Get the proper variable content output to debug.
192 *
193 * Moved to {@see Helpers::pvar()}. Kept as a thin passthrough so external
194 * callers don't break.
195 *
196 * @since 1.2.0
197 * @deprecated {VERSION}
198 *
199 * @param mixed $var Variable to output.
200 *
201 * @return string
202 */
203 public static function pvar( $var = '' ) {
204
205 return Helpers::pvar( $var );
206 }
207 }
208