function wpcs_settings_page_section() { ?> <?php if (wpcs_sitemap_exists()) { ?> Sitemap file has been generated and is avalable by this url: <a href="<?php echo wpcs_get_url(); ?> " target="_blank"><?php echo wpcs_get_url(); ?> </a> <br> <button id="wpcs_remove" type="submit" class="button button-reset">Remove the sitemap file</button> <button id="wpcs_create" type="submit" class="button button-reset">Rebuild the sitemap file</button> <?php } else { ?> Sitemap file is missing, it was either removed or never generated. <br> <?php if (!get_option('wpcs_app') || !get_option('wpcs_url_template') || !get_option('wpcs_law_slug')) { ?> <button disabled class="button button-reset">Generate the sitemap file</button> <span style="position: relative; top: 5px; color: red;"> Please specify GovRight <b>Application</b>, <b>Article URL template</b> and <b>Law slug</b> below. </span> <?php } else { ?> <button id="wpcs_create" type="submit" class="button button-reset">Generate the sitemap file</button> <?php } ?> <?php } ?> <img class="wpcs_spinner wpcs_spinner_create wpcs_spinner_remove" src="/wp-admin/images/spinner.gif" alt=""> <?php }
die; } add_action('wp_ajax_wpcs_gxmls_remove', 'wpcs_gxmls_remove_action'); function wpcs_gxmls_remove_action() { wpcs_remove_from_gxmls(); die; } add_action('sm_init', function () { if (wpcs_is_sitemap_in_gxmls()) { add_action('shutdown', function () { ob_end_flush(); }); ob_start(function ($buffer) { $request_uri = trim(explode('?', $_SERVER['REQUEST_URI'])[0], '/'); if ($request_uri === 'sitemap.xml') { $xml = simplexml_load_string($buffer); $sitemap = $xml->addChild('sitemap'); $sitemap->addChild('loc', wpcs_get_url()); $sitemap->addChild('lastmod', date('c', filemtime(wpcs_get_path()))); return $xml->asXML(); } else { if ($request_uri === 'sitemap.html') { return str_replace('</table>', '<tr><td><a href="' . wpcs_get_url() . '">' . wpcs_get_url() . '</a></td><td>' . date('Y-m-d H:i', filemtime(wpcs_get_path())) . '</td></tr></table>', $buffer); } else { return $buffer; } } }); } });