PluginProbe
Orderable – Restaurant & Food Ordering System / 1.19.0
Orderable – Restaurant & Food Ordering System v1.19.0
0.1.4 0.1.5 0.2.0 1.0.0 1.1.0 1.1.1 1.10.0 1.10.1 1.11.0 1.12.0 1.12.1 1.12.2 1.13.0 1.14.0 1.15.0 1.16.0 1.17.0 1.17.1 1.18.0 1.19.0 1.19.1 1.19.2 1.2.0 1.20.0 1.20.1 All 44 releases
orderable / inc / modules / layouts / class-layouts-blocks.php

class-layouts-blocks.php in Orderable – Restaurant & Food Ordering System 1.19.0, at inc/modules/layouts/class-layouts-blocks.php

78 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Module: Layouts Blocks.
4 *
5 * @package Orderable/Classes
6 */
7
8 defined( 'ABSPATH' ) || exit;
9
10 /**
11 * Layouts blocks class.
12 */
13 class Orderable_Layouts_Blocks {
14 /**
15 * Init.
16 */
17 public static function run() {
18 add_action( 'init', array( __CLASS__, 'register_blocks' ) );
19 }
20
21 /**
22 * Register blocks.
23 */
24 public static function register_blocks() {
25 if ( ! function_exists( 'register_block_type' ) ) {
26 return;
27 }
28
29 wp_register_script(
30 'orderable-layout',
31 ORDERABLE_URL . 'inc/modules/layouts/assets/admin/js/block-layout.js',
32 array(
33 'wp-blocks',
34 'wp-i18n',
35 'wp-element',
36 'wp-components',
37 'wp-editor',
38 ),
39 ORDERABLE_VERSION
40 );
41
42 wp_localize_script(
43 'orderable-layout',
44 'orderable_vars',
45 array(
46 'admin_url' => get_admin_url(),
47 )
48 );
49
50 register_block_type(
51 'orderable/layout',
52 array(
53 'editor_script' => 'orderable-layout',
54 'render_callback' => array( __CLASS__, 'layout_block_handler' ),
55 'attributes' => array(
56 'id' => array(
57 'default' => '0',
58 'type' => 'string',
59 ),
60 'layoutIds' => array(
61 'default' => new stdClass(),
62 'type' => 'object',
63 ),
64 ),
65 )
66 );
67 }
68
69 /**
70 * Handle block: Layout.
71 */
72 public static function layout_block_handler( $args = array() ) {
73 $layout_settings = Orderable_Layouts::get_layout_settings( $args['id'] );
74
75 return Orderable_Layouts::orderable_shortcode( $layout_settings );
76 }
77 }
78