From 41923bf4632e0f0a575fee13369221db9210e8df Mon Sep 17 00:00:00 2001 From: yehudah Date: Sat, 23 Dec 2017 23:23:04 +0000 Subject: = 1.8 - 2017-12-24 * New: Mailgun API integration * New: New filter controls * New: WPML conflict fix * Fix: Minor old bugs git-svn-id: https://plugins.svn.wordpress.org/post-smtp/trunk@1791840 b8457f37-d9ea-0310-8a92-e5e31aec5664 --- Postman/Postman.php | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'Postman/Postman.php') diff --git a/Postman/Postman.php b/Postman/Postman.php index 7eb512a..153257b 100644 --- a/Postman/Postman.php +++ b/Postman/Postman.php @@ -117,6 +117,14 @@ class Postman { 'on_plugins_loaded', ) ); + $active_plugins = (array) get_option( 'active_plugins', array() ); + if ( in_array( 'sitepress-multilingual-cms/sitepress.php', $active_plugins ) && !get_option( 'postman_wpml_fixed' ) ) { + add_action( 'admin_notices', array( $this, 'post_smtp_wpml_admin_notice' ) ); + + // Temp: Just a quick solution, need to find a better option. + add_action( 'admin_init', array( $this, 'postman_fix_wpml' ) ); + } + // hook on the wp_loaded event add_action( 'wp_loaded', array( $this, @@ -136,6 +144,31 @@ class Postman { ) ); } + public function post_smtp_wpml_admin_notice() { + $class = 'notice notice-error'; + $title = __( 'Post SMTP notice!', Postman::TEXT_DOMAIN ); + $intro = __( 'WPML is installed and has a known bug with Post SMTP and few other plugins.', Postman::TEXT_DOMAIN ); + $text = __( 'Click here to fix', Postman::TEXT_DOMAIN ); + $message = '
' . $text . ''; + + printf( '

%2$s

%3$s

%4$s

', esc_attr( $class ), $title, $intro, $message ); + } + + public function postman_fix_wpml() { + if ( isset( $_GET['action'] ) && $_GET['action'] == 'postman_fix_wpml' ) { + $wpml_file_path = WP_PLUGIN_DIR . '/sitepress-multilingual-cms/inc/utilities/wpml-data-encryptor.class.php'; + + if ( file_exists( $wpml_file_path ) ) { + $content = file_get_contents( $wpml_file_path ); + $content = str_replace( "require_once ABSPATH . '/wp-includes/pluggable.php';", "//require_once ABSPATH . '/wp-includes/pluggable.php';", $content ); + file_put_contents( $wpml_file_path, $content ); + } + + update_option( 'postman_wpml_fixed', true ); + wp_redirect( esc_url( remove_query_arg( 'action' ) ) ); + } + } + /** * Functions to execute on the plugins_loaded event * -- cgit v1.2.3