function wpcs_settings_integration_section()
{
    $dep_plugin = wpcs_config('gxmls_dep');
    $dep_path = WP_CONTENT_DIR . '/plugins/' . $dep_plugin;
    if (!file_exists($dep_path)) {
        echo "Google XML Sitemaps plugin is not installed.";
        return;
    }
    if (!is_plugin_active($dep_plugin)) {
        echo "Google XML Sitemaps plugin is not activated.";
        return;
    }
    if (!wpcs_sitemap_exists()) {
        echo 'Sitemap file is missing, please generate the sitemap first. Then you\'ll be able to add it
        to the sitemap index generated by Google XML Sitemaps.';
        return;
    }
    ?>
    <?php 
    if (wpcs_is_sitemap_in_gxmls()) {
        ?>
        Your sitemap has been added to the sitemap index generated by Google XML Sitemaps. <br>
        <button id="wpcs_gxmls_remove" class="button button-reset">Remove the sitemap from Google XML Sitemaps</button>
    <?php 
    } else {
        ?>
        Add your sitemap file to the sitemap index generated by Google XML Sitemaps. <br>
        <button id="wpcs_gxmls_add" class="button button-reset">Add the sitemap to Google XML Sitemaps</button>
    <?php 
    }
    ?>
    <img class="wpcs_spinner wpcs_spinner_gxmls_remove wpcs_spinner_gxmls_add" src="/wp-admin/images/spinner.gif" alt="">
<?php 
}
Beispiel #2
0
    die;
}
add_action('wp_ajax_wpcs_gxmls_add', 'wpcs_gxmls_add_action');
function wpcs_gxmls_add_action()
{
    wpcs_add_to_gxmls();
    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 {
Beispiel #3
0
function wpcs_add_to_gxmls()
{
    if (!wpcs_is_sitemap_in_gxmls()) {
        update_option('wpcs_gxmls_connected', '1');
    }
}