32 } |
32 } |
33 |
33 |
34 $custom_class_name = empty( $attributes['className'] ) ? '' : ' ' . $attributes['className']; |
34 $custom_class_name = empty( $attributes['className'] ) ? '' : ' ' . $attributes['className']; |
35 $align_class_name = empty( $attributes['align'] ) ? '' : ' ' . "align{$attributes['align']}"; |
35 $align_class_name = empty( $attributes['align'] ) ? '' : ' ' . "align{$attributes['align']}"; |
36 |
36 |
37 return sprintf( |
37 $output = sprintf( |
38 '<div class="%1$s">%2$s</div>', |
38 '<div class="%1$s">%2$s</div>', |
39 esc_attr( 'wp-block-calendar' . $custom_class_name . $align_class_name ), |
39 esc_attr( 'wp-block-calendar' . $custom_class_name . $align_class_name ), |
40 get_calendar( true, false ) |
40 get_calendar( true, false ) |
41 ); |
41 ); |
42 |
42 |
43 // phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited |
43 // phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited |
44 $monthnum = $previous_monthnum; |
44 $monthnum = $previous_monthnum; |
45 // phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited |
45 // phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited |
46 $year = $previous_year; |
46 $year = $previous_year; |
|
47 |
|
48 return $output; |
47 } |
49 } |
48 |
50 |
49 /** |
51 /** |
50 * Registers the `core/calendar` block on server. |
52 * Registers the `core/calendar` block on server. |
51 */ |
53 */ |
52 function register_block_core_calendar() { |
54 function register_block_core_calendar() { |
53 register_block_type( |
55 register_block_type_from_metadata( |
54 'core/calendar', |
56 __DIR__ . '/calendar', |
55 array( |
57 array( |
56 'attributes' => array( |
|
57 'align' => array( |
|
58 'type' => 'string', |
|
59 ), |
|
60 'className' => array( |
|
61 'type' => 'string', |
|
62 ), |
|
63 'month' => array( |
|
64 'type' => 'integer', |
|
65 ), |
|
66 'year' => array( |
|
67 'type' => 'integer', |
|
68 ), |
|
69 ), |
|
70 'render_callback' => 'render_block_core_calendar', |
58 'render_callback' => 'render_block_core_calendar', |
71 ) |
59 ) |
72 ); |
60 ); |
73 } |
61 } |
74 |
62 |