WPML
ステータス
解決済み
報告対象
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;
    }

すべての既知の問題 →