Skip to content

Commit 7a39211

Browse files
committed
Merge branch 'main' into 'release3.x'
Release 3.2.2 See merge request really-simple-plugins/simplybook-me/simplybook!152
2 parents 5ebabbb + f2ce673 commit 7a39211

File tree

94 files changed

+1949
-1282
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+1949
-1282
lines changed

app/App.php

Lines changed: 0 additions & 211 deletions
This file was deleted.
Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
namespace SimplyBook\Controllers;
33

44
use Carbon\Carbon;
5-
use SimplyBook\App;
5+
use SimplyBook\Bootstrap\App;
66
use SimplyBook\Traits\HasViews;
77
use SimplyBook\Traits\HasAllowlistControl;
88
use SimplyBook\Interfaces\ControllerInterface;
@@ -12,18 +12,24 @@ class AdminController implements ControllerInterface
1212
use HasViews;
1313
use HasAllowlistControl;
1414

15+
private App $app;
1516
private string $restApiAction = 'resp_rest_api_notice_form_submit';
1617
private string $restApiNonceName = 'resp_rest_api_notice_nonce';
1718
private string $restApiAccessibleOptionName = 'simplybook_rest_api_accessible';
1819
private string $restApiValidationTimeOptionName = 'simplybook_rest_api_validation_time';
1920

21+
public function __construct(App $app)
22+
{
23+
$this->app = $app;
24+
}
25+
2026
public function register(): void
2127
{
2228
if ($this->adminAccessAllowed() === false) {
2329
return;
2430
}
2531

26-
add_filter('plugin_action_links_' . App::env('plugin.base_file'), [$this, 'addPluginSettingsAction']);
32+
add_filter('plugin_action_links_' . $this->app->env->getString('plugin.base_file'), [$this, 'addPluginSettingsAction']);
2733
add_action('admin_notices', [$this, 'showRestApiNotice']);
2834
add_action('admin_init', [$this, 'processRestApiNoticeFormSubmit']);
2935
}
@@ -37,11 +43,11 @@ public function addPluginSettingsAction(array $links): array
3743
return $links;
3844
}
3945

40-
$settings_link = '<a href="' . App::env('plugin.dashboard_url') . '">' . esc_html__('Settings', 'simplybook') . '</a>';
46+
$settings_link = '<a href="' . $this->app->env->getUrl('plugin.dashboard_url') . '">' . esc_html__('Settings', 'simplybook') . '</a>';
4147
array_unshift($links, $settings_link);
4248

4349
//support
44-
$support = '<a rel="noopener noreferrer" target="_blank" href="' . esc_attr(App::env('simplybook.support_url')) . '">' . esc_html__('Support', 'simplybook') . '</a>';
50+
$support = '<a rel="noopener noreferrer" target="_blank" href="' . esc_attr($this->app->env->getUrl('simplybook.support_url')) . '">' . esc_html__('Support', 'simplybook') . '</a>';
4551
array_unshift($links, $support);
4652

4753
return $links;
@@ -75,12 +81,11 @@ public function showRestApiNotice(): void
7581
*/
7682
public function processRestApiNoticeFormSubmit(): void
7783
{
78-
$request = App::provide('request')->fromGlobal();
79-
if ($request->isEmpty('simplybook_rest_api_notice_form')) {
84+
if ($this->app->request->isEmpty('simplybook_rest_api_notice_form')) {
8085
return;
8186
}
8287

83-
$nonce = $request->get($this->restApiNonceName);
88+
$nonce = $this->app->request->get($this->restApiNonceName);
8489
if (wp_verify_nonce($nonce, $this->restApiAction) === false) {
8590
return; // Invalid nonce
8691
}
Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
<?php namespace SimplyBook\Controllers;
22

3+
use SimplyBook\Bootstrap\App;
34
use Elementor\Widgets_Manager;
4-
use SimplyBook\App;
55
use SimplyBook\Interfaces\ControllerInterface;
6-
use SimplyBook\Widgets\ElementorWidget;
6+
use SimplyBook\Support\Widgets\ElementorWidget;
77

88
class 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

Comments
 (0)