From 104c57e867e944d5436e3940455d4ba449103388 Mon Sep 17 00:00:00 2001 From: Vedant Gandhi Date: Fri, 15 Nov 2024 12:49:59 +0530 Subject: [PATCH 1/4] fix: move settings tab in admin to separate function and initialize it on init hook. --- admin/class-nginx-helper-admin.php | 11 +++++++++-- includes/class-nginx-helper.php | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/admin/class-nginx-helper-admin.php b/admin/class-nginx-helper-admin.php index 46b04c7..ed40f3a 100644 --- a/admin/class-nginx-helper-admin.php +++ b/admin/class-nginx-helper-admin.php @@ -78,6 +78,14 @@ public function __construct( $plugin_name, $version ) { $this->plugin_name = $plugin_name; $this->version = $version; + $this->options = $this->nginx_helper_settings(); + } + + /** + * Initialize the settings tab. + * Required since i18n is used in the settings tab which can be invoked only after init hook since WordPress 6.7 + */ + public function initialize_setting_tab() { /** * Define settings tabs */ @@ -94,10 +102,9 @@ public function __construct( $plugin_name, $version ) { ), ) ); - - $this->options = $this->nginx_helper_settings(); } + /** * Register the stylesheets for the admin area. * diff --git a/includes/class-nginx-helper.php b/includes/class-nginx-helper.php index 71cb137..2922cd4 100644 --- a/includes/class-nginx-helper.php +++ b/includes/class-nginx-helper.php @@ -169,7 +169,7 @@ private function define_admin_hooks() { global $nginx_helper_admin, $nginx_purger; $nginx_helper_admin = new Nginx_Helper_Admin( $this->get_plugin_name(), $this->get_version() ); - + $this->loader->add_action( 'init', $nginx_helper_admin, 'initialize_setting_tab' ); // Defines global variables. if ( ! empty( $nginx_helper_admin->options['cache_method'] ) && 'enable_redis' === $nginx_helper_admin->options['cache_method'] ) { From 87e780d3d637a42343c505984ff5654b62c9dc87 Mon Sep 17 00:00:00 2001 From: Vedant Gandhi Date: Fri, 15 Nov 2024 14:13:00 +0530 Subject: [PATCH 2/4] refactor: add proper tab in function description. --- admin/class-nginx-helper-admin.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/admin/class-nginx-helper-admin.php b/admin/class-nginx-helper-admin.php index ed40f3a..0fa36c5 100644 --- a/admin/class-nginx-helper-admin.php +++ b/admin/class-nginx-helper-admin.php @@ -83,9 +83,10 @@ public function __construct( $plugin_name, $version ) { /** * Initialize the settings tab. - * Required since i18n is used in the settings tab which can be invoked only after init hook since WordPress 6.7 + * Required since i18n is used in the settings tab which can be invoked only after init hook since WordPress 6.7 */ public function initialize_setting_tab() { + /** * Define settings tabs */ From 273aa68dff246c05f0e0509e1f6f94c98860d59a Mon Sep 17 00:00:00 2001 From: Vedant Gandhi Date: Mon, 18 Nov 2024 16:15:23 +0530 Subject: [PATCH 3/4] refactor: remove extra space. --- admin/class-nginx-helper-admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/class-nginx-helper-admin.php b/admin/class-nginx-helper-admin.php index 0fa36c5..cf5b9e1 100644 --- a/admin/class-nginx-helper-admin.php +++ b/admin/class-nginx-helper-admin.php @@ -104,7 +104,7 @@ public function initialize_setting_tab() { ) ); } - + /** * Register the stylesheets for the admin area. From 687c116d1f7aaf700797eb24b65221637e89b5b0 Mon Sep 17 00:00:00 2001 From: Vedant Gandhi Date: Mon, 18 Nov 2024 16:16:14 +0530 Subject: [PATCH 4/4] refactor: remove extra space. --- admin/class-nginx-helper-admin.php | 1 - 1 file changed, 1 deletion(-) diff --git a/admin/class-nginx-helper-admin.php b/admin/class-nginx-helper-admin.php index cf5b9e1..5ecd8bf 100644 --- a/admin/class-nginx-helper-admin.php +++ b/admin/class-nginx-helper-admin.php @@ -104,7 +104,6 @@ public function initialize_setting_tab() { ) ); } - /** * Register the stylesheets for the admin area.