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 4.7.6 4.7.7 4.7.8 4.7.9 4.8.0 4.9.0 4.9.1 5.0.1 5.0.2 5.1.1 5.1.2 5.1.3 5.2.0 5.2.1 5.3.2 5.3.3.1 5.3.4 5.3.5 5.3.6 5.3.7
woocommerce-multilingual / classes / AdminNotices / Review.php
woocommerce-multilingual / classes / AdminNotices Last commit date
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
Review.php
90 lines
1 <?php
2
3 namespace WCML\AdminNotices;
4
5 use WCML\StandAlone\IStandAloneAction;
6 use WPML_Notices;
7 use IWPML_Backend_Action;
8 use IWPML_Frontend_Action;
9 use IWPML_DIC_Action;
10 use function WCML\functions\isStandAlone;
11
12 class Review implements IWPML_Backend_Action, IWPML_Frontend_Action, IWPML_DIC_Action, IStandAloneAction {
13
14 const OPTION_NAME = 'wcml-rate-notice';
15
16 private $wpmlNotices;
17
18 public function __construct( WPML_Notices $wpmlNotices ) {
19 $this->wpmlNotices = $wpmlNotices;
20 }
21
22 public function add_hooks() {
23 if ( isStandAlone() ) {
24 add_action( 'admin_notices', [ $this, 'addNotice' ] );
25 add_action( 'woocommerce_after_order_object_save', [ $this, 'onNewOrder' ] );
26 }
27 }
28
29 public function addNotice() {
30
31 if ( $this->shouldDisplayNotice() ) {
32 $notice = $this->wpmlNotices->get_new_notice( 'wcml-rate', $this->getNoticeText(), 'wcml-admin-notices' );
33
34 if ( $this->wpmlNotices->is_notice_dismissed( $notice ) ) {
35 return;
36 }
37
38 $notice->set_css_class_types( 'info' );
39 $notice->set_css_classes( [ 'otgs-notice-wcml-rating' ] );
40 $notice->set_dismissible( true );
41
42 $reviewLink = 'https://wordpress.org/support/plugin/woocommerce-multilingual/reviews/?filter=5#new-post';
43 $reviewButton = $this->wpmlNotices->get_new_notice_action( esc_html__( 'Review WPML Multilingual & Multicurrency for WooCommerce', 'woocommerce-multilingual' ), $reviewLink, false, false, true );
44 $notice->add_action( $reviewButton );
45
46 $notice->set_restrict_to_screen_ids( RestrictedScreens::get() );
47 $notice->add_capability_check( [ 'manage_options', 'wpml_manage_woocommerce_multilingual' ] );
48 $this->wpmlNotices->add_notice( $notice );
49 }
50 }
51
52 private function getNoticeText(): string {
53 $text = '<h2>';
54 $text .= esc_html__( 'Congrats on making your first multicurrency sale!', 'woocommerce-multilingual' );
55 $text .= '</h2>';
56
57 $text .= '<p>';
58 $text .= sprintf(
59 /* translators: %1$s and %2$s are opening and closing HTML link tags */
60 esc_html__( 'Want to help <strong>WPML Multilingual & Multicurrency for WooCommerce</strong> plugin? %1$sGive us a review%2$s!', 'woocommerce-multilingual' ),
61 '<a href="https://wordpress.org/support/plugin/woocommerce-multilingual/reviews/?filter=5#new-post" class="wpml-external-link" target="_blank">',
62 '</a>'
63 );
64 $text .= '</p>';
65
66 return $text;
67 }
68
69 private function shouldDisplayNotice(): bool {
70 return get_option( self::OPTION_NAME, false );
71 }
72
73 public function onNewOrder( $order ) {
74 if ( ! $this->shouldDisplayNotice() ) {
75 $this->maybeAddOptionToShowNotice( $order );
76 }
77 }
78
79 private function maybeAddOptionToShowNotice( \WC_Order $order ) {
80 if ( $order->is_paid() && $this->isOrderInSecondCurrency( $order ) ) {
81 add_option( self::OPTION_NAME, true );
82 }
83 }
84
85 private function isOrderInSecondCurrency( \WC_Order $order ): bool {
86 return wcml_is_multi_currency_on()
87 && $order->get_currency() !== wcml_get_woocommerce_currency_option();
88 }
89 }
90