activation.php
61 lines
| 1 | <?php |
| 2 | // Exit if accessed directly. |
| 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | exit; |
| 5 | } |
| 6 | |
| 7 | if ( ! function_exists( 'aioseo_lite_just_activated' ) ) { |
| 8 | /** |
| 9 | * Store temporarily that the Lite version of the plugin was activated. |
| 10 | * This is needed because WP does a redirect after activation and |
| 11 | * we need to preserve this state to know whether user activated Lite or not. |
| 12 | * |
| 13 | * @since 4.0.0 |
| 14 | */ |
| 15 | function aioseo_lite_just_activated() { |
| 16 | aioseo()->core->cache->update( 'lite_just_activated', true ); |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | if ( ! function_exists( 'aioseo_lite_just_deactivated' ) ) { |
| 21 | /** |
| 22 | * Store temporarily that Lite plugin was deactivated. |
| 23 | * Convert temporary "activated" value to a global variable, |
| 24 | * so it is available through the request. Remove from the storage. |
| 25 | * |
| 26 | * @since 4.0.0 |
| 27 | */ |
| 28 | function aioseo_lite_just_deactivated() { |
| 29 | global $aioseoLiteJustActivated, $aioseoLiteJustDeactivated; |
| 30 | |
| 31 | $aioseoLiteJustActivated = (bool) aioseo()->core->cache->get( 'lite_just_activated' ); |
| 32 | $aioseoLiteJustDeactivated = true; |
| 33 | |
| 34 | aioseo()->core->cache->delete( 'lite_just_activated' ); |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | if ( ! function_exists( 'aioseo_pro_just_activated' ) ) { |
| 39 | /** |
| 40 | * Store temporarily that the Pro version of the plugin was activated. |
| 41 | * This is needed because when we activate the Pro version on top |
| 42 | * of the Lite version, it does not trigger the activation hook in Pro. |
| 43 | * |
| 44 | * @since 4.0.0 |
| 45 | */ |
| 46 | function aioseo_pro_just_activated() { |
| 47 | $liteActivated = is_plugin_active( 'all-in-one-seo-pack/all_in_one_seo_pack.php' ); |
| 48 | if ( $liteActivated ) { |
| 49 | // Add capabilities for the current user on upgrade so that the menu is visible on the first request. |
| 50 | aioseo()->activate->addCapabilitiesOnUpgrade(); |
| 51 | |
| 52 | aioseo()->core->cache->update( 'pro_just_deactivated_lite', true ); |
| 53 | } |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | // If we detect that V3 is active, let's deactivate it now. |
| 58 | if ( defined( 'AIOSEOP_VERSION' ) && defined( 'AIOSEO_PLUGIN_FILE' ) ) { |
| 59 | require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 60 | deactivate_plugins( plugin_basename( AIOSEO_PLUGIN_FILE ) ); |
| 61 | } |