11<?php namespace SimplyBook \Controllers ;
22
3+ use SimplyBook \Bootstrap \App ;
34use Elementor \Widgets_Manager ;
4- use SimplyBook \App ;
55use SimplyBook \Interfaces \ControllerInterface ;
6- use SimplyBook \Widgets \ElementorWidget ;
6+ use SimplyBook \Support \ Widgets \ElementorWidget ;
77
88class BlockController implements ControllerInterface
99{
10+ private App $ app ;
11+
12+ public function __construct (App $ app ) {
13+ $ this ->app = $ app ;
14+ }
15+
1016 public function register ()
1117 {
1218 if (!function_exists ('register_block_type ' )) {
@@ -33,7 +39,7 @@ public function registerGutenbergBlockType(): void
3339 return ;
3440 }
3541
36- $ blockMetaData = App:: env ('plugin.assets_path ' ) . '/block/build/block.json ' ;
42+ $ blockMetaData = $ this -> app -> env -> getString ('plugin.assets_path ' ) . '/block/build/block.json ' ;
3743 if ( file_exists ( $ blockMetaData ) === false ) {
3844 $ this ->registerGutenbergBlockTypeManually ();
3945 return ;
@@ -92,10 +98,10 @@ class_exists('\WP_Block_Type_Registry')
9298 $ this ->registerGutenbergBlockType ();
9399 }
94100
95- $ assetsData = include (App:: env ('plugin.assets_path ' ) . '/block/build/index.asset.php ' );
96- $ indexJs = App:: env ('plugin.assets_url ' ) . 'block/build/index.js ' ;
97- $ indexCss = App:: env ('plugin.assets_url ' ) . 'block/build/index.css ' ;
98- $ preview = App:: env ('plugin.assets_url ' ) . '/img/preview.png ' ;
101+ $ assetsData = include ($ this -> app -> env -> getString ('plugin.assets_path ' ) . '/block/build/index.asset.php ' );
102+ $ indexJs = $ this -> app -> env -> getUrl ('plugin.assets_url ' ) . 'block/build/index.js ' ;
103+ $ indexCss = $ this -> app -> env -> getUrl ('plugin.assets_url ' ) . 'block/build/index.css ' ;
104+ $ preview = $ this -> app -> env -> getUrl ('plugin.assets_url ' ) . '/img/preview.png ' ;
99105
100106 wp_enqueue_script (
101107 'simplybook-block ' ,
@@ -114,20 +120,20 @@ class_exists('\WP_Block_Type_Registry')
114120 'preview ' => $ preview ,
115121 'nonce ' => wp_create_nonce ('simplybook_nonce ' ),
116122 'x_wp_nonce ' => wp_create_nonce ('wp_rest ' ),
117- 'rest_namespace ' => App:: env ('http.namespace ' ),
118- 'rest_version ' => App:: env ('http.version ' ),
123+ 'rest_namespace ' => $ this -> app -> env -> getString ('http.namespace ' ),
124+ 'rest_version ' => $ this -> app -> env -> getString ('http.version ' ),
119125 'site_url ' => site_url (),
120- 'dashboard_url ' => App:: env ('plugin.dashboard_url ' ),
121- 'assets_url ' => App:: env ('plugin.assets_url ' ),
126+ 'dashboard_url ' => $ this -> app -> env -> getUrl ('plugin.dashboard_url ' ),
127+ 'assets_url ' => $ this -> app -> env -> getUrl ('plugin.assets_url ' ),
122128 'debug ' => defined ( 'SIMPLYBOOK_DEBUG ' ) && SIMPLYBOOK_DEBUG ,
123129 ]
124130 );
125131
126132 // Add widget.js script in the header of the page. We need it to be
127133 // Loaded as soon as possible, as our widgets are dependent on it.
128- wp_enqueue_script ('simplybookMePl_widget_scripts ' , App:: env ('simplybook.widget_script_url ' ), [], App:: env ('simplybook.widget_script_version ' ), false );
134+ wp_enqueue_script ('simplybookMePl_widget_scripts ' , $ this -> app -> env -> getUrl ('simplybook.widget_script_url ' ), [], $ this -> app -> env -> getString ('simplybook.widget_script_version ' ), false );
129135
130- wp_register_style ('simplybookMePl_widget_styles ' , $ indexCss , [], App:: env ('plugin.version ' ));
136+ wp_register_style ('simplybookMePl_widget_styles ' , $ indexCss , [], $ this -> app -> env -> getString ('plugin.version ' ));
131137 wp_enqueue_style ('simplybookMePl_widget_styles ' );
132138
133139 wp_set_script_translations ('simplybook-block ' , 'simplybook ' );
0 commit comments