tracking_link = new WCML_Tracking_Link(); } public function check() { /** * @var SitePress|null $sitepress * @var WooCommerce|null $woocommerce */ global $sitepress, $woocommerce; if ( null === $this->allok ) { $this->allok = true; $missing = []; $core_ok = true; $st_ok = true; $wc_ok = true; if ( ! defined( 'ICL_SITEPRESS_VERSION' ) || ICL_PLUGIN_INACTIVE || is_null( $sitepress ) || ! class_exists( 'SitePress' ) ) { $missing['WPML'] = $this->tracking_link->getWpmlHome(); $core_ok = false; } elseif ( version_compare( ICL_SITEPRESS_VERSION, self::MIN_WPML, '<' ) ) { add_action( 'admin_notices', [ $this, '_old_wpml_warning' ] ); $core_ok = false; } elseif ( ! $sitepress->setup() ) { /* phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected */ if ( ! ( isset( $_GET['page'] ) && WPML_PLUGIN_FOLDER . '/menu/languages.php' === $_GET['page'] ) ) { add_action( 'admin_notices', [ $this, '_wpml_not_installed_warning' ] ); } $core_ok = false; } if ( ! class_exists( 'WooCommerce' ) || ! function_exists( 'WC' ) ) { $missing['WooCommerce'] = 'http://www.woothemes.com/woocommerce/'; $wc_ok = false; } elseif ( defined( 'WC_VERSION' ) && version_compare( WC_VERSION, self::MIN_WOOCOMMERCE, '<' ) || isset( $woocommerce->version ) && version_compare( $woocommerce->version, self::MIN_WOOCOMMERCE, '<' ) ) { add_action( 'admin_notices', [ $this, '_old_wc_warning' ] ); $wc_ok = false; } if ( ! defined( 'WPML_ST_VERSION' ) ) { $missing['WPML String Translation'] = $this->tracking_link->getWpmlStFaq(); $st_ok = false; } elseif ( version_compare( WPML_ST_VERSION, self::MIN_WPML_ST, '<' ) ) { add_action( 'admin_notices', [ $this, '_old_wpml_st_warning' ] ); $st_ok = false; } $has_no_wpml_plugin = ! ( $core_ok || $st_ok ); $full_mode = $core_ok && $st_ok && $wc_ok; $standalone = $has_no_wpml_plugin && $wc_ok; $this->allok = $full_mode || $standalone; if ( ! $this->allok && count( $missing ) ) { $possibly_standalone = $has_no_wpml_plugin && ! $wc_ok; add_action( 'admin_notices', self::show_missing_plugins_warning( $missing, $possibly_standalone ) ); } if ( $full_mode ) { $this->check_for_incompatible_permalinks(); add_action( 'init', [ $this, 'check_for_translatable_default_taxonomies' ] ); } if ( isset( $sitepress ) ) { $this->allok = $full_mode && $sitepress->setup(); } } return $this->allok; } /** * Adds admin notice. */ public function _old_wpml_warning() { ?>
' . __( 'WPML support', 'woocommerce-multilingual' ) . ''; /* translators: Part 1/6 of a message telling users that some taxonomies, required for WCML to work, are not set as translatable when they should */ $sentences[] = _x( "Some taxonomies in your site are forced to be untranslatable. This is causing a problem when you're trying to run a multilingual WooCommerce site.", 'Default taxonomies must be translatable: 1/6', 'woocommerce-multilingual' ); /* translators: Part 2/6 of a message telling users that some taxonomies, required for WCML to work, are not set as translatable when they should */ $sentences[] = _x( 'A plugin or the theme are probably doing this.', 'Default taxonomies must be translatable: 2/6', 'woocommerce-multilingual' ); /* translators: Part 3/6 of a message telling users that some taxonomies, required for WCML to work, are not set as translatable when they should */ $sentences[] = _x( 'What you can do:', 'Default taxonomies must be translatable: 3/6', 'woocommerce-multilingual' ); /* translators: Part 4/6 of a message telling users that some taxonomies, required for WCML to work, are not set as translatable when they should */ $sentences[] = _x( '1. Temporarily disable plugins and see if this message disappears.', 'Default taxonomies must be translatable: 4/6', 'woocommerce-multilingual' ); /* translators: Part 5/6 of a message telling users that some taxonomies, required for WCML to work, are not set as translatable when they should */ $sentences[] = _x( '2. Temporarily switch the theme and see if this message disappears.', 'Default taxonomies must be translatable: 5/6', 'woocommerce-multilingual' ); /* translators: Part 6/6 of a message telling users that some taxonomies, required for WCML to work, are not set as translatable when they should */ $sentences[] = sprintf( _x( "It's best to contact %s, tell that you're getting this message and offer to send a Duplicator copy of the site. We will work with the theme/plugin author and fix the problem for good. In the meanwhile, we'll give you a temporary solution, so you're not stuck.", 'Default taxonomies must be translatable: 6/6', 'woocommerce-multilingual' ), $support_link ); $this->err_message = ' '; add_action( 'admin_notices', [ $this, 'plugin_notice_message' ] ); } } /** * @param array $missing_plugins * @param bool $possibly_standalone * * @return Closure */ private static function show_missing_plugins_warning( $missing_plugins, $possibly_standalone ) { return function() use ( $missing_plugins, $possibly_standalone ) { if ( $possibly_standalone ) { // Limit missing plugins to 'WooCommerce' $missing_plugins = array_intersect_key( $missing_plugins, [ 'WooCommerce' => 1 ] ); } $missing = ''; $counter = 0; foreach ( $missing_plugins as $title => $url ) { $counter ++; if ( $counter == sizeof( $missing_plugins ) ) { $sep = ''; } elseif ( $counter == sizeof( $missing_plugins ) - 1 ) { $sep = ' ' . __( 'and', 'woocommerce-multilingual' ) . ' '; } else { $sep = ', '; } $missing .= '' . $title . '' . $sep; } ?> '' ] ); if ( empty( $permalinks['product_base'] ) ) { return; } $tm_folder = defined( 'WPML_TM_FOLDER' ) ? WPML_TM_FOLDER : 'tm'; $message = __( 'Because this site uses the default permalink structure, you cannot use slug translation for product permalinks.', 'woocommerce-multilingual' ); $message .= '