私はプラグインを使用していますが、このプラグインは動作していないカスタムフィールドチェックを持っています。特定の条件でカスタムフィールドをチェックするために使用されるプラグインのコードの下。preg_match():デリミタは、英数字またはバックスラッシュでカスタムフィールドチェックを使用しないでください。
<?php if ($custom_field_value != null) {
if (($set['condition']['value']['operator'] == 'is' && $set['condition']['value']['value'] == $custom_field_value)
|| ($set['condition']['value']['operator'] == 'is_not' && $set['condition']['value']['value'] != $custom_field_value)
|| ($set['condition']['value']['operator'] == 'contains' && preg_match($set['condition']['value']['value'], $custom_field_value)) //The problematic line.
|| ($set['condition']['value']['operator'] == 'does_not_contain' && !preg_match($set['condition']['value']['value'], $custom_field_value))
|| ($set['condition']['value']['operator'] == 'lt' && $set['condition']['value']['value'] < $custom_field_value)
|| ($set['condition']['value']['operator'] == 'le' && $set['condition']['value']['value'] <= $custom_field_value)
|| ($set['condition']['value']['operator'] == 'eq' && $set['condition']['value']['value'] == $custom_field_value)
|| ($set['condition']['value']['operator'] == 'ge' && $set['condition']['value']['value'] >= $custom_field_value)
|| ($set['condition']['value']['operator'] == 'gt' && $set['condition']['value']['value'] > $custom_field_value)) {
$proceed = true;
}
}?>
問題は、 '含む' ライン内にあり、私のDEBUG.LOGに次のエラーを与える:
あってはなりませんがPHPの警告:するpreg_match():区切り文字は英数字またはバックスラッシュ
このチェックは、カスタムフィールドに '30'、 'text1'または 'text2'のいずれかが含まれているかどうかを確認するために使用されます。
ここで私は間違っている可能性がありますが、ここでは区切り文字を使用していないと思います。おそらくここで間違っている可能性がありますか?
私はこれを読んだとき私はそれがうまくいくと思った、それはない..私はワードプレスのカスタムフィールドが 'Array'を返すことが時々あると信じています。 preg_match()が配列に対して機能しないことがありますか? –
このマニュアルでは、1(見つかったもの)、0(見つからなかったもの)、FALSE(エラーが発生した場合)を返します。 – noreabu
私にとってはエラーが発生しましたが、私は配列だからだと思うが、間違っている可能性がある。私は開発者に連絡して、回答を受け取ったときに更新します。 –