check_for_notices(); foreach ( $this->notices as $notice_key => $notice ) { echo '
'; if ( $notice['dismissible'] ) { ?> '; echo wp_kses( $notice['message'], [ 'a' => [ 'href' => [], 'target' => [], ], ] ); echo '

'; } } /** * Hides any admin notices. */ public function hide_notices() { if ( isset( $_GET['wcpay-multi-currency-hide-notice'] ) && isset( $_GET['_wcpay_multi_currency_notice_nonce'] ) ) { if ( ! wp_verify_nonce( wc_clean( wp_unslash( $_GET['_wcpay_multi_currency_notice_nonce'] ) ), 'wcpay_multi_currency_hide_notices_nonce' ) ) { wp_die( esc_html__( 'Action failed. Please refresh the page and retry.', 'woocommerce-payments' ) ); } if ( ! current_user_can( 'manage_woocommerce' ) ) { wp_die( esc_html__( 'Cheatin’ huh?', 'woocommerce-payments' ) ); } $notice = wc_clean( wp_unslash( $_GET['wcpay-multi-currency-hide-notice'] ) ); if ( 'currency_changed' === $notice ) { update_option( 'wcpay_multi_currency_show_store_currency_changed_notice', 'no' ); } } } /** * Adds admin notice to be displayed. * * @param string $slug Slug for the notice. * @param string $class Class(es) for the notice. * @param string $message Message in the notice. * @param bool $dismissible Whether the notice can be dismissed or not. */ private function add_admin_notice( $slug, $class, $message, $dismissible = false ) { $this->notices[ $slug ] = [ 'class' => $class, 'message' => $message, 'dismissible' => $dismissible, ]; } /** * Checks for notices and add them. */ private function check_for_notices() { $manual_currencies = get_option( 'wcpay_multi_currency_show_store_currency_changed_notice', false ); if ( is_array( $manual_currencies ) ) { $currencies = implode( ', ', $manual_currencies ); // translators: %s List of currencies that are already translated in WooCommerce core. $this->add_admin_notice( 'currency_changed', 'notice notice-warning', sprintf( __( 'The store currency was recently changed. The following currencies are set to manual rates and may need updates: %s', 'woocommerce-payments' ), $currencies ), true ); } } }