dependencies_are_ok && ! current_user_can( 'wpml_manage_woocommerce_multilingual' ) && current_user_can( 'wpml_operate_woocommerce_multilingual' ) && ! current_user_can( 'translate' ) ) { add_filter( 'wpml_menu_page', [ __CLASS__, 'wpml_menu_page' ] ); } add_action( 'admin_menu', [ __CLASS__, 'register_menus' ], 80 ); if ( AdminPages::isWcmlSettings() ) { add_action( 'admin_body_class', Str::concat( Fns::__, ' ' . self::SLUG . '-' . AdminPages::getTabToDisplay() ) ); } if ( self::is_page_without_admin_language_switcher() ) { self::remove_wpml_admin_language_switcher(); } if ( is_admin() && ! is_null( $sitepress ) && self::$woocommerce_wpml->dependencies_are_ok && WCML_Capabilities::canManageWcml() ) { add_action( 'admin_footer', [ __CLASS__, 'documentation_links' ] ); add_action( 'admin_head', [ __CLASS__, 'hide_multilingual_content_setup_box' ] ); if ( ! isStandAlone() ) { add_action( 'admin_init', [ __CLASS__, 'restrict_admin_with_redirect' ] ); } add_filter( 'plugin_action_links_woocommerce-multilingual/wpml-woocommerce.php', [ __CLASS__, 'add_settings_links_to_plugin_actions' ] ); } add_filter( 'woocommerce_prevent_admin_access', [ __CLASS__, 'check_user_admin_access' ] ); if ( ! isStandAlone() ) { add_action( 'admin_head', [ __CLASS__, 'add_menu_warning' ] ); } } /** * @return bool */ private static function is_page_without_admin_language_switcher() { $get_page = isset( $_GET['page'] ) ? $_GET['page'] : false; $is_page_wpml_wcml = self::SLUG === $get_page; $is_shipping_zones = 'shipping_zones' === $get_page; $is_attributes_page = apply_filters( 'wcml_is_attributes_page', 'product_attributes' === $get_page ); $is_order_create_or_edit = \WCML\Orders\Helper::isOrderCreateAdminScreen() || \WCML\Orders\Helper::isOrderEditAdminScreen(); $is_coupon_create_or_edit = \WCML\Coupons\Helper::isCouponCreateAdminScreen() || \WCML\Coupons\Helper::isCouponEditAdminScreen(); return is_admin() && ( $is_page_wpml_wcml || $is_order_create_or_edit || $is_coupon_create_or_edit || $is_shipping_zones || $is_attributes_page ); } public static function remove_wpml_admin_language_switcher() { remove_action( 'wp_before_admin_bar_render', [ self::$sitepress, 'admin_language_switcher' ] ); } /** * @param array $menu * * @return array */ public static function wpml_menu_page( $menu ) { if ( isset( $menu['menu_slug'] ) && WPML_TM_FOLDER . '/menu/translations-queue.php' === $menu['menu_slug'] ) { $menu['capability'] = 'wpml_operate_woocommerce_multilingual'; } return $menu; } public static function register_menus() { $pageTitle = $menuTitle = self::getWcmlLabel(); if ( self::$woocommerce_wpml->dependencies_are_ok || class_exists( 'WooCommerce' ) ) { add_submenu_page( 'woocommerce', $pageTitle, $menuTitle, 'wpml_operate_woocommerce_multilingual', self::SLUG, [ __CLASS__, 'render_menus' ] ); } else { add_menu_page( $pageTitle, $menuTitle, 'wpml_manage_woocommerce_multilingual', self::SLUG, [ __CLASS__, 'render_menus' ], WCML_PLUGIN_URL . '/res/images/icon16.png' ); } } public static function render_menus() { if ( self::$woocommerce_wpml->dependencies_are_ok ) { if ( isStandAlone() ) { $plugins_wrap = new AdminMenu( self::$sitepress, self::$woocommerce_wpml ); $plugins_wrap->show(); } elseif ( getSetting( 'set_up_wizard_run' ) ) { $menus_wrap = new WCML_Menus_Wrap( self::$woocommerce_wpml ); $menus_wrap->show(); } else { $wizard_wrap = new WizardNotice( self::$woocommerce_wpml ); $wizard_wrap->show(); } } } public static function documentation_links() { global $post, $pagenow; if ( $post && ! is_object( $post ) ) { $post = get_post( $post ); } if ( ! $post ) { return; } $tracking_link = new WCML_Tracking_Link(); $get_post_type = get_post_type( $post->ID ); if ( 'product' === $get_post_type && 'edit.php' === $pagenow ) { $quick_edit_notice = '
'; $quick_edit_notice .= sprintf( /* translators: 1: WooCommerce Multilingual products editor, 2: Edit this product translation */ __( 'Quick edit is disabled for product translations. It\'s recommended to use the %1$s for editing products translations. %2$s', 'woocommerce-multilingual' ), '' . __( 'WooCommerce Multilingual & Multicurrency products editor', 'woocommerce-multilingual' ) . '', '' . __( 'Edit this product translation', 'woocommerce-multilingual' ) . '' ); $quick_edit_notice .= '
'; $quick_edit_notice_prod_link = ''; // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped ?>