PluginProbe
Forumax – AI Powered Advanced Community Forum Plugin / 2.4.0
Forumax – AI Powered Advanced Community Forum Plugin v2.4.0
2.4.4 2.4.3 2.4.2 2.4.1 2.4.0 trunk 1.0.8 1.1.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 2.0.0 2.1.0 All 29 releases
bbp-core / includes / admin / notices / deactivate-other-forum-plugins.php

deactivate-other-forum-plugins.php in Forumax – AI Powered Advanced Community Forum Plugin 2.4.0, at includes/admin/notices/deactivate-other-forum-plugins.php

64 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 * Cannot access directly.
4 */
5 if ( ! defined( 'ABSPATH' ) ) {
6 exit;
7 }
8
9 /**
10 * Show notice if other Knowledge Base plugins are active.
11 */
12 add_action( 'admin_notices', function () {
13 $conflicting_plugins = [
14 'bbpress/bbpress.php' => [
15 'name' => 'bbPress',
16 'migrate'=> false
17 ]
18 ];
19 foreach ( $conflicting_plugins as $plugin_file => $plugin_data ) :
20 if ( is_plugin_active( $plugin_file ) ) :
21 ?>
22 <div class="notice notice-warning bbpc-notice">
23 <p>
24 <?php esc_html_e( 'We have detected the bbPress plugin is installed on the site.', 'forumax' ); ?>
25 <br>
26 <?php esc_html_e( 'To ensure Forumax works properly and without conflicts, please deactivate bbPress.', 'forumax' ); ?>
27 </p>
28 <p>
29 <a href="<?php echo esc_url( wp_nonce_url( add_query_arg( [ 'bbpc_deactivate' => $plugin_file ] ), 'bbpc_deactivate_plugin' ) ); ?>" class="button-primary button-large red-bg">
30 <?php
31 // translators: %s is the name of the plugin being deactivated.
32 printf( esc_html__( 'Deactivate %s', 'forumax' ), esc_html( $plugin_data['name'] ) );
33 ?>
34 </a>
35 </p>
36 </div>
37 <?php
38 endif;
39 endforeach;
40 });
41
42 /**
43 * Deactivate other Knowledge Base plugins securely.
44 */
45 add_action( 'admin_init', function () {
46 if ( isset( $_GET['bbpc_deactivate'] ) && check_admin_referer( 'bbpc_deactivate_plugin' ) ) {
47
48 if ( ! current_user_can( 'activate_plugins' ) ) {
49 return;
50 }
51
52 $plugin_file = sanitize_text_field( wp_unslash( $_GET['bbpc_deactivate'] ) );
53
54 if ( is_plugin_active( $plugin_file ) ) {
55 deactivate_plugins( $plugin_file );
56
57 wp_safe_redirect( add_query_arg( [
58 'deactivated' => 'true',
59 'plugin' => urlencode( $plugin_file )
60 ], admin_url( 'plugins.php' ) ) );
61 exit;
62 }
63 }
64 });