From 78425f77cc49c47811bd235586c8a30240d4be99 Mon Sep 17 00:00:00 2001 From: 3xs <31252669+my-3xs@users.noreply.github.com> Date: Fri, 1 May 2020 13:08:42 +0800 Subject: [PATCH] check_incompatible_notice --- index.php | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/index.php b/index.php index 891da09..735f6a1 100644 --- a/index.php +++ b/index.php @@ -8,7 +8,52 @@ * License: GPLv3 or later * License URI: http://www.gnu.org/licenses/gpl-3.0.html */ - +register_activation_hook( __FILE__, function() { + $check_incompatible = check_incompatible(); + if ( $check_incompatible ) { + set_transient( 'wp-china-yes-warning-notice', true, 5 ); + } +}); +add_action( 'admin_notices', function(){ + if( get_transient( 'wp-china-yes-warning-notice' ) ){ + echo check_incompatible()['error']; + delete_transient( 'wp-china-yes-warning-notice' ); + } +} ); +function check_incompatible(){ + $error = false; + $html = '

WP-CHINA-YES 启动提醒

'; + $html .= ''; + $incompatible_plugins = [ + 'wpjam-basic/wpjam-basic.php', + 'cardui-x/cardui-x.php', + 'nicetheme-jimu/nc-plugins.php', + ]; + if ( is_network_admin() ) { + $active_plugins = (array) get_site_option( 'active_sitewide_plugins', array() ); + $active_plugins = array_keys( $active_plugins ); + } else{ + $active_plugins = (array) get_option( 'active_plugins' ); + } + $matches = array_intersect( $active_plugins, $incompatible_plugins ); + if($matches){ + $error = true; + $html .= '

检测到您已启用下列提供类似功能的插件,请注意:您必须关闭这些插件中带有的wp代理更新、429错误解决等相关功能,以免系统更新被多次接管而产生错误。

'; + if($error) return ['error' => $html]; +} (new WP_CHINA_YES)->init(); class WP_CHINA_YES {