2013-04-07 4 views
1

간단한 PHP 파일을 사용하여 내 WordPress에 게시하고 있습니다. 지금까지 900posts 정도가 있지만 아직 게시 시간이 오래 걸리는 것으로 나타났습니다! 그것은 어느정도 (심지어 30 초 +) 다 떨어집니다! 여기 내가 사용하는 코드입니다. wordpress wp_insert_post가 너무 오래 걸립니다.

<?php 
    require_once('./../wp-blog-header.php'); 
    require_once('./simple_html_dom.php'); 
    require_once('./../wp-admin/includes/taxonomy.php'); 

function postit($category,$date,$title,$content,$keys){ 
$cat=wp_create_category($category); 
$post = array(
    'comment_status' => 'open',// 'closed' means no comments. 
    'ping_status' => 'open', // 'closed' means pingbacks or trackbacks turned off 
    'post_author' => '1', //The user ID number of the author. 
    'post_category' => array($cat), //post_category no longer exists, try wp_set_post_terms() for setting a post's categories 
    'post_content' => $content, //The full text of the post. 
    'post_date'  => date('Y-m-d H:i:s',strtotime($date)), //The time post was made. 
    'post_date_gmt' => date('Y-m-d H:i:s',strtotime($date)), //The time post was made, in GMT. 
    'post_status' => 'publish', //Set the status of the new post. 
    'post_title'  => $title, //The title of your post. 
    'post_type'  => 'post', //You may want to insert a regular post, page, link, a menu item or some custom post type 
    'tags_input'  => $keys,//For tags. 
    'post_content_filtered' => '1', 
    'filter' => '1' 
); 

remove_filter('content_save_pre', 'wp_filter_post_kses'); 
remove_filter('content_filtered_save_pre', 'wp_filter_post_kses'); 
$r=wp_insert_post($post ,$wp_error); 
add_filter('content_save_pre', 'wp_filter_post_kses'); 
add_filter('content_filtered_save_pre', 'wp_filter_post_kses'); 
return $r; 
} 

내가 프로파일이를 실행

,

wp_create_category 0.01 초를 실행합니다. 그리고 나머지 코드는 0.8 초가 걸리는 반면 필터와 wp_insert_post를 제거하는 부분은 나머지 실행 시간이 걸립니다 ..

누구나 이것을 최적화 할 수있는 제안이 있습니까?

+0

대시 보드에서도 여전히 이러한 현상이 발생합니까? –

+0

@RobertLee 대시 보드의 경우 동일합니다 – Zalaboza

+0

데이터베이스를 최적화하려고 시도 했습니까? 당신이 할 수있는 수동 질의가 있지만 이것은 좀 더 사용하기 쉽습니다. http://wordpress.org/extend/plugins/tentblogger-optimize-wordpress-database-plugin/ –

답변

2

발견 된 솔루션. 그것은 내 지연내 플러그인 중 하나였습니다. 일단 모든 플러그인을 사용 중지하면 지연이 발생합니다!

일부 플러그인은 필터/후크를 wp_new_post에 추가하고 그 후크로 인해 지연 문제가 발생했다고 생각합니다.

미래의 Google 직원을위한 정보. 그냥 모든 플러그인을 비활성화하고 게시하려고하면 문제가 goan 다음이 문제를 일으키는 플러그인을 찾을 때까지 그들을 하나씩 차례대로 시작하십시오.

감사하고 도움을 주신 모든 분께

+0

저에게 많은 도움을 주신 고마워요. "WP-Mail-SMTP"플러그인이었습니다. 나는 "wp_insert_post"훅으로 이메일을 보내고, smtp가 잘못 구성되었다. 사용 중지하면 문제가 해결되었습니다. –

관련 문제