0
나는 WP 테마 개발자이며 사용자 정의 메타 박스 값 저장에 문제가 있습니다.사용자 정의 메타 박스 저장 값 문제 - 폐기 됨 : 함수 ereg() 등
자습서에서 설명하는 방법을 찾았습니다.
내가 다음 코드를 사용하여 내 functions.php 내에서 사용자 정의 메타 박스 - save.php라는 파일이 포함되어있다: 게시물과 페이지에 게시 타격 후
<?php
function save_postdata($post_id) {
global $post, $new_meta_boxes, $page_settings, $blogroll, $post_settings, $team_info, $slide_info, $meta_box_groups;
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
return $post_id;
}
if(defined('DOING_AJAX') && DOING_AJAX) { //Prevents the metaboxes from being overwritten while quick editing.
return $post_id;
}
if(ereg('/\edit\.php', $_SERVER['REQUEST_URI'])) { //Detects if the save action is coming from a quick edit/batch edit.
return $post_id;
}
foreach($meta_box_groups as $group) {
foreach($group as $meta_box) {
if(isset($_POST[$meta_box['name'].'_noncename'])){
if (!wp_verify_nonce($_POST[$meta_box['name'].'_noncename'], $meta_box['name'].'-meta')) {
error_log(print_r($meta_box, TRUE).'{err_end}');
return $post_id;
}
}
if (isset($_POST['post_type']) && 'page' == $_POST['post_type']) {
if (!current_user_can('edit_page', $post_id))
return $post_id;
} else {
if (!current_user_can('edit_post', $post_id))
return $post_id;
}
if(isset($_POST[$meta_box['name'].'_value'])){
$data = $_POST[$meta_box['name'].'_value'];
}
if(get_post_meta($post_id, $meta_box['name'].'_value') == "")
add_post_meta($post_id, $meta_box['name'].'_value', $data, true);
elseif($data != get_post_meta($post_id, $meta_box['name'].'_value', true))
update_post_meta($post_id, $meta_box['name'].'_value', $data);
elseif($data == "" || $data == $meta_box['std'])
delete_post_meta($post_id, $meta_box['name'].'_value', get_post_meta($post_id, $meta_box['name'].'_value', true));
} // end foreach
} // end foreach
} // end save_postdata
add_action('save_post', 'save_postdata');
?>
내가 오류 때의 번호를 내 wp_debug가 켜져 있습니다 :
Deprecated: Function ereg() is deprecated in /home/creat/domains/tester.net/public_html/re/wp-content/themes/rev2/includes/custom-meta-boxes-save.php on line 14
Notice: Undefined variable: data in /home/creat/domains/tester.net/public_html/re/wp-content/themes/rev2/includes/custom-meta-boxes-save.php on line 41
Notice: Undefined variable: data in /home/creat/domains/tester.net/public_html/re/wp-content/themes/rev2/includes/custom-meta-boxes-save.php on line 43
Warning: Cannot modify header information - headers already sent by (output started at /home/creat/domains/tester.net/public_html/re/wp-content/themes/rev2/includes/custom-meta-boxes-save.php:41) in /home/creative/domains/ctproject.net/public_html/sa2/wp-admin/post.php on line 233
Warning: Cannot modify header information - headers already sent by (output started at /home/creat/domains/tester.net/public_html/re/wp-content/themes/rev2/includes/custom-meta-boxes-save.php:41) in /home/creative/domains/ctproject.net/public_html/sa2/wp-includes/pluggable.php on line 1178
내 마감 시간이 매우 짧기 때문에 많은 도움이 필요합니다.
감사합니다.