【发布时间】:2023-03-19 12:47:01
【问题描述】:
在发布 Wordpress 重力表单插件的“输入”数据时,我使用 function.php 代码将所有字符转换为大写。
add_action('gform_pre_submission_1', 'capitalize_fields_1');
function capitalize_fields_1($form){
// add all the field IDs you want to capitalize, to this array
$fields_to_cap = array('input_1');
foreach ($fields_to_cap as $each) {
// for each field, convert the submitted value to uppercase and assign back to the POST variable
// the rgpost function strips slashes
$_POST[$each] = strtoupper(rgpost($each));
}
// return the form, even though we did not modify it
return $form;
}
但是,我使用的是土耳其语,并且有一个 UTF-8 之外的字符。转换时小写字母“i”变成字母“I”。这两个字符的含义不同。我想把小写字母“i”转换成字母“I”。
我找到了这个过程的 php 代码,但是我无法将它适配到 function.php 文件中。
function mb_strtoupper_tr($metin){
$metin=str_replace('i', 'İ', $metin);
谁能帮助我如何调整或实施更有效的方法?
【问题讨论】:
标签: wordpress uppercase gravity-forms-plugin