PluginProbe
پارسی دیت – Parsi Date / 6.3
پارسی دیت – Parsi Date v6.3
6.3 6.2.1 6.2 6.1 5.1.6 5.1.7 5.1.8 5.1.8.2 6.0 trunk 1.0 1.1 1.2 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 2.0.0-alpha 2.1 2.1.1 2.1.2 2.1.3 2.1.5 All 49 releases
wp-parsidate / inc / Block / CalendarBlock.php
CalendarBlock.php
60 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * ParsiDate Calendar Block
4 *
5 * Register the Gutenberg block version of the calendar widget
6 */
7
8 namespace WPParsidate\Block;
9
10 defined( 'ABSPATH' ) || exit;
11
12 use WPParsidate\Core\Calendar;
13 use WPParsidate\Helper\Assets;
14
15 class CalendarBlock extends Block {
16 private const STYLE = 'wp-parsidate-calendar-style';
17
18 protected string $editorScript = 'wp-parsidate-calendar-editor-script';
19
20 protected string $blockJsonPath = 'blocks/calendar/block.json';
21
22 protected string $scriptBaseName = 'calendar-block';
23
24 protected string $dataVar = 'wppCalendarBlockData';
25
26 public function registerBlock(): void {
27 parent::registerBlock();
28
29 wp_register_style(
30 self::STYLE,
31 Assets::url( 'css-admin/calendar-wdiget.min.css' ),
32 array(),
33 Assets::getVersion()
34 );
35 }
36
37 protected function renderContent( $attributes ): string {
38 $title = $attributes['title'] ?? '';
39 $postType = $attributes['postType'] ?? 'post';
40 $theme = $attributes['theme'] ?? 'simple';
41 $blockId = 'wp-parsidate-calendar-block-' . md5( $postType . $theme );
42
43 ob_start();
44
45 echo '<div ' . get_block_wrapper_attributes() . '>';
46
47 if ( ! empty( $title ) ) {
48 echo '<h2 class="wp-block-wp-parsidate-calendar__title">' . esc_html( $title ) . '</h2>';
49 }
50
51 do_action( 'wp_parsidate_calendar_block_start', $title, $postType, $theme, $blockId );
52 Calendar::printCalendar( $postType, $theme );
53 do_action( 'wp_parsidate_calendar_block_end', $title, $postType, $theme, $blockId );
54
55 echo '</div>';
56
57 return ob_get_clean();
58 }
59 }
60