- 状态
- 已解决
- 报告针对
- WPML Multilingual CMS 4.6.4
- 解决于
- WPML 4.7
- 相关插件/主题
- WooCommerce Memberships
- 主题标签
- Compatibility
问题概述
如果您使用的是WooCommerce Membership,您会发现,如果在会员计划的Restrict Content设置下添加了一个页面并随后将其删除,WPML会错误地将该限制应用到整个站点的所有页面,而不仅仅是会员计划中指定的页面。
临时解决方法
在继续操作之前,请确保已对您的站点进行了完整备份。
- 打开 …/wp-content/plugins/woocommerce-multilingual/compatibility/WcMemberships/class-wcml-wc-memberships.php 文件。
- 找到第 134 行。
- 将此代码:
public function add_translated_object_ids( $object_ids ) { $result = []; foreach ( $object_ids as $object_id ) { $type = apply_filters( 'wpml_element_type', get_post_type( $object_id ) ); $trid = apply_filters( 'wpml_element_trid', null, $object_id, $type ); $translations = array_values( wp_list_pluck( apply_filters( 'wpml_get_element_translations', [], $trid, $type ), 'element_id' ) ); $result = array_merge( $result, $translations ); } return $result; } - 替换为:
public function add_translated_object_ids( $object_ids ) { $result = []; foreach ( $object_ids as $object_id ) { $type = apply_filters( 'wpml_element_type', get_post_type( $object_id ) ); $trid = apply_filters( 'wpml_element_trid', null, $object_id, $type ); $translations = array_values( wp_list_pluck( apply_filters( 'wpml_get_element_translations', [], $trid, $type ), 'element_id' ) ); $result = array_merge( $result, $translations ); } // Workaround for compsupp-6900 if ( empty($result) ) { return $object_ids; } return $result; }