Skip to content

Commit 212be13

Browse files
committed
v5.12.1
v5.12.1 Signed-off-by: Kolja Nolte <kolja.nolte@gmail.com>
1 parent f40d0f3 commit 212be13

27 files changed

+13991
-12183
lines changed

README.md

Lines changed: 0 additions & 37 deletions
This file was deleted.

acf.php

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
Plugin Name: Advanced Custom Fields PRO
44
Plugin URI: https://www.advancedcustomfields.com
55
Description: Customize WordPress with powerful, professional and intuitive fields.
6-
Version: 5.11.4
6+
Version: 5.12.1
77
Author: Delicious Brains
88
Author URI: https://www.advancedcustomfields.com
9+
Update URI: https://www.advancedcustomfields.com/pro
910
Text Domain: acf
1011
Domain Path: /lang
1112
*/
@@ -19,7 +20,7 @@
1920
class ACF {
2021

2122
/** @var string The plugin version number. */
22-
var $version = '5.11.4';
23+
var $version = '5.12.1';
2324

2425
/** @var array The plugin settings array. */
2526
var $settings = array();
@@ -100,6 +101,7 @@ function initialize() {
100101
'rest_api_enabled' => true,
101102
'rest_api_format' => 'light',
102103
'rest_api_embed_links' => true,
104+
'preload_blocks' => true,
103105
);
104106

105107
// Include utility functions.
@@ -193,6 +195,8 @@ function initialize() {
193195
add_action( 'init', array( $this, 'init' ), 5 );
194196
add_action( 'init', array( $this, 'register_post_types' ), 5 );
195197
add_action( 'init', array( $this, 'register_post_status' ), 5 );
198+
add_action( 'activated_plugin', array( $this, 'deactivate_other_instances' ) );
199+
add_action( 'pre_current_active_plugins', array( $this, 'plugin_deactivated_notice' ) );
196200

197201
// Add filters.
198202
add_filter( 'posts_where', array( $this, 'posts_where' ), 10, 2 );
@@ -444,6 +448,65 @@ function register_post_status() {
444448
);
445449
}
446450

451+
/**
452+
* Checks if another version of ACF/ACF PRO is active and deactivates it.
453+
* Hooked on `activated_plugin` so other plugin is deactivated when current plugin is activated.
454+
*
455+
* @param string $plugin The plugin being activated.
456+
*/
457+
public function deactivate_other_instances( $plugin ) {
458+
if ( ! in_array( $plugin, array( 'advanced-custom-fields/acf.php', 'advanced-custom-fields-pro/acf.php' ) ) ) {
459+
return;
460+
}
461+
462+
$plugin_to_deactivate = 'advanced-custom-fields/acf.php';
463+
$deactivated_notice_id = '1';
464+
465+
// If we just activated the free version, deactivate the pro version.
466+
if ( $plugin === $plugin_to_deactivate ) {
467+
$plugin_to_deactivate = 'advanced-custom-fields-pro/acf.php';
468+
$deactivated_notice_id = '2';
469+
}
470+
471+
if ( is_multisite() && is_network_admin() ) {
472+
$active_plugins = (array) get_site_option( 'active_sitewide_plugins', array() );
473+
$active_plugins = array_keys( $active_plugins );
474+
} else {
475+
$active_plugins = (array) get_option( 'active_plugins', array() );
476+
}
477+
478+
foreach ( $active_plugins as $plugin_basename ) {
479+
if ( $plugin_to_deactivate === $plugin_basename ) {
480+
set_transient( 'acf_deactivated_notice_id', $deactivated_notice_id, 1 * HOUR_IN_SECONDS );
481+
deactivate_plugins( $plugin_basename );
482+
return;
483+
}
484+
}
485+
}
486+
487+
/**
488+
* Displays a notice when either ACF or ACF PRO is automatically deactivated.
489+
*/
490+
public function plugin_deactivated_notice() {
491+
$deactivated_notice_id = get_transient( 'acf_deactivated_notice_id' );
492+
if ( ! in_array( $deactivated_notice_id, array( '1', '2' ) ) ) {
493+
return;
494+
}
495+
496+
$message = __( "Advanced Custom Fields and Advanced Custom Fields PRO should not be active at the same time. We've automatically deactivated Advanced Custom Fields.", 'acf' );
497+
if ( '2' === $deactivated_notice_id ) {
498+
$message = __( "Advanced Custom Fields and Advanced Custom Fields PRO should not be active at the same time. We've automatically deactivated Advanced Custom Fields PRO.", 'acf' );
499+
}
500+
501+
?>
502+
<div class="updated" style="border-left: 4px solid #ffba00;">
503+
<p><?php echo esc_html( $message ); ?></p>
504+
</div>
505+
<?php
506+
507+
delete_transient( 'acf_deactivated_notice_id' );
508+
}
509+
447510
/**
448511
* posts_where
449512
*

0 commit comments

Comments
 (0)