The main function to return the Torro Forms instance.
Description
Any extension can use this function to access the main plugin object or to simply check whether the plugin is active and running. Example:
if ( function_exists( 'torro' ) && torro() ) { // Do custom extension stuff. }
Return
(Torro_Forms|null) The Torro Forms instance, or null on failure.
Source
File: torro-forms.php
function torro() { if ( ! class_exists( 'Torro_Forms' ) ) { $main_file = __FILE__; $basedir_relative = ''; $file = wp_normalize_path( $main_file ); $mu_plugin_dir = wp_normalize_path( WPMU_PLUGIN_DIR ); if ( preg_match( '#^' . preg_quote( $mu_plugin_dir, '#' ) . '/#', $file ) && file_exists( $mu_plugin_dir . '/torro-forms.php' ) ) { $basedir_relative = 'torro-forms/'; } if ( ! class_exists( 'Leaves_And_Love_Plugin_Loader' ) ) { $locations = array( plugin_dir_path( $main_file ) . $basedir_relative . 'vendor/felixarntz/plugin-lib/plugin-loader.php', $mu_plugin_dir . '/plugin-lib/plugin-loader.php', dirname( ABSPATH ) . '/vendor/felixarntz/plugin-lib/plugin-loader.php', dirname( dirname( ABSPATH ) ) . '/vendor/felixarntz/plugin-lib/plugin-loader.php', ); foreach ( $locations as $location ) { if ( file_exists( $location ) ) { require_once $location; break; } } } require_once plugin_dir_path( $main_file ) . $basedir_relative . 'src/torro-forms.php'; Leaves_And_Love_Plugin_Loader::load( 'Torro_Forms', $main_file, $basedir_relative ); } $torro = Leaves_And_Love_Plugin_Loader::get( 'Torro_Forms' ); if ( is_wp_error( $torro ) ) { return null; } return $torro; }
Changelog
Version | Description |
---|---|
1.0.0 | Introduced. |