=' ) ) {
self::show_activate_error( __( 'The Page Builder plugin requires WordPress version 3.5 or greater. Please update WordPress before activating the plugin.', 'fl-builder' ) );
}
// Allow extensions to hook activation.
$activate = apply_filters( 'fl_builder_activate', true );
// Should we continue with activation?
if ( $activate ) {
// Check for multisite.
if ( is_multisite() ) {
$url = FLBuilderModel::get_upgrade_url( array(
'utm_medium' => 'bb-pro',
'utm_source' => 'plugins-admin-page',
'utm_campaign' => 'no-multisite-support',
) );
self::show_activate_error( sprintf( __( 'This version of the Page Builder plugin is not compatible with WordPress Multisite. Please upgrade to the Multisite version of this plugin.', 'fl-builder' ), ' href="' . $url . '" target="_blank"' ) );
}
// Success! Run the install.
self::install();
// Trigger the activation notice.
self::trigger_activate_notice();
// Allow add-ons to hook into activation.
do_action( 'fl_builder_activated' );
// Flush the rewrite rules.
flush_rewrite_rules();
}
}
/**
* Show a message if there is an activation error and
* deactivates the plugin.
*
* @since 1.0
* @param string $message The message to show.
* @return void
*/
static public function show_activate_error( $message ) {
deactivate_plugins( FLBuilderModel::plugin_basename(), false, is_network_admin() );
die( $message );
}
/**
* @since 2.1.3
*/
static public function sanity_checks() {
if ( true !== FL_BUILDER_LITE ) {
// fetch the plugin install folder this should be bb-plugin
$folder = rtrim( FLBuilderModel::plugin_basename(), '/fl-builder.php' );
if ( 'bb-plugin' != $folder ) {
$error = sprintf( __( 'Install Error! We detected that Beaver Builder appears to be installed in a folder called %s.
For automatic updates to work the plugin must be installed in the folder bb-plugin.', 'fl-builder' ), $folder );
FLBuilderAdminSettings::add_error( $error );
}
}
}
/**
* Sets the transient that triggers the activation notice
* or welcome page redirect.
*
* @since 1.8
* @return void
*/
static public function trigger_activate_notice() {
if ( current_user_can( 'delete_users' ) ) {
set_transient( '_fl_builder_activation_admin_notice', true, 30 );
}
}
/**
* Shows the activation success message or redirects to the
* welcome page.
*
* @since 1.0
* @return void
*/
static public function show_activate_notice() {
// Bail if no activation transient is set.
if ( ! get_transient( '_fl_builder_activation_admin_notice' ) ) {
return;
}
// Delete the activation transient.
delete_transient( '_fl_builder_activation_admin_notice' );
if ( isset( $_GET['activate-multi'] ) || is_multisite() ) {
// Show the notice if we are activating multiple plugins or on multisite.
add_action( 'admin_notices', __CLASS__ . '::activate_notice' );
add_action( 'network_admin_notices', __CLASS__ . '::activate_notice' );
} else {
// Redirect to the welcome page.
wp_safe_redirect( add_query_arg( array(
'page' => 'fl-builder-settings',
), admin_url( 'options-general.php' ) ) );
}
}
/**
* Shows the activation success message.
*
* @since 1.0
* @return void
*/
static public function activate_notice() {
if ( FL_BUILDER_LITE !== true ) {
$hash = '#license';
$message = __( 'Page Builder activated! Click here to enable remote updates.', 'fl-builder' );
} else {
$hash = '#welcome';
$message = __( 'Page Builder activated! Click here to get started.', 'fl-builder' );
}
$url = apply_filters( 'fl_builder_activate_redirect_url', admin_url( '/options-general.php?page=fl-builder-settings' . $hash ) );
echo '
' . sprintf( $message, ' href="' . esc_url( $url ) . '"' ) . '
'; echo '