CachePlugins.php
1 week ago
CurrencySwitcherUseTwigTemplate.php
1 week ago
ExportImport.php
1 week ago
MultiCurrencyMissing.php
1 week ago
RestrictedScreens.php
1 week ago
Review.php
1 week ago
TranslationControlMovedNotice.php
1 week ago
WizardNotice.php
1 week ago
TranslationControlMovedNotice.php
72 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WCML\AdminNotices; |
| 4 | |
| 5 | use WPML\LIB\WP\User; |
| 6 | use WPML_Notices; |
| 7 | use IWPML_Backend_Action; |
| 8 | use IWPML_Frontend_Action; |
| 9 | use IWPML_DIC_Action; |
| 10 | |
| 11 | class TranslationControlMovedNotice implements IWPML_Backend_Action, IWPML_Frontend_Action, IWPML_DIC_Action { |
| 12 | const NOTICE_ID = 'wcml-translation-control-moved'; |
| 13 | const NOTICE_GROUP = 'wcml-admin-notices'; |
| 14 | |
| 15 | const NOTICE_CLASSES = [ |
| 16 | 'wcml-translation-control-moved-notice', |
| 17 | ]; |
| 18 | |
| 19 | private $wpmlNotices; |
| 20 | |
| 21 | public function __construct( WPML_Notices $wpmlNotices ) { |
| 22 | $this->wpmlNotices = $wpmlNotices; |
| 23 | } |
| 24 | |
| 25 | public function add_hooks() { |
| 26 | add_action( 'admin_notices', [ $this, 'addNoticeWhenWPMLIsActive' ] ); |
| 27 | } |
| 28 | |
| 29 | public function addNoticeWhenWPMLIsActive() { |
| 30 | |
| 31 | $notice = $this->wpmlNotices->get_new_notice( |
| 32 | self::NOTICE_ID, |
| 33 | $this->getNoticeText(), |
| 34 | self::NOTICE_GROUP |
| 35 | ); |
| 36 | |
| 37 | if ( $this->wpmlNotices->is_notice_dismissed( $notice ) ) { |
| 38 | return; |
| 39 | } |
| 40 | |
| 41 | $notice->set_css_class_types( 'info' ); |
| 42 | $notice->set_css_classes( self::NOTICE_CLASSES ); |
| 43 | $notice->set_dismissible( true ); |
| 44 | $notice->add_user_restriction( User::getCurrentId() ); |
| 45 | $notice->set_restrict_to_screen_ids( [ 'woocommerce_page_wpml-wcml' ] ); |
| 46 | |
| 47 | $this->wpmlNotices->add_notice( $notice ); |
| 48 | } |
| 49 | |
| 50 | private function getNoticeText(): string { |
| 51 | |
| 52 | $text = ''; |
| 53 | $text .= '<h2>' . esc_html__( 'The Translation Controls Have Moved', 'woocommerce-multilingual' ) . '</h2>'; |
| 54 | |
| 55 | $text .= '<p>' . esc_html__( 'We updated WPML Multilingual & Multicurrency for WooCommerce to streamline your translation work.', 'woocommerce-multilingual' ) . '</p>'; |
| 56 | |
| 57 | $text .= '<p><strong>'; |
| 58 | |
| 59 | $text .= sprintf( |
| 60 | /* translators: %1$s and %2$s are opening and closing HTML link tags */ |
| 61 | esc_html__( 'Translate your whole site\'s content, including products, from %1$sWPML → Translation Management%2$s.', 'woocommerce-multilingual' ), |
| 62 | '<a href="' . \WCML\Utilities\AdminUrl::getWPMLTMDashboard() . '">', |
| 63 | '</a>' |
| 64 | ); |
| 65 | |
| 66 | $text .= '</strong>'; |
| 67 | $text .= '<span class="recommended-badge">Recommended</span></p>'; |
| 68 | |
| 69 | return $text; |
| 70 | } |
| 71 | } |
| 72 |