Skip to content

Commit

Permalink
chore: fix code style
Browse files Browse the repository at this point in the history
  • Loading branch information
suabahasa committed Sep 13, 2024
1 parent 86affdd commit 5075c11
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 16 deletions.
12 changes: 7 additions & 5 deletions src/Api/Admin/Volume.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@

class Volume extends AbstractApi implements ApiInterface
{
public function __construct() {}
public function __construct()
{
}

public function get_prefix(): string
{
Expand All @@ -36,8 +38,8 @@ public function register_custom_endpoints(): void
$this->get_prefix() . '/index',
[
'methods' => WP_REST_Server::READABLE,
'callback' => fn(\WP_REST_Request $wprestRequest): \WP_REST_Response => $this->index($wprestRequest),
'permission_callback' => fn(\WP_REST_Request $wprestRequest): bool => $this->permission_callback($wprestRequest),
'callback' => fn (\WP_REST_Request $wprestRequest): \WP_REST_Response => $this->index($wprestRequest),
'permission_callback' => fn (\WP_REST_Request $wprestRequest): bool => $this->permission_callback($wprestRequest),
]
);

Expand All @@ -46,8 +48,8 @@ public function register_custom_endpoints(): void
$this->get_prefix() . '/store',
[
'methods' => WP_REST_Server::CREATABLE,
'callback' => fn(\WP_REST_Request $wprestRequest): \WP_REST_Response => $this->store($wprestRequest),
'permission_callback' => fn(\WP_REST_Request $wprestRequest): bool => $this->permission_callback($wprestRequest),
'callback' => fn (\WP_REST_Request $wprestRequest): \WP_REST_Response => $this->store($wprestRequest),
'permission_callback' => fn (\WP_REST_Request $wprestRequest): bool => $this->permission_callback($wprestRequest),
]
);
}
Expand Down
18 changes: 12 additions & 6 deletions src/Core/Runtime.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,16 @@ class Runtime
* The Singleton's constructor should always be private to prevent direct
* construction calls with the `new` operator.
*/
private function __construct() {}
private function __construct()
{
}

/**
* Singletons should not be cloneable.
*/
private function __clone() {}
private function __clone()
{
}

/**
* Singletons should not be restorable from strings.
Expand Down Expand Up @@ -89,17 +93,17 @@ public function append_header()
$is_exclude_admin = apply_filters('f!windpress/core/runtime:append_header.exclude_admin', $is_exclude_admin);

if ($is_cache_enabled && $this->is_cache_exists() && ! $is_exclude_admin) {
add_action('wp_head', fn() => $this->enqueue_css_cache(), 1_000_001);
add_action('wp_head', fn () => $this->enqueue_css_cache(), 1_000_001);
} else {
add_action('wp_head', fn() => $this->enqueue_play_cdn(), 1_000_001);
add_action('wp_head', fn () => $this->enqueue_play_cdn(), 1_000_001);
}

if (
Config::get('general.ubiquitous-panel.enabled', true)
&& current_user_can('manage_options')
&& ! apply_filters('f!windpress/core/runtime:append_header.ubiquitous_panel.is_prevent_load', false)
) {
add_action('wp_head', fn() => $this->enqueue_front_panel(), 1_000_001);
add_action('wp_head', fn () => $this->enqueue_front_panel(), 1_000_001);
}
}

Expand Down Expand Up @@ -136,7 +140,9 @@ public function enqueue_css_cache()

public function enqueue_play_cdn($display = true)
{
$volumeEntries = array_reduce(Volume::get_entries(), fn($carry, $entry) => $carry + ['/' . $entry['relative_path'] => $entry['content']], []);
$volumeEntries = array_reduce(Volume::get_entries(), fn ($carry, $entry) => $carry + [
'/' . $entry['relative_path'] => $entry['content'],
], []);

// Script content are base64 encoded to prevent it from being executed by the browser.
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
Expand Down
6 changes: 3 additions & 3 deletions src/Core/Volume.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static function get_entries(): array
$stubs_main_css = file_get_contents(dirname(WIND_PRESS::FILE) . '/stubs/main.css');

// check if 'main.css' already exists and content is not empty, else use the stubs
$main_css_key = array_search('main.css', array_column($entries, 'name'));
$main_css_key = array_search('main.css', array_column($entries, 'name'), true);

if ($main_css_key === false) {
$entries[] = [
Expand Down Expand Up @@ -106,7 +106,7 @@ public static function save_entries($entries)
do_action('f!windpress/core/volume:save_entries.entry', $entry);

// use specific handler instead for efficient handling
do_action("f!windpress/core/volume:save_entries.entry.{$entry['handler']}", $entry);
do_action('f!windpress/core/volume:save_entries.entry.' . $entry['handler'], $entry);
}

continue;
Expand All @@ -122,7 +122,7 @@ public static function save_entries($entries)
continue;
}

$entry['relative_path'] = "custom/{$file_name}";
$entry['relative_path'] = 'custom/' . $file_name;

$entry['signature'] = wp_create_nonce(sprintf('%s:%s', WIND_PRESS::WP_OPTION, $entry['relative_path']));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Integration/Bricks/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __construct()
add_filter('f!windpress/core/runtime:is_prevent_load', fn (bool $is_prevent_load): bool => $this->is_prevent_load($is_prevent_load));
add_filter('f!windpress/core/runtime:append_header.ubiquitous_panel.is_prevent_load', fn (bool $is_prevent_load): bool => $this->is_prevent_load($is_prevent_load));
add_filter('f!windpress/core/runtime:append_header.exclude_admin', fn (bool $is_exclude_admin): bool => $this->is_exclude_admin($is_exclude_admin));

new Editor();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Utils/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public static function save_file($content, string $file_path, int $flags = 0): v
/**
* Deletes a file or directory.
*
* @param string $file Path to the file or directory.
* @param string $file_path Path to the file or directory.
* @param bool $recursive Optional. If set to true, deletes files and folders recursively.
* Default false.
* @param string|false $type Type of resource. 'f' for file, 'd' for directory.
Expand Down

0 comments on commit 5075c11

Please sign in to comment.