Skip to content

Commit b599c77

Browse files
committed
fix: linter fixes
1 parent 6fa9c6a commit b599c77

File tree

1 file changed

+32
-26
lines changed

1 file changed

+32
-26
lines changed

plugins/hwp-previews/src/Integration/Faust_Integration.php

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace HWP\Previews\Integration;
46

57
use HWP\Previews\Admin\Settings\Helper\Settings_Group;
6-
use HWP\Previews\Post\Type\Contracts\Post_Types_Config_Interface;
78
use HWP\Previews\Post\Type\Post_Types_Config_Registry;
89

910
class Faust_Integration {
1011
/**
1112
* Whether Faust is enabled.
1213
*/
13-
protected static bool $faust_enabled = false;
14+
protected static bool $faust_enabled = false;
1415

1516
/**
1617
* Initialize the hooks for the preview functionality.
@@ -21,15 +22,18 @@ public static function init(): void {
2122
self::configure_faust();
2223
}
2324

25+
/**
26+
* Configure Faust settings and remove conflicting filters.
27+
*/
2428
public static function configure_faust(): void {
25-
if(self::$faust_enabled) {
29+
if ( self::$faust_enabled ) {
2630
self::set_default_faust_settings();
2731

2832
// Remove FaustWP post preview link filter to avoid conflicts with our custom preview link generation.
29-
remove_filter('preview_post_link', 'WPE\FaustWP\Replacement\post_preview_link', 1000);
33+
remove_filter( 'preview_post_link', 'WPE\FaustWP\Replacement\post_preview_link', 1000 );
3034

3135
self::faust_admin_notice();
32-
}
36+
}
3337
}
3438

3539
/**
@@ -49,8 +53,8 @@ public static function is_faust_enabled(): bool {
4953
public static function get_faust_frontend_url(): string {
5054
$default_value = 'http://localhost:3000';
5155

52-
if ( self::$faust_enabled && function_exists('\WPE\FaustWP\Settings\faustwp_get_setting') ) {
53-
$frontend_uri = \WPE\FaustWP\Settings\faustwp_get_setting('frontend_uri', '');
56+
if ( self::$faust_enabled && function_exists( '\WPE\FaustWP\Settings\faustwp_get_setting' ) ) {
57+
$frontend_uri = \WPE\FaustWP\Settings\faustwp_get_setting( 'frontend_uri', '' );
5458

5559
if ( ! empty( $frontend_uri ) ) {
5660
return $frontend_uri;
@@ -64,37 +68,39 @@ public static function get_faust_frontend_url(): string {
6468
* Get default preview URL for Faust.
6569
*/
6670
public static function get_faust_preview_url(): string {
67-
return self::get_faust_frontend_url() . "/preview?p={ID}&preview=true&previewPathname=p{ID}&typeName={type}";
71+
return self::get_faust_frontend_url() . '/preview?p={ID}&preview=true&previewPathname=p{ID}&typeName={type}';
6872
}
6973

7074
/**
7175
* Sets default Faust settings if there are no existing settings.
7276
*/
7377
public static function set_default_faust_settings(): void {
7478
$settings_group = Settings_Group::get_instance();
75-
$types_config = apply_filters(
79+
$types_config = apply_filters(
7680
'hwp_previews_hooks_post_type_config',
7781
Post_Types_Config_Registry::get_post_type_config()
7882
);
7983

8084

81-
$plugin_settings = $settings_group->get_cached_settings();
85+
$plugin_settings = $settings_group->get_cached_settings();
8286

83-
if( empty($plugin_settings) ) {
84-
$setting_preview_key = $settings_group->get_settings_key_preview_url();
85-
$setting_enabled_key = $settings_group->get_settings_key_enabled();
87+
if ( ! empty( $plugin_settings ) ) {
88+
return;
89+
}
90+
91+
$setting_preview_key = $settings_group->get_settings_key_preview_url();
92+
$setting_enabled_key = $settings_group->get_settings_key_enabled();
8693

87-
$default_settings = array();
88-
89-
foreach ( $types_config->get_public_post_types() as $key => $label ) {
90-
$default_settings[$key] = array(
91-
$setting_enabled_key => true,
92-
$setting_preview_key => self::get_faust_preview_url(),
93-
);
94-
}
94+
$default_settings = [];
95+
96+
foreach ( $types_config->get_public_post_types() as $key => $label ) {
97+
$default_settings[ $key ] = [
98+
$setting_enabled_key => true,
99+
$setting_preview_key => self::get_faust_preview_url(),
100+
];
101+
}
95102

96-
update_option(HWP_PREVIEWS_SETTINGS_KEY, $default_settings);
97-
}
103+
update_option( HWP_PREVIEWS_SETTINGS_KEY, $default_settings );
98104
}
99105

100106
/**
@@ -104,11 +110,11 @@ public static function set_default_faust_settings(): void {
104110
public static function faust_admin_notice(): void {
105111

106112
// Exit if Faust is not enabled.
107-
if( ! self::$faust_enabled ) {
113+
if ( ! self::$faust_enabled ) {
108114
return;
109115
}
110116

111-
add_action( 'admin_notices', function(): void {
117+
add_action( 'admin_notices', static function (): void {
112118
$screen = get_current_screen();
113119

114120
// Exit if not this plugin's settings page.
@@ -118,7 +124,7 @@ public static function faust_admin_notice(): void {
118124
?>
119125

120126
<div class="notice notice-info">
121-
<p><?php esc_html_e( 'HWP Previews is automatically configured to support Faust previews on the front end. However, you can still customize it to fit your needs.', HWP_PREVIEWS_TEXT_DOMAIN ); ?></p>
127+
<p><?php esc_html_e( 'HWP Previews is automatically configured to support Faust previews on the front end. However, you can still customize it to fit your needs.', 'hwp-previews' ); ?></p>
122128
</div>
123129

124130
<?php

0 commit comments

Comments
 (0)