|
3 | 3 | Plugin Name: Advanced Custom Fields PRO |
4 | 4 | Plugin URI: https://www.advancedcustomfields.com |
5 | 5 | Description: Customize WordPress with powerful, professional and intuitive fields. |
6 | | -Version: 5.11.4 |
| 6 | +Version: 5.12.1 |
7 | 7 | Author: Delicious Brains |
8 | 8 | Author URI: https://www.advancedcustomfields.com |
| 9 | +Update URI: https://www.advancedcustomfields.com/pro |
9 | 10 | Text Domain: acf |
10 | 11 | Domain Path: /lang |
11 | 12 | */ |
|
19 | 20 | class ACF { |
20 | 21 |
|
21 | 22 | /** @var string The plugin version number. */ |
22 | | - var $version = '5.11.4'; |
| 23 | + var $version = '5.12.1'; |
23 | 24 |
|
24 | 25 | /** @var array The plugin settings array. */ |
25 | 26 | var $settings = array(); |
@@ -100,6 +101,7 @@ function initialize() { |
100 | 101 | 'rest_api_enabled' => true, |
101 | 102 | 'rest_api_format' => 'light', |
102 | 103 | 'rest_api_embed_links' => true, |
| 104 | + 'preload_blocks' => true, |
103 | 105 | ); |
104 | 106 |
|
105 | 107 | // Include utility functions. |
@@ -193,6 +195,8 @@ function initialize() { |
193 | 195 | add_action( 'init', array( $this, 'init' ), 5 ); |
194 | 196 | add_action( 'init', array( $this, 'register_post_types' ), 5 ); |
195 | 197 | 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' ) ); |
196 | 200 |
|
197 | 201 | // Add filters. |
198 | 202 | add_filter( 'posts_where', array( $this, 'posts_where' ), 10, 2 ); |
@@ -444,6 +448,65 @@ function register_post_status() { |
444 | 448 | ); |
445 | 449 | } |
446 | 450 |
|
| 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 | + |
447 | 510 | /** |
448 | 511 | * posts_where |
449 | 512 | * |
|
0 commit comments