PluginProbe ʕ •ᴥ•ʔ
WP Mail SMTP by WPForms – The Most Popular SMTP and Email Log Plugin / 4.7.1
WP Mail SMTP by WPForms – The Most Popular SMTP and Email Log Plugin v4.7.1
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 / Migrations.php
wp-mail-smtp / src Last commit date
Admin 6 months ago Compatibility 6 months ago Helpers 6 months ago Providers 6 months ago Queue 6 months ago Reports 6 months ago Tasks 6 months ago UsageTracking 6 months ago AbstractConnection.php 6 months ago Conflicts.php 6 months ago Connect.php 6 months ago Connection.php 6 months ago ConnectionInterface.php 6 months ago ConnectionsManager.php 6 months ago Core.php 6 months ago DBRepair.php 6 months ago Debug.php 6 months ago Geo.php 6 months ago MailCatcher.php 6 months ago MailCatcherInterface.php 6 months ago MailCatcherTrait.php 6 months ago MailCatcherV6.php 6 months ago Migration.php 6 months ago MigrationAbstract.php 6 months ago Migrations.php 6 months ago OptimizedEmailSending.php 6 months ago Options.php 6 months ago Processor.php 6 months ago SiteHealth.php 6 months ago Upgrade.php 6 months ago Uploads.php 6 months ago WP.php 6 months ago WPMailArgs.php 6 months ago WPMailInitiator.php 6 months ago
Migrations.php
171 lines
1 <?php
2
3 namespace WPMailSMTP;
4
5 use WP_Upgrader;
6 use WPMailSMTP\Admin\DebugEvents\Migration as DebugEventsMigration;
7 use WPMailSMTP\Queue\Migration as QueueMigration;
8
9 /**
10 * Class Migrations.
11 *
12 * @since 4.0.0
13 */
14 class Migrations {
15
16 /**
17 * Register hooks.
18 *
19 * @since 4.0.0
20 */
21 public function hooks() {
22
23 // Initialize migrations during request in the admin panel only.
24 add_action( 'admin_init', [ $this, 'init_migrations_on_request' ] );
25
26 // Initialize migrations after plugin update.
27 add_action( 'upgrader_process_complete', [ $this, 'init_migrations_after_upgrade' ], PHP_INT_MAX, 2 );
28 add_action(
29 'wp_ajax_nopriv_wp_mail_smtp_init_migrations',
30 [ $this, 'init_migrations_ajax_handler' ]
31 );
32 }
33
34 /**
35 * Initialize DB migrations during request.
36 *
37 * @since 4.0.0
38 */
39 public function init_migrations_on_request() {
40
41 // Do not initialize migrations during AJAX and cron requests.
42 if ( WP::is_doing_ajax() || wp_doing_cron() ) {
43 return;
44 }
45
46 $this->init_migrations();
47 }
48
49 /**
50 * Initialize DB migrations.
51 *
52 * @since 4.0.0
53 */
54 private function init_migrations() {
55
56 $migrations = $this->get_migrations();
57
58 foreach ( $migrations as $migration ) {
59 if ( is_subclass_of( $migration, MigrationAbstract::class ) && $migration::is_enabled() ) {
60 ( new $migration() )->init();
61 }
62 }
63 }
64
65 /**
66 * Get migrations classes.
67 *
68 * @since 4.0.0
69 *
70 * @return array Migrations classes.
71 */
72 private function get_migrations() {
73
74 $migrations = [
75 Migration::class,
76 DebugEventsMigration::class,
77 QueueMigration::class,
78 ];
79
80 /**
81 * Filters DB migrations classes.
82 *
83 * @deprecated 4.0.0
84 *
85 * @since 3.0.0
86 *
87 * @param array $migrations Migrations classes.
88 */
89 $migrations = apply_filters_deprecated(
90 'wp_mail_smtp_core_init_migrations',
91 [ $migrations ],
92 '3.10.0',
93 'wp_mail_smtp_migrations_get_migrations'
94 );
95
96 /**
97 * Filters DB migrations classes.
98 *
99 * @since 4.0.0
100 *
101 * @param array $migrations Migrations classes.
102 */
103 return apply_filters( 'wp_mail_smtp_migrations_get_migrations', $migrations );
104 }
105
106 /**
107 * Initialize DB migrations after plugin update.
108 * Initiate ajax call to perform the migration with the new plugin version code.
109 *
110 * @since 4.0.0
111 *
112 * @param WP_Upgrader $upgrader WP_Upgrader instance.
113 * @param array $options Array of update data.
114 */
115 public function init_migrations_after_upgrade( $upgrader, $options ) {
116
117 if (
118 // Skip if in admin panel.
119 ( is_admin() && ! wp_doing_ajax() ) ||
120 // Skip if it's update from plugins list page.
121 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
122 ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] === 'update-plugin' )
123 ) {
124 return;
125 }
126
127 $plugins = [];
128
129 if ( isset( $options['plugins'] ) && is_array( $options['plugins'] ) ) {
130 $plugins = $options['plugins'];
131 } elseif ( isset( $options['plugin'] ) && is_string( $options['plugin'] ) ) {
132 $plugins = [ $options['plugin'] ];
133 }
134
135 if (
136 ! in_array( 'wp-mail-smtp/wp_mail_smtp.php', $plugins, true ) &&
137 ! in_array( 'wp-mail-smtp-pro/wp_mail_smtp.php', $plugins, true )
138 ) {
139 return;
140 }
141
142 $url = add_query_arg(
143 [
144 'action' => 'wp_mail_smtp_init_migrations',
145 ],
146 admin_url( 'admin-ajax.php' )
147 );
148
149 $timeout = (int) ini_get( 'max_execution_time' );
150
151 $args = [
152 'sslverify' => false,
153 'timeout' => $timeout ? $timeout : 30,
154 ];
155
156 wp_remote_post( $url, $args );
157 }
158
159 /**
160 * Initialize migrations via AJAX request.
161 *
162 * @since 4.0.0
163 */
164 public function init_migrations_ajax_handler() {
165
166 $this->init_migrations();
167
168 wp_send_json_success();
169 }
170 }
171