(string) get_option( BAYLE_MENU_WIDGET_OPTION_SLUG, '' ), 'lang' => (string) get_option( BAYLE_MENU_WIDGET_OPTION_LANG, '' ), 'menuBase' => bayle_menu_widget_resolve_base_url(), 'menuMode' => bayle_menu_widget_menu_mode_setting(), ) ); wp_set_script_translations( 'bayle-menu-widget-block', 'bayle-menu-widget', plugin_dir_path( BAYLE_MENU_WIDGET_FILE ) . 'languages' ); wp_register_style( 'bayle-menu-widget', plugins_url( 'assets/iframe.css', BAYLE_MENU_WIDGET_FILE ), array(), BAYLE_MENU_WIDGET_VERSION ); register_block_type( plugin_dir_path( BAYLE_MENU_WIDGET_FILE ) . 'block', array( 'render_callback' => 'bayle_menu_widget_render_block', ) ); } /** * Server render for the block. * * @param array $attributes Block attributes. * @param string $content Unused (dynamic block). * @return string */ function bayle_menu_widget_render_block( $attributes = array(), $content = '' ): string { unset( $content ); $attributes = is_array( $attributes ) ? $attributes : array(); return bayle_menu_widget_render_menu( array( 'slug' => isset( $attributes['slug'] ) ? (string) $attributes['slug'] : '', 'lang' => isset( $attributes['lang'] ) ? (string) $attributes['lang'] : '', 'display' => isset( $attributes['display'] ) ? (string) $attributes['display'] : '', 'layout' => isset( $attributes['layout'] ) ? (string) $attributes['layout'] : 'list', 'images' => $attributes['showImages'] ?? true, 'categories' => $attributes['showCategories'] ?? true, 'ordering' => $attributes['ordering'] ?? true, 'heading' => isset( $attributes['headingLevel'] ) ? (int) $attributes['headingLevel'] : 2, ) ); }