notices = $notices; } public function add_hooks() { if ( wcml_is_multi_currency_on() && ! $this->notices->get_notice( self::NOTICE_ID ) && self::hasActiveCachePlugin() ) { add_action( 'admin_init', [ $this, 'addNotice' ] ); } } public function addNotice() { $text = '
' . __( 'Caching may cause currency display issues for your customers if you are using the multi-currency feature.', 'woocommerce-multilingual' ) . '
'; $text .= '' . __( 'To avoid this, set your cache plugin to not cache pages for visitors that have a cookie set in their browser.', 'woocommerce-multilingual' ) . '
'; $notice = $this->notices->create_notice( self::NOTICE_ID, $text ); $notice->set_css_class_types( 'notice-warning' ); $notice->set_restrict_to_screen_ids( RestrictedScreens::get() ); $notice->set_dismissible( true ); $this->notices->add_notice( $notice ); } /** * @return bool */ private static function hasActiveCachePlugin() { // $isActive :: ( array, string ) -> bool $isActive = pipe( Fns::nthArg( 1 ), // array index 'is_plugin_active' ); // $isAboutCaching :: array -> bool $isAboutCaching = pipe( Obj::prop( 'Description' ), Logic::anyPass( [ Str::includes( 'cache' ), Str::includes( 'caching' ) ] ) ); return (bool) wpml_collect( get_plugins() ) ->filter( $isActive ) ->filter( $isAboutCaching ) ->first(); } }