From dba9f905b121090ba17ed8fd2040aba4224c6748 Mon Sep 17 00:00:00 2001 From: KJ Roelke Date: Sat, 11 Apr 2026 22:17:22 -0500 Subject: [PATCH] add plugin handler and use it to add acf handler back into theme bootstrap --- CHANGELOG.md | 6 +++- inc/plugins/{acf => }/class-acf-handler.php | 10 ++---- inc/theme/class-plugin-handler.php | 34 +++++++++++++++++++++ inc/theme/class-theme-init.php | 4 ++- 4 files changed, 44 insertions(+), 10 deletions(-) rename inc/plugins/{acf => }/class-acf-handler.php (90%) create mode 100644 inc/theme/class-plugin-handler.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 39580f1..3f43e00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog -## 3.0.0 - [April 11, 2026] +## 3.0.1 - [April 11, 2026] + +- Fixed: Add plugin handling back into the theme init + +## 3.0.0 - Breaking: Swap to autoloading classes - Added: PMPro handler diff --git a/inc/plugins/acf/class-acf-handler.php b/inc/plugins/class-acf-handler.php similarity index 90% rename from inc/plugins/acf/class-acf-handler.php rename to inc/plugins/class-acf-handler.php index 1fa7286..c7cb1ec 100644 --- a/inc/plugins/acf/class-acf-handler.php +++ b/inc/plugins/class-acf-handler.php @@ -31,10 +31,6 @@ class ACF_Handler { * Constructor function that initializes the ACF Handler. */ public function __construct() { - if ( ! defined( 'ACF_VERSION' ) ) { - return; - } - $this->base_path = get_stylesheet_directory() . '/inc/plugins/acf/acf-fields/'; $this->paths_array = array( 'field-group' => 'fields', @@ -42,14 +38,12 @@ public function __construct() { 'taxonomy' => 'taxonomies', 'ui-options-page' => 'options', ); - $this->init_save_filters(); - add_filter( 'acf/settings/load_json', array( $this, 'load_json_paths' ) ); } /** * Loops through the paths array and adds filters to save ACF JSON files */ - private function init_save_filters() { + public function init_save_filters() { foreach ( $this->paths_array as $slug => $dir ) { add_filter( 'acf/settings/save_json/type=acf-' . $slug, @@ -82,4 +76,4 @@ public function load_json_paths( array $paths ): array { $paths = array_map( fn( $dir ) => $this->base_path . $dir, array_values( $this->paths_array ) ); return $paths; } -} \ No newline at end of file +} diff --git a/inc/theme/class-plugin-handler.php b/inc/theme/class-plugin-handler.php new file mode 100644 index 0000000..6f67913 --- /dev/null +++ b/inc/theme/class-plugin-handler.php @@ -0,0 +1,34 @@ +handle_acf(); + } + + /** + * Handle ACF by checking if it is defined and initializing the ACF Handler. + */ + private function handle_acf() { + if ( ! defined( 'ACF_VERSION' ) ) { + return; + } + $acf_handler = new ACF_Handler(); + $acf_handler->init_save_filters(); + add_filter( 'acf/settings/load_json', array( $acf_handler, 'load_json_paths' ) ); + } +} diff --git a/inc/theme/class-theme-init.php b/inc/theme/class-theme-init.php index 0fc16f7..80275f1 100644 --- a/inc/theme/class-theme-init.php +++ b/inc/theme/class-theme-init.php @@ -19,6 +19,8 @@ class Theme_Init { public function bootstrap_theme() { $this->disable_discussion(); $this->configure_theme_support(); + $plugin_handler = new Plugin_Handler(); + $plugin_handler->handle_plugins(); add_action( 'init', array( $this, 'alter_post_types' ) ); add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); add_filter( 'wp_speculation_rules_configuration', array( $this, 'handle_speculative_loading' ) ); @@ -132,4 +134,4 @@ public function handle_speculative_loading( $config ) { } return $config; } -} \ No newline at end of file +}