WPML

問題の概要

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

回避策

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

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

  • …/wp-content/plugins/wpum-wpml/includes/class-wpum-wpml-fields.phpファイルを開きます。
  • 20行目を見つけます。
  • 次のコードを:
    PHP
    add_action( 'update_wpum_field_meta', array( $this, 'update_meta_strings' ), 10, 4 );
  • 以下に置き換えます:
    PHP
    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ファイルを開きます。
  • 56行目を見つけます。
  • get_formatted_output()関数全体を以下に置き換えます:
    PHP
    public function get_formatted_output( $field, $value ) {
    
        $stored_field_options = $field->get_meta( 'dropdown_options' );
        $stored_options       = array();
        $stored_index         = array();
    
        // Keep the plugin's own guard.
        if ( ! is_array( $stored_field_options ) ) {
            return '';
        }
    
        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();
    
        // Keep the plugin's (array) cast.
        foreach ( (array) $value as $user_stored_value ) {
            if ( ! isset( $stored_options[ $user_stored_value ] ) ) {
                continue;
            }
    
            $label = $stored_options[ $user_stored_value ];
            $index = isset( $stored_index[ $user_stored_value ] ) ? $stored_index[ $user_stored_value ] : 0;
    
            $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 );
    }

すべての既知の問題

この問題についてサポートが必要な場合

サポートのご質問をお寄せください。一緒に調査いたします。