(string) $cal['slug'], 'title' => (string) ( $cal['title'] ?? $cal['slug'] ), ]; } $settings = Plugin::get_settings(); wp_localize_script( $asset_handle, 'AgentsiaBlocks', [ 'calendars' => $calendar_options, 'defaultSlug' => (string) ( $settings['default_booking_slug'] ?? '' ), ] ); wp_enqueue_script( $asset_handle ); } public function register_blocks(): void { register_block_type( 'agentsia/chatbot', [ 'api_version' => 2, 'title' => __( 'Chatbot Agentsia', 'agentsia-agents' ), 'category' => 'widgets', 'icon' => 'format-chat', 'editor_script' => 'agentsia-agents-blocks', 'render_callback' => [ $this, 'render_chatbot_block' ], 'attributes' => [ 'mode' => [ 'type' => 'string', 'default' => 'fullpage' ], 'position' => [ 'type' => 'string', 'default' => 'right' ], 'configId' => [ 'type' => 'string', 'default' => '' ], 'headerText' => [ 'type' => 'string', 'default' => '' ], 'bubbleLabel' => [ 'type' => 'string', 'default' => '' ], 'accentColor' => [ 'type' => 'string', 'default' => '' ], 'containerHeight' => [ 'type' => 'string', 'default' => '600px' ], ], ] ); register_block_type( 'agentsia/booking', [ 'api_version' => 2, 'title' => __( 'Rendez-vous Agentsia', 'agentsia-agents' ), 'category' => 'widgets', 'icon' => 'calendar-alt', 'editor_script' => 'agentsia-agents-blocks', 'render_callback' => [ $this, 'render_booking_block' ], 'attributes' => [ 'slug' => [ 'type' => 'string', 'default' => '' ], 'height' => [ 'type' => 'string', 'default' => '780' ], ], ] ); register_block_type( 'agentsia/demo-button', [ 'api_version' => 2, 'title' => __( 'Bouton démo Agentsia', 'agentsia-agents' ), 'category' => 'widgets', 'icon' => 'megaphone', 'editor_script' => 'agentsia-agents-blocks', 'render_callback' => [ $this, 'render_demo_block' ], 'attributes' => [ 'label' => [ 'type' => 'string', 'default' => '' ], 'path' => [ 'type' => 'string', 'default' => '/demo' ], 'style' => [ 'type' => 'string', 'default' => 'primary' ], 'target' => [ 'type' => 'string', 'default' => '_self' ], ], ] ); // Derniers articles d'une catégorie ou d'un auteur : même rendu que [agentsia_derniers_articles]. register_block_type( 'agentsia/derniers-articles', [ 'api_version' => 2, 'title' => __( 'Derniers articles', 'agentsia-agents' ), 'category' => 'widgets', 'icon' => 'list-view', 'editor_script' => 'agentsia-agents-blocks', 'render_callback' => [ $this, 'render_latest_posts_block' ], 'attributes' => [ 'nombre' => [ 'type' => 'integer', 'default' => 3 ], 'titre' => [ 'type' => 'string', 'default' => __( 'Derniers articles', 'agentsia-agents' ) ], 'categorie' => [ 'type' => 'string', 'default' => '' ], 'auteur' => [ 'type' => 'string', 'default' => '' ], ], ] ); } public function render_chatbot_block( array $attributes ): string { return Shortcodes::instance()->render_chatbot( [ 'mode' => $attributes['mode'] ?? 'fullpage', 'position' => $attributes['position'] ?? 'right', 'config_id' => $attributes['configId'] ?? '', 'header_text' => $attributes['headerText'] ?? '', 'bubble_label' => $attributes['bubbleLabel'] ?? '', 'accent_color' => $attributes['accentColor'] ?? '', 'container_height' => $attributes['containerHeight'] ?? '600px', ] ); } public function render_booking_block( array $attributes ): string { return Shortcodes::instance()->render_booking( [ 'slug' => $attributes['slug'] ?? '', 'height' => $attributes['height'] ?? '780', ] ); } public function render_latest_posts_block( array $attributes ): string { return Latest_Posts::instance()->render( [ 'nombre' => (string) ( $attributes['nombre'] ?? 3 ), 'titre' => (string) ( $attributes['titre'] ?? __( 'Derniers articles', 'agentsia-agents' ) ), 'categorie' => (string) ( $attributes['categorie'] ?? '' ), 'auteur' => (string) ( $attributes['auteur'] ?? '' ), ] ); } public function render_demo_block( array $attributes ): string { return Shortcodes::instance()->render_demo_cta( [ 'label' => $attributes['label'] ?? '', 'path' => $attributes['path'] ?? '/demo', 'style' => $attributes['style'] ?? 'primary', 'target' => $attributes['target'] ?? '_self', ] ); } }