forked from awsmug/torro-forms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
torro-forms.php
97 lines (86 loc) · 2.81 KB
/
torro-forms.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
/**
* Plugin initialization file
*
* @package TorroForms
* @since 1.0.0
*
* @wordpress-plugin
* Plugin Name: Torro Forms
* Plugin URI: https://torro-forms.com
* Description: Torro Forms is an extendable WordPress form builder with Drag & Drop functionality, chart evaluation and more - with WordPress look and feel.
* Version: 1.0.16
* Author: Awesome UG
* Author URI: https://www.awesome.ug
* License: GNU General Public License v2 (or later)
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: torro-forms
* Tags: forms, form builder, surveys, polls, votes, charts, api
*/
defined( 'ABSPATH' ) || exit;
/**
* The main function to return the Torro Forms instance.
*
* 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.
* }
* `
*
* @since 1.0.0
*
* @return Torro_Forms|null The Torro Forms instance, or null on failure.
*/
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;
}
/**
* Executes a callback after Torro Forms has been initialized.
*
* This function should be used by all Torro Forms extensions to initialize themselves.
*
* This doc block was added in the 1500th commit :)
*
* @since 1.0.0
*
* @param callable $callback Callback to bootstrap the extension.
*/
function torro_load( $callback ) {
if ( did_action( 'torro_loaded' ) || doing_action( 'torro_loaded' ) ) {
call_user_func( $callback, torro() );
return;
}
add_action( 'torro_loaded', $callback, 10, 1 );
}
torro();