0

WordPress Atom Publishing Protocol プラグイン(以前の wp-app.php も)を使用して Atompub API 経由でエントリを投稿するとき、エントリに公開フィールドとして非 GMT 時刻値が含まれている場合、次のようになります。

<entry xmlns='http://www.w3.org/2005/Atom'><title type='text'>test</title><content type='text/html'>test</content>
<published>2013-08-27T00:00:00+09:00</published>
<app:control xmlns:app='http://www.w3.org/2007/app'><app:draft>no</app:draft></app:control><category term='test'/></entry>

タイムゾーン ( +09:00 ) が正しく解析されず、同じ値 (GMT 時間) が と のフィールドに格納さpost_datepost_date_gmtますwp_posts

post_date: 2013-08-27 00:00:00
post_date_gmt: 2013-08-27 00:00:00
4

1 に答える 1

0

get_publish_time()の関数wp-content/plugins/atom-publishing-protocol/class-wp-atom-server.phpを次のコードに置き換えます。

/**
 * Retrieve published time to display in XML.
 *
 * @since 2.3.0
 *
 * @param string $published Time string.
 * @return string
 */
function get_publish_time($published) {
    $pubtime = DateTime::createFromFormat(DateTime::RFC3339, $published);

    if (!$pubtime) {
        return array(current_time('mysql'),current_time('mysql',1));
    } else {
        $localtime = $pubtime->format("Y-m-d H:i:s");
        $pubtime->setTimezone( new DateTimeZone('UTC') );
        $gmttime = $pubtime->format("Y-m-d H:i:s");
        return array($localtime, $gmttime);
    }
}

知らせ

  • PHP >= 5.2 が必要
  • wp-app.php がまだ存在する場合、プラグインは使用されません。

理由

これはrfc3339_str2time()、元の実装の関数がタイムゾーン情報を削除するためです。

于 2013-08-24T22:07:22.400 に答える