'."\n";
// $header .= ''."\n";
// $footer = ''."\n";
// // News一覧
// $rows = [];
// foreach($areas as $area) {
// if ($area == 'singapore') {
// // データベースに接続
// $pdo = new PDO(
// 'mysql:dbname=navybadger3_rbs;host=mysql57.navybadger3.sakura.ne.jp;charset=utf8mb4',
// 'navybadger3',
// 'mike7936',
// [
// PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
// PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
// ]
// );
// define('MAX', '30'); // 1ページの記事の表示数
// // 件数取得
// $stmt = $pdo->prepare("select count(*) as cnt from news where country = ?");
// $stmt->bindValue(1, 40); // 国コード
// $stmt->execute();
// $res = $stmt->fetch();
// $news_num = $res['cnt'];
// $pages = ceil($news_num / MAX); // 総ページ数
// for ($i=1; $i<=$pages; $i++) {
// $rows[] = "";
// if ($i == 1) {
// $rows[] = "\thttps://rin-bird-space.com/". $area. "/news";
// } else {
// $rows[] = "\thttps://rin-bird-space.com/". $area. "/news?no=". $i. "";
// }
// $rows[] = "\t". date(DateTime::W3C). "";
// $rows[] = "\tdaily";
// $rows[] = "\t0.6";
// $rows[] = "";
// }
// }
// }
// // ファイル出力
// $file = $header . implode("\n", $rows) . "\n". $footer;
// $path = ABSPATH . 'sitemaps/news-list.xml';
// file_put_contents($path, $file);
// // News詳細
// $rows = [];
// foreach($areas as $area) {
// if ($area == 'singapore') {
// // データベースに接続
// $pdo = new PDO(
// 'mysql:dbname=navybadger3_rbs;host=mysql57.navybadger3.sakura.ne.jp;charset=utf8mb4',
// 'navybadger3',
// 'mike7936',
// [
// PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
// PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
// ]
// );
// // 件数取得
// $stmt = $pdo->prepare("select id, post_date from news where country = ? order by post_date desc");
// $stmt->bindValue(1, 40); // 国コード
// $stmt->execute();
// $res = $stmt->fetchAll();
// foreach($res as $item) {
// $rows[] = "";
// $rows[] = "\thttps://rin-bird-space.com/". $area. "/news/detail?id=". $item['id']. "";
// $rows[] = "\t". date(DateTime::W3C, strtotime($item['post_date'])). "";
// $rows[] = "\tdaily";
// $rows[] = "\t0.6";
// $rows[] = "";
// }
// }
// }
// // ファイル出力
// $file = $header . implode("\n", $rows) . "\n". $footer;
// $path = ABSPATH . 'sitemaps/news-detail.xml';
// file_put_contents($path, $file);
// // 国一覧
// $rows = [];
// foreach($areas as $area) {
// $rows[] = "";
// $rows[] = "\thttps://rin-bird-space.com/". $area. "";
// $rows[] = "\t". date(DateTime::W3C). "";
// $rows[] = "\tdaily";
// $rows[] = "\t0.6";
// $rows[] = "";
// }
// // ファイル出力
// $file = $header . implode("\n", $rows) . "\n". $footer;
// $path = ABSPATH . 'sitemaps/areas.xml';
// file_put_contents($path, $file);
// // タグ一覧
// $rows = [];
// $tags = get_terms('post_tag');
// foreach ($tags as $tag) {
// $u = (get_term_link( $tag, 'post_tag' ));
// $rows[] = "";
// $rows[] = "\t". $u. "";
// $rows[] = "\t". date(DateTime::W3C). "";
// $rows[] = "\tdaily";
// $rows[] = "\t0.6";
// $rows[] = "";
// }
// // ファイル出力
// $file = $header . implode("\n", $rows) . "\n". $footer;
// $path = ABSPATH . 'sitemaps/tags.xml';
// file_put_contents($path, $file);
// // 記事詳細
// $rows = [];
// foreach($areas as $area) {
// // $paged = get_query_var('paged') ? get_query_var('paged') : 1 ;
// $args = array(
// // 'post_type' => array('A','B','C'),
// 'category_name' => $area,
// 'orderby' => 'dade',
// 'order' => 'asc',
// 'posts_per_page' => 10000, //表示(取得)する記事の数
// // 'paged' => $paged
// );
// $query = new WP_Query($args);
// if( $query->have_posts() ) {
// while($query->have_posts()) {
// $query->the_post();
// $rows[] = "";
// $rows[] = "\t". get_the_permalink(). "";
// $rows[] = "\t". get_the_modified_date(DateTime::W3C). "";
// $rows[] = "\tdaily";
// $rows[] = "\t0.6";
// $rows[] = "";
// }
// }
// }
// // ファイル出力
// $file = $header . implode("\n", $rows) . "\n". $footer;
// $path = ABSPATH . 'sitemaps/article-detail.xml';
// file_put_contents($path, $file);
// // 国×タグ
// $rows = [];
// foreach($areas as $area) {
// foreach ($tags as $tag) {
// $query = new WP_Query(array('category_name'=>$area, 'tag'=>$tag->slug));
// if($query->found_posts) {
// $url = "https://rin-bird-space.com/{$area}?tag={$tag->slug}";
// $rows[] = "";
// $rows[] = "\t". $url. "";
// $rows[] = "\t". date(DateTime::W3C). "";
// $rows[] = "\tdaily";
// $rows[] = "\t0.6";
// $rows[] = "";
// }
// }
// }
// // ファイル出力
// $file = $header . implode("\n", $rows) . "\n". $footer;
// $path = ABSPATH . 'sitemaps/area-tag.xml';
// file_put_contents($path, $file);
// // 質問一覧
// $rows = [];
// foreach($areas as $area) {
// $rows[] = "";
// $rows[] = "\thttps://rin-bird-space.com/{$area}/faq";
// $rows[] = "\t". date(DateTime::W3C). "";
// $rows[] = "\tdaily";
// $rows[] = "\t0.6";
// $rows[] = "";
// }
// // ファイル出力
// $file = $header . implode("\n", $rows) . "\n". $footer;
// $path = ABSPATH . 'sitemaps/faq.xml';
// file_put_contents($path, $file);
// // 質問詳細
// $rows = [];
// // 国名とIDのマッピング情報
// $map = [
// 'indonesia' => '10',
// 'australia' => '20',
// 'canada' => '30',
// 'singapore' => '40',
// 'thailand' => '50',
// 'new_zealand' => '60',
// 'malaysia' => '70',
// ];
// foreach($areas as $area) {
// // その他は除外
// if ($area == 'other') {
// continue;
// }
// $fid = $map[$area];
// include("faqdata/{$fid}.php");
// foreach ($items as $id=>$item) {
// $url = "https://rin-bird-space.com/{$area}/faq/detail?id={$fid}{$id}";
// $rows[] = "";
// $rows[] = "\t{$url}";
// $rows[] = "\t". date(DateTime::W3C). "";
// $rows[] = "\tdaily";
// $rows[] = "\t0.6";
// $rows[] = "";
// }
// }
// // ファイル出力
// $file = $header . implode("\n", $rows) . "\n". $footer;
// $path = ABSPATH . 'sitemaps/faq-detail.xml';
// file_put_contents($path, $file);