Admin
3 years ago
Compatibility
3 years ago
Helpers
3 years ago
Providers
3 years ago
Reports
3 years ago
Tasks
3 years ago
UsageTracking
3 years ago
Conflicts.php
3 years ago
Connect.php
3 years ago
Core.php
3 years ago
Debug.php
3 years ago
Geo.php
3 years ago
MailCatcher.php
3 years ago
MailCatcherInterface.php
3 years ago
MailCatcherV6.php
3 years ago
Migration.php
3 years ago
MigrationAbstract.php
3 years ago
Options.php
3 years ago
Processor.php
3 years ago
SiteHealth.php
3 years ago
Upgrade.php
3 years ago
Uploads.php
3 years ago
WP.php
3 years ago
Conflicts.php
546 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WPMailSMTP; |
| 4 | |
| 5 | /** |
| 6 | * Class Conflicts |
| 7 | * |
| 8 | * @since 1.5.0 |
| 9 | */ |
| 10 | class Conflicts { |
| 11 | |
| 12 | /** |
| 13 | * List of plugins WP Mail SMTP may be conflicting with. |
| 14 | * |
| 15 | * @since 1.5.0 |
| 16 | * @since 2.8.0 Updated the format of the plugins array. |
| 17 | * |
| 18 | * @var array List of plugins WP Mail SMTP may be conflicting with. |
| 19 | */ |
| 20 | public static $plugins = []; |
| 21 | |
| 22 | /** |
| 23 | * Conflict information. |
| 24 | * |
| 25 | * @var array |
| 26 | */ |
| 27 | protected $conflict = []; |
| 28 | |
| 29 | /** |
| 30 | * Constructor. |
| 31 | * |
| 32 | * @since 2.9.0 |
| 33 | */ |
| 34 | public function __construct() { |
| 35 | |
| 36 | self::$plugins = [ |
| 37 | |
| 38 | /** |
| 39 | * Url: https://wordpress.org/plugins/easy-wp-smtp/ |
| 40 | */ |
| 41 | [ |
| 42 | 'name' => 'Easy WP SMTP', |
| 43 | 'slug' => 'easy-wp-smtp/easy-wp-smtp.php', |
| 44 | 'class' => 'EasyWPSMTP', |
| 45 | ], |
| 46 | |
| 47 | /** |
| 48 | * Closed. |
| 49 | * |
| 50 | * Url: https://wordpress.org/plugins/postman-smtp/ |
| 51 | */ |
| 52 | [ |
| 53 | 'name' => 'Postman SMTP', |
| 54 | 'slug' => 'postman-smtp/postman-smtp.php', |
| 55 | 'function' => 'postman_start', |
| 56 | ], |
| 57 | |
| 58 | /** |
| 59 | * Url: https://wordpress.org/plugins/post-smtp/ |
| 60 | */ |
| 61 | [ |
| 62 | 'name' => 'Post SMTP', |
| 63 | 'slug' => 'post-smtp/postman-smtp.php', |
| 64 | 'function' => 'post_smtp_start', |
| 65 | ], |
| 66 | |
| 67 | /** |
| 68 | * Url: https://wordpress.org/plugins/wp-mail-bank/ |
| 69 | */ |
| 70 | [ |
| 71 | 'name' => 'Mail Bank', |
| 72 | 'slug' => 'wp-mail-bank/wp-mail-bank.php', |
| 73 | 'function' => 'mail_bank', |
| 74 | ], |
| 75 | |
| 76 | /** |
| 77 | * Url: https://wordpress.org/plugins/smtp-mailer/ |
| 78 | */ |
| 79 | [ |
| 80 | 'name' => 'SMTP Mailer', |
| 81 | 'slug' => 'smtp-mailer/main.php', |
| 82 | 'class' => 'SMTP_MAILER', |
| 83 | ], |
| 84 | |
| 85 | /** |
| 86 | * Url: https://wordpress.org/plugins/gmail-smtp/ |
| 87 | */ |
| 88 | [ |
| 89 | 'name' => 'Gmail SMTP', |
| 90 | 'slug' => 'gmail-smtp/main.php', |
| 91 | 'class' => 'GMAIL_SMTP', |
| 92 | ], |
| 93 | |
| 94 | /** |
| 95 | * Url: https://wordpress.org/plugins/wp-email-smtp/ |
| 96 | */ |
| 97 | [ |
| 98 | 'name' => 'WP Email SMTP', |
| 99 | 'class' => 'WP_Email_Smtp', |
| 100 | ], |
| 101 | |
| 102 | /** |
| 103 | * Url: https://wordpress.org/plugins/smtp-mail/ |
| 104 | */ |
| 105 | [ |
| 106 | 'name' => 'SMTP Mail', |
| 107 | 'slug' => 'smtp-mail/index.php', |
| 108 | 'function' => 'smtpmail_include', |
| 109 | ], |
| 110 | |
| 111 | /** |
| 112 | * Url: https://wordpress.org/plugins/bws-smtp/ |
| 113 | */ |
| 114 | [ |
| 115 | 'name' => 'SMTP by BestWebSoft', |
| 116 | 'slug' => 'bws-smtp/bws-smtp.php', |
| 117 | 'function' => 'bwssmtp_init', |
| 118 | ], |
| 119 | |
| 120 | /** |
| 121 | * Url: https://wordpress.org/plugins/wp-sendgrid-smtp/ |
| 122 | */ |
| 123 | [ |
| 124 | 'name' => 'WP SendGrid SMTP', |
| 125 | 'slug' => 'wp-sendgrid-smtp/wp-sendgrid-smtp.php', |
| 126 | 'class' => 'WPSendGrid_SMTP', |
| 127 | ], |
| 128 | |
| 129 | /** |
| 130 | * Url: https://wordpress.org/plugins/sar-friendly-smtp/ |
| 131 | */ |
| 132 | [ |
| 133 | 'name' => 'SAR Friendly SMTP', |
| 134 | 'slug' => 'sar-friendly-smtp/sar-friendly-smtp.php', |
| 135 | 'function' => 'sar_friendly_smtp', |
| 136 | ], |
| 137 | |
| 138 | /** |
| 139 | * Url: https://wordpress.org/plugins/wp-gmail-smtp/ |
| 140 | */ |
| 141 | [ |
| 142 | 'name' => 'WP Gmail SMTP', |
| 143 | 'slug' => 'wp-gmail-smtp/wp-gmail-smtp.php', |
| 144 | 'class' => 'WPGmail_SMTP', |
| 145 | ], |
| 146 | |
| 147 | /** |
| 148 | * Url: https://wordpress.org/plugins/cimy-swift-smtp/ |
| 149 | */ |
| 150 | [ |
| 151 | 'name' => 'Cimy Swift SMTP', |
| 152 | 'slug' => 'cimy-swift-smtp/cimy_swift_smtp.php', |
| 153 | 'function' => 'st_smtp_check_config', |
| 154 | ], |
| 155 | |
| 156 | /** |
| 157 | * Closed. |
| 158 | * |
| 159 | * Url: https://wordpress.org/plugins/wp-easy-smtp/ |
| 160 | */ |
| 161 | [ |
| 162 | 'name' => 'WP Easy SMTP', |
| 163 | 'slug' => 'wp-easy-smtp/wp-easy-smtp.php', |
| 164 | 'class' => 'WP_Easy_SMTP', |
| 165 | ], |
| 166 | |
| 167 | /** |
| 168 | * Url: https://wordpress.org/plugins/wp-mailgun-smtp/ |
| 169 | */ |
| 170 | [ |
| 171 | 'name' => 'WP Mailgun SMTP', |
| 172 | 'slug' => 'wp-mailgun-smtp/wp-mailgun-smtp.php', |
| 173 | 'class' => 'WPMailgun_SMTP', |
| 174 | ], |
| 175 | |
| 176 | /** |
| 177 | * Url: https://wordpress.org/plugins/my-smtp-wp/ |
| 178 | */ |
| 179 | [ |
| 180 | 'name' => 'MY SMTP WP', |
| 181 | 'slug' => 'my-smtp-wp/my-smtp-wp.php', |
| 182 | 'function' => 'my_smtp_wp', |
| 183 | ], |
| 184 | |
| 185 | /** |
| 186 | * Closed. |
| 187 | * |
| 188 | * Url: https://wordpress.org/plugins/wp-mail-booster/ |
| 189 | */ |
| 190 | [ |
| 191 | 'name' => 'WP Mail Booster', |
| 192 | 'slug' => 'wp-mail-booster/wp-mail-booster.php', |
| 193 | 'function' => 'mail_booster', |
| 194 | ], |
| 195 | |
| 196 | /** |
| 197 | * Url: https://wordpress.org/plugins/sendgrid-email-delivery-simplified/ |
| 198 | */ |
| 199 | [ |
| 200 | 'name' => 'SendGrid', |
| 201 | 'slug' => 'sendgrid-email-delivery-simplified/wpsendgrid.php', |
| 202 | 'class' => 'Sendgrid_Settings', |
| 203 | ], |
| 204 | |
| 205 | /** |
| 206 | * Url: https://wordpress.org/plugins/wp-mail-smtp-mailer/ |
| 207 | */ |
| 208 | [ |
| 209 | 'name' => 'WP Mail Smtp Mailer', |
| 210 | 'slug' => 'wp-mail-smtp-mailer/wp-mail-smtp-mailer.php', |
| 211 | 'function' => 'WPMS_php_mailer', |
| 212 | ], |
| 213 | |
| 214 | /** |
| 215 | * Closed. |
| 216 | * |
| 217 | * Url: https://wordpress.org/plugins/wp-amazon-ses-smtp/ |
| 218 | */ |
| 219 | [ |
| 220 | 'name' => 'WP Amazon SES SMTP', |
| 221 | 'slug' => 'wp-amazon-ses-smtp/wp-amazon-ses.php', |
| 222 | 'class' => 'WPAmazonSES_SMTP', |
| 223 | ], |
| 224 | |
| 225 | /** |
| 226 | * Url: https://wordpress.org/plugins/postmark-approved-wordpress-plugin/ |
| 227 | */ |
| 228 | [ |
| 229 | 'name' => 'Postmark (Official)', |
| 230 | 'slug' => 'postmark-approved-wordpress-plugin/postmark.php', |
| 231 | 'class' => 'Postmark_Mail', |
| 232 | ], |
| 233 | |
| 234 | /** |
| 235 | * Url: https://wordpress.org/plugins/mailgun/ |
| 236 | */ |
| 237 | [ |
| 238 | 'name' => 'Mailgun', |
| 239 | 'slug' => 'mailgun/mailgun.php', |
| 240 | 'class' => 'Mailgun', |
| 241 | ], |
| 242 | |
| 243 | /** |
| 244 | * Url: https://wordpress.org/plugins/sparkpost/ |
| 245 | */ |
| 246 | [ |
| 247 | 'name' => 'SparkPost', |
| 248 | 'slug' => 'sparkpost/wordpress-sparkpost.php', |
| 249 | 'class' => 'WPSparkPost\SparkPost', |
| 250 | ], |
| 251 | |
| 252 | /** |
| 253 | * Url: https://wordpress.org/plugins/wp-yahoo-smtp/ |
| 254 | */ |
| 255 | [ |
| 256 | 'name' => 'WP Yahoo SMTP', |
| 257 | 'slug' => 'wp-yahoo-smtp/wp-yahoo-smtp.php', |
| 258 | 'class' => 'WPYahoo_SMTP', |
| 259 | ], |
| 260 | |
| 261 | /** |
| 262 | * Url: https://wordpress.org/plugins/wp-ses/ |
| 263 | */ |
| 264 | [ |
| 265 | 'name' => 'WP Offload SES Lite', |
| 266 | 'slug' => 'wp-ses/wp-ses.php', |
| 267 | 'function' => 'wp_offload_ses_lite_init', |
| 268 | ], |
| 269 | |
| 270 | /** |
| 271 | * Url: https://deliciousbrains.com/wp-offload-ses/ |
| 272 | */ |
| 273 | [ |
| 274 | 'name' => 'WP Offload SES', |
| 275 | 'slug' => 'wp-offload-ses/wp-offload-ses.php', |
| 276 | ], |
| 277 | |
| 278 | /** |
| 279 | * Url: https://wordpress.org/plugins/turbosmtp/ |
| 280 | */ |
| 281 | [ |
| 282 | 'name' => 'turboSMTP', |
| 283 | 'slug' => 'turbosmtp/turbo-smtp-plugin.php', |
| 284 | 'function' => 'TSPHPMailer', |
| 285 | ], |
| 286 | |
| 287 | /** |
| 288 | * Url: https://wordpress.org/plugins/wp-smtp/ |
| 289 | */ |
| 290 | [ |
| 291 | 'name' => 'WP SMTP', |
| 292 | 'slug' => 'wp-smtp/wp-smtp.php', |
| 293 | 'class' => 'WP_SMTP', |
| 294 | ], |
| 295 | |
| 296 | /** |
| 297 | * This plugin can be used along with our plugin if disable next option |
| 298 | * WooCommerce -> Settings -> Sendinblue -> Email Options -> Enable Sendinblue to send WooCommerce emails. |
| 299 | * |
| 300 | * Url: https://wordpress.org/plugins/woocommerce-sendinblue-newsletter-subscription |
| 301 | */ |
| 302 | [ |
| 303 | 'name' => 'Sendinblue - WooCommerce Email Marketing', |
| 304 | 'slug' => 'woocommerce-sendinblue-newsletter-subscription/woocommerce-sendinblue.php', |
| 305 | 'class' => 'WC_Sendinblue_Integration', |
| 306 | 'test' => 'test_wc_sendinblue_integration', |
| 307 | 'message' => esc_html__( 'Or disable the Sendinblue email sending setting in WooCommerce > Settings > Sendinblue (tab) > Email Options (tab) > Enable Sendinblue to send WooCommerce emails.', 'wp-mail-smtp' ), |
| 308 | ], |
| 309 | |
| 310 | /** |
| 311 | * Url: https://wordpress.org/plugins/disable-emails/ |
| 312 | */ |
| 313 | [ |
| 314 | 'name' => 'Disable Emails', |
| 315 | 'slug' => 'disable-emails/disable-emails.php', |
| 316 | 'class' => '\webaware\disable_emails\Plugin', |
| 317 | ], |
| 318 | |
| 319 | /** |
| 320 | * Url: https://wordpress.org/plugins/fluent-smtp/ |
| 321 | */ |
| 322 | [ |
| 323 | 'name' => 'FluentSMTP', |
| 324 | 'slug' => 'fluent-smtp/fluent-smtp.php', |
| 325 | 'function' => 'fluentSmtpInit', |
| 326 | ], |
| 327 | |
| 328 | /** |
| 329 | * This plugin can be used along with our plugin if enable next option |
| 330 | * Settings > Email template > Sender (tab) -> Do not change email sender by default. |
| 331 | * |
| 332 | * Url: https://wordpress.org/plugins/wp-html-mail/ |
| 333 | */ |
| 334 | [ |
| 335 | 'name' => 'WP HTML Mail - Email Template Designer', |
| 336 | 'slug' => 'wp-html-mail/wp-html-mail.php', |
| 337 | 'function' => 'Haet_Mail', |
| 338 | 'test' => 'test_wp_html_mail_integration', |
| 339 | 'message' => esc_html__( 'Or enable "Do not change email sender by default" setting in Settings > Email template > Sender (tab).', 'wp-mail-smtp' ), |
| 340 | ], |
| 341 | |
| 342 | /** |
| 343 | * This plugin can be used along with our plugin if "SMTP" module is deactivated. |
| 344 | * |
| 345 | * Url: https://wordpress.org/plugins/branda-white-labeling/ |
| 346 | */ |
| 347 | [ |
| 348 | 'name' => 'Branda', |
| 349 | 'slug' => 'branda-white-labeling/ultimate-branding.php', |
| 350 | 'function' => 'set_ultimate_branding', |
| 351 | 'test' => 'test_branda_integration', |
| 352 | 'message' => esc_html__( 'Or deactivate "SMTP" module in Branda > Emails > SMTP.', 'wp-mail-smtp' ), |
| 353 | ], |
| 354 | ]; |
| 355 | } |
| 356 | |
| 357 | /** |
| 358 | * Whether we have a conflict with predefined list of plugins. |
| 359 | * |
| 360 | * @since 1.5.0 |
| 361 | * |
| 362 | * @return bool |
| 363 | */ |
| 364 | public function is_detected() { |
| 365 | |
| 366 | foreach ( self::$plugins as $plugin ) { |
| 367 | if ( $this->is_conflicting_plugin( $plugin ) ) { |
| 368 | $this->conflict = $plugin; |
| 369 | break; |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | return ! empty( $this->conflict ); |
| 374 | } |
| 375 | |
| 376 | /** |
| 377 | * Whether we have a conflict with plugin. |
| 378 | * |
| 379 | * @since 2.9.0 |
| 380 | * |
| 381 | * @param array $plugin Plugin data. |
| 382 | * |
| 383 | * @return bool |
| 384 | */ |
| 385 | protected function is_conflicting_plugin( $plugin ) { |
| 386 | |
| 387 | $conflict = false; |
| 388 | |
| 389 | if ( isset( $plugin['slug'] ) && WP::is_plugin_activated( $plugin['slug'] ) ) { |
| 390 | $conflict = true; |
| 391 | } elseif ( isset( $plugin['class'] ) && class_exists( $plugin['class'], false ) ) { |
| 392 | $conflict = true; |
| 393 | } elseif ( isset( $plugin['function'] ) && function_exists( $plugin['function'] ) ) { |
| 394 | $conflict = true; |
| 395 | } |
| 396 | |
| 397 | if ( |
| 398 | $conflict && |
| 399 | isset( $plugin['test'] ) && |
| 400 | is_callable( [ $this, $plugin['test'] ] ) |
| 401 | ) { |
| 402 | $conflict = call_user_func( [ $this, $plugin['test'] ] ); |
| 403 | } |
| 404 | |
| 405 | /** |
| 406 | * Filters whether the plugin is conflicting. |
| 407 | * |
| 408 | * @since 2.9.0 |
| 409 | * |
| 410 | * @param bool $conflict Whether the plugin is conflicting. |
| 411 | * @param array $plugin { |
| 412 | * Plugin data. |
| 413 | * |
| 414 | * @type string $name Plugin name. |
| 415 | * @type string $slug Plugin slug. |
| 416 | * } |
| 417 | */ |
| 418 | return apply_filters( 'wp_mail_smtp_conflicts_is_conflicting_plugin', $conflict, $plugin ); |
| 419 | } |
| 420 | |
| 421 | /** |
| 422 | * Add a warning admin message to a user about the conflicting plugin. |
| 423 | * |
| 424 | * @since 1.5.0 |
| 425 | */ |
| 426 | public function notify() { |
| 427 | |
| 428 | if ( empty( $this->conflict ) ) { |
| 429 | return; |
| 430 | } |
| 431 | |
| 432 | WP::add_admin_notice( $this->get_conflict_message(), WP::ADMIN_NOTICE_WARNING ); |
| 433 | } |
| 434 | |
| 435 | /** |
| 436 | * Get the conflicting plugin name is any. |
| 437 | * |
| 438 | * @since 1.5.0 |
| 439 | * |
| 440 | * @return null|string |
| 441 | */ |
| 442 | public function get_conflict_name() { |
| 443 | |
| 444 | $name = null; |
| 445 | |
| 446 | if ( ! empty( $this->conflict['name'] ) ) { |
| 447 | $name = $this->conflict['name']; |
| 448 | } |
| 449 | |
| 450 | return $name; |
| 451 | } |
| 452 | |
| 453 | /** |
| 454 | * Get the conflicting plugin message. |
| 455 | * |
| 456 | * @since 2.9.0 |
| 457 | * |
| 458 | * @return string |
| 459 | */ |
| 460 | public function get_conflict_message() { |
| 461 | |
| 462 | $message = sprintf( /* translators: %1$s - Plugin name causing conflict. */ |
| 463 | esc_html__( 'Heads up! WP Mail SMTP has detected %1$s is activated. Please deactivate %1$s to prevent conflicts.', 'wp-mail-smtp' ), |
| 464 | $this->get_conflict_name() |
| 465 | ); |
| 466 | |
| 467 | if ( ! empty( $this->conflict['message'] ) ) { |
| 468 | $message .= ' ' . $this->conflict['message']; |
| 469 | } |
| 470 | |
| 471 | return $message; |
| 472 | } |
| 473 | |
| 474 | /** |
| 475 | * Check whether we have conflict with "WooCommerce Sendinblue Newsletter Subscription" plugin. |
| 476 | * |
| 477 | * @since 2.9.0 |
| 478 | * |
| 479 | * @return bool Returns true if we have conflict otherwise false. |
| 480 | */ |
| 481 | protected function test_wc_sendinblue_integration() { |
| 482 | |
| 483 | // Check requirements for test. |
| 484 | if ( |
| 485 | ! class_exists( 'WC_Sendinblue_Integration', false ) || |
| 486 | ! property_exists( 'WC_Sendinblue_Integration', 'ws_smtp_enabled' ) |
| 487 | ) { |
| 488 | return true; |
| 489 | } |
| 490 | |
| 491 | // Display or hide conflict message after toggle "Enable Sendinblue to send WooCommerce emails" option. |
| 492 | // phpcs:disable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing |
| 493 | if ( |
| 494 | ! empty( $_POST ) && |
| 495 | ( isset( $_GET['page'] ) && $_GET['page'] === 'wc-settings' ) && |
| 496 | ( isset( $_GET['tab'] ) && $_GET['tab'] === 'sendinblue' ) && |
| 497 | ( isset( $_GET['section'] ) && $_GET['section'] === 'email_options' ) |
| 498 | ) { |
| 499 | return isset( $_POST['ws_smtp_enable'] ); |
| 500 | } |
| 501 | // phpcs:enable |
| 502 | |
| 503 | return \WC_Sendinblue_Integration::$ws_smtp_enabled === 'yes'; |
| 504 | } |
| 505 | |
| 506 | /** |
| 507 | * Check whether we have conflict with "WP HTML Mail - Email Template Designer" plugin. |
| 508 | * |
| 509 | * @since 3.3.0 |
| 510 | * |
| 511 | * @return bool Returns true if we have conflict otherwise false. |
| 512 | */ |
| 513 | protected function test_wp_html_mail_integration() { |
| 514 | |
| 515 | // Check requirements for test. |
| 516 | if ( |
| 517 | ! function_exists( 'Haet_Mail' ) || |
| 518 | ! is_object( Haet_Mail() ) || |
| 519 | ! method_exists( Haet_Mail(), 'get_options' ) |
| 520 | ) { |
| 521 | return true; |
| 522 | } |
| 523 | |
| 524 | $options = Haet_Mail()->get_options(); |
| 525 | |
| 526 | return ! isset( $options['disable_sender'] ) || ! $options['disable_sender']; |
| 527 | } |
| 528 | |
| 529 | /** |
| 530 | * Check whether we have conflict with "Branda" plugin. |
| 531 | * |
| 532 | * @since 3.5.0 |
| 533 | * |
| 534 | * @return bool Returns true if we have conflict otherwise false. |
| 535 | */ |
| 536 | protected function test_branda_integration() { |
| 537 | |
| 538 | // Check requirements for test. |
| 539 | if ( ! function_exists( 'branda_is_active_module' ) ) { |
| 540 | return true; |
| 541 | } |
| 542 | |
| 543 | return branda_is_active_module( 'emails/smtp.php' ); |
| 544 | } |
| 545 | } |
| 546 |