add_category( BookingBlock::CATEGORY, [ 'title' => __( 'Vizyt', 'vizyt' ), 'icon' => 'vizyt-eicon', ] ); } /** * @param \Elementor\Widgets_Manager $widgets_manager */ public static function register_widget( $widgets_manager ): void { if ( ! class_exists( '\Elementor\Widget_Base' ) ) { return; } $widgets_manager->register( new Elementor\BookingWidget() ); } /** * Files (the widget lists them as dependencies) and the appearance CSS: * Elementor may print the stylesheet in
, before the form renders, * so CSS added at render time would be lost. The strings are added when * the form is on the page. */ public static function register_assets(): void { BookingWidget::register_assets(); BookingWidget::add_theme_css(); wp_register_script( self::PREVIEW_SCRIPT, VIZYT_PLUGIN_URL . 'assets/js/elementor-preview.js', [ 'jquery', 'vizyt-booking-widget' ], VIZYT_VERSION . '.' . (int) @filemtime( VIZYT_PLUGIN_DIR . 'assets/js/elementor-preview.js' ), // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- a missing file only changes the cache-busting version. true ); } /** * Editor preview: the widget can be added later (rendered over AJAX), so * the form, its strings and appearance must already be on the page. */ public static function enqueue_preview(): void { self::register_assets(); BookingWidget::enqueue_assets(); wp_enqueue_script( self::PREVIEW_SCRIPT ); } /** * The Vizyt symbol as the widget's (and the group's) icon in the panel. * On a handle of our own, whatever Elementor calls its editor stylesheet. */ public static function editor_styles(): void { $svg = ""; $url = 'url("data:image/svg+xml,' . rawurlencode( $svg ) . '")'; wp_register_style( self::EDITOR_STYLE, false, [], VIZYT_VERSION ); wp_enqueue_style( self::EDITOR_STYLE ); wp_add_inline_style( self::EDITOR_STYLE, BookingWidget::inline_css( '.vizyt-eicon::before{content:"";display:inline-block;width:1em;height:1em;vertical-align:middle;background-color:currentColor;' . '-webkit-mask:' . $url . ' center/contain no-repeat;mask:' . $url . ' center/contain no-repeat}' ) ); } }