diff --git a/src/Plugin/HookableParent.php b/src/Plugin/HookableParent.php index 937ff77efe5ba9c3528e69c3fd78586369e9db34..5aca3784d46ede75c9938c0248f5fd0c8c9b605f 100644 --- a/src/Plugin/HookableParent.php +++ b/src/Plugin/HookableParent.php @@ -23,6 +23,22 @@ trait HookableParent { $this->hookable_objects[] = $hookable_object; } + /** + * Get hookable instance. + * + * @param string $class_name Class name. + * + * @return false|Hookable + */ + public function get_hookable_instance_by_class_name( $class_name ) { + foreach ( $this->hookable_objects as $hookable_object ) { + if ( $hookable_object instanceof $class_name ) { + return $hookable_object; + } + } + return false; + } + /** * Run hooks method on all hookable objects. */