init.php 570 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. class Api_Content_Lang extends Plugin {
  3. private $host;
  4. function about() {
  5. return array(1.0,
  6. "Sets lang=zh to article content returned via API (Chrome issue workaround)",
  7. "fox");
  8. }
  9. function init($host) {
  10. $this->host = $host;
  11. $host->add_hook($host::HOOK_RENDER_ARTICLE_API, $this);
  12. }
  13. function hook_render_article_api($row) {
  14. $article = isset($row['headline']) ? $row['headline'] : $row['article'];
  15. $article['content'] = "<div lang='zh'>" . $article['content'] . "</div>";
  16. return $article;
  17. }
  18. function api_version() {
  19. return 2;
  20. }
  21. }