Skip to content

Commit 045db1b

Browse files
committed
fix: phpstan fixes and simplification
1 parent 4303053 commit 045db1b

File tree

1 file changed

+14
-41
lines changed

1 file changed

+14
-41
lines changed

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

Lines changed: 14 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,11 @@
22

33
namespace HWP\Previews\Integration;
44

5-
use HWP\Previews\Admin\Settings\Helper\Settings_Helper;
65
use HWP\Previews\Admin\Settings\Helper\Settings_Group;
76
use HWP\Previews\Post\Type\Contracts\Post_Types_Config_Interface;
87
use HWP\Previews\Post\Type\Post_Types_Config_Registry;
98

109
class Faust_Integration {
11-
/**
12-
* Post types configuration.
13-
*
14-
* @var Post_Types_Config_Interface|null
15-
*/
16-
protected static ?Post_Types_Config_Interface $types_config = null;
17-
18-
/**
19-
* Settings helper instance that provides access to plugin settings.
20-
*
21-
* @var Settings_Helper|null
22-
*/
23-
protected static ?Settings_Helper $settings_helper = null;
24-
25-
/**
26-
* Settings group instance that provides access to plugin settings.
27-
*
28-
* @var Settings_Group|null
29-
*/
30-
protected static ?Settings_Group $settings_group = null;
31-
3210
/**
3311
* Whether Faust is enabled.
3412
*/
@@ -38,21 +16,9 @@ class Faust_Integration {
3816
* Initialize the hooks for the preview functionality.
3917
*/
4018
public static function init(): void {
41-
self::init_class_properties();
42-
self::configure_faust();
43-
}
44-
45-
public static function init_class_properties(): void {
46-
self::$settings_helper = Settings_Helper::get_instance();
19+
self::$faust_enabled = self::is_faust_enabled();
4720

48-
self::$settings_group = Settings_Group::get_instance();
49-
50-
self::$types_config = apply_filters(
51-
'hwp_previews_hooks_post_type_config',
52-
Post_Types_Config_Registry::get_post_type_config()
53-
);
54-
55-
self::$faust_enabled = self::is_faust_enabled();
21+
self::configure_faust();
5622
}
5723

5824
public static function configure_faust(): void {
@@ -105,15 +71,22 @@ public static function get_faust_preview_url(): string {
10571
* Sets default Faust settings if there are no existing settings.
10672
*/
10773
public static function set_default_faust_settings(): void {
108-
$plugin_settings = self::$settings_group->get_cached_settings();
74+
$settings_group = Settings_Group::get_instance();
75+
$types_config = apply_filters(
76+
'hwp_previews_hooks_post_type_config',
77+
Post_Types_Config_Registry::get_post_type_config()
78+
);
79+
80+
81+
$plugin_settings = $settings_group->get_cached_settings();
10982

11083
if( empty($plugin_settings) ) {
111-
$setting_preview_key = self::$settings_group->get_settings_key_preview_url();
112-
$setting_enabled_key = self::$settings_group->get_settings_key_enabled();
84+
$setting_preview_key = $settings_group->get_settings_key_preview_url();
85+
$setting_enabled_key = $settings_group->get_settings_key_enabled();
11386

11487
$default_settings = array();
11588

116-
foreach ( self::$types_config->get_public_post_types() as $key => $label ) {
89+
foreach ( $types_config->get_public_post_types() as $key => $label ) {
11790
$default_settings[$key] = array(
11891
$setting_enabled_key => true,
11992
$setting_preview_key => self::get_faust_preview_url(),
@@ -139,7 +112,7 @@ public static function faust_admin_notice(): void {
139112
$screen = get_current_screen();
140113

141114
// Exit if not this plugin's settings page.
142-
if ( 'settings_page_hwp-previews' !== $screen->id ) {
115+
if ( ! is_object( $screen ) || 'settings_page_hwp-previews' !== $screen->id ) {
143116
return;
144117
}
145118
?>

0 commit comments

Comments
 (0)