PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.2.6
Yatra – Travel Booking & Tour Operator Software v3.0.2.6
3.0.14 3.0.14.1 3.0.14.2 3.0.12 3.0.13 3.0.11 3.0.10 3.0.9 3.0.8 3.0.7 3.0.6 3.0.5 3.0.5.1 3.0.4 3.0.3 3.0.2.9 3.0.2.7 3.0.2.8 3.0.2.6 trunk 1.0.0 2.0.0 2.0.1 2.0.10 2.0.11 All 82 releases
yatra / app / Blocks / ActivityBlock.php

ActivityBlock.php in Yatra – Travel Booking & Tour Operator Software 3.0.2.6, at app/Blocks/ActivityBlock.php

99 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace Yatra\Blocks;
6
7 use Yatra\Services\BlockDataService;
8
9 /**
10 * Activity Block
11 *
12 * Gutenberg block for displaying activity listings
13 * Maintains backward compatibility with old yatra/activity block
14 *
15 * @package Yatra\Blocks
16 * @since 3.0.0
17 */
18 class ActivityBlock
19 {
20 public function __construct()
21 {
22 $this->register();
23 }
24
25 /**
26 * @param array<string, mixed> $attributes Block attributes
27 * @param string $content Block content
28 */
29 public function renderCallback(array $attributes, string $content): string
30 {
31 wp_enqueue_style('yatra-activity-shortcode', \YATRA_PLUGIN_URL . 'assets/css/shortcodes/activity-shortcode.css', [], YATRA_VERSION);
32
33 return BlockDataService::renderActivityBlock($attributes);
34 }
35
36 public function register(): void
37 {
38 BlockEditorScript::reclaimBlockName('yatra/activity');
39
40 $editorDeps = BlockEditorScript::editorDependencies();
41 if (! BlockEditorScript::register('yatra-activity-block-editor', 'activity', $editorDeps)) {
42 return;
43 }
44
45 wp_register_style(
46 'yatra-listing',
47 \YATRA_PLUGIN_URL . 'assets/css/listing.css',
48 [],
49 YATRA_VERSION
50 );
51
52 wp_register_style(
53 'yatra-activity-shortcode',
54 \YATRA_PLUGIN_URL . 'assets/css/shortcodes/activity-shortcode.css',
55 [],
56 YATRA_VERSION
57 );
58
59 wp_register_script(
60 'yatra-activity-shortcode',
61 \YATRA_PLUGIN_URL . 'assets/js/activity-shortcode.js',
62 ['jquery'],
63 YATRA_VERSION,
64 true
65 );
66
67 $block = register_block_type_from_metadata(
68 BlockEditorScript::blockJsonPath('activity'),
69 [
70 'render_callback' => [$this, 'renderCallback'],
71 'editor_style' => ['yatra-listing', 'yatra-activity-shortcode'],
72 'style' => ['yatra-activity-shortcode'],
73 'script' => 'yatra-activity-shortcode',
74 ]
75 );
76
77 if ($block === false) {
78 register_block_type('yatra/activity', [
79 'api_version' => 3,
80 'title' => __('Activity', 'yatra'),
81 'category' => 'yatra',
82 'description' => __('Display activity listings with customizable options', 'yatra'),
83 'icon' => 'buddicons-pm',
84 'keywords' => ['activity', 'things to do', 'yatra'],
85 'render_callback' => [$this, 'renderCallback'],
86 'editor_script' => 'yatra-activity-block-editor',
87 'editor_style' => ['yatra-listing', 'yatra-activity-shortcode'],
88 'style' => ['yatra-activity-shortcode'],
89 'script' => 'yatra-activity-shortcode',
90 'supports' => [
91 'align' => ['wide', 'full'],
92 'html' => false,
93 'inserter' => true,
94 ],
95 ]);
96 }
97 }
98 }
99