-
Notifications
You must be signed in to change notification settings - Fork 2
/
eea-beaver-builder.php
135 lines (123 loc) · 4.58 KB
/
eea-beaver-builder.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
<?php
/*
Plugin Name: Event Espresso - Beaver Builder (EE 4.9+)
Plugin URI: http://www.eventespresso.com
Description: The Event Espresso Beaver Builder add-on adds Event Espresso options to the BB interface.
Version: 1.0.0.dev.000
Author: Event Espresso
Author URI: http://www.eventespresso.com
Copyright 2017 Event Espresso (email : [email protected])
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA02110-1301USA
*
* ------------------------------------------------------------------------
*
* Event Espresso
*
* Event Registration and Management Plugin for WordPress
*
* @ package Event Espresso
* @ author Event Espresso
* @ copyright (c) 2008-2017 Event Espresso All Rights Reserved.
* @ license http://eventespresso.com/support/terms-conditions/ * see Plugin Licensing *
* @ link http://www.eventespresso.com
* @ version EE4
*
* ------------------------------------------------------------------------
*/
// define versions and this file
define('EE_BEAVER_BUILDER_CORE_VERSION_REQUIRED', '4.8.0.rc.0000');
define('EE_BEAVER_BUILDER_VERSION', '1.0.0.dev.000');
define('EE_BEAVER_BUILDER_PLUGIN_FILE', __FILE__);
/**
* captures plugin activation errors for debugging
*/
function espresso_beaver_builder_plugin_activation_errors()
{
if (WP_DEBUG) {
$activation_errors = ob_get_contents();
file_put_contents(EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_beaver_builder_plugin_activation_errors.html', $activation_errors);
}
}
add_action('activated_plugin', 'espresso_beaver_builder_plugin_activation_errors');
/**
* registers addon with EE core
*/
function load_espresso_beaver_builder()
{
if (class_exists('EE_Addon') && class_exists('FLBuilder')) {
// beaver_builder version
require_once(plugin_dir_path(__FILE__) . 'EE_Beaver_Builder.class.php');
EE_Beaver_Builder::register_addon();
} else {
add_action('admin_notices', 'espresso_beaver_builder_activation_error');
}
}
add_action('AHEE__EE_System__load_espresso_addons', 'load_espresso_beaver_builder');
/**
* verifies that addon was activated
*/
function espresso_beaver_builder_activation_check()
{
if (! did_action('AHEE__EE_System__load_espresso_addons')) {
add_action('admin_notices', 'espresso_beaver_builder_activation_error');
}
}
add_action('init', 'espresso_beaver_builder_activation_check', 1);
/**
* displays activation error admin notice
*/
function espresso_beaver_builder_activation_error()
{
unset($_GET['activate']);
unset($_REQUEST['activate']);
if (! function_exists('deactivate_plugins')) {
require_once(ABSPATH . 'wp-admin/includes/plugin.php');
}
deactivate_plugins(plugin_basename(EE_BEAVER_BUILDER_PLUGIN_FILE));
?>
<div class="error">
<p><?php printf(
__('Event Espresso Beaver Builder could not be activated. Please ensure that Event Espresso version %1$s or higher is running', 'event_espresso'),
EE_BEAVER_BUILDER_CORE_VERSION_REQUIRED
); ?></p>
</div>
<?php
}
if (!function_exists('ee_bb_suppress_notices')) {
function ee_bb_suppress_notices()
{
if (class_exists('FLBuilderModel') && (FLBuilderModel::is_builder_enabled())) {
add_filter('FHEE__EE_Front_Controller__display_errors', '__return_false');
}
}
add_action('wp', 'ee_bb_suppress_notices', 1);
}
/*
* Hex to Rgba
*/
function espresso_hex2rgba($hex, $opacity)
{
$hex = str_replace('#', '', $hex);
if (strlen($hex) == 3) {
$r = hexdec(substr($hex, 0, 1) . substr($hex, 0, 1));
$g = hexdec(substr($hex, 1, 1) . substr($hex, 1, 1));
$b = hexdec(substr($hex, 2, 1) . substr($hex, 2, 1));
} else {
$r = hexdec(substr($hex, 0, 2));
$g = hexdec(substr($hex, 2, 2));
$b = hexdec(substr($hex, 4, 2));
}
$rgba = array($r, $g, $b, $opacity);
return 'rgba(' . implode(', ', $rgba) . ')';
}
// End of file espresso_beaver_builder.php
// Location: wp-content/plugins/eea-beaver-builder/espresso_beaver_builder.php