問題の概要
Ninja FormsとそのRepeatable Fields (新しいタブで開く)機能を使用する場合、翻訳に関する問題が発生することがあります。WPML文字列翻訳を使用してフィールドを翻訳することは可能ですが、親リピーターフィールドのラベルを翻訳すると、サブフィールドの翻訳が上書きされます。
回避策
この問題はNinja Forms Multilingual 0.3.1で修正されました。 更新するとサイト上の問題は解決するため、この回避策が必要になるのは、まだ更新できない場合のみです。
続行する前に、必ずサイトの完全なバックアップを作成してください。
- …/wp-content/plugins/wpml-ninja-forms/classes/Hooks/NinjaForms/Strings.phpファイルを開きます。
- 62行目を探します。
- 次のコードを:
以下に置き換えます:PHP
if ( $this->getFormId() && $this->notEmpty( 'settings', $field ) && $this->notEmpty( 'type', $field['settings'] ) && $this->isTranslatableFieldType( $field['settings']['type'] ) ) { $field['settings'] = $this->getPackage()->translateField( $field['settings'], $this->getId( $field ) ); }
PHPif ( $this->getFormId() && $this->notEmpty( 'settings', $field ) && $this->notEmpty( 'type', $field['settings'] ) && $this->isTranslatableFieldType( $field['settings']['type'] ) ) { if (! array_key_exists('repeaterField', $field['settings'] ) && $field['settings']['repeaterField'] != true ) { $field['settings'] = $this->getPackage()->translateField( $field['settings'], $this->getId( $field ) ); } }