-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbb-ultimate-addon.php
144 lines (123 loc) · 5.04 KB
/
bb-ultimate-addon.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
<?php
/**
* Plugin Name: Ultimate Addons for Beaver Builder - Lite
* Plugin URI: http://www.ultimatebeaver.com/
* Description: Ultimate Addons is a free extension for Beaver Builder that adds 10 modules, and works on top of any Beaver Builder Package. (Free, Standard, Pro & Agency) You can use it with on any WordPress theme.
* Version: 1.3.0
* Author: Brainstorm Force
* Author URI: http://www.brainstormforce.com
* Text Domain: uabb
*
* @package Ultimate Addons For Beaver Builder
*/
/**
* Custom modules
*/
if ( ! class_exists( 'BB_Ultimate_Addon' ) ) {
define( 'BB_ULTIMATE_ADDON_DIR', plugin_dir_path( __FILE__ ) );
define( 'BB_ULTIMATE_ADDON_URL', plugins_url( '/', __FILE__ ) );
define( 'BB_ULTIMATE_ADDON_LITE_VERSION', '1.3.0' );
define( 'BSF_REMOVE_UABB_FROM_REGISTRATION_LISTING', true );
define( 'BB_ULTIMATE_ADDON_FILE', trailingslashit( dirname( __FILE__ ) ) . 'bb-ultimate-addon.php' );// @codingStandardsIgnoreLine.
define( 'BB_ULTIMATE_ADDON_LITE', true );
define( 'BB_ULTIMATE_ADDON_UPGRADE_URL', 'https://www.ultimatebeaver.com/pricing/?utm_source=uabb-dashboard&utm_campaign=uabblite_upgrade&utm_medium=upgrade-button' );
define( 'BB_ULTIMATE_ADDON_FB_URL', 'https://www.brainstormforce.com/go/uabb-facebook-group/?utm_source=uabb-dashboard&utm_campaign=Lite&utm_medium=FB' );
define( 'BB_ULTIMATE_ADDON_TWITTER_URL', 'https://twitter.com/WeBrainstorm' );
/**
* This class initializes BB Ultiamte Addons
*
* @class BB_Ultimate_Addon
*/
class BB_Ultimate_Addon {
/**
* Constructor function that initializes required actions and hooks
*
* @since 1.0
*/
function __construct() {
register_activation_hook( __FILE__, array( $this, 'activation_reset' ) );
// UABB Initialize.
require_once 'classes/class-uabb-init.php';
}
/**
* Function which resets the plugin activation if necessary memmory not found
*
* @Since 1.0
*/
function activation_reset() {
$no_memory = $this->check_memory_limit();
if ( true == $no_memory && ! defined( 'WP_CLI' ) ) {
$msg = sprintf( __( 'Unfortunately, plugin could not be activated as the memory allocated by your host has almost exhausted. UABB plugin recommends that your site should have 15M PHP memory remaining. <br/><br/>Please check <a target="_blank" href="https://www.ultimatebeaver.com/docs/increase-memory-limit-site/">this</a> article for solution or contact <a target="_blank" href="http://store.brainstormforce.com/support">support</a>.<br/><br/><a class="button button-primary" href="%s">Return to Plugins Page</a>', 'uabb' ), network_admin_url( 'plugins.php' ) ); // @codingStandardsIgnoreLine.
deactivate_plugins( plugin_basename( __FILE__ ) );
wp_die( $msg );
}
delete_option( 'uabb_hide_branding' );
// Force check graupi bundled products.
update_site_option( 'bsf_force_check_extensions', true );
update_option( 'uabb_lite_redirect', true );
}
/**
* Memory Limit function that checks for memory limit for the UABB plugin
*
* @Since 1.0
*/
function check_memory_limit() {
$memory_limit = ini_get( 'memory_limit' ); // Total Memory.
$peak_memory = memory_get_peak_usage( true ); // Available Memory.
$uabb_required = 14999999; // Required Memory for UABB.
if ( '-1' !== $memory_limit ) {
if ( preg_match( '/^(\d+)(.)$/', $memory_limit, $matches ) ) {
switch ( $matches[2] ) {
case 'K':
case 'k':
$memory_limit = $matches[1] * 1024;
break;
case 'M':
case 'm':
$memory_limit = $matches[1] * 1024 * 1024;
break;
case 'G':
case 'g':
$memory_limit = $matches[1] * 1024 * 1024 * 1024;
break;
}
}
if ( $memory_limit - $peak_memory <= $uabb_required ) {
return true;
} else {
return false;
}
}
}
}
new BB_Ultimate_Addon();
} else {
// Display admin notice for activating beaver builder.
add_action( 'admin_notices', 'admin_notices' );
add_action( 'network_admin_notices', 'admin_notices' );
/**
* Memory Limit function that checks for memory limit for the UABB plugin
*
* @Since 1.0
*/
function admin_notices() {
$deactivate_url = admin_url( 'plugins.php' );
if ( is_plugin_active_for_network( 'ultimate-addons-for-beaver-builder-lite/bb-ultimate-addon.php' ) ) {
$deactivate_url = network_admin_url( 'plugins.php' );
}
$slug = 'bb-ultimate-addon';
$deactivate_url = add_query_arg(
array(
'action' => 'deactivate',
'plugin' => rawurlencode( 'ultimate-addons-for-beaver-builder-lite/' . $slug . '.php' ),
'plugin_status' => 'all',
'paged' => '1',
'_wpnonce' => wp_create_nonce( 'deactivate-plugin_ultimate-addons-for-beaver-builder-lite/' . $slug . '.php' ),
),
$deactivate_url
);
echo '<div class="notice notice-error"><p>';
echo sprintf( __( "You currently have two versions of <strong>Ultimate Addon for Beaver Builder</strong> active on this site. Please <a href='%s'>deactivate one</a> before continuing.", 'uabb' ), $deactivate_url ); // @codingStandardsIgnoreLine.
echo '</p></div>';
}
}