Skip to content

Commit

Permalink
feat(initialize): new filter for class instance
Browse files Browse the repository at this point in the history
  • Loading branch information
Mte90 committed Feb 6, 2024
1 parent 7eea83d commit 99a2b35
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
6 changes: 6 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 3.3.3

* Enhancement: New filter on \Initialize to get the class instance
* Updated: CS changes
* Updated: to latest libraries changes

## 3.3.2

* Enhancement: Tests use a dedicated .env file instead to manipulate the env file (GitHub/GitLab CI updated)
Expand Down
2 changes: 1 addition & 1 deletion plugin-name/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"cmb2/cmb2": "2.9.*",
"composer/installers": "1.x",
"decodelabs/tagged": "^0.11.9",
"freemius/wordpress-sdk": "2.5.*",
"freemius/wordpress-sdk": "2.6.*",
"inpsyde/assets": "^2.8",
"inpsyde/wp-context": "1.3.*",
"johnbillion/extended-cpts": "4.5.*",
Expand Down
8 changes: 7 additions & 1 deletion plugin-name/engine/Initialize.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ private function load_classes() {
} catch ( \Throwable $err ) {
\do_action( 'plugin_name_initialize_failed', $err );

if ( WP_DEBUG ) {
if ( \WP_DEBUG ) {
throw new \Exception( $err->getMessage() ); //phpcs:ignore
}
}
Expand All @@ -121,6 +121,12 @@ private function initialize_plugin_class( $classtovalidate ) {
}

$temp = new $classtovalidate;
\add_filter(
'plugin_name_instance_' . $classtovalidate,
function() use ( $temp ) {
return $temp;
}
);

if ( !\method_exists( $temp, 'initialize' ) ) {
return;
Expand Down

0 comments on commit 99a2b35

Please sign in to comment.