tribe_get_class_instance( string|object $class )
Gets the class instance / Tribe Container from the passed object or string.
Contents
See also
Parameters
- $class
-
(string|object) (Required) The plugin class' singleton name, class name, or instance.
Return
(mixed|object|Tribe__Container|null) Null if not found, else the result from tribe().
Source
File: src/functions/utils.php
function tribe_get_class_instance( $class ) { if ( is_object( $class ) ) { return $class; } if ( ! is_string( $class ) ) { return null; } // Check if class exists and has instance getter method. if ( class_exists( $class ) ) { if ( method_exists( $class, 'instance' ) ) { return $class::instance(); } if ( method_exists( $class, 'get_instance' ) ) { return $class::get_instance(); } } try { return tribe( $class ); } catch ( \RuntimeException $exception ) { return null; } }
Changelog
Version | Description |
---|---|
4.10.0 | Introduced. |