WPML
ステータス
開発者からの返答待ち
関連するプラグイン/テーマ
WP User Manager
トピックタグ
Compatibility

問題の概要

WP User Managerを使用してプロフィールにカスタムフィールドを追加する場合、次の問題が発生する可能性があります。カスタムフィールドの複数選択のオプションが、WPMLの文字列翻訳で翻訳できません。

回避策

続行する前に、必ずサイトの完全なバックアップを取得してください。

1. 統合プラグイン(WPUM-WPML)の修正


  • …/wp-content/plugins/wpum-wpml/includes/class-wpum-wpml-fields.phpファイルを開きます。

  • 20行目を見つけます。

  • 次のコードを:
    add_action( 'update_wpum_field_meta', array( $this, 'update_meta_strings' ), 10, 4 );
            


  • 以下に置き換えます:
    add_action( 'updated_wpum_field_meta', array( $this, 'update_meta_strings' ), 10, 4 );
            

  • その後、ユーザー > カスタムフィールドに移動し、少なくとも1つの複数選択フィールドのオプションを編集してから、WPML > 文字列翻訳に移動して値を翻訳します。

2. WP User Managerのフロントエンド出力の修正


  • …/wp-content/plugins/wp-user-manager/includes/fields/types/class-wpum-field-multiselect.phpファイルを開きます。

  • 該当する行を見つけます。

  • get_formatted_output()関数全体を以下に置き換えます:
    	public function get_formatted_output( $field, $value ) {
    
    		$stored_field_options = $field->get_meta( 'dropdown_options' );
    		$stored_options       = array();
    		$stored_index         = array();
    
    		// Build lookup maps: value => label and value => original index
    		foreach ( $stored_field_options as $key => $stored_option ) {
    			$val = isset( $stored_option['value'] ) ? $stored_option['value'] : $key;
    			$lbl = isset( $stored_option['label'] ) ? $stored_option['label'] : '';
    			$stored_options[ $val ] = $lbl;
    			$stored_index[ $val ]   = $key;
    		}
    
    		$values = array();
    
    		foreach ( $value as $user_stored_value ) {
    			if ( ! isset( $stored_options[ $user_stored_value ] ) ) {
    				continue;
    			}
    
    			$label = $stored_options[ $user_stored_value ];
    
    			// Determine original index for this option so we can match textdomain package
    			$index = isset( $stored_index[ $user_stored_value ] ) ? $stored_index[ $user_stored_value ] : 0;
    
    			// Translation via WPML. 
    			$translated_label = apply_filters( 'wpml_translate_single_string', $label, 'wpum-fields-wpum-field-' . $field->get_ID(), 'wpum-field-dropdown_options_' . $index );
    
    			$values[] = $translated_label;
    		}
    
    		return implode( ', ', $values );
    
    	}
            

すべての既知の問題 →