function pof_sitemap_run() { if (!current_user_can('manage_options')) { wp_die(__('You do not have sufficient permissions to access this page.')); } global $wpdb; $res = $wpdb->get_results("\n\t\t\t SELECT wp_postmeta.meta_value, wp_posts.ID, wp_posts.post_type, wp_posts.post_name\n FROM wp_postmeta\n JOIN wp_posts\n ON wp_postmeta.post_id = wp_posts.ID\n WHERE wp_postmeta.meta_key = 'post_guid'\n AND wp_posts.post_status = 'publish'\n #AND wp_posts.post_type IN ('page', 'pof_post_agegroup', 'pof_post_program', 'pof_post_task', 'pof_post_taskgroup')\n AND wp_posts.post_type IN ('page', 'pof_post_agegroup', 'pof_post_program', 'pof_post_taskgroup')\n ORDER BY wp_posts.post_type, wp_posts.ID;\n\t\t\t "); $langs = pof_settigs_get_active_lang_codes(false); $content = "<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">"; foreach ($res as $item) { switch ($item->post_type) { case "page": $content .= "<url>"; $content .= "<loc>" . get_site_url() . "/" . $item->post_name . "</loc>"; $content .= "<priority>0.9</priority>"; $content .= "</url>"; break; case "pof_post_program": $content .= "<url>\n"; $content .= "<loc>" . get_site_url() . "/spn-ohjelma-json-taysi/?postGUID=" . $item->meta_value . "</loc>"; $content .= "<priority>0.9</priority>"; $content .= "</url>"; break; case "pof_post_task": foreach ($langs as $lang_code) { $content .= "<url>\n"; $content .= "<loc>" . get_site_url() . "/item-json/?postGUID=" . $item->meta_value . "&lang=" . $lang_code . "</loc>"; $content .= "<priority>0.8</priority>"; $content .= "</url>"; $content .= "<url>"; $content .= "<loc>" . get_site_url() . "/item-jso-vinkit/?postGUID=" . $item->meta_value . "&lang=" . $lang_code . "</loc>"; $content .= "<priority>0.2</priority>"; $content .= "</url>"; } break; default: foreach ($langs as $lang_code) { $content .= "<url>"; $content .= "<loc>" . get_site_url() . "/item-json/?postGUID=" . $item->meta_value . "&lang=" . $lang_code . "</loc>"; $content .= "<priority>0.5</priority>"; $content .= "</url>"; } break; } } $content .= "</urlset>"; $destination = get_home_path() . "/pof-sitemap.xml"; if (file_exists($destination)) { unlink($destination); } $file2 = fopen($destination, "w+"); fputs($file2, $content); fclose($file2); echo '<div class="wrap">'; echo '<h1>POF Sitemap</h1>'; echo '<p><textarea rows="40" cols="40">' . $content . '</textarea></p>'; echo '</div>'; }
$child = generate_xml_element($doc, $data); if ($child) { $doc->appendChild($child); } $outXml = $doc->saveXML(); $xml = new DOMDocument(); $xml->preserveWhiteSpace = false; $xml->formatOutput = true; $xml->loadXML($outXml); $outXml = $xml->saveXML(); return $outXml; } /** JSON FUNCTIONS */ //$pof_available_languages = array('sv', 'en'); $pof_settings_langs = array(); $pof_available_languages = pof_settigs_get_active_lang_codes(); $pof_settings_lastupdate_overwrite = pof_settings_get_lastupdate_overwrite(); function getLastModifiedBy($userId) { $tmp = new stdClass(); $tmp->id = $userId; if (!empty($userId)) { $tmp->name = get_userdata($userId)->display_name; } return $tmp; } function getJsonItemBaseDetails($jsonItem, $post) { global $pof_available_languages; global $pof_settings_lastupdate_overwrite; if ($pof_settings_lastupdate_overwrite == null) {