Skip to content

Commit 60ec16d

Browse files
committed
Finished constants changes
1 parent 30b15b9 commit 60ec16d

File tree

13 files changed

+33
-82
lines changed

13 files changed

+33
-82
lines changed

blocks/DocPagesNav/Block.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
defined('ABSPATH') || exit;
66

77
use StarterKit\Handlers\Blocks\BlockAbstract;
8-
use StarterKit\Exception\ConfigEntryNotFoundException;
98
use StarterKit\Repository\DocPageRepository;
109
use Throwable;
1110

@@ -57,7 +56,6 @@ public function registerBlockArgs(): void
5756
*
5857
* @return string
5958
*
60-
* @throws ConfigEntryNotFoundException
6159
* @throws Throwable
6260
*/
6361
public function blockServerSideCallback(array $attributes, string $content, object $block): string
@@ -79,10 +77,6 @@ public function blockServerSideCallback(array $attributes, string $content, obje
7977
* Runs by abstract constructor
8078
*
8179
* @return void
82-
*
83-
* @throws ContainerExceptionInterface
84-
* @throws ConfigEntryNotFoundException
85-
* @throws NotFoundExceptionInterface
8680
*/
8781
public function blockRestApiEndpoints(): void
8882
{

blocks/Image/Block.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use Exception;
88
use StarterKit\Handlers\Blocks\BlockAbstract;
99
use StarterKit\Error\ErrorHandler;
10-
use StarterKit\Exception\ConfigEntryNotFoundException;
1110
use StarterKit\Helper\Utils;
1211
use Throwable;
1312
use WPRI\ResponsiveImages\Img;
@@ -63,7 +62,6 @@ public function registerBlockArgs(): void
6362
*
6463
* @return string
6564
*
66-
* @throws ConfigEntryNotFoundException
6765
* @throws Throwable
6866
*/
6967
public function blockServerSideCallback(array $attributes, string $content, object $block): string

blocks/Navigation/Block.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
defined('ABSPATH') || exit;
66

77
use StarterKit\Handlers\Blocks\BlockAbstract;
8-
use StarterKit\Helper\Config;
9-
use StarterKit\Exception\ConfigEntryNotFoundException;
108
use Throwable;
119

1210
/**
@@ -62,7 +60,6 @@ public function registerBlockArgs(): void
6260
*
6361
* @return string
6462
*
65-
* @throws ConfigEntryNotFoundException
6663
* @throws Throwable
6764
*/
6865
public function blockServerSideCallback(array $attributes, string $content, object $block): string
@@ -145,18 +142,16 @@ private function buildMenuTree($menuItems): array
145142
* Runs by abstract constructor
146143
*
147144
* @return void
148-
*
149-
* @throws ConfigEntryNotFoundException
150145
*/
151146
public function blockRestApiEndpoints(): void
152147
{
153-
register_rest_route(Config::get('restApiNamespace'), '/get-menu-locations', [
148+
register_rest_route(SK_REST_API_NS, '/get-menu-locations', [
154149
'methods' => 'GET',
155150
'callback' => [$this, 'getMenuLocations'],
156151
'permission_callback' => [$this, 'getMenusPermissionCheck'],
157152
]);
158153

159-
register_rest_route(Config::get('restApiNamespace'), '/get-menus', [
154+
register_rest_route(SK_REST_API_NS, '/get-menus', [
160155
'methods' => 'GET',
161156
'callback' => [$this, 'getMenus'],
162157
'permission_callback' => [$this, 'getMenusPermissionCheck'],

blocks/News/Block.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use StarterKit\Handlers\PostTypes;
88
use StarterKit\Handlers\Blocks\BlockAbstract;
99
use StarterKit\Helper\Config;
10-
use StarterKit\Exception\ConfigEntryNotFoundException;
1110
use StarterKit\Repository\NewsRepository;
1211
use Throwable;
1312
use WP_Error;
@@ -63,7 +62,6 @@ public function registerBlockArgs(): void
6362
*
6463
* @return string
6564
*
66-
* @throws ConfigEntryNotFoundException
6765
* @throws Throwable
6866
*/
6967
public function blockServerSideCallback(array $attributes, string $content, object $block): string
@@ -83,12 +81,10 @@ public function blockServerSideCallback(array $attributes, string $content, obje
8381
* Runs by Blocks Register Handler
8482
*
8583
* @return void
86-
*
87-
* @throws ConfigEntryNotFoundException
8884
*/
8985
public function blockRestApiEndpoints(): void
9086
{
91-
register_rest_route(Config::get('restApiNamespace'), '/news', [
87+
register_rest_route(SK_REST_API_NS, '/news', [
9288
'methods' => 'GET,POST',
9389
'callback' => [$this, 'getNewsCallback'],
9490
'permission_callback' => '__return_true',
@@ -101,8 +97,6 @@ public function blockRestApiEndpoints(): void
10197
* @param WP_REST_Request $request
10298
*
10399
* @return WP_Error|WP_REST_Response|WP_HTTP_Response
104-
*
105-
* @throws ConfigEntryNotFoundException
106100
*/
107101
public function getNewsCallback(WP_REST_Request $request): WP_Error|WP_REST_Response|WP_HTTP_Response
108102
{

blocks/PricingTable/Block.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
defined('ABSPATH') || exit;
66

77
use StarterKit\Handlers\Blocks\BlockAbstract;
8-
use StarterKit\Exception\ConfigEntryNotFoundException;
98
use StarterKit\Repository\PricingRepository;
109
use Throwable;
1110

@@ -57,7 +56,6 @@ public function registerBlockArgs(): void
5756
*
5857
* @return string
5958
*
60-
* @throws ConfigEntryNotFoundException
6159
* @throws Throwable
6260
*/
6361
public function blockServerSideCallback(array $attributes, string $content, object $block): string

src/Base/Constants.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,12 @@ public static function define(): void
2222
{
2323
define('SK_PREFIX', Config::get('settingsPrefix'));
2424
define('_SK_PREFIX', '_' . SK_PREFIX);
25+
define('SK_HOOKS_PREFIX', Config::get('hooksPrefix'));
26+
define('SK_REST_API_NS', Config::get('restApiNamespace'));
27+
define('SK_ASSETS_DIR', Config::get('assetsDir'));
28+
define('SK_ASSETS_URI', Config::get('assetsUri'));
29+
define('SK_BLOCKS_DIR', Config::get('blocksDir'));
30+
define('SK_BLOCKS_URI', Config::get('blocksUri'));
31+
define('SK_BLOCKS_VIEW_DIR', Config::get('blocksViewDir'));
2532
}
2633
}

src/Base/Hooks.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public static function initHooks(): void
8585
************************************/
8686
add_action('enqueue_block_assets', [Handlers\Front::class, 'enqueueCriticalAssets'], 2);
8787
add_filter(
88-
Config::get('hooksPrefix') . '/block_asset_dependencies',
88+
SK_HOOKS_PREFIX . '/block_asset_dependencies',
8989
[Handlers\Front::class, 'addThemeStyleDependencyToBlocks'],
9090
10,
9191
3

src/Handlers/Back.php

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
defined('ABSPATH') || exit;
66

7-
use StarterKit\Helper\Config;
8-
use StarterKit\Exception\ConfigEntryNotFoundException;
9-
107
/**
118
* Back End handler
129
*
@@ -18,30 +15,28 @@ class Back
1815
* Load assets in editor
1916
*
2017
* @return void
21-
*
22-
* @throws ConfigEntryNotFoundException
2318
*/
2419
public static function enqueueBlockEditorAssets(): void
2520
{
2621
$style = 'build/styles/editor.css';
2722

28-
$styleUri = Config::get('assetsUri') . $style;
29-
$stylePath = Config::get('assetsDir') . $style;
23+
$styleUri = SK_ASSETS_URI . $style;
24+
$stylePath = SK_ASSETS_DIR . $style;
3025

3126
wp_enqueue_style('theme-editor-style', $styleUri, [], filemtime($stylePath));
3227

3328
$editorScript = 'build/js/editor.js';
3429

35-
$editorScriptUri = Config::get('assetsUri') . $editorScript;
36-
$editorScriptPath = Config::get('assetsDir') . $editorScript;
30+
$editorScriptUri = SK_ASSETS_URI . $editorScript;
31+
$editorScriptPath = SK_ASSETS_DIR . $editorScript;
3732

3833
wp_enqueue_script('theme-editor-script', $editorScriptUri, [], filemtime($editorScriptPath), true);
3934

4035

4136
$style = 'build/fonts/block-icons/block-icons.font.css';
4237

43-
$styleUri = Config::get('assetsUri') . $style;
44-
$stylePath = Config::get('assetsDir') . $style;
38+
$styleUri = SK_ASSETS_URI . $style;
39+
$stylePath = SK_ASSETS_DIR . $style;
4540

4641
wp_enqueue_style('block-icons-style', $styleUri, [], filemtime($stylePath));
4742
}

src/Handlers/Blocks/BlockAbstract.php

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
use RuntimeException;
99
use StarterKit\App;
1010
use StarterKit\Error\ErrorHandler;
11-
use StarterKit\Helper\Config;
12-
use StarterKit\Exception\ConfigEntryNotFoundException;
1311
use StarterKit\Helper\Utils;
1412
use Throwable;
1513

@@ -46,9 +44,6 @@ abstract class BlockAbstract implements BlockInterface
4644
* Runs on 'init' hook
4745
*
4846
* @param $blockName
49-
*
50-
* @throws ConfigEntryNotFoundException
51-
* @throws Throwable
5247
*/
5348
public function __construct($blockName)
5449
{
@@ -70,13 +65,11 @@ public function __construct($blockName)
7065
* Add your server side render callback into $this->blockArgs
7166
*
7267
* @return void
73-
*
74-
* @throws ConfigEntryNotFoundException
7568
*/
7669
public function registerBlock(): void
7770
{
7871
register_block_type_from_metadata(
79-
Config::get('blocksDir') . $this->blockName,
72+
SK_BLOCKS_DIR . $this->blockName,
8073
$this->blockArgs
8174
);
8275
}
@@ -91,13 +84,12 @@ public function registerBlock(): void
9184
*
9285
* @return string
9386
*
94-
* @throws ConfigEntryNotFoundException
9587
* @throws Throwable
9688
*/
9789
public function loadBlockView(string $file = '', array $data = [], string $base = null, bool $echo = false): string
9890
{
9991
if ($base === null) {
100-
$base = Config::get('blocksDir') . $this->blockName . '/' . Config::get('blocksViewDir');
92+
$base = SK_BLOCKS_DIR . $this->blockName . '/' . SK_BLOCKS_VIEW_DIR;
10193
}
10294

10395
$viewFilePath = $base . $file . '.php';
@@ -191,14 +183,11 @@ public function generateSpacersClasses(array $spacers): array
191183
* Use $blockAssets property instead
192184
*
193185
* @return void
194-
*
195-
* @throws ConfigEntryNotFoundException
196-
* @throws Throwable
197186
*/
198187
public function registerBlockAssets(): void
199188
{
200-
$blockUri = Config::get('blocksUri') . $this->blockName . '/build/';
201-
$blockDir = Config::get('blocksDir') . $this->blockName . '/build/';
189+
$blockUri = SK_BLOCKS_URI . $this->blockName . '/build/';
190+
$blockDir = SK_BLOCKS_DIR . $this->blockName . '/build/';
202191

203192
foreach ($this->blockAssets as $type => $asset) {
204193
if (empty($asset['file'])) {
@@ -212,7 +201,7 @@ public function registerBlockAssets(): void
212201
* Filter block asset dependencies
213202
*/
214203
$deps = apply_filters(
215-
Config::get('hooksPrefix') . '/block_asset_dependencies',
204+
SK_HOOKS_PREFIX . '/block_asset_dependencies',
216205
$asset['dependencies'],
217206
$this->blockName,
218207
$type

src/Handlers/Blocks/Init.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ public static function loadBlocksCategories(array $categories): array
4646
*
4747
* @return void
4848
*
49-
* @throws ConfigEntryNotFoundException
5049
* @throws Throwable
5150
*/
5251
public static function loadBlocks(): void
@@ -55,7 +54,7 @@ public static function loadBlocks(): void
5554
return;
5655
}
5756

58-
$blocks = glob(Config::get('blocksDir') . '*', GLOB_ONLYDIR);
57+
$blocks = glob(SK_BLOCKS_DIR . '*', GLOB_ONLYDIR);
5958

6059
foreach ($blocks as $blockPath) {
6160
$blockName = basename($blockPath);

0 commit comments

Comments
 (0)