Example #1
0
    protected function generate_data()
    {
        global $wpdb, $blog_id;
        if (!BWP_SIMPLE_GXS::is_multisite() || BWP_SIMPLE_GXS::is_subdomain_install() || !empty($blog_id) && $blog_id > 1) {
            // if this is not a multisite installation,
            // OR a subdomain multisite installation,
            // OR not on main site, just show the lonely domain
            $last_post = $wpdb->get_row('
				SELECT
					post_date, post_date_gmt,
					post_modified, post_modified_gmt
				FROM ' . $wpdb->posts . "\n\t\t\t\tWHERE post_status = 'publish'\n\t\t\t\t\tAND post_password = ''\n\t\t\t\tORDER BY post_modified DESC\n\t\t\t\tLIMIT 1");
            $data = array();
            $data['location'] = trailingslashit(home_url());
            $data['lastmod'] = $this->get_lastmod($last_post);
            $data['freq'] = apply_filters('bwp_gxs_freq_site', $this->cal_frequency(false, $data['lastmod']), $blog_id);
            $data['freq'] = 'always' == $data['freq'] ? 'hourly' : $data['freq'];
            $data['priority'] = 1;
            $this->data[] = $data;
            // no SQL cycling needed
            return false;
        } else {
            if (isset($blog_id) && 1 == $blog_id) {
                if (!empty($wpdb->dmtable)) {
                    // if domain mapping is active, we only get blogs that don't
                    // have their domains mapped as this sitemap can only contains
                    // links on the same domain @see http://www.sitemaps.org/protocol.html#locdef
                    $blog_sql = '
					SELECT
						b.*
					FROM ' . $wpdb->blogs . ' b
					LEFT JOIN ' . $wpdb->dmtable . ' dm
						ON b.blog_id = dm.blog_id
						AND dm.active = 1
					WHERE b.public = 1
						AND b.spam = 0
						AND b.deleted = 0' . "\n\t\t\t\t\t\tAND (b.blog_id = 1 OR b.path <> '/')" . '
						AND dm.id is NULL';
                } else {
                    $blog_sql = '
					SELECT *
					FROM ' . $wpdb->blogs . '
					WHERE public = 1
						AND spam = 0
						AND deleted = 0' . "\n\t\t\t\t\t\tAND (blog_id = 1 OR path <> '/')";
                }
                $blogs = $this->get_results($blog_sql);
                if (!isset($blogs) || 0 == sizeof($blogs)) {
                    return false;
                }
                $data = array();
                for ($i = 0; $i < sizeof($blogs); $i++) {
                    $blog = $blogs[$i];
                    $data = $this->init_data($data);
                    $scheme = is_ssl() ? 'https://' : 'http://';
                    $path = $blog->path;
                    $data['location'] = $scheme . $blog->domain . $path;
                    $data['lastmod'] = $this->format_lastmod(strtotime($blog->last_updated));
                    $data['freq'] = apply_filters('bwp_gxs_freq_site', $this->cal_frequency(false, $blog->last_updated), $blog->blog_id);
                    $data['freq'] = 'always' == $data['freq'] ? 'hourly' : $data['freq'];
                    // always give primary blog a priority of 1
                    $data['priority'] = 0 == $i ? 1 : $this->cal_priority(false, $data['freq']);
                    $this->data[] = $data;
                }
                unset($blogs);
                return true;
            } else {
                return false;
            }
        }
    }
Example #2
0
<?php

/*
Plugin Name: BWP Google XML Sitemaps
Plugin URI: http://betterwp.net/wordpress-plugins/google-xml-sitemaps/
Description: A more lightweight Google XML Sitemap WordPress plugin that generates a <a href="http://en.wikipedia.org/wiki/Sitemap_index">Sitemap index</a> rather than a single sitemap. Despite its simplicity, it is still very powerful and has plenty of options to choose.
Version: 1.2.2
Text Domain: bwp-simple-gxs
Domain Path: /languages/
Author: Khang Minh
Author URI: http://betterwp.net
License: GPLv3
*/
// Pre-emptive
$bwp_gxs_ob_level = @ob_get_level();
$bwp_gxs_ob_start = ob_start();
// Frontend
require_once dirname(__FILE__) . '/includes/class-bwp-simple-gxs.php';
$bwp_gxs_gzipped = !BWP_SIMPLE_GXS::is_gzipped() ? false : true;
$bwp_gxs = new BWP_SIMPLE_GXS();
// Backend
add_action('admin_menu', 'bwp_gxs_init_admin', 1);
function bwp_gxs_init_admin()
{
    global $bwp_gxs;
    $bwp_gxs->init_admin();
}