Wordpress 的 comment type



在嘗試使用 MBLA (MyBlogLog Avatar) 的時候發現, 如果使用 K2 theme, 則在 MBLA option 裡面設定的 avatar 的 class 和 style 屬性都會無效.

Trace 了一下 mbla.php, 問題應該是出在 19 行的 $comment->comment_type == '', 在 Wordpress 的 default theme 裡, 如果是 comment, 則 comment_type 會傳回 "", 因此 MBLA 可以正確執行. 但在 K2 裡, comment 會傳回 "comment", 因此根本就不會進入這個 if-else 的任何一段, 所以 class 和 style 當然就無效了.

  // $comment               === NULL         -> post
  // $comment->comment_type  == 'pingback'   -> pingback
  // $comment->comment_type  == ''           -> comment
  if ($comment === NULL) {
    $_class = $mbla_options['mbla_regular_class'];
    $_style = $mbla_options['mbla_regular_style'];
    $_size  = "height: {$mbla_options['mbla_post_avatar_size']}px; width: {$mbla
_options['mbla_post_avatar_size']}px;";
  } elseif ($comment->comment_type == 'pingback') {
    if (!empty($mbla_options['mbla_mbl_id']) && (substr($_linkto, 0, strlen($mys
ite)) == $mysite) ) {
      $target_url = "http://{$_SERVER['HTTP_HOST']}{$mbla_options['mbla_cache_lo
cation']}/mybloglog_".md5($mbla_options['mbla_mbl_id']);
    }
    $_class = $mbla_options['mbla_regular_class'];
    $_style = $mbla_options['mbla_regular_style'];
    $_size  = "height: {$mbla_options['mbla_comment_avatar_size']}px; width: {$m
bla_options['mbla_comment_avatar_size']}px;";
  } elseif ($comment->comment_type == '') {
    $_class = $mbla_options['mbla_regular_class'];
    $_style = $mbla_options['mbla_regular_style'];
    $_size  = "height: {$mbla_options['mbla_comment_avatar_size']}px; width: {$m
bla_options['mbla_comment_avatar_size']}px;";
  }