WordPressの開発版、2.7-almost-beta-9300をXAMPP上に入れてみました。メニューの配置が変わったりと、UIに結構手が入れられたのが2.7一番のポイントですが、それで物凄く使いやすくなったかというと、別にそうでもないというのが自分の受けた印象。まぁ、長く使っていくうちにじわじわと道具としての良さが分かってくるのかもしれないですが。
さて、WP2.7の重要な新機能の一つである、Comment APIをちょっと調べてみました。
2.7からはコメントをXMLRPCを通じて編集出来るようになりました。この機能をWPではComment APIとして呼ぶのですが、具体的には以下に引用した通りのメソッドが実装されています。
http://trac.wordpress.org/ticket/7446
Latest patch:
http://trac.wordpress.org/attachment/ticket/7446/7446.9.diff
The following methods are implemented:
wp.getComment(blog_id, username, password, comment_id)
wp.getComments(blog_id, username, password, {status, post_id, number, offset}
wp.deleteComment(blog_id, username, password, comment_id)
wp.editComment(blog_id, username, password, comment_id, {status,
date_created_gmt, content, author, author_url, author_email, })wp.newComment(blog_id, username, password, post, {content, author,
author_email, author_url})
// author info is optional if authorization is successful.
Unregistered commenting is allowed if a plugin sets the
xmlrpc_allow_anonymous_comments filter to true. Default is to not
allow unregistered comments. User must auth.wp.getCommentStatusList(blog_id, username, password)
で、これらの中で注意が必要なのが、wp.newCommentメソッド。引用文中に
author info is optional if authorization is successful.
というコメントが入っていますが、認証に通っている場合、実はauthorやauthor_emailに指定した値は無視され、使用されません。WPのユーザーアカウント情報の対応する値が使用されることに注意しましょう。以上のことは、xmlrpc.phpの1275行目で確認できます。
if ( $logged_in ) {
$user = wp_get_current_user();
$comment['comment_author'] = $wpdb->escape( $user->display_name );
$comment['comment_author_email'] = $wpdb->escape( $user->user_email );
$comment['comment_author_url'] = $wpdb->escape( $user->user_url );
$comment['user_ID'] = $user->ID;
} else {
では認証を通さなければ、一般ビジターとして好きなメルアドやURLを指定してコメントをつけられるかというと、そうでもなくて、今度は
Unregistered commenting is allowed if a plugin sets the xmlrpc_allow_anonymous_comments filter to true.
という問題に引っかかります。ままならないものですね…。
あと気になった点といえば、同一内容のコメントを連投しようとした場合、Response Code 500で撥ねられるという点。XMLRPC経由なのだから、XMLRPC Faultでエラーを通知するべきだと思うのですが…。
WP-XMLRPCのパースエラーのデモンストレーション用コード