AI要約
説明
wpforms_field_select_choicesjs_config フィルターは、モダンなドロップダウンフォームフィールドのデフォルト設定を変更する機能を提供するために使用されます。
パラメーター
- $config
- (array) ドロップダウンに使用されるデフォルト設定の配列。
- $forms
- (int) フォームID。
ソース
wpforms/includes/fields/class-base.php
詳細情報
このフィルターには、読み込み中、結果なし、項目選択などのテキストのデフォルト設定があります。テキスト値とそのキー名の完全なリストは以下で確認できます。
'loadingText' => esc_html__( '読み込み中...', 'wpforms-lite' ),
'noResultsText' => esc_html__( '結果が見つかりませんでした。', 'wpforms-lite' ),
'noChoicesText' => esc_html__( '選択できる選択肢がありません。', 'wpforms-lite' ),
'itemSelectText' => esc_attr__( '選択するには押してください。', 'wpforms-lite' ),
'uniqueItemText' => esc_html__( '一意の値のみ追加できます。', 'wpforms-lite' ),
'customAddItemText' => esc_html__( '特定の条件に一致する値のみ追加できます。', 'wpforms-lite' ),
例
/**
* Configuration text settings for the Modern Dropdown form field.
*
* @link https://wpforms.com/developers/wpforms_field_select_choicesjs_config/
*
* @param array $config
* @param int $forms
* @return array
*/
function wpf_dev_change_modern_dropdown_noresults_text( $config, $forms ) {
// Change 519 to an ID of your actual form or remove this condition to apply to all forms.
if ( ! array_key_exists( 519, $forms ) ) {
return $config;
}
// If there are several forms on the same page, the customization will be applied to all of them.
$config[ 'loadingText' ] = __( 'Searching....', 'your-text-domain' );
$config[ 'noResultsText' ] = __( 'Nothing to be found', 'your-text-domain' );
$config[ 'noChoicesText' ] = __( 'These are not the choices you are looking for', 'your-text-domain' );
$config[ 'itemSelectText' ] = __( 'Select me', 'your-text-domain' );
$config[ 'uniqueItemText' ] = __( 'Only unique values can be added.', 'your-text-domain' );
$config[ 'customAddItemText' ] = __( 'Only values matching specific conditions can be added.', 'your-text-domain' );
$config[ 'searchResultLimit' ] = 2;
return $config;
}
add_filter( 'wpforms_field_select_choicesjs_config', 'wpf_dev_change_modern_dropdown_noresults_text', 10, 2 );