Ktai Styleの管理画面でコメント周りにエラーが出るときの対処法 [WordPress]

WordPressを3.1以降にアップデートすると、Ktai Styleの管理画面で、コメント機能にエラーが出ます。どうやら_wp_get_comment_list()が使えないっぽい現象。

対処方法

Ktai Styleのテーマファイルの中の『functions.』に、以下を書き足します。
[]function _wp_get_comment_list( $status = ”, $s = false, $start, $num, $post = 0, $type = ” ) {
global $wpdb;

$start = abs( (int) $start );
$num = (int) $num;
$post = (int) $post;
$count = wp_count_comments();
$index = ”;

if ( ‘moderated’ == $status ) {
$approved = “c.comment_approved = ‘0’”;
$total = $count->moderated;
} elseif ( ‘approved’ == $status ) {
$approved = “c.comment_approved = ‘1’”;
$total = $count->approved;
} elseif ( ‘spam’ == $status ) {
$approved = “c.comment_approved = ‘spam'”;
$total = $count->spam;
} elseif ( ‘trash’ == $status ) {
$approved = “c.comment_approved = ‘trash'”;
$total = $count->trash;
} else {
$approved = “( c.comment_approved = ‘0’ OR c.comment_approved = ‘1’ )”;
$total = $count->moderated + $count->approved;
$index = ‘USE INDEX (c.comment_date_gmt)’;
}

if ( $post ) {
$total = ”;
$post = ” AND c.comment_post_ID = ‘$post'”;
} else {
$post = ”;
}

$orderby = “ORDER BY c.comment_date_gmt DESC LIMIT $start, $num”;

if ( ‘comment’ == $type )
$typesql = “AND c.comment_type = ””;
elseif ( ‘pings’ == $type )
$typesql = “AND ( c.comment_type = ‘pingback’ OR c.comment_type = ‘trackback’ )”;
elseif ( ‘all’ == $type )
$typesql = ”;
elseif ( !empty($type) )
$typesql = $wpdb->prepare(“AND c.comment_type = %s”, $type);
else
$typesql = ”;

if ( !empty($type) )
$total = ”;

$query = “FROM $wpdb->comments c LEFT JOIN $wpdb->posts p ON c.comment_post_ID = p.ID WHERE p.post_status != ‘trash’ “;
if ( $s ) {
$total = ”;
$s = $wpdb->escape($s);
$query .= “AND
(c.comment_author LIKE ‘%$s%’ OR
c.comment_author_email LIKE ‘%$s%’ OR
c.comment_author_url LIKE (‘%$s%’) OR
c.comment_author_IP LIKE (‘%$s%’) OR
c.comment_content LIKE (‘%$s%’) ) AND
$approved
$typesql”;
} else {
$query .= “AND $approved $post $typesql”;
}

$comments = $wpdb->get_results(“SELECT * $query $orderby”);
if ( ” === $total )
$total = $wpdb->get_var(“SELECT COUNT(c.comment_ID) $query”);

update_comment_cache($comments);

return array($comments, $total);
}
[/] プラグインのアップデートがなされれば、解消するかと思いますが現時点での対応方法です。

参考:WordPress › フォーラム » Ktai Styleの管理機能でPHP Fatal

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

CAPTCHA