콘텐츠의 텍스트를 기반으로 맞춤 입력란을 업데이트하는 content_save_pre 필터를 추가하려고합니다 (예 : [something] Thing [/ something]은 플러그인에게 사용자 정의 필드를 "Thing"으로 설정하도록 지시합니다.필터 내에서 WordPress 게시물 ID 가져 오기
내 코드 (아래)는 웹 인터페이스를 통해 게시 할 때 잘 작동하지만 시도한 클라이언트 (MarsEdit 및 WordPress iOS)와 "Press This"북마크릿에서 실패합니다. [] 태그는 제거되지만 사용자 정의 필드는 설정되지 않습니다.
function dfll_get_link($post_content) {
$dflink = dfll_find_link($post_content);
if ($dflink) {
global $post;
$post_id = $post->ID;
update_post_meta($post_id, 'linked_list_url', $dflink);
}
$temp = '/(' . dfll_regesc('[ll]') . '(.*?)' . dfll_regesc('[/ll]') . ')/i';
$post_content = (preg_replace($temp, '', $post_content));
return $post_content;
}
add_filter('content_save_pre', 'dfll_get_link');
일부 테스트에서 $ post_id 변수가 설정되지 않은 것으로 보입니다. 이 경우 게시물 ID를 가져 오는 방법이 있습니까? 아니면 필터를 다른 후크에 추가해야합니까? (나는 그런 생각을 할 수 없다.)
그 자체로는 해결책이 아니지만 다음 패치를 사용해보십시오. http://core.trac.wordpress.org/ticket/15515 – windyjonas