Ktai Entry に関して、附属ドキュメントに掲載されていない疑問点やノウハウなどを掲載します。ここにない質問があれば、まず、附属ドキュメントをよく読んでみてください。それでも解決できなければ、作者にメールするか、WordPress 日本語フォーラム の「プラグイン」で質問してください。
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or ‘}’ in /****/wp-content/plugins/ktai_entry/ktai_entry.php on line 73サーバーが PHP5 を提供していても、自身が利用しているサービス/ドメイン名では PHP4 のままであることも多いので、よく確認してください。
2,17,32,47 * * * * /usr/bin/php /PATH/TO/retrieve.php※0,15,30,45 ではないのは、他の cron ジョブが使わなさそうな時刻にするためです。
$this->load_textdomain('ktai_entry_log', 'lang');」を有効にすると日本語化できます。文字コードはウェブログの文字コード (UTF-8 等) と同じです。ただし、メールサーバーに返答するためのメッセージ、および外部のメールボックスから返されたメッセージは英語のままです。POP3 connect: Error [152892360] [Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?] のようなメッセージが出る場合は、SSL が組み込まれていません。| /usr/bin/php /PATH/TO/inject.php ではなく、| /PATH/TO/inject.php としないと動かない場合があります。この場合は、inject.php の先頭に #! /usr/bin/php を記載し、かつ、実行権限を与えてください。define('KE_LOGFILE', 'logs/error.log'); define('KE_DEBUG', TRUE); のコメントを外して詳細のログ記録を有効にしてみてください。これで問題発生個所が分かるかもしれません。define('KE_LOGFILE', 'logs/error.log'); のコメントを外して有効にした場合に動作ログが有効になりますが、パーミッションの設定によっては、ログが作られない場合があります。特に、外部メールボックス読み込み方式と、メール着信でスクリプトを起動する方式を併用している場合は、両者でプロセスオーナーが違うため、問題が起きやすいです (前者は Apache, 後者は HOME ディレクトリーのオーナー)。あらかじめ以下のようにしてログファイルを作成しておくのが無難です。
mkdir logs chmod 0777 logs/; touch logs/error.log chmod 1666 logs/error.log
.photo {
padding-left:6px;
float:right;
line-height:110%;
font-size:0.85em;
text-indent:0;
}
.photo img {
background:white;
margin:0 0 4px 4px;
padding:3px;
border:1px solid #999;
}
.photo-end {
clear:left;
}
function ke_rel_lightbox($html, $id, $size) {
if (preg_match('/rel=["\']/', $html, $match)) {
$html = str_replace($match[0], $match[0] . 'lightbox ', $html);
} elseif (! preg_match('/rel=/', $html)) {
$html = str_replace('<a ', '<a rel="lightbox" ', $html);
}
return $html;
}
add_filter('image_link/ktai_entry.php', 'ke_rel_lightbox', 10, 3);function ke_another_author($user_id, $address) {
$authors = array(
'foo@example.com' => 1,
'bar@example.net' => 4,
);
return isset($authors[$address]) ? $authors[$address] : $user_id;
}
add_filter('validate_address/ktai_entry.php', 'ke_another_author', 10, 2);function ke_fix_author($user_id, $address) {
return $user_id ? 1 : 0
}
add_filter('validate_address/ktai_entry.php', 'ke_fix_author', 10, 2);function ke_restrict_author($user_id, $address) {
$restricts = array(2, 10);
return in_array($user_id, $restricts) ? 0 : $user_id;
}
add_filter('validate_address/ktai_entry.php', 'ke_restrict_author', 10, 2);function ke_allow_mailpost($status, $can_pending, $user_id, $address) {
if (! $user_id) {
return $status;
}
$user = get_userdata($user_id);
if ($user->user_level >= 1) {
$status = 'publish';
}
return $status;
}
add_filter('post_status/ktai_entry.php', 'ke_allow_mailpost', 10, 4);WP_User(1) の部分を管理者の ID 番号に変更してください。以下のサンプルコードに対応する日本語リソースは Ktai Entry に組み込みずみですので、メッセージは日本語になります。
function ke_notify_publish($post_id) {
if (! $post_id) {
return $post_id;
}
$admin = new WP_User(1);
$post = get_post($post_id);
$poster = new WP_User($post->post_author);
$blogname = get_option('blogname');
$message = __('New post on your blog.', 'ktai_entry') . "\r\n";
$message .= sprintf(__('Title: %s', 'ktai_entry'), $post->post_title) . "\r\n";
$message .= sprintf(__('Author: %s', 'ktai_entry'), $poster->display_name) . "\r\n\r\n";
$message .= __('You can see the post here:', 'ktai_entry') . "\r\n";
$message .= get_permalink($post->ID) . "\r\n";
$message .= sprintf(__('Edit it: %s', 'ktai_entry'), get_option('siteurl') . "/wp-admin/post.php?action=edit&post=$post->ID") . "\r\n";
$subject = sprintf(__('[%1$s] New Post: "%2$s"', 'ktai_entry'), $blogname, $post->post_title);
$wp_email = 'wordpress@' . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME']));
$headers = "From: \"$blogname\" <$wp_email>\n"
. "MIME-Version: 1.0\n"
. "Content-Type: text/plain; charset=ISO-2022-JP\n";
if (function_exists('mb_language') && function_exists('mb_internal_encoding') && function_exists('mb_send_mail')) {
mb_language('Japanese');
mb_internal_encoding(get_bloginfo('charset'));
mb_send_mail($admin->user_email, $subject, $message, $headers);
} else {
wp_mail($admin->user_email, $subject, $message, $headers);
}
}
add_action('publish_phone', 'ke_notify_publish');ke_rotate_vga($rotations, $rot_direction, $images) {
if (count($rotations) && function_exists('imagecreatefromstring')) {
for ($i = 0 ; $i < count($rotations) ; $i++) {
if (! isset($rotations[$i]) || $rotations[$i] != 'N') {
continue;
}
$image = imagecreatefromstring($images[$i]['body']);
if (! $image) {
continue;
}
$width = imagesx($image);
$height = imagesy($image);
if ($width > $height && $width >= 640 && $height >= 480) {
$rotations[$i] = 'R';
// $rotations[$i] = 'L';
}
}
}
return $rotations;
}
add_filter('image_rotate/ktai_entry.php', 'ke_rotate_vga', 10, 3);
なお、端末によっては、撮影時のカメラ位置を判断して適切な向きに直すので、上記のコードは不要です。以上