修改后的class-vc-notice-controller.php 文件
对 class-vc-notice-controller.php 文件进行修改,屏蔽远程请求(get_notice_list_from_api_request() 方法)以避免后台加载缓慢或超时问题。以下是修改后的代码,您可以直接覆盖原文件。
/*** Show notices to user.** @since 7.0* @param mixed $notice_list*/public function show_notices( $notice_list ) {if ( empty( $notice_list ) || ! is_array( $notice_list ) ) {return;}
// last api request was empty or failed.if ( $this-is_api_response_empty( $notice_list ) ) {return;}
$is_show_at_least_one_notice = false;foreach ( $notice_list as $notice ) {if ( ! $this-is_notice_valid( $notice ) ) {continue;}
if ( ! $this-is_show_notice( $noticeid ) ) {continue;}
$this-output_notice( $notice );$is_show_at_least_one_notice = true;}
if ( $is_show_at_least_one_notice ) {add_action(admin_notices,function () {vc_include_template( params/notice/notice-assets.php );});}}
/*** Check if notice is valid.** @since 7.0* @param mixed $notice* @return bool*/public function is_notice_valid( $notice ) {
if ( empty( $notice ) || ! is_array( $notice ) ) {return false;}
if ( ! $this-is_notice_version_valid( $notice, WPB_VC_VERSION ) ) {return false;}
// phpcs:ignoreif ( ! $this-is_notice_date_valid( $notice, current_time( timestamp ) ) ) {return false;}
if ( ! $this-is_notice_content_valid( $notice ) ) {return false;}
return true;}
/*** Check if we should show notice.** @note we dont show notice if user already closed it.** @since 7.0* @param int $notice_id* @return bool*/public function is_show_notice( $notice_id ) {$notice_close_list = get_user_meta( get_current_user_id(), $this-user_notice_close_list, true );
if ( empty( $notice_close_list ) ) {return true;}
$notice_close_list = is_string( $notice_close_list ) ? json_decode( $notice_close_list ) : ;
return ! ( is_array( $notice_close_list ) in_array( $notice_id, $notice_close_list ) );}
/*** Get notices that should be displayed.** @since 7.0* @return array*/public function get_notice_list() {// 直接返回空数组,屏蔽远程请求。return ;
// 以下是原始逻辑,如果需要恢复原始功能,请删除上面的 return 语句。$notice_list = get_transient( $this-transient_notice_list );
if ( $this-is_api_response_empty( $notice_list ) ) {return ;}
if ( ! $this-is_notice_list_valid( $notice_list ) ) {$notice_list = $this-get_notice_list_from_api_request();
$this-save_notice_list_to_transient( $notice_list );}
return json_decode( $notice_list, true );}
/*** Get notices from notice API.** @note we fire up request to our API once per 12 hours.** @since 7.0* @return string*/public function get_notice_list_from_api_request() {// 屏蔽远程请求,直接返回空字符串。return ;
// 以下是原始逻辑,如果需要恢复远程功能,请删除上面的 return 语句。$empty_notice_list = ;
$response = wp_remote_get( $this-notification_api_url, timeout = 30 );
if ( is_wp_error( $response ) ) {return $empty_notice_list;}
if ( wp_remote_retrieve_response_code( $response ) !== 200 ) {return $empty_notice_list;}
$response_body = wp_remote_retrieve_body( $response );
if ( $this-is_notice_list_valid( $response_body ) ) {$notice_list = $response_body;} else {$notice_list = $empty_notice_list;}
return $notice_list;}}
new Vc_Notice_Controller();
修改内容说明禁用通知功能:在init() 方法中直接 return;,完全禁用通知功能,防止后台加载通知。如果需要恢复通知功能,只需删除 return; 语句。屏蔽远程请求:在 get_notice_list() 方法中直接返回空数组 ,避免调用远程 API。在 get_notice_list_from_api_request() 方法中直接返回空字符串 '',屏蔽实际的远程请求。保留原始逻辑:原始逻辑仍然保留在代码中,方便在需要时恢复功能。使用方法将修改后的代码复制并覆盖
wp-content/plugins/js_composer/include/autoload/class-vc-notice-controller.php 文件。保存文件后刷新 WordPress 后台,通知功能将被禁用,远程请求也会被屏蔽。注意事项插件更新后修改可能失效:如果插件更新,修改的文件可能会被覆盖。建议在更新后重新应用修改,或者使用更持久的解决方案(例如自定义钩子)。备份文件:在修改之前,请备份原始文件,以便在出现问题时可以恢复。
通过以上修改,您可以有效屏蔽插件的通知功能和远程请求,从而提升后台加载速度并避免相关问题。
修改后的class-vc-notice-controller.php 文件 https://cdnanqi.cn/wangluoyingxiao/16861.html
400电话办理