2011-10-31 4 views
1

몇 가지 사용자 정의 필드가있는 사용자 정의 게시물을 만들고 있습니다. 사용자 정의 필드에 입력 한 값에 작은 따옴표가 있으면 그 뒤에 오는 모든 것이 잘립니다. 따옴표를 이스케이프 처리하여 문자열의 일부로 읽을 수있는 필터가 있습니까?Wordpress 사용자 정의 필드에서 작은 따옴표를 처리 할 수 ​​없습니다.

나는 커스텀 필드를 많이 가지고있다. 그러나 여기에 내가 사용하고있는 코드의 예가있다.

// prefix of meta keys, optional 
// use underscore (_) at the beginning to make keys hidden, for example $prefix =  '_rw_'; 
// you also can make prefix empty to disable it 
$prefix = 'rw_'; 
$meta_boxes = array(); 
// first meta box 
$meta_boxes[] = array(
'id' => 'entry_data',       // meta box  id, unique per meta box 
'title' => 'Entry Data',   // meta box title 
'pages' => array('dictionary_entry'), // post types, accept custom post types as  well, default is array('post'); optional 
'context' => 'normal',      // where the meta box appear: normal (default), advanced, side; optional 
'priority' => 'high',      // order of meta box: high (default), low; optional 
'fields' => array(       // list of meta fields 
    array(
     'name' => 'Definition 1',     // field name 
     'desc' => 'What does this mean?', // field description, optional 
     'id' => $prefix . 'definition1',    // field id, i.e. the meta key 
     'type' => 'text',      // text box 
     'std' => '',     // default value, optional 
     'validate_func' => 'check_name'   // validate function, created below, inside RW_Meta_Box_Validate class 
    ), 
    array(
     'name' => 'Example 1',     // field name 
     'desc' => 'Use it in a sentence?', // field description, optional 
     'id' => $prefix . 'example1',    // field id, i.e. the meta key 
     'type' => 'text',      // text box 
     'std' => '',     // default value, optional 
     'validate_func' => 'check_name'   // validate function, created below, inside RW_Meta_Box_Validate class 
    ), 
) 
); 

답변

1

htmlentities($value, ENT_QUOTES) 값을 텍스트 상자에서 읽으셨습니까?

+0

그게 내가하고 싶은 일이지만, 어디에서해야할지 모르겠습니다. 작은 따옴표가 문자열의 나머지 부분을 잘라내 기 때문에 저장된 텍스트에 적용 할 함수가 필요합니다. – emersonthis

+0

그래서'validate_func'' 또는'textbox 값을 읽어서 sth로하고 싶다면 다른 곳에서'htmlentities'를 사용하고 싶을 것입니다. – maialithar

+0

이 문제가 해결되었습니다. 'save_post' 후크를 저장하기 전에 필드 데이터에서 실행하면 매회마다 다시 올 것입니다. – Kaji

관련 문제