forked from CalderaWP/Caldera-Forms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
caldera-core.php
executable file
·186 lines (160 loc) · 6.99 KB
/
caldera-core.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<?php
/*
Plugin Name: Caldera Forms
Plugin URI: https://CalderaForms.com
Description: Easy to use, grid based responsive form builder for creating simple to complex forms.
Author: Caldera Labs
Version: 1.7.6
Author URI: http://CalderaLabs.org
Text Domain: caldera-forms
GitHub Plugin URI: https://github.com/CalderaWP/caldera-forms
*/
// If this file is called directly, abort.
if (!defined('WPINC')) {
die;
}
global $wp_version;
if (!version_compare(PHP_VERSION, '5.6.0', '>=')) {
function caldera_forms_php_version_nag()
{
?>
<div class="notice notice-error">
<p>
<?php _e('Your version of PHP is incompatible with Caldera Forms and can not be used.', 'caldera-forms'); ?>
<?php printf(' <a href="https://calderaforms.com/php?utm_source=wp-admin&utm_campaign=php_deprecated&utm_source=admin-nag" target="__blank">%s</a>',
esc_html__('Learn More', 'caldera-forms')
) ?></p>
</div>
<?php
}
add_shortcode('caldera_form', 'caldera_forms_fallback_shortcode');
add_shortcode('caldera_form_modal', 'caldera_forms_fallback_shortcode');
add_action('admin_notices', 'caldera_forms_php_version_nag');
} elseif (!version_compare($wp_version, '4.7.0', '>=')) {
function caldera_forms_wp_version_nag()
{
?>
<div class="notice notice-error">
<p>
<?php _e('Your version of WordPress is incompatible with Caldera Forms and can not be used.', 'caldera-forms'); ?>
</p>
</div>
<?php
}
add_shortcode('caldera_form', 'caldera_forms_fallback_shortcode');
add_shortcode('caldera_form_modal', 'caldera_forms_fallback_shortcode');
add_action('admin_notices', 'caldera_forms_wp_version_nag');
} else {
define('CFCORE_PATH', plugin_dir_path(__FILE__));
define('CFCORE_URL', plugin_dir_url(__FILE__));
define( 'CFCORE_VER', '1.7.6' );
define('CFCORE_EXTEND_URL', 'https://api.calderaforms.com/1.0/');
define('CFCORE_BASENAME', plugin_basename(__FILE__));
/**
* Caldera Forms DB version
*
* @since 1.3.4
*
* PLEASE keep this an integer
*/
define('CF_DB', 7);
// init internals of CF
include_once CFCORE_PATH . 'classes/core.php';
add_action('init', array('Caldera_Forms', 'init_cf_internal'));
// table builder
register_activation_hook(__FILE__, array('Caldera_Forms', 'activate_caldera_forms'));
// load system
add_action('plugins_loaded', 'caldera_forms_load', 0);
function caldera_forms_load()
{
include_once CFCORE_PATH . 'classes/autoloader.php';
include_once CFCORE_PATH . 'classes/widget.php';
Caldera_Forms_Autoloader::add_root('Caldera_Forms_DB', CFCORE_PATH . 'classes/db');
Caldera_Forms_Autoloader::add_root('Caldera_Forms_Entry', CFCORE_PATH . 'classes/entry');
Caldera_Forms_Autoloader::add_root('Caldera_Forms_Email', CFCORE_PATH . 'classes/email');
Caldera_Forms_Autoloader::add_root('Caldera_Forms_Admin', CFCORE_PATH . 'classes/admin');
Caldera_Forms_Autoloader::add_root('Caldera_Forms_Render', CFCORE_PATH . 'classes/render');
Caldera_Forms_Autoloader::add_root('Caldera_Forms_Sync', CFCORE_PATH . 'classes/sync');
Caldera_Forms_Autoloader::add_root('Caldera_Forms_CSV', CFCORE_PATH . 'classes/csv');
Caldera_Forms_Autoloader::add_root('Caldera_Forms_Processor_Interface', CFCORE_PATH . 'processors/classes/interfaces');
Caldera_Forms_Autoloader::add_root('Caldera_Forms_API', CFCORE_PATH . 'classes/api');
Caldera_Forms_Autoloader::add_root('Caldera_Forms_Field', CFCORE_PATH . 'classes/field');
Caldera_Forms_Autoloader::add_root('Caldera_Forms_Magic', CFCORE_PATH . 'classes/magic');
Caldera_Forms_Autoloader::add_root('Caldera_Forms_Processor', CFCORE_PATH . 'processors/classes');
Caldera_Forms_Autoloader::add_root('Caldera_Forms_Shortcode', CFCORE_PATH . 'classes/shortcode');
Caldera_Forms_Autoloader::add_root('Caldera_Forms_CDN', CFCORE_PATH . 'classes/cdn');
Caldera_Forms_Autoloader::add_root('Caldera_Forms_Settings', CFCORE_PATH . 'classes/settings');
Caldera_Forms_Autoloader::add_root('Caldera_Forms_Import', CFCORE_PATH . 'classes/import');
Caldera_Forms_Autoloader::add_root('Caldera_Forms_Query', CFCORE_PATH . 'classes/query');
Caldera_Forms_Autoloader::add_root('Caldera_Forms', CFCORE_PATH . 'classes');
Caldera_Forms_Autoloader::register();
// includes
include_once CFCORE_PATH . 'includes/ajax.php';
include_once CFCORE_PATH . 'includes/field_processors.php';
include_once CFCORE_PATH . 'includes/custom_field_class.php';
include_once CFCORE_PATH . 'includes/filter_addon_plugins.php';
include_once CFCORE_PATH . 'includes/compat.php';
include_once CFCORE_PATH . 'processors/functions.php';
include_once CFCORE_PATH . 'includes/functions.php';
include_once CFCORE_PATH . 'ui/blocks/init.php';
include_once CFCORE_PATH . 'vendor/autoload.php';
include_once CFCORE_PATH . 'includes/cf-pro-client/cf-pro-init.php';
/**
* Runs after all of the includes and autoload setup is done in Caldera Forms core
*
* @since 1.3.5.3
*/
do_action('caldera_forms_includes_complete');
}
add_action('plugins_loaded', array('Caldera_Forms', 'get_instance'));
add_action('plugins_loaded', array('Caldera_Forms_Tracking', 'get_instance'));
//@see https://github.com/CalderaWP/Caldera-Forms/issues/2855
add_filter( 'caldera_forms_pro_log_mode', '__return_false' );
add_filter( 'caldera_forms_pro_mail_debug', '__return_false' );
// Admin & Admin Ajax stuff.
if (is_admin() || defined('DOING_AJAX')) {
add_action('plugins_loaded', array('Caldera_Forms_Admin', 'get_instance'));
add_action('plugins_loaded', array('Caldera_Forms_Support', 'get_instance'));
include_once CFCORE_PATH . 'includes/plugin-page-banner.php';
}
/**
* Get the Caldera Forms Freemius instance
*
* @since 1.6.0
* @deprecated 1.7.5
*
* @return Freemius
* @throws Freemius_Exception
*/
function caldera_forms_freemius()
{
global $caldera_forms_freemius;
return $caldera_forms_freemius;
}
/**
* Get the path for the icon used by Caldera Forms
*
* @since 1.6.0
* @deprecated 1.7.5
*
* @return string
*/
function caldera_forms_freemius_icon_path()
{
return CFCORE_PATH . 'assets/build/images/new-icon.png';
}
}
/**
* Shortcode handler to be used when Caldera Forms can not be loaded
*
* @since 1.7.0
*
* @return string
*/
function caldera_forms_fallback_shortcode()
{
if (current_user_can('edit_posts')) {
return esc_html__('Your version of WordPress or PHP is incompatible with Caldera Forms.', 'caldera-forms');
}
return esc_html__('Form could not be loaded. Contact the site administrator.', 'caldera-forms');
}