PluginProbe
WP Import Export Lite / trunk
WP Import Export Lite vtrunk
3.9.33 trunk 3.9.27 3.9.28 3.9.29 3.9.30 3.9.31 3.9.32
wp-import-export-lite / deactivate-plugins.php

deactivate-plugins.php in WP Import Export Lite trunk, at deactivate-plugins.php

80 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Auto-deactivation of conflicting plugins.
4 *
5 * Automatically deactivates the Lite version if the Pro version of WP Import Export
6 * or Woo Import Export is detected as active.
7 *
8 * @package WP_Import_Export_Lite
9 * @subpackage WP_Import_Export_Lite/bootstrap
10 * @since 1.0.0
11 */
12
13 defined( 'ABSPATH' ) || exit;
14
15 if ( ! function_exists( 'wpie_auto_deactivate_pro_plugins' ) ) {
16 /**
17 * Automatically deactivates the Lite version if Pro version is active.
18 *
19 * Checks for the presence of the Pro plugin and cleanly deactivates Lite,
20 * ensuring no function or class redeclaration conflicts occur.
21 *
22 * @since 1.0.0
23 * @return void
24 */
25 function wpie_auto_deactivate_pro_plugins() {
26 if ( ! function_exists( 'is_plugin_active' ) ) {
27 require_once ABSPATH . 'wp-admin/includes/plugin.php';
28 }
29
30 if ( ! current_user_can( 'activate_plugins' ) ) {
31 return;
32 }
33
34 $pro_plugins = array(
35 'woo-import-export/woo-import-export.php',
36 'vj-wp-import-export/vj-wp-import-export.php',
37 );
38
39 $is_pro_active = false;
40 foreach ( $pro_plugins as $pro_plugin ) {
41 if ( is_plugin_active( $pro_plugin ) ) {
42 $is_pro_active = true;
43 break;
44 }
45 }
46
47 if ( $is_pro_active ) {
48 $lite_plugin = 'wp-import-export-lite/wp-import-export-lite.php';
49 if ( is_plugin_active( $lite_plugin ) ) {
50 deactivate_plugins( array( $lite_plugin ) );
51 set_transient( 'wpie_lite_deactivated_notice', 1, 60 );
52 }
53 }
54 }
55 }
56
57 if ( ! function_exists( 'wpie_deactivated_pro_admin_notice' ) ) {
58 /**
59 * Displays an admin notice informing the user that Lite was deactivated in favor of Pro.
60 *
61 * @since 1.0.0
62 * @return void
63 */
64 function wpie_deactivated_pro_admin_notice() {
65 if ( get_transient( 'wpie_lite_deactivated_notice' ) ) {
66 delete_transient( 'wpie_lite_deactivated_notice' );
67 ?>
68 <div class="notice notice-warning is-dismissible">
69 <p>
70 <?php
71 echo esc_html__( 'WP Import Export Lite has been automatically deactivated because WP Import Export Pro is active.', 'wp-import-export-lite' );
72 ?>
73 </p>
74 </div>
75 <?php
76 }
77 }
78 add_action( 'admin_notices', 'wpie_deactivated_pro_admin_notice' );
79 }
80