public function get_related($id = '', $filter = array(), $context = 'view')
 {
     $option = get_option('sirp_options');
     $num = !empty($filter['num']) ? (int) $filter['num'] : (int) $option['display_num'];
     $ids = sirp_get_related_posts_id_api($num, $id);
     $posts_list = array();
     foreach ($ids as $id) {
         $posts_list[] = get_post($id['ID']);
     }
     $response = new WP_JSON_Response();
     if (!$posts_list) {
         $response->set_data(array());
         return $response;
     }
     $struct = array();
     $response->header('Last-Modified', mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0) . ' GMT');
     foreach ($posts_list as $post) {
         $post = get_object_vars($post);
         if (!$this->check_read_permission($post)) {
             continue;
         }
         $response->link_header('item', json_url('/posts/' . $post['ID']), array('title' => $post['post_title']));
         $post_data = $this->prepare_post($post, $context);
         if (is_wp_error($post_data)) {
             continue;
         }
         $struct[] = $post_data;
     }
     $response->set_data($struct);
     return $response;
 }
 /**
  * Retrieve ranking
  *
  * Overrides the $type to set to 'post', then passes through to the post
  * endpoints.
  *
  * @see WP_JSON_Posts::get_posts()
  */
 public function get_ranking($filter = array(), $context = 'view')
 {
     $ids = sga_ranking_get_date($filter);
     $posts_list = array();
     foreach ($ids as $id) {
         $posts_list[] = get_post($id);
     }
     $response = new WP_JSON_Response();
     if (!$posts_list) {
         $response->set_data(array());
         return $response;
     }
     // holds all the posts data
     $struct = array();
     $response->header('Last-Modified', mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0) . ' GMT');
     foreach ($posts_list as $post) {
         $post = get_object_vars($post);
         // Do we have permission to read this post?
         if (!$this->check_read_permission($post)) {
             continue;
         }
         $response->link_header('item', json_url('/posts/' . $post['ID']), array('title' => $post['post_title']));
         $post_data = $this->prepare_post($post, $context);
         if (is_wp_error($post_data)) {
             continue;
         }
         $struct[] = $post_data;
     }
     $response->set_data($struct);
     return $response;
 }
Esempio n. 3
0
 /**
  * Test the <feed> element to make sure its present and populated
  * with the expected child elements and attributes.
  */
 function test_feed_element()
 {
     $this->go_to('/?feed=atom');
     $feed = $this->do_atom();
     $xml = xml_to_array($feed);
     // Get the <feed> child element of <xml>.
     $atom = xml_find($xml, 'feed');
     // There should only be one <feed> child element.
     $this->assertCount(1, $atom);
     // Verify attributes.
     $this->assertEquals('http://www.w3.org/2005/Atom', $atom[0]['attributes']['xmlns']);
     $this->assertEquals('http://purl.org/syndication/thread/1.0', $atom[0]['attributes']['xmlns:thr']);
     $this->assertEquals(site_url('/wp-atom.php'), $atom[0]['attributes']['xml:base']);
     // Verify the <feed> element is present and contains a <title> child element.
     $title = xml_find($xml, 'feed', 'title');
     $this->assertEquals(get_option('blogname'), $title[0]['content']);
     // Verify the <feed> element is present and contains a <updated> child element.
     $updated = xml_find($xml, 'feed', 'updated');
     $this->assertEquals(strtotime(get_lastpostmodified()), strtotime($updated[0]['content']));
     // Verify the <feed> element is present and contains a <subtitle> child element.
     $subtitle = xml_find($xml, 'feed', 'subtitle');
     $this->assertEquals(get_option('blogdescription'), $subtitle[0]['content']);
     // Verify the <feed> element is present and contains two <link> child elements.
     $link = xml_find($xml, 'feed', 'link');
     $this->assertCount(2, $link);
     // Verify the <feed> element is present and contains a <link rel="alternate"> child element.
     $this->assertEquals('alternate', $link[0]['attributes']['rel']);
     $this->assertEquals(home_url(), $link[0]['attributes']['href']);
     // Verify the <feed> element is present and contains a <link rel="href"> child element.
     $this->assertEquals('self', $link[1]['attributes']['rel']);
     $this->assertEquals(home_url('/?feed=atom'), $link[1]['attributes']['href']);
 }
Esempio n. 4
0
 /**
  * Add the XML News Sitemap to the Sitemap Index.
  *
  * @param string $str String with Index sitemap content.
  * @return string
  */
 function add_to_index($str)
 {
     $result = strtotime(get_lastpostmodified('gmt'));
     $date = date('c', $result);
     $str .= '<sitemap>' . "\n";
     $str .= '<loc>' . home_url('news-sitemap.xml') . '</loc>' . "\n";
     $str .= '<lastmod>' . $date . '</lastmod>' . "\n";
     $str .= '</sitemap>' . "\n";
     return $str;
 }
/**
 * Google XML Sitemap
 *
 * @author Cor van Noorloos
 * @license http://www.opensource.org/licenses/gpl-license.php GPL v2.0 (or later)
 * @link https://github.com/corvannoorloos/google-xml-sitemap
 *
 * @wordpress
 * HiddenPlugin Name: Google XML Sitemap
 * Plugin URI: https://github.com/corvannoorloos/google-xml-sitemap
 * Description: Sitemaps are a way to tell Google about pages on your site we might not otherwise discover. In its simplest terms, a XML Sitemap&mdash;usually called Sitemap, with a capital S&mdash;is a list of the pages on your website. Creating and submitting a Sitemap helps make sure that Google knows about all the pages on your site, including URLs that may not be discoverable by Google's normal crawling process.
 * Author: Cor van Noorloos
 * Version: 0.1.1
 * Author URI: http://corvannoorloos.com/
 * (Bookt) The original file has been modified to output specific entries from BAPI seo data
 */
function google_sitemap()
{
    if (!preg_match('/sitemap\\.xml$/', $_SERVER['REQUEST_URI'])) {
        return;
    }
    global $wpdb;
    $posts = $wpdb->get_results("SELECT ID, post_title, post_modified_gmt\r\n\t\tFROM {$wpdb->posts}\r\n\t\tWHERE post_status = 'publish'\r\n\t\tAND post_type <> 'nav_menu_item'\r\n\t\tAND post_name <> 'hello-world'\r\n\t\tAND post_password = ''\r\n\t\tORDER BY post_type DESC, post_modified DESC\r\n\t\tLIMIT 50000");
    header("HTTP/1.1 200 OK");
    header('X-Robots-Tag: noindex, follow', true);
    header('Content-Type: text/xml');
    echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '"?>' . "\n";
    echo '<!-- generator="' . home_url('/') . '" -->' . "\n";
    $xml = '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">' . "\n";
    $xml .= "\t<url>" . "\n";
    $xml .= "\t\t<loc>" . home_url('/') . "</loc>\n";
    $xml .= "\t\t<lastmod>" . mysql2date('Y-m-d\\TH:i:s+00:00', get_lastpostmodified('GMT'), false) . "</lastmod>\n";
    $xml .= "\t\t<changefreq>" . 'daily' . "</changefreq>\n";
    $xml .= "\t\t<priority>" . '1' . "</priority>\n";
    $xml .= "\t</url>" . "\n";
    foreach ($posts as $post) {
        if ($post->ID == get_option('page_on_front')) {
            continue;
        }
        if (!empty($post->post_title)) {
            // prevent outputing detail screens which can be determined by seeing if the post has a meta bapikey
            $bapikey = get_post_meta($post->ID, "bapikey", true);
            if (empty($bapikey)) {
                $xml .= "\t<url>\n";
                $xml .= "\t\t<loc>" . get_permalink($post->ID) . "</loc>\n";
                $xml .= "\t\t<lastmod>" . mysql2date('Y-m-d\\TH:i:s+00:00', $post->post_modified_gmt, false) . "</lastmod>\n";
                $xml .= "\t\t<changefreq>" . 'weekly' . "</changefreq>\n";
                $xml .= "\t\t<priority>" . '0.8' . "</priority>\n";
                $xml .= "\t</url>\n";
            }
        }
    }
    // now output the pages from bapi seo data
    global $bapisync;
    global $bapi_all_options;
    foreach ($bapisync->seodata as $seo) {
        if (!empty($seo["entity"]) && !empty($seo["pkid"])) {
            $turl = BAPISync::cleanurl($seo["DetailURL"]);
            $xml .= "\t<url>\n";
            $xml .= "\t\t<loc>" . $bapi_all_options['bapi_site_cdn_domain'] . $turl . "</loc>\n";
            $xml .= "\t\t<lastmod>" . mysql2date('Y-m-d\\TH:i:s+00:00', $seo["ModifiedOn"]["LongDateTime"], false) . "</lastmod>\n";
            $xml .= "\t\t<changefreq>" . 'weekly' . "</changefreq>\n";
            $xml .= "\t\t<priority>" . '0.8' . "</priority>\n";
            $xml .= "\t</url>\n";
        }
    }
    $xml .= '</urlset>';
    echo "{$xml}";
    exit;
}
Esempio n. 6
0
 public static function find($app)
 {
     $found = 0;
     $posts = array();
     $request_args = $app->request()->get();
     $args = self::convert_request($request_args);
     if ($lastModified = apply_filters('thermal_get_lastpostmodified', get_lastpostmodified('gmt'))) {
         $app->lastModified(strtotime($lastModified . ' GMT'));
     }
     $model = self::model();
     $posts = $model->find($args, $found);
     array_walk($posts, array(__CLASS__, 'format'), 'read');
     return empty($args['no_found_rows']) ? compact('posts', 'found') : compact('posts');
 }
Esempio n. 7
0
/**
 * Xml site Map generator
 * @param array $availables_post_types
 * @return true if success, false otherwise
 */
function seo_update_xmlsitemap($availables_post_types)
{
    $success = false;
    // $xmlsitemappath = trailingslashit(get_home_path()) . "sitemap.xml"; makes error with woocommerce payplug/paypal purchase method
    $xmlsitemappath = trailingslashit(ABSPATH) . "sitemap.xml";
    if (($fp = @fopen($xmlsitemappath, 'w')) !== FALSE) {
        $xml_sitemap = "";
        $xml_sitemap .= '<?xml version="1.0" encoding="UTF-8"?>';
        $xsl = locate_web_ressource(CUSTOM_PLUGIN_TOOLS_FOLDER . SEO_TOOL_NAME . '/xmlsitemap/xmlsitemap.xsl');
        if (!empty($xsl)) {
            $xml_sitemap .= "\n" . '<?xml-stylesheet type="text/xsl" href="' . $xsl . '"?>';
        }
        $xml_sitemap .= "\n" . '<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
        // root
        $lm = intval(get_timestamp_from_mysql(get_lastpostmodified('GMT')));
        $date = date('Y-m-d\\TH:i:s+00:00', $lm);
        $xml_sitemap .= "\n\t" . '<url>';
        $xml_sitemap .= "\n\t\t" . '<loc>' . get_bloginfo('url') . '</loc>';
        $xml_sitemap .= "\n\t\t" . '<lastmod>' . $date . '</lastmod>';
        $xml_sitemap .= "\n\t\t" . '<changefreq>weekly</changefreq>';
        $xml_sitemap .= "\n\t\t" . '<priority>1.0</priority>';
        $xml_sitemap .= "\n\t" . '</url>';
        if ($availables_post_types) {
            // posts
            $posts = get_posts(array('numberposts' => -1, 'orderby' => 'modified', 'order' => 'DESC', 'post_type' => $availables_post_types, 'suppress_filters' => true));
            foreach ($posts as $post) {
                $lm = intval(get_timestamp_from_mysql($post->post_modified_gmt));
                $date = date('Y-m-d\\TH:i:s+00:00', $lm);
                $xml_sitemap .= "\n\t" . '<url>';
                $xml_sitemap .= "\n\t\t" . '<loc>' . get_permalink($post->ID) . '</loc>';
                $xml_sitemap .= "\n\t\t" . '<lastmod>' . $date . '</lastmod>';
                $xml_sitemap .= "\n\t\t" . '<changefreq>weekly</changefreq>';
                $xml_sitemap .= "\n\t\t" . '<priority>0.6</priority>';
                $xml_sitemap .= "\n\t" . '</url>';
            }
        }
        $xml_sitemap .= "\n" . '</urlset>';
        // ecriture du fichier
        fwrite($fp, $xml_sitemap);
        fclose($fp);
        $success = true;
    } else {
        trace_err("Impossible d'écrire le fichier : " . trailingslashit(get_home_path()) . "sitemap.xml");
    }
    return $success;
}
Esempio n. 8
0
 function test_channel()
 {
     $this->go_to('/?feed=rss2');
     $feed = $this->do_rss2();
     $xml = xml_to_array($feed);
     // get the rss -> channel element
     $channel = xml_find($xml, 'rss', 'channel');
     $this->assertTrue(empty($channel[0]['attributes']));
     $title = xml_find($xml, 'rss', 'channel', 'title');
     $this->assertEquals(get_option('blogname'), $title[0]['content']);
     $desc = xml_find($xml, 'rss', 'channel', 'description');
     $this->assertEquals(get_option('blogdescription'), $desc[0]['content']);
     $link = xml_find($xml, 'rss', 'channel', 'link');
     $this->assertEquals(get_option('siteurl'), $link[0]['content']);
     $pubdate = xml_find($xml, 'rss', 'channel', 'lastBuildDate');
     $this->assertEquals(strtotime(get_lastpostmodified()), strtotime($pubdate[0]['content']));
 }
Esempio n. 9
0
function wpjam_headers($headers, $wp)
{
    if (!is_user_logged_in() && empty($wp->query_vars['feed'])) {
        $headers['Cache-Control'] = 'max-age:600';
        $headers['Expires'] = gmdate('D, d M Y H:i:s', time() + 600) . " GMT";
        $wpjam_timestamp = get_lastpostmodified('GMT') > get_lastcommentmodified('GMT') ? get_lastpostmodified('GMT') : get_lastcommentmodified('GMT');
        $wp_last_modified = mysql2date('D, d M Y H:i:s', $wpjam_timestamp, 0) . ' GMT';
        $wp_etag = '"' . md5($wp_last_modified) . '"';
        $headers['Last-Modified'] = $wp_last_modified;
        $headers['ETag'] = $wp_etag;
        // Support for Conditional GET
        if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
            $client_etag = stripslashes(stripslashes($_SERVER['HTTP_IF_NONE_MATCH']));
        } else {
            $client_etag = false;
        }
        $client_last_modified = empty($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? '' : trim($_SERVER['HTTP_IF_MODIFIED_SINCE']);
        // If string is empty, return 0. If not, attempt to parse into a timestamp
        $client_modified_timestamp = $client_last_modified ? strtotime($client_last_modified) : 0;
        // Make a timestamp for our most recent modification...
        $wp_modified_timestamp = strtotime($wp_last_modified);
        $exit_required = false;
        if ($client_last_modified && $client_etag ? $client_modified_timestamp >= $wp_modified_timestamp && $client_etag == $wp_etag : $client_modified_timestamp >= $wp_modified_timestamp || $client_etag == $wp_etag) {
            $status = 304;
            $exit_required = true;
        }
        if ($exit_required) {
            if (!empty($status)) {
                status_header($status);
            }
            foreach ((array) $headers as $name => $field_value) {
                @header("{$name}: {$field_value}");
            }
            if (isset($headers['Last-Modified']) && empty($headers['Last-Modified']) && function_exists('header_remove')) {
                @header_remove('Last-Modified');
            }
            exit;
        }
    }
    return $headers;
}
Esempio n. 10
0
    public function print_eventlist_feed()
    {
        header('Content-Type: ' . feed_content_type('rss-http') . '; charset=' . get_option('blog_charset'), true);
        $events = $this->db->get_events($this->options->get('el_feed_upcoming_only') ? 'upcoming' : null);
        // Print feeds
        echo '<?xml version="1.0" encoding="' . get_option('blog_charset') . '"?>
	<rss version="2.0"
		xmlns:content="http://purl.org/rss/1.0/modules/content/"
		xmlns:wfw="http://wellformedweb.org/CommentAPI/"
		xmlns:dc="http://purl.org/dc/elements/1.1/"
		xmlns:atom="http://www.w3.org/2005/Atom"
		xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>
		<channel>
			<title>' . get_bloginfo_rss('name') . '</title>
			<atom:link href="' . apply_filters('self_link', get_bloginfo()) . '" rel="self" type="application/rss+xml" />
			<link>' . get_bloginfo_rss('url') . '</link>
			<description>' . __('Eventlist') . '</description>
			<lastBuildDate>' . mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false) . '</lastBuildDate>
			<language>' . get_option('rss_language') . '</language>
			<sy:updatePeriod>' . apply_filters('rss_update_period', 'hourly') . '</sy:updatePeriod>
			<sy:updateFrequency>' . apply_filters('rss_update_frequency', '1') . '</sy:updateFrequency>
			';
        do_action('rss2_head');
        if (!empty($events)) {
            foreach ($events as $event) {
                echo '
			<item>
				<title>' . esc_attr($this->format_date($event->start_date, $event->end_date) . ' - ' . $event->title) . '</title>
				<pubDate>' . mysql2date('D, d M Y H:i:s +0000', $event->start_date, false) . '</pubDate>
				<description>' . esc_attr($this->format_date($event->start_date, $event->end_date) . ' ' . ('' != $event->time ? $event->time : '') . ('' != $event->location ? ' - ' . $event->location : '')) . '</description>
				' . ('' != $event->details ? '<content:encoded><![CDATA[' . esc_attr($this->format_date($event->start_date, $event->end_date) . ' ' . ('' != $event->time ? $event->time : '') . ('' != $event->location ? ' - ' . $event->location : '')) . $event->details . ']]></content:encoded>' : '') . '
			</item>';
            }
        }
        echo '
		</channel>
	</rss>';
    }
Esempio n. 11
0
 /**
  * Handles publishing or updating a post
  *
  * @param  string $post_id the post id
  * @return bool   whether the request worked
  */
 public static function post_notify($post_id)
 {
     global $wpdb;
     $post = get_post($post_id);
     $url = get_permalink($post_id);
     $tags = wp_get_post_tags($post_id, array('fields' => 'names'));
     $categories = array_map(array('ShareaholicNotifier', 'post_notify_iterator'), get_the_category($post_id));
     if (function_exists('has_post_thumbnail') && has_post_thumbnail($post_id)) {
         $featured_image = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), 'large');
     } else {
         $featured_image = ShareaholicUtilities::post_first_image();
         if (!$featured_image) {
             $featured_image = '';
         }
     }
     if ($post->post_author) {
         $author_data = get_userdata($post->post_author);
         $author_name = $author_data->display_name;
     }
     $notification = array('url' => $url, 'api_key' => ShareaholicUtilities::get_option('api_key'), 'content' => array('title' => $post->post_title, 'excerpt' => $post->post_excerpt, 'body' => $post->post_content, 'featured-image-url' => $featured_image), 'metadata' => array('author-id' => $post->post_author, 'author-name' => $author_name, 'post-type' => $post->post_type, 'post-id' => $post_id, 'post-tags' => $tags, 'post-categories' => $categories, 'post-language' => get_bloginfo('language'), 'published' => $post->post_date_gmt, 'updated' => get_lastpostmodified('GMT'), 'visibility' => $post->post_status), 'diagnostics' => array('platform' => 'wordpress', 'platform-version' => get_bloginfo('version'), 'shareaholic-version' => Shareaholic::VERSION, 'wp-multisite' => is_multisite(), 'wp-theme' => get_option('template'), 'wp-posts-total' => $wpdb->get_var("SELECT count(ID) FROM {$wpdb->posts} where post_type = 'post' AND post_status = 'publish'"), 'wp-pages-total' => $wpdb->get_var("SELECT count(ID) FROM {$wpdb->posts} where post_type = 'page' AND post_status = 'publish'"), 'wp-comments-total' => wp_count_comments()->approved, 'wp-users-total' => $wpdb->get_var("SELECT count(ID) FROM {$wpdb->users}")));
     return self::send_notification($notification);
 }
Esempio n. 12
0
 public function tax_query($data)
 {
     $allowed = array('post_type', 'tax_query');
     foreach ($data as $key => $value) {
         if (!in_array($key, $allowed)) {
             unset($data[$key]);
         }
     }
     if (!is_array($data) || empty($data) || !isset($data['tax_query'])) {
         return new WP_Error('jp_api_tax_query', __('Invalid tax query.'), array('status' => 500));
     }
     $post_query = new WP_Query();
     $posts_list = $post_query->query($data);
     $response = new WP_JSON_Response();
     $response->query_navigation_headers($post_query);
     if (!$posts_list) {
         $response->set_data(array());
         return $response;
     }
     // holds all the posts data
     $struct = array();
     $response->header('Last-Modified', mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0) . ' GMT');
     foreach ($posts_list as $post) {
         $post = get_object_vars($post);
         // Do we have permission to read this post?
         if (json_check_post_permission($post, 'read')) {
             continue;
         }
         $response->link_header('item', json_url('/posts/' . $post['ID']), array('title' => $post['post_title']));
         $post_data = $this->prepare_post($post, 'view');
         if (is_wp_error($post_data)) {
             continue;
         }
         $struct[] = $post_data;
     }
     $response->set_data($struct);
     return $response;
 }
Esempio n. 13
0
/**
 * Google XML Sitemap
 *
 * @since 0.1.1
 *
 * @global type $wpdb
 *
 * @return type
 */
function google_sitemap()
{
    if (!preg_match('/sitemap\\.xml$/', $_SERVER['REQUEST_URI'])) {
        return;
    }
    global $wpdb;
    $posts = $wpdb->get_results("SELECT ID, post_title, post_modified_gmt\r\n    FROM {$wpdb->posts}\r\n    WHERE post_status = 'publish'\r\n    AND post_password = ''\r\n    ORDER BY post_type DESC, post_modified DESC\r\n    LIMIT 50000");
    header("HTTP/1.1 200 OK");
    header('X-Robots-Tag: noindex, follow', true);
    header('Content-Type: text/xml');
    echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '"?>' . "\n";
    echo '<!-- generator="' . home_url('/') . '" -->' . "\n";
    $xml = '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">' . "\n";
    $xml .= "\t<url>" . "\n";
    $xml .= "\t\t<loc>" . home_url('/') . "</loc>\n";
    $xml .= "\t\t<lastmod>" . mysql2date('Y-m-d\\TH:i:s+00:00', get_lastpostmodified('GMT'), false) . "</lastmod>\n";
    $xml .= "\t\t<changefreq>" . 'daily' . "</changefreq>\n";
    $xml .= "\t\t<priority>" . '1' . "</priority>\n";
    $xml .= "\t</url>" . "\n";
    foreach ($posts as $post) {
        if ($post->ID == get_option('page_on_front')) {
            continue;
        }
        if (!empty($post->post_title)) {
            $xml .= "\t<url>\n";
            $xml .= "\t\t<loc>" . get_permalink($post->ID) . "</loc>\n";
            $xml .= "\t\t<lastmod>" . mysql2date('Y-m-d\\TH:i:s+00:00', $post->post_modified_gmt, false) . "</lastmod>\n";
            $xml .= "\t\t<changefreq>" . 'weekly' . "</changefreq>\n";
            $xml .= "\t\t<priority>" . '0.8' . "</priority>\n";
            $xml .= "\t</url>\n";
        }
    }
    $xml .= '</urlset>';
    echo "{$xml}";
    exit;
}
Esempio n. 14
0
    function feed()
    {
        $title = sprintf('%s log', $this->name);
        header('Content-type: text/xml; charset=' . get_option('blog_charset'), true);
        echo '<?xml version="1.0" encoding="' . get_option('blog_charset') . '"?' . ">\r\n";
        ?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
	<title><?php 
        echo $title . ' - ';
        bloginfo_rss('name');
        ?>
</title>
	<link><?php 
        bloginfo_rss('url');
        ?>
</link>
	<description><?php 
        bloginfo_rss("description");
        ?>
</description>
	<pubDate><?php 
        echo htmlspecialchars(mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false));
        ?>
</pubDate>
	<generator><?php 
        echo htmlspecialchars('http://wordpress.org/?v=');
        bloginfo_rss('version');
        ?>
</generator>
	<language><?php 
        echo get_option('rss_language');
        ?>
</language>
<?php 
        if (count($this->items) > 0) {
            foreach ($this->items as $log) {
                ?>
	<item>
		<title><![CDATA[<?php 
                echo $log->url;
                ?>
]]></title>
		<link><![CDATA[<?php 
                bloginfo('home');
                echo $log->url;
                ?>
]]></link>
		<pubDate><?php 
                echo mysql2date('D, d M Y H:i:s +0000', $log->created_at, false);
                ?>
</pubDate>
		<guid isPermaLink="false"><?php 
                print $log->id;
                ?>
</guid>
		<description><![CDATA[<?php 
                echo $log->url;
                ?>
]]></description>
		<content:encoded><![CDATA[<?php 
                if ($log->referrer) {
                    echo 'Referred by ' . $log->referrer;
                }
                ?>
]]></content:encoded>
	</item>
		<?php 
            }
        }
        ?>
</channel>
</rss>
<?php 
        die;
    }
 function send_headers()
 {
     @header('X-Pingback: ' . get_bloginfo('pingback_url'));
     if (is_user_logged_in()) {
         nocache_headers();
     }
     if (!empty($this->query_vars['error']) && '404' == $this->query_vars['error']) {
         status_header(404);
         if (!is_user_logged_in()) {
             nocache_headers();
         }
         @header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
     } else {
         if (empty($this->query_vars['feed'])) {
             @header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
         } else {
             // We're showing a feed, so WP is indeed the only thing that last changed
             if (!empty($this->query_vars['withcomments']) || empty($this->query_vars['withoutcomments']) && (!empty($this->query_vars['p']) || !empty($this->query_vars['name']) || !empty($this->query_vars['page_id']) || !empty($this->query_vars['pagename']) || !empty($this->query_vars['attachment']) || !empty($this->query_vars['attachment_id']))) {
                 $wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastcommentmodified('GMT'), 0) . ' GMT';
             } else {
                 $wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0) . ' GMT';
             }
             $wp_etag = '"' . md5($wp_last_modified) . '"';
             @header("Last-Modified: {$wp_last_modified}");
             @header("ETag: {$wp_etag}");
             // Support for Conditional GET
             if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
                 $client_etag = stripslashes(stripslashes($_SERVER['HTTP_IF_NONE_MATCH']));
             } else {
                 $client_etag = false;
             }
             $client_last_modified = empty($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? '' : trim($_SERVER['HTTP_IF_MODIFIED_SINCE']);
             // If string is empty, return 0. If not, attempt to parse into a timestamp
             $client_modified_timestamp = $client_last_modified ? strtotime($client_last_modified) : 0;
             // Make a timestamp for our most recent modification...
             $wp_modified_timestamp = strtotime($wp_last_modified);
             if ($client_last_modified && $client_etag ? $client_modified_timestamp >= $wp_modified_timestamp && $client_etag == $wp_etag : $client_modified_timestamp >= $wp_modified_timestamp || $client_etag == $wp_etag) {
                 status_header(304);
                 exit;
             }
         }
     }
     do_action_ref_array('send_headers', array(&$this));
 }
Esempio n. 16
0
 /**
  * Send additional HTTP headers for caching, content type, etc.
  *
  * Sets the X-Pingback header, 404 status (if 404), Content-type. If showing
  * a feed, it will also send last-modified, etag, and 304 status if needed.
  *
  * @since 2.0.0
  */
 function send_headers()
 {
     $headers = array('X-Pingback' => get_bloginfo('pingback_url'));
     $status = null;
     $exit_required = false;
     if (is_user_logged_in()) {
         $headers = array_merge($headers, wp_get_nocache_headers());
     }
     if (!empty($this->query_vars['error'])) {
         $status = (int) $this->query_vars['error'];
         if (404 === $status) {
             if (!is_user_logged_in()) {
                 $headers = array_merge($headers, wp_get_nocache_headers());
             }
             $headers['Content-Type'] = get_option('html_type') . '; charset=' . get_option('blog_charset');
         } elseif (in_array($status, array(403, 500, 502, 503))) {
             $exit_required = true;
         }
     } else {
         if (empty($this->query_vars['feed'])) {
             $headers['Content-Type'] = get_option('html_type') . '; charset=' . get_option('blog_charset');
         } else {
             // We're showing a feed, so WP is indeed the only thing that last changed
             if (!empty($this->query_vars['withcomments']) || empty($this->query_vars['withoutcomments']) && (!empty($this->query_vars['p']) || !empty($this->query_vars['name']) || !empty($this->query_vars['page_id']) || !empty($this->query_vars['pagename']) || !empty($this->query_vars['attachment']) || !empty($this->query_vars['attachment_id']))) {
                 $wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastcommentmodified('GMT'), 0) . ' GMT';
             } else {
                 $wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0) . ' GMT';
             }
             $wp_etag = '"' . md5($wp_last_modified) . '"';
             $headers['Last-Modified'] = $wp_last_modified;
             $headers['ETag'] = $wp_etag;
             // Support for Conditional GET
             if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
                 $client_etag = stripslashes(stripslashes($_SERVER['HTTP_IF_NONE_MATCH']));
             } else {
                 $client_etag = false;
             }
             $client_last_modified = empty($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? '' : trim($_SERVER['HTTP_IF_MODIFIED_SINCE']);
             // If string is empty, return 0. If not, attempt to parse into a timestamp
             $client_modified_timestamp = $client_last_modified ? strtotime($client_last_modified) : 0;
             // Make a timestamp for our most recent modification...
             $wp_modified_timestamp = strtotime($wp_last_modified);
             if ($client_last_modified && $client_etag ? $client_modified_timestamp >= $wp_modified_timestamp && $client_etag == $wp_etag : $client_modified_timestamp >= $wp_modified_timestamp || $client_etag == $wp_etag) {
                 $status = 304;
                 $exit_required = true;
             }
         }
     }
     $headers = apply_filters('wp_headers', $headers, $this);
     if (!empty($status)) {
         status_header($status);
     }
     foreach ((array) $headers as $name => $field_value) {
         @header("{$name}: {$field_value}");
     }
     if ($exit_required) {
         exit;
     }
     do_action_ref_array('send_headers', array(&$this));
 }
Esempio n. 17
0
 /**
  * Process conditionals for posts.
  *
  * @since 2.2.0
  */
 function process_conditionals()
 {
     if (empty($this->params)) {
         return;
     }
     if ($_SERVER['REQUEST_METHOD'] == 'DELETE') {
         return;
     }
     switch ($this->params[0]) {
         case $this->ENTRY_PATH:
             global $post;
             $post = wp_get_single_post($this->params[1]);
             $wp_last_modified = get_post_modified_time('D, d M Y H:i:s', true);
             $post = NULL;
             break;
         case $this->ENTRIES_PATH:
             $wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0) . ' GMT';
             break;
         default:
             return;
     }
     $wp_etag = md5($wp_last_modified);
     @header("Last-Modified: {$wp_last_modified}");
     @header("ETag: {$wp_etag}");
     // Support for Conditional GET
     if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
         $client_etag = stripslashes($_SERVER['HTTP_IF_NONE_MATCH']);
     } else {
         $client_etag = false;
     }
     $client_last_modified = trim($_SERVER['HTTP_IF_MODIFIED_SINCE']);
     // If string is empty, return 0. If not, attempt to parse into a timestamp
     $client_modified_timestamp = $client_last_modified ? strtotime($client_last_modified) : 0;
     // Make a timestamp for our most recent modification...
     $wp_modified_timestamp = strtotime($wp_last_modified);
     if ($client_last_modified && $client_etag ? $client_modified_timestamp >= $wp_modified_timestamp && $client_etag == $wp_etag : $client_modified_timestamp >= $wp_modified_timestamp || $client_etag == $wp_etag) {
         status_header(304);
         exit;
     }
 }
Esempio n. 18
0
echo '<?xml version="1.0" encoding="UTF-8"?>';
echo '<?xml-stylesheet type="text/xsl" href="/sitemap.xsl"?>';
// XSL地址
echo '<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
?>
<!-- generated-on=<?php 
echo get_lastpostdate('blog');
?>
 Modified Gimhoy(http://blog.gimhoy.com)-->
  <url>
      <loc><?php 
echo get_home_url();
?>
</loc>
      <lastmod><?php 
$ltime = get_lastpostmodified(GMT);
$ltime = gmdate('Y-m-d\\TH:i:s+00:00', strtotime($ltime));
echo $ltime;
?>
</lastmod>
      <changefreq>daily</changefreq>
      <priority>1.0</priority>
  </url>
<?php 
header("Content-type: text/xml");
$myposts = get_posts("numberposts=" . $posts_to_show);
foreach ($myposts as $post) {
    ?>
  <url>
      <loc><?php 
    the_permalink();
function asxs_sitemap2()
{
    $Index_Sitemap_url = home_url('/sitemap.xml', $scheme = 'relative');
    $Normal_Sitemap_urltype = home_url('/sitemap_part_', $scheme = 'relative');
    $uri = rtrim($_SERVER['REQUEST_URI'], '/');
    $Index_S = $Index_Sitemap_url == $uri ? true : false;
    $Normal_S = stristr($uri, $Normal_Sitemap_urltype) && strstr($uri, '.xml') ? true : false;
    if (!$Index_S && !$Normal_S) {
        return;
    }
    global $wpdb;
    $xml = array();
    header("HTTP/1.1 200 OK");
    header('X-Robots-Tag: noindex, follow', true);
    header('Content-Type: text/xml');
    echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '"?>' . '<!-- generator="' . home_url('/') . ' (' . basename(__FILE__) . ')" -->' . "\n";
    $default = 'xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"';
    /* --- INDEX SITEMAP ---
     * splits XML per every
     */
    if ($Index_S) {
        $cached_id = 'index';
        if ($cached = wp_cache_get($cached_id, __FUNCTION__)) {
            die($cached);
        }
        $posts = $wpdb->get_results("SELECT ID FROM {$wpdb->posts} WHERE post_status = 'publish' AND post_password = ''");
        $xml[] = '<sitemapindex ' . $default . '>';
        for ($i = 1; $i < count($posts) / ASXS_LIMIT + 1; $i++) {
            $xml[] = '<sitemap><loc>' . home_url() . '/sitemap_part_' . $i . '.xml</loc></sitemap>';
        }
        $xml[] = '</sitemapindex>';
        $xml = join("\n", $xml);
        wp_cache_set($cached_id, $xml, __FUNCTION__, ASXS_EXPIRE);
        die($xml);
    }
    // --- NORMAL SITEMAP ---
    if ($Normal_S) {
        preg_match("#{$Normal_Sitemap_urltype}([0-9]+)\\.xml#si", $_SERVER['REQUEST_URI'], $new);
        $partNumber = $new[1];
        $cached_id = $new[1];
        if ($cached = wp_cache_get($cached_id, __FUNCTION__)) {
            die($cached);
        }
        $posts = $wpdb->get_results("SELECT ID, post_title, post_name, post_modified_gmt FROM {$wpdb->posts} WHERE post_status = 'publish' AND post_password = '' ORDER BY post_type DESC, post_modified DESC LIMIT " . ASXS_LIMIT . " OFFSET " . ($partNumber - 1) * ASXS_LIMIT);
        $frontpage_id = get_option('page_on_front');
        $xml[] = '<urlset ' . $default . '>' . "\n";
        // include home url
        if ($partNumber == 1) {
            $xml[] = "\t<url>\n" . "\t\t<loc>" . htmlspecialchars(home_url('/')) . "</loc>\n" . "\t\t<lastmod>" . mysql2date('c', get_lastpostmodified('GMT'), false) . "</lastmod>\n" . "\t\t<changefreq>" . 'daily' . "</changefreq>\n" . "\t\t<priority>" . '1' . "</priority>\n" . "\t</url>\n";
        }
        foreach ($posts as $post) {
            $title = empty($post->post_title) ? $post->post_name : $post->post_title;
            if (!empty($title) && $post->ID != $frontpage_id) {
                $xml[] = "\t<url>\n" . "\t\t<loc>" . htmlspecialchars(get_permalink($post->ID)) . "</loc>\n" . "\t\t<lastmod>" . mysql2date('c', $post->post_modified_gmt, false) . "</lastmod>\n" . "\t\t<changefreq>" . 'weekly' . "</changefreq>\n" . "\t\t<priority>" . '0.5' . "</priority>\n" . "\t</url>\n";
            }
        }
        $xml[] = '</urlset>';
        $xml = join("\n", $xml);
        wp_cache_set($cached_id, $xml, __FUNCTION__, ASXS_EXPIRE);
        die($xml);
    }
}
?>
</title>
		<atom:link href="<?php 
self_link();
?>
" rel="self" type="application/rss+xml" />
		<link><?php 
bloginfo_rss('url');
?>
</link>
		<description><?php 
bloginfo_rss('description');
?>
</description>
		<lastBuildDate><?php 
echo balanceTags(mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false));
?>
</lastBuildDate>
		<language><?php 
bloginfo_rss('language');
?>
</language>
		<sy:updatePeriod><?php 
echo balanceTags(apply_filters('rss_update_period', 'hourly'));
?>
</sy:updatePeriod>
		<sy:updateFrequency><?php 
echo balanceTags(apply_filters('rss_update_frequency', '1'));
?>
</sy:updateFrequency>
		<?php 
Esempio n. 21
0
function export_wp($author = '')
{
    global $wpdb, $post_ids, $post;
    do_action('export_wp');
    $filename = 'wordpress.' . date('Y-m-d') . '.xml';
    header('Content-Description: File Transfer');
    header("Content-Disposition: attachment; filename={$filename}");
    header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
    $where = '';
    if ($author and $author != 'all') {
        $author_id = (int) $author;
        $where = $wpdb->prepare(" WHERE post_author = %d ", $author_id);
    }
    // grab a snapshot of post IDs, just in case it changes during the export
    $post_ids = $wpdb->get_col("SELECT ID FROM {$wpdb->posts} {$where} ORDER BY post_date_gmt ASC");
    $categories = (array) get_categories('get=all');
    $tags = (array) get_tags('get=all');
    function wxr_missing_parents($categories)
    {
        if (!is_array($categories) || empty($categories)) {
            return array();
        }
        foreach ($categories as $category) {
            $parents[$category->term_id] = $category->parent;
        }
        $parents = array_unique(array_diff($parents, array_keys($parents)));
        if ($zero = array_search('0', $parents)) {
            unset($parents[$zero]);
        }
        return $parents;
    }
    while ($parents = wxr_missing_parents($categories)) {
        $found_parents = get_categories("include=" . join(', ', $parents));
        if (is_array($found_parents) && count($found_parents)) {
            $categories = array_merge($categories, $found_parents);
        } else {
            break;
        }
    }
    // Put them in order to be inserted with no child going before its parent
    $pass = 0;
    $passes = 1000 + count($categories);
    while (($cat = array_shift($categories)) && ++$pass < $passes) {
        if ($cat->parent == 0 || isset($cats[$cat->parent])) {
            $cats[$cat->term_id] = $cat;
        } else {
            $categories[] = $cat;
        }
    }
    unset($categories);
    function wxr_cdata($str)
    {
        if (seems_utf8($str) == false) {
            $str = utf8_encode($str);
        }
        // $str = ent2ncr(wp_specialchars($str));
        $str = "<![CDATA[{$str}" . (substr($str, -1) == ']' ? ' ' : '') . "]]>";
        return $str;
    }
    function wxr_site_url()
    {
        global $current_site;
        // mu: the base url
        if (isset($current_site->domain)) {
            return 'http://' . $current_site->domain . $current_site->path;
        } else {
            return get_bloginfo_rss('url');
        }
    }
    function wxr_cat_name($c)
    {
        if (empty($c->name)) {
            return;
        }
        echo '<wp:cat_name>' . wxr_cdata($c->name) . '</wp:cat_name>';
    }
    function wxr_category_description($c)
    {
        if (empty($c->description)) {
            return;
        }
        echo '<wp:category_description>' . wxr_cdata($c->description) . '</wp:category_description>';
    }
    function wxr_tag_name($t)
    {
        if (empty($t->name)) {
            return;
        }
        echo '<wp:tag_name>' . wxr_cdata($t->name) . '</wp:tag_name>';
    }
    function wxr_tag_description($t)
    {
        if (empty($t->description)) {
            return;
        }
        echo '<wp:tag_description>' . wxr_cdata($t->description) . '</wp:tag_description>';
    }
    function wxr_post_taxonomy()
    {
        $categories = get_the_category();
        $tags = get_the_tags();
        $the_list = '';
        $filter = 'rss';
        if (!empty($categories)) {
            foreach ((array) $categories as $category) {
                $cat_name = sanitize_term_field('name', $category->name, $category->term_id, 'category', $filter);
                // for backwards compatibility
                $the_list .= "\n\t\t<category><![CDATA[{$cat_name}]]></category>\n";
                // forwards compatibility: use a unique identifier for each cat to avoid clashes
                // http://trac.wordpress.org/ticket/5447
                $the_list .= "\n\t\t<category domain=\"category\" nicename=\"{$category->slug}\"><![CDATA[{$cat_name}]]></category>\n";
            }
        }
        if (!empty($tags)) {
            foreach ((array) $tags as $tag) {
                $tag_name = sanitize_term_field('name', $tag->name, $tag->term_id, 'post_tag', $filter);
                $the_list .= "\n\t\t<category domain=\"tag\"><![CDATA[{$tag_name}]]></category>\n";
                // forwards compatibility as above
                $the_list .= "\n\t\t<category domain=\"tag\" nicename=\"{$tag->slug}\"><![CDATA[{$tag_name}]]></category>\n";
            }
        }
        echo $the_list;
    }
    echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '"?' . ">\n";
    ?>
<!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your blog. -->
<!-- It contains information about your blog's posts, comments, and categories. -->
<!-- You may use this file to transfer that content from one site to another. -->
<!-- This file is not intended to serve as a complete backup of your blog. -->

<!-- To import this information into a WordPress blog follow these steps. -->
<!-- 1. Log into that blog as an administrator. -->
<!-- 2. Go to Manage: Import in the blog's admin panels. -->
<!-- 3. Choose "WordPress" from the list. -->
<!-- 4. Upload this file using the form provided on that page. -->
<!-- 5. You will first be asked to map the authors in this export file to users -->
<!--    on the blog.  For each author, you may choose to map to an -->
<!--    existing user on the blog or to create a new user -->
<!-- 6. WordPress will then import each of the posts, comments, and categories -->
<!--    contained in this file into your blog -->

<?php 
    the_generator('export');
    ?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:wp="http://wordpress.org/export/<?php 
    echo WXR_VERSION;
    ?>
/"
>

<channel>
	<title><?php 
    bloginfo_rss('name');
    ?>
</title>
	<link><?php 
    bloginfo_rss('url');
    ?>
</link>
	<description><?php 
    bloginfo_rss("description");
    ?>
</description>
	<pubDate><?php 
    echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false);
    ?>
</pubDate>
	<generator>http://wordpress.org/?v=<?php 
    bloginfo_rss('version');
    ?>
</generator>
	<language><?php 
    echo get_option('rss_language');
    ?>
</language>
	<wp:wxr_version><?php 
    echo WXR_VERSION;
    ?>
</wp:wxr_version>
	<wp:base_site_url><?php 
    echo wxr_site_url();
    ?>
</wp:base_site_url>
	<wp:base_blog_url><?php 
    bloginfo_rss('url');
    ?>
</wp:base_blog_url>
<?php 
    if ($cats) {
        foreach ($cats as $c) {
            ?>
	<wp:category><wp:category_nicename><?php 
            echo $c->slug;
            ?>
</wp:category_nicename><wp:category_parent><?php 
            echo $c->parent ? $cats[$c->parent]->name : '';
            ?>
</wp:category_parent><?php 
            wxr_cat_name($c);
            wxr_category_description($c);
            ?>
</wp:category>
<?php 
        }
    }
    if ($tags) {
        foreach ($tags as $t) {
            ?>
	<wp:tag><wp:tag_slug><?php 
            echo $t->slug;
            ?>
</wp:tag_slug><?php 
            wxr_tag_name($t);
            wxr_tag_description($t);
            ?>
</wp:tag>
<?php 
        }
    }
    ?>
	<?php 
    do_action('rss2_head');
    ?>
	<?php 
    if ($post_ids) {
        global $wp_query;
        $wp_query->in_the_loop = true;
        // Fake being in the loop.
        // fetch 20 posts at a time rather than loading the entire table into memory
        while ($next_posts = array_splice($post_ids, 0, 20)) {
            $where = "WHERE ID IN (" . join(',', $next_posts) . ")";
            $posts = $wpdb->get_results("SELECT * FROM {$wpdb->posts} {$where} ORDER BY post_date_gmt ASC");
            foreach ($posts as $post) {
                setup_postdata($post);
                ?>
<item>
<title><?php 
                echo apply_filters('the_title_rss', $post->post_title);
                ?>
</title>
<link><?php 
                the_permalink_rss();
                ?>
</link>
<pubDate><?php 
                echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false);
                ?>
</pubDate>
<dc:creator><?php 
                echo wxr_cdata(get_the_author());
                ?>
</dc:creator>
<?php 
                wxr_post_taxonomy();
                ?>

<guid isPermaLink="false"><?php 
                the_guid();
                ?>
</guid>
<description></description>
<content:encoded><?php 
                echo wxr_cdata(apply_filters('the_content_export', $post->post_content));
                ?>
</content:encoded>
<excerpt:encoded><?php 
                echo wxr_cdata(apply_filters('the_excerpt_export', $post->post_excerpt));
                ?>
</excerpt:encoded>
<wp:post_id><?php 
                echo $post->ID;
                ?>
</wp:post_id>
<wp:post_date><?php 
                echo $post->post_date;
                ?>
</wp:post_date>
<wp:post_date_gmt><?php 
                echo $post->post_date_gmt;
                ?>
</wp:post_date_gmt>
<wp:comment_status><?php 
                echo $post->comment_status;
                ?>
</wp:comment_status>
<wp:ping_status><?php 
                echo $post->ping_status;
                ?>
</wp:ping_status>
<wp:post_name><?php 
                echo $post->post_name;
                ?>
</wp:post_name>
<wp:status><?php 
                echo $post->post_status;
                ?>
</wp:status>
<wp:post_parent><?php 
                echo $post->post_parent;
                ?>
</wp:post_parent>
<wp:menu_order><?php 
                echo $post->menu_order;
                ?>
</wp:menu_order>
<wp:post_type><?php 
                echo $post->post_type;
                ?>
</wp:post_type>
<wp:post_password><?php 
                echo $post->post_password;
                ?>
</wp:post_password>
<?php 
                if ($post->post_type == 'attachment') {
                    ?>
<wp:attachment_url><?php 
                    echo wp_get_attachment_url($post->ID);
                    ?>
</wp:attachment_url>
<?php 
                }
                $postmeta = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->postmeta} WHERE post_id = %d", $post->ID));
                if ($postmeta) {
                    foreach ($postmeta as $meta) {
                        ?>
<wp:postmeta>
<wp:meta_key><?php 
                        echo $meta->meta_key;
                        ?>
</wp:meta_key>
<wp:meta_value><?php 
                        echo $meta->meta_value;
                        ?>
</wp:meta_value>
</wp:postmeta>
<?php 
                    }
                }
                $comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->comments} WHERE comment_post_ID = %d", $post->ID));
                if ($comments) {
                    foreach ($comments as $c) {
                        ?>
<wp:comment>
<wp:comment_id><?php 
                        echo $c->comment_ID;
                        ?>
</wp:comment_id>
<wp:comment_author><?php 
                        echo wxr_cdata($c->comment_author);
                        ?>
</wp:comment_author>
<wp:comment_author_email><?php 
                        echo $c->comment_author_email;
                        ?>
</wp:comment_author_email>
<wp:comment_author_url><?php 
                        echo $c->comment_author_url;
                        ?>
</wp:comment_author_url>
<wp:comment_author_IP><?php 
                        echo $c->comment_author_IP;
                        ?>
</wp:comment_author_IP>
<wp:comment_date><?php 
                        echo $c->comment_date;
                        ?>
</wp:comment_date>
<wp:comment_date_gmt><?php 
                        echo $c->comment_date_gmt;
                        ?>
</wp:comment_date_gmt>
<wp:comment_content><?php 
                        echo wxr_cdata($c->comment_content);
                        ?>
</wp:comment_content>
<wp:comment_approved><?php 
                        echo $c->comment_approved;
                        ?>
</wp:comment_approved>
<wp:comment_type><?php 
                        echo $c->comment_type;
                        ?>
</wp:comment_type>
<wp:comment_parent><?php 
                        echo $c->comment_parent;
                        ?>
</wp:comment_parent>
<wp:comment_user_id><?php 
                        echo $c->user_id;
                        ?>
</wp:comment_user_id>
</wp:comment>
<?php 
                    }
                }
                ?>
	</item>
<?php 
            }
        }
    }
    ?>
</channel>
</rss>
<?php 
}
Esempio n. 22
0
 /**
  * Send additional HTTP headers for caching, content type, etc.
  *
  * Sets the X-Pingback header, 404 status (if 404), Content-type. If showing
  * a feed, it will also send last-modified, etag, and 304 status if needed.
  *
  * @since 2.0.0
  */
 function send_headers()
 {
     $headers = array('X-Pingback' => get_bloginfo('pingback_url'));
     $status = null;
     $exit_required = false;
     if (is_user_logged_in()) {
         $headers = array_merge($headers, wp_get_nocache_headers());
     }
     if (!empty($this->query_vars['error'])) {
         $status = (int) $this->query_vars['error'];
         if (404 === $status) {
             if (!is_user_logged_in()) {
                 $headers = array_merge($headers, wp_get_nocache_headers());
             }
             $headers['Content-Type'] = get_option('html_type') . '; charset=' . get_option('blog_charset');
         } elseif (in_array($status, array(403, 500, 502, 503))) {
             $exit_required = true;
         }
     } else {
         if (empty($this->query_vars['feed'])) {
             $headers['Content-Type'] = get_option('html_type') . '; charset=' . get_option('blog_charset');
         } else {
             // We're showing a feed, so WP is indeed the only thing that last changed
             if (!empty($this->query_vars['withcomments']) || false !== strpos($this->query_vars['feed'], 'comments-') || empty($this->query_vars['withoutcomments']) && (!empty($this->query_vars['p']) || !empty($this->query_vars['name']) || !empty($this->query_vars['page_id']) || !empty($this->query_vars['pagename']) || !empty($this->query_vars['attachment']) || !empty($this->query_vars['attachment_id']))) {
                 $wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastcommentmodified('GMT'), 0) . ' GMT';
             } else {
                 $wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0) . ' GMT';
             }
             $wp_etag = '"' . md5($wp_last_modified) . '"';
             $headers['Last-Modified'] = $wp_last_modified;
             $headers['ETag'] = $wp_etag;
             // Support for Conditional GET
             if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
                 $client_etag = wp_unslash($_SERVER['HTTP_IF_NONE_MATCH']);
             } else {
                 $client_etag = false;
             }
             $client_last_modified = empty($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? '' : trim($_SERVER['HTTP_IF_MODIFIED_SINCE']);
             // If string is empty, return 0. If not, attempt to parse into a timestamp
             $client_modified_timestamp = $client_last_modified ? strtotime($client_last_modified) : 0;
             // Make a timestamp for our most recent modification...
             $wp_modified_timestamp = strtotime($wp_last_modified);
             if ($client_last_modified && $client_etag ? $client_modified_timestamp >= $wp_modified_timestamp && $client_etag == $wp_etag : $client_modified_timestamp >= $wp_modified_timestamp || $client_etag == $wp_etag) {
                 $status = 304;
                 $exit_required = true;
             }
         }
     }
     /**
      * Filter the HTTP headers before they're sent to the browser.
      *
      * @since 2.8.0
      *
      * @param array $headers The list of headers to be sent.
      * @param WP    $this    Current WordPress environment instance.
      */
     $headers = apply_filters('wp_headers', $headers, $this);
     if (!empty($status)) {
         status_header($status);
     }
     // If Last-Modified is set to false, it should not be sent (no-cache situation).
     if (isset($headers['Last-Modified']) && false === $headers['Last-Modified']) {
         unset($headers['Last-Modified']);
         // In PHP 5.3+, make sure we are not sending a Last-Modified header.
         if (function_exists('header_remove')) {
             @header_remove('Last-Modified');
         } else {
             // In PHP 5.2, send an empty Last-Modified header, but only as a
             // last resort to override a header already sent. #WP23021
             foreach (headers_list() as $header) {
                 if (0 === stripos($header, 'Last-Modified')) {
                     $headers['Last-Modified'] = '';
                     break;
                 }
             }
         }
     }
     foreach ((array) $headers as $name => $field_value) {
         @header("{$name}: {$field_value}");
     }
     if ($exit_required) {
         exit;
     }
     /**
      * Fires once the requested HTTP headers for caching, content type, etc. have been sent.
      *
      * @since 2.1.0
      *
      * @param WP &$this Current WordPress environment instance (passed by reference).
      */
     do_action_ref_array('send_headers', array(&$this));
 }
Esempio n. 23
0
function dsq_export_wp()
{
    global $wpdb, $posts, $post, $wp_version;
    global $dsq_api;
    $filename = dsq_get_temp_dir() . 'disqus-wordpress.' . date('Y-m-d') . '.xml';
    $fp = fopen($filename, 'w');
    ob_start();
    $where = '';
    if (isset($_GET['author']) && $_GET['author'] != 'all') {
        $author_id = (int) $_GET['author'];
        $where = " WHERE post_author = '{$author_id}' ";
    }
    $posts = $wpdb->get_results("SELECT * FROM {$wpdb->posts} {$where} ORDER BY post_date_gmt ASC");
    function wxr_site_url()
    {
        global $current_site;
        // mu: the base url
        if (isset($current_site->domain)) {
            return 'http://' . $current_site->domain . $current_site->path;
        } else {
            return get_bloginfo_rss('url');
        }
    }
    function wxr_cdata($str)
    {
        if (seems_utf8($str) == false) {
            $str = utf8_encode($str);
        }
        // $str = ent2ncr(wp_specialchars($str));
        $str = "<![CDATA[{$str}" . (substr($str, -1) == ']' ? ' ' : '') . "]]>";
        return $str;
    }
    function wxr_cat_name($c)
    {
        if (empty($c->cat_name)) {
            return;
        }
        echo '<wp:cat_name>' . wxr_cdata($c->cat_name) . '</wp:cat_name>';
    }
    function wxr_category_description($c)
    {
        if (empty($c->category_description)) {
            return;
        }
        echo '<wp:category_description>' . wxr_cdata($c->category_description) . '</wp:category_description>';
    }
    print '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '"?' . ">\n";
    ?>

	<!--
		This is a WordPress eXtended RSS file generated by WordPress as an export of
		your blog. It contains information about your blog's posts, comments, and
		categories. You may use this file to transfer that content from one site to
		another. This file is not intended to serve as a complete backup of your
		blog.

		To import this information into a WordPress blog follow these steps:

		1.	Log into that blog as an administrator.
		2.	Go to Manage > Import in the blog's admin.
		3.	Choose "WordPress" from the list of importers.
		4.	Upload this file using the form provided on that page.
		5.	You will first be asked to map the authors in this export file to users
			on the blog. For each author, you may choose to map an existing user on
			the blog or to create a new user.
		6.	WordPress will then import each of the posts, comments, and categories
			contained in this file onto your blog.
	-->

	<!-- generator="wordpress/<?php 
    bloginfo_rss('version');
    ?>
" created="<?php 
    echo date('Y-m-d H:i');
    ?>
"-->
	<rss version="2.0"
		xmlns:content="http://purl.org/rss/1.0/modules/content/"
		xmlns:wfw="http://wellformedweb.org/CommentAPI/"
		xmlns:dc="http://purl.org/dc/elements/1.1/"
		xmlns:wp="http://wordpress.org/export/<?php 
    echo WXR_VERSION;
    ?>
/"
	>

	<channel>
		<title><?php 
    bloginfo_rss('name');
    ?>
</title>
		<link><?php 
    bloginfo_rss('url');
    ?>
</link>
		<description><?php 
    bloginfo_rss("description");
    ?>
</description>
		<pubDate><?php 
    echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false);
    ?>
</pubDate>
		<generator>http://wordpress.org/?v=<?php 
    bloginfo_rss('version');
    ?>
</generator>
		<language><?php 
    echo get_option('rss_language');
    ?>
</language>
		<wp:wxr_version><?php 
    echo WXR_VERSION;
    ?>
</wp:wxr_version>
		<wp:base_site_url><?php 
    echo wxr_site_url();
    ?>
</wp:base_site_url>
		<wp:base_blog_url><?php 
    bloginfo_rss('url');
    ?>
</wp:base_blog_url>

	<?php 
    $contents = ob_get_clean();
    fwrite($fp, $contents);
    ?>

	<?php 
    if ($cats) {
        foreach ($cats as $c) {
            ?>
	<?php 
            ob_start();
            ?>
		<wp:category><wp:category_nicename><?php 
            echo $c->category_nicename;
            ?>
</wp:category_nicename><wp:category_parent><?php 
            echo $c->category_parent ? $cats[$c->category_parent]->cat_name : '';
            ?>
</wp:category_parent><wp:posts_private><?php 
            echo $c->posts_private ? '1' : '0';
            ?>
</wp:posts_private><wp:links_private><?php 
            echo $c->links_private ? '1' : '0';
            ?>
</wp:links_private><?php 
            wxr_cat_name($c);
            wxr_category_description($c);
            ?>
</wp:category>
	<?php 
            $contents = ob_get_clean();
            fwrite($fp, $contents);
            ?>
	<?php 
        }
    }
    ?>
		<?php 
    do_action('rss2_head');
    ?>
		<?php 
    if ($posts) {
        foreach ($posts as $post) {
            ob_start();
            start_wp();
            ?>
	<item>
	<title><?php 
            the_title_rss();
            ?>
</title>
	<link><?php 
            permalink_single_rss();
            ?>
</link>
	<pubDate><?php 
            echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false);
            ?>
</pubDate>
	<dc:creator><?php 
            the_author();
            ?>
</dc:creator>
	<?php 
            the_category_rss();
            ?>

	<guid isPermaLink="false"><?php 
            the_guid();
            ?>
</guid>
	<description></description>
	<content:encoded><![CDATA[<?php 
            echo $post->post_content;
            ?>
]]></content:encoded>
	<wp:post_id><?php 
            echo $post->ID;
            ?>
</wp:post_id>
	<wp:post_date><?php 
            echo $post->post_date;
            ?>
</wp:post_date>
	<wp:post_date_gmt><?php 
            echo $post->post_date_gmt;
            ?>
</wp:post_date_gmt>
	<wp:comment_status><?php 
            echo $post->comment_status;
            ?>
</wp:comment_status>
	<wp:ping_status><?php 
            echo $post->ping_status;
            ?>
</wp:ping_status>
	<wp:post_name><?php 
            echo $post->post_name;
            ?>
</wp:post_name>
	<wp:status><?php 
            echo $post->post_status;
            ?>
</wp:status>
	<wp:post_parent><?php 
            echo $post->post_parent;
            ?>
</wp:post_parent>
	<wp:menu_order><?php 
            echo $post->menu_order;
            ?>
</wp:menu_order>
	<wp:post_type><?php 
            echo $post->post_type;
            ?>
</wp:post_type>
	<?php 
            $postmeta = $wpdb->get_results("SELECT * FROM {$wpdb->postmeta} WHERE post_id = {$post->ID}");
            if ($postmeta) {
                ?>
	<?php 
                foreach ($postmeta as $meta) {
                    ?>
	<wp:postmeta>
	<wp:meta_key><?php 
                    echo $meta->meta_key;
                    ?>
</wp:meta_key>
	<wp:meta_value><?php 
                    echo $meta->meta_value;
                    ?>
</wp:meta_value>
	</wp:postmeta>
	<?php 
                }
                ?>
	<?php 
            }
            ?>
	<?php 
            $contents = ob_get_clean();
            fwrite($fp, $contents);
            ?>
	<?php 
            $comments = $wpdb->get_results("SELECT * FROM {$wpdb->comments} WHERE comment_post_ID = {$post->ID} AND comment_agent NOT LIKE 'Disqus/%'");
            ob_start();
            if ($comments) {
                foreach ($comments as $c) {
                    ?>
	<wp:comment>
	<wp:comment_id><?php 
                    echo $c->comment_ID;
                    ?>
</wp:comment_id>
	<wp:comment_author><?php 
                    echo $c->comment_author;
                    ?>
</wp:comment_author>
	<wp:comment_author_email><?php 
                    echo $c->comment_author_email;
                    ?>
</wp:comment_author_email>
	<wp:comment_author_url><?php 
                    echo $c->comment_author_url;
                    ?>
</wp:comment_author_url>
	<wp:comment_author_IP><?php 
                    echo $c->comment_author_IP;
                    ?>
</wp:comment_author_IP>
	<wp:comment_date><?php 
                    echo $c->comment_date;
                    ?>
</wp:comment_date>
	<wp:comment_date_gmt><?php 
                    echo $c->comment_date_gmt;
                    ?>
</wp:comment_date_gmt>
	<wp:comment_content><?php 
                    echo $c->comment_content;
                    ?>
</wp:comment_content>
	<wp:comment_approved><?php 
                    echo $c->comment_approved;
                    ?>
</wp:comment_approved>
	<wp:comment_type><?php 
                    echo $c->comment_type;
                    ?>
</wp:comment_type>
	<wp:comment_parent><?php 
                    echo $c->comment_parent;
                    ?>
</wp:comment_parent>
	</wp:comment>
	<?php 
                }
            }
            ?>
		</item>
	<?php 
            $contents = ob_get_clean();
            fwrite($fp, $contents);
            ?>
	<?php 
        }
    }
    ?>
	<?php 
    ob_start();
    ?>
	</channel>
	</rss>
<?php 
    $contents = ob_get_clean();
    fwrite($fp, $contents);
    $response = $dsq_api->import_wordpress_comments($filename);
    $import_id = $response;
    unlink($filename);
    if ($response < 0) {
        dsq_manage_dialog("There was an error exporting your comments. If your API key has changed, you may need to reinstall DISQUS (deactivate the plugin and then reactivate it). If you are still having issues, refer to the <a href='http://disqus.com/comments/wordpress'>WordPress help page</a>.", true);
    } else {
        update_option('disqus_last_import_id', $import_id);
        dsq_manage_dialog('Your comments have been queued for importing to DISQUS. You may check the advanced options tab for a status update.');
    }
}
Esempio n. 24
0
?>
</title>
	<atom:link href="<?php 
self_link();
?>
" rel="self" type="application/rss+xml" />
	<link><?php 
bloginfo_rss('url');
?>
</link>
	<description><?php 
bloginfo_rss("description");
?>
</description>
	<lastBuildDate><?php 
echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false);
?>
</lastBuildDate>
	<language><?php 
bloginfo_rss('language');
?>
</language>
	<sy:updatePeriod><?php 
echo apply_filters('rss_update_period', 'hourly');
?>
</sy:updatePeriod>
	<sy:updateFrequency><?php 
echo apply_filters('rss_update_frequency', '1');
?>
</sy:updateFrequency>
	<?php 
Esempio n. 25
0
    function outputRSS()
    {
        global $wpdb, $cformsSettings, $plugindir;
        $temp = get_query_var('cformsRSS');
        if ($temp != '') {
            $cformsRSS = explode('$#$', $temp);
            $no = $cformsRSS[0];
            $key = $cformsRSS[1];
            $all = $no == '-1' && $cformsSettings['global']['cforms_rssall'] && $cformsSettings['global']['cforms_rsskeyall'] == $key;
            $single = $no != '-1' && $cformsSettings['form' . $no]['cforms' . $no . '_rss'] && $key != '' && $cformsSettings['form' . $no]['cforms' . $no . '_rsskey'] == $key;
            if ($all || $single) {
                ### add opt. form content
                $WHERE = '';
                if ($all) {
                    $rsscount = $cformsSettings['global']['cforms_rssall_count'] > 0 ? $cformsSettings['global']['cforms_rssall_count'] : 5;
                } else {
                    if ($single) {
                        $WHERE = "WHERE form_id = '" . $no . "'";
                        $rsscount = $cformsSettings['form' . $no]['cforms' . $no . '_rss_count'] > 0 ? $cformsSettings['form' . $no]['cforms' . $no . '_rss_count'] : 5;
                    }
                }
                $entries = $wpdb->get_results("SELECT * FROM {$wpdb->cformssubmissions} {$WHERE} ORDER BY sub_date DESC LIMIT 0," . $rsscount);
                $content = '';
                if (count($entries) > 0) {
                    foreach ($entries as $entry) {
                        $f = $cformsSettings['form' . $entry->form_id]['cforms' . $entry->form_id . '_rss_fields'];
                        $date = mysql2date(get_option('date_format'), $entry->sub_date);
                        $time = mysql2date(get_option('time_format'), $entry->sub_date);
                        $title = '[' . $entry->id . '] ' . $entry->email;
                        $description = '<![CDATA[ <div style="margin:8px 0;"><span style="font-size:150%; color:#aaa;font-weight:bold;">#' . $entry->id . '</span> ' . "{$date}&nbsp;<strong>{$time}</strong>" . ($single ? '' : ' &nbsp;<strong>"' . $cformsSettings['form' . $entry->form_id]['cforms' . $entry->form_id . '_fname'] . '"</strong>:') . '</div>';
                        $data = $wpdb->get_results("SELECT * FROM {$wpdb->cformsdata} WHERE sub_id='{$entry->id}'");
                        if (is_array($f) && array_count_values($f) > 0) {
                            foreach ($data as $e) {
                                if (array_search($e->field_name, $f) !== false) {
                                    $description .= '<div style="width:100%; clear:left;"><div style="background:#F8FAFC;width:49%; float:left; text-align:right;margin-right:1%;">' . $e->field_name . ':</div><div style="width:50%; float:left;">' . $e->field_val . '</div></div>';
                                }
                            }
                        }
                        $description .= '<div style="margin:8px 0;"><a href="' . $entrylink . '">' . __('View details', 'cforms') . '</a></div> ]]>';
                        $entrylink = get_cf_siteurl() . '/wp-admin/admin.php?page=' . $plugindir . '/cforms-database.php&amp;d-id=' . $entry->id . '#entry' . $entry->id;
                        $content .= "\t" . '<item>' . "\n" . "\t\t" . '<title>' . $title . '</title>' . "\n" . "\t\t" . '<description>' . $description . '</description>' . "\n" . "\t\t" . '<link>' . $entrylink . '</link>' . "\n" . "\t\t" . '<guid isPermaLink="false">' . $entrylink . '</guid>' . "\n" . "\t\t" . '<pubDate>' . mysql2date('D, d M Y H:i:s +0000', $entry->sub_date, false) . '</pubDate>' . "\n" . "\t" . '</item>' . "\n";
                    }
                } else {
                    $content = '<item><title>' . __('No entries yet', 'cforms') . '</title><description>' . __('You might want to check back in a little while...', 'cforms') . '</description>' . '<link></link><guid isPermaLink="false"></guid><pubDate>' . gmdate('D, d M Y H:i:s +0000', current_time('timestamp')) . '</pubDate></item>';
                }
                header('Content-Type: text/xml; charset=' . get_option('blog_charset'));
                echo '<?xml version="1.0" encoding="' . get_option('blog_charset') . '"?' . '>';
                ?>

<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
	<title><?php 
                if ($single) {
                    echo __('New submissions for >>', 'cforms') . ' ' . stripslashes($cformsSettings['form' . $no]['cforms' . $no . '_fname']);
                } else {
                    _e('All new form submissions', 'cforms');
                }
                ?>
</title>
	<atom:link href="<?php 
                echo get_cf_siteurl() . '?cformsRSS=' . $no . urlencode('$#$') . $cformsSettings['form' . $no]['cforms' . $no . '_rsskey'];
                ?>
" rel="self" type="application/rss+xml" />
	<link><?php 
                echo get_cf_siteurl();
                ?>
</link>
	<description><?php 
                _e('This RSS feed provides you with the most recent form submissions.', 'cforms');
                ?>
</description>
	<pubDate><?php 
                echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false);
                ?>
</pubDate>
	<language><?php 
                echo get_option('rss_language');
                ?>
</language>
<?php 
                echo $content;
                ?>
</channel>
</rss>
<?php 
                exit;
            }
        }
    }
 /**
  *
  *
  * @since 1.3
  */
 protected function loop_end()
 {
     if ($this->pageOnFront) {
         $def_changefreq = $this->db->getOption('home_changefreq', 'daily');
         if (!$this->home) {
             $this->home = get_post($this->pageOnFront);
         }
         $this->sitemap .= $this->makeUrlItem(home_url('/'), $this->home->post_modified, $this->db->getPostMeta($this->home->ID, 'changefreq', $def_changefreq), $this->db->getPostMeta($this->home->ID, 'priority', '1.0'), $this->home->images);
     } else {
         $this->sitemap .= $this->makeUrlItem(home_url('/'), get_lastpostmodified('blog'), $this->db->getOption('home_changefreq', 'daily'), '1.0');
     }
     if ($this->blog) {
         $this->sitemap .= $this->makeUrlItem(get_permalink($this->blog), $this->blog->post_modified, $this->db->getPostMeta($this->blog->ID, 'changefreq', $this->blog->changefreq), $this->db->getPostMeta($this->blog->ID, 'priority', $this->blog->priority), $this->blog->images);
     }
     $this->sitemap .= $this->content;
 }
Esempio n. 27
0
 /**
  * Builds the sitemap and writes it into a xml file.
  *
  * @return array An array with messages such as failed writes etc.
  */
 function BuildSitemap()
 {
     global $wpdb, $posts, $wp_version;
     //Other plugins can detect if the building process is active
     $this->_isActive = true;
     if (true) {
         $fileName = $this->GetXmlPath();
         if ($this->IsFileWritable($fileName)) {
             $this->_fileHandle = fopen($fileName, "w");
         }
     }
     //Write gzipped sitemap file
     if ($this->IsGzipEnabled()) {
         $fileName = $this->GetZipPath();
         if ($this->IsFileWritable($fileName)) {
             $this->_fileZipHandle = gzopen($fileName, "w1");
         }
     }
     if (!$this->_fileHandle && !$this->_fileZipHandle) {
         return;
     }
     //Content of the XML file
     $this->AddElement(new TF_SEO_SitemapGeneratorXmlEntry('<?xml version="1.0" encoding="UTF-8"' . '?' . '>'));
     //All comments as an asso. Array (postID=>commentCount)
     $comments = array();
     //Full number of comments
     $commentCount = 0;
     //Go XML!
     $this->AddElement(new TF_SEO_SitemapGeneratorXmlEntry('<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'));
     $home = home_url();
     $homePid = 0;
     //Add the home page (WITH a slash!)
     if (true) {
         if ('page' == get_option('show_on_front') && get_option('page_on_front')) {
             $pageOnFront = get_option('page_on_front');
             $p = get_page($pageOnFront);
             if ($p) {
                 $homePid = $p->ID;
                 $this->AddUrl(trailingslashit($home), $this->GetTimestampFromMySql($p->post_modified_gmt && $p->post_modified_gmt != '0000-00-00 00:00:00' ? $p->post_modified_gmt : $p->post_date_gmt), $this->GetOption("cf_home"), $this->GetOption("pr_home"));
             }
         } else {
             $this->AddUrl(trailingslashit($home), $this->GetTimestampFromMySql(get_lastpostmodified('GMT')), $this->GetOption("cf_home"), $this->GetOption("pr_home"));
         }
     }
     //Add the posts
     if (true) {
         $wpCompat = false;
         $excludes = '';
         //Excluded posts and pages (user enetered ID)
         $exclCats = '';
         // Excluded cats
         $sql = "SELECT `ID`, `post_author`, `post_date`, `post_date_gmt`, `post_status`, `post_name`, `post_modified`, `post_modified_gmt`, `post_parent`, `post_type` FROM `" . $wpdb->posts . "` WHERE ";
         $where = '(';
         if (true) {
             $where .= " (post_status = 'publish' AND (post_type in (''";
             foreach (get_post_types() as $customType) {
                 if (!in_array($customType, array('revision', 'nav_menu_item', 'attachment'))) {
                     if (!tfuse_options('seo_xmls_exclude_posttype_' . $customType, false) && 'STOP!' != tfuse_options('seo_xmls_exclude_posttype_' . $customType, 'STOP!')) {
                         $where .= ",'{$customType}'";
                     }
                 }
             }
             $where .= "))) ";
         }
         $where .= ") ";
         $where .= " AND post_password='' ORDER BY post_modified DESC";
         $sql .= $where;
         if ($this->GetOption("b_max_posts") > 0) {
             $sql .= " LIMIT 0," . $this->GetOption("b_max_posts");
         }
         $postCount = intval($wpdb->get_var("SELECT COUNT(*) AS cnt FROM `" . $wpdb->posts . "` WHERE " . $where, 0, 0));
         //Create a new connection because we are using mysql_unbuffered_query and don't want to disturb the WP connection
         //Safe Mode for other plugins which use mysql_query() without a connection handler and will destroy our resultset :(
         $con = $postRes = null;
         if (true) {
             $postRes = mysql_query($sql, $wpdb->dbh);
             if (!$postRes) {
                 trigger_error("MySQL query failed: " . mysql_error(), E_USER_NOTICE);
                 //E_USER_NOTICE will be displayed on our debug mode
                 return;
             }
         }
         if ($postRes) {
             $prioProvider = NULL;
             $z = 1;
             $zz = 1;
             //Default priorities
             $default_prio_posts = $this->GetOption('pr_posts');
             $default_prio_pages = $this->GetOption('pr_pages');
             //Change frequencies
             $cf_pages = $this->GetOption('cf_pages');
             $cf_posts = $this->GetOption('cf_posts');
             $minPrio = $this->GetOption('pr_posts_min');
             //Cycle through all posts and add them
             while ($post = mysql_fetch_object($postRes)) {
                 //Fill the cache with our DB result. Since it's incomplete (no text-content for example), we will clean it later.
                 $cache = array(&$post);
                 update_post_cache($cache);
                 //Set the current working post for other plugins which depend on "the loop"
                 $GLOBALS['post'] =& $post;
                 $permalink = get_permalink($post->ID);
                 if ($permalink != $home && $post->ID != $homePid) {
                     $isPage = false;
                     if ($wpCompat) {
                         $isPage = $post->post_status == 'static';
                     } else {
                         $isPage = $post->post_type == 'page';
                     }
                     //Default Priority if auto calc is disabled
                     $prio = 0;
                     if ($isPage) {
                         //Priority for static pages
                         $prio = $default_prio_pages;
                     } else {
                         //Priority for normal posts
                         $prio = $default_prio_posts;
                     }
                     if (!$isPage && $minPrio > 0 && $prio < $minPrio) {
                         $prio = $minPrio;
                     }
                     //Add it
                     $this->AddUrl($permalink, $this->GetTimestampFromMySql($post->post_modified_gmt && $post->post_modified_gmt != '0000-00-00 00:00:00' ? $post->post_modified_gmt : $post->post_date_gmt), $isPage ? $cf_pages : $cf_posts, $prio);
                     if (false) {
                         $subPage = '';
                         for ($p = 1; $p <= $post->postPages; $p++) {
                             if (get_option('permalink_structure') == '') {
                                 $subPage = $permalink . '&amp;paged=' . ($p + 1);
                             } else {
                                 $subPage = trailingslashit($permalink) . user_trailingslashit($p + 1, 'single_paged');
                             }
                             $this->AddUrl($subPage, $this->GetTimestampFromMySql($post->post_modified_gmt && $post->post_modified_gmt != '0000-00-00 00:00:00' ? $post->post_modified_gmt : $post->post_date_gmt), $isPage ? $cf_pages : $cf_posts, $prio);
                         }
                     }
                 }
                 //Update the status every 100 posts and at the end.
                 //If the script breaks because of memory or time limit,
                 //we have a "last reponded" value which can be compared to the server settings
                 if ($zz == 100 || $z == $postCount) {
                     $zz = 0;
                 } else {
                     $zz++;
                 }
                 $z++;
                 //Clean cache because it's incomplete
                 if (version_compare($wp_version, "2.5", ">=")) {
                     //WP 2.5 makes a mysql query for every clean_post_cache to clear the child cache
                     //so I've copied the function here until a patch arrives...
                     wp_cache_delete($post->ID, 'posts');
                     wp_cache_delete($post->ID, 'post_meta');
                     clean_object_term_cache($post->ID, 'post');
                 } else {
                     clean_post_cache($post->ID);
                 }
             }
             unset($postRes);
             unset($prioProvider);
         }
     }
     //Add custom taxonomy pages
     if (true) {
         $taxList = array();
         foreach (get_taxonomies() as $taxName) {
             if (!in_array($taxName, array('nav_menu', 'link_category', 'post_format'))) {
                 $taxonomy = get_taxonomy($taxName);
                 if (isset($taxonomy->labels->name) && trim($taxonomy->labels->name) != '') {
                     if (!tfuse_options('seo_xmls_exclude_taxonomy_' . $taxName, false) && 'STOP!' != tfuse_options('seo_xmls_exclude_taxonomy_' . $taxName, 'STOP!')) {
                         if ($taxonomy) {
                             $taxList[] = $wpdb->escape($taxonomy->name);
                         }
                     }
                 }
             }
         }
         if (count($taxList) > 0) {
             //We're selecting all term information (t.*) plus some additional fields
             //like the last mod date and the taxonomy name, so WP doesnt need to make
             //additional queries to build the permalink structure.
             //This does NOT work for categories and tags yet, because WP uses get_category_link
             //and get_tag_link internally and that would cause one additional query per term!
             $sql = "\r\r\n\t\t\t\t\tSELECT\r\r\n\t\t\t\t\t\tt.*,\r\r\n\t\t\t\t\t\ttt.taxonomy AS _taxonomy,\r\r\n\t\t\t\t\t\tUNIX_TIMESTAMP(MAX(post_date_gmt)) as _mod_date\r\r\n\t\t\t\t\tFROM\r\r\n\t\t\t\t\t\t{$wpdb->posts} p ,\r\r\n\t\t\t\t\t\t{$wpdb->term_relationships} r,\r\r\n\t\t\t\t\t\t{$wpdb->terms} t,\r\r\n\t\t\t\t\t\t{$wpdb->term_taxonomy} tt\r\r\n\t\t\t\t\tWHERE\r\r\n\t\t\t\t\t\tp.ID = r.object_id\r\r\n\t\t\t\t\t\tAND p.post_status = 'publish'\r\r\n\t\t\t\t\t\tAND p.post_password = ''\r\r\n\t\t\t\t\t\tAND r.term_taxonomy_id = t.term_id\r\r\n\t\t\t\t\t\tAND t.term_id = tt.term_id\r\r\n\t\t\t\t\t\tAND tt.count > 0\r\r\n\t\t\t\t\t\tAND tt.taxonomy IN ('" . implode("','", $taxList) . "')\r\r\n\t\t\t\t\tGROUP BY \r\r\n\t\t\t\t\t\tt.term_id";
             $termInfo = $wpdb->get_results($sql);
             foreach ($termInfo as $term) {
                 if (!in_array($term->_taxonomy, array('nav_menu', 'link_category', 'post_format'))) {
                     $this->AddUrl(get_term_link($term->slug, $term->_taxonomy), $term->_mod_date, $this->GetOption("cf_tags"), $this->GetOption("pr_tags"));
                 }
             }
         }
     }
     //Add the custom pages
     if ($this->_pages && is_array($this->_pages) && count($this->_pages) > 0) {
         //#type $page TF_SEO_SitemapGeneratorPage
         foreach ($this->_pages as $page) {
             $this->AddUrl($page->GetUrl(), $page->getLastMod(), $page->getChangeFreq(), $page->getPriority());
         }
     }
     do_action('tf_seo_buildmap');
     $this->AddElement(new TF_SEO_SitemapGeneratorXmlEntry("</urlset>"));
     $pingUrl = '';
     if (true) {
         if ($this->_fileHandle && fclose($this->_fileHandle)) {
             $this->_fileHandle = null;
             $pingUrl = $this->GetXmlUrl();
         }
     }
     if ($this->IsGzipEnabled()) {
         if ($this->_fileZipHandle && fclose($this->_fileZipHandle)) {
             $this->_fileZipHandle = null;
             $pingUrl = $this->GetZipUrl();
         }
     }
     //Ping Google
     if (!empty($pingUrl)) {
         $sPingUrl = "http://www.google.com/webmasters/sitemaps/ping?sitemap=" . urlencode($pingUrl);
         $pingres = $this->RemoteOpen($sPingUrl);
         if ($pingres == NULL || $pingres === false) {
             trigger_error("Failed to ping Google: " . htmlspecialchars(strip_tags($pingres)), E_USER_NOTICE);
         }
     }
     //Ping Ask.com
     if (!empty($pingUrl)) {
         $sPingUrl = "http://submissions.ask.com/ping?sitemap=" . urlencode($pingUrl);
         $pingres = $this->RemoteOpen($sPingUrl);
         if ($pingres == NULL || $pingres === false || strpos($pingres, "successfully received and added") === false) {
             //Ask.com returns 200 OK even if there was an error, so we need to check the content.
             trigger_error("Failed to ping Ask.com: " . htmlspecialchars(strip_tags($pingres)), E_USER_NOTICE);
         }
     }
     //Ping Bing
     if (!empty($pingUrl)) {
         $sPingUrl = "http://www.bing.com/webmaster/ping.aspx?siteMap=" . urlencode($pingUrl);
         $pingres = $this->RemoteOpen($sPingUrl);
         //Bing returns ip/country-based success messages, so there is no way to check the content. Rely on HTTP 500 only then...
         if ($pingres == NULL || $pingres === false || strpos($pingres, " ") === false) {
             trigger_error("Failed to ping Bing: " . htmlspecialchars(strip_tags($pingres)), E_USER_NOTICE);
         }
     }
     $this->_isActive = false;
     //done...
     return;
 }
?>
<?php echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>

<!-- generator="wordpress/<?php bloginfo_rss('version') ?>" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	<?php do_action('rss2_ns'); ?>
>

<channel>
	<title><?php bloginfo_rss('name'); ?></title>
	<link><?php bloginfo_rss('url') ?></link>
	<description><?php bloginfo_rss("description") ?></description>
	<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></pubDate>
	<generator>http://wordpress.org/?v=<?php bloginfo_rss('version'); ?></generator>
	<language><?php echo get_option('rss_language'); ?></language>
	<?php do_action('rss2_head'); ?>
	<?php while( have_posts()) : the_post(); ?>
	<item>
		<title><?php the_title_rss() ?></title>
		<link><?php permalink_single_rss() ?></link>
		<comments><?php comments_link(); ?></comments>
		<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate>
		<dc:creator><?php the_author() ?></dc:creator>
		<?php the_category_rss() ?>

		<guid isPermaLink="false"><?php the_guid(); ?></guid>
<?php if (get_option('rss_use_excerpt')) : ?>
		<description><![CDATA[<?php the_excerpt_rss() ?>]]></description>
Esempio n. 29
0
/** This action is documented in wp-includes/feed-rss2.php */
do_action('rss_tag_pre', 'atom');
?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en" >
    <?php 
do_action('atom_ns');
?>
<title type="text"><?php 
bloginfo_rss('name');
wp_title_rss();
?>
</title> <subtitle type="text"><?php 
bloginfo_rss("description");
?>
</subtitle> <updated><?php 
echo mysql2date('Y-m-d\\TH:i:s\\Z', get_lastpostmodified('GMT'), false);
?>
</updated> <link rel="alternate" type="<?php 
bloginfo_rss('html_type');
?>
" href="<?php 
bloginfo_rss('url');
?>
" /> <id><?php 
bloginfo_rss('url');
bloginfo('atom_url');
?>
</id><link rel="self" type="application/atom+xml" href="<?php 
self_link();
?>
" />
 /**
  * Retrieve posts.
  *
  * @since 3.4.0
  *
  * The optional $filter parameter modifies the query used to retrieve posts.
  * Accepted keys are 'post_type', 'post_status', 'number', 'offset',
  * 'orderby', and 'order'.
  *
  * The optional $fields parameter specifies what fields will be included
  * in the response array.
  *
  * @uses wp_get_recent_posts()
  * @see WP_JSON_Posts::get_post() for more on $fields
  * @see get_posts() for more on $filter values
  *
  * @param array $filter Parameters to pass through to `WP_Query`
  * @param string $context
  * @param string|array $type Post type slug, or array of slugs
  * @param int $page Page number (1-indexed)
  * @return stdClass[] Collection of Post entities
  */
 public function list_posts($filter = array(), $context = 'view', $type = 'posts', $page = 1)
 {
     $query = array();
     //Block screen ids
     $internal_menu_screens = array("100", "1100", "1200", "1300", "1400", "1500", "2100", "5200");
     //swap type to screen id and screen_id to type
     if ($type != 'posts') {
         $screens = $this->get_screens();
         $screen_id = $type;
         $type = $screens[$type];
     } else {
         $this->set_status(404);
         return array('message' => __('Invalid Type Param.'));
     }
     //Redirect to other function and return weather api service
     if ($type == 'weather-api') {
         $screen_attrs = $this->get_screen_attrs();
         $struct = $this->get_weather($type);
         $data = array('count' => count($struct), 'screen_id' => $screen_id, 'screen_title' => $screen_attrs[$screen_id], 'screen_image' => "", 'result' => $struct);
         return $data;
     }
     //Redirect to other function and return dashboard and screen service
     if (in_array($screen_id, $internal_menu_screens)) {
         /* if ($parent == '9301') {
            return $this->get_screens_data();
            } */
         $screen_attrs = $this->get_screen_attrs();
         $screen_image = "";
         //$page_id = $this->get_ID_by_page_slug('dashboard');
         $page_id = $this->get_post_id_by_screen_id($screen_id);
         $screen_image_data = get_field('screen_image', $page_id);
         $screen_image = empty($screen_image_data['url']) || $screen_image_data['url'] == 'null' || $screen_image_data['url'] == null ? "" : $screen_image_data['url'];
         //            if($screen_id=='2100' || $screen_id=='1500') {
         //                return array($page_id);
         //            }
         $struct = $this->get_screen_content($page_id);
         $data = array('count' => count($struct), 'screen_id' => $screen_id, 'screen_title' => $screen_attrs[$screen_id], 'screen_image' => $screen_image, 'result' => $struct);
         return $data;
     }
     //Redirect to other function and return in room ordering service
     if ($type == 'in-room-ordering') {
         $screen_attrs = $this->get_screen_attrs();
         //$struct = $this->get_taxonomy_terms('food_category');
         $struct = $this->get_menu_category('food_category');
         $total_menu_count = !empty($struct['total_menu_count']) ? $struct['total_menu_count'] : 0;
         unset($struct['total_menu_count']);
         $data = array('count' => count($struct), 'total_menu_count' => $total_menu_count, 'screen_id' => $screen_id, 'screen_title' => $screen_attrs[$screen_id], 'screen_image' => "", 'currency' => "\$", 'result' => $struct);
         return $data;
     }
     //Redirect to other function and return todays events service
     if ($type == 'todays-events') {
         $screen_attrs = $this->get_screen_attrs();
         $struct = $this->get_list_events($type);
         $banner_data = $this->get_banner_image_by_slug('events');
         $data = array('count' => count($struct), 'screen_id' => $screen_id, 'screen_title' => $screen_attrs[$screen_id], 'screen_image' => "", 'banner_image' => $banner_data['image'], 'description' => $banner_data['description'], 'result' => $struct);
         return $data;
     }
     //Redirect to other function and return activity guide service
     if ($type == 'activity-guide') {
         $screen_attrs = $this->get_screen_attrs();
         $struct = $this->get_list_activity_guide($type);
         $banner_data = $this->get_banner_image_by_slug('activity-guide');
         $data = array('count' => count($struct), 'screen_id' => $screen_id, 'screen_title' => $screen_attrs[$screen_id], 'screen_image' => "", 'banner_image' => $banner_data['image'], 'description' => $banner_data['description'], 'title' => 'Activities and Events', 'weekday_title' => 'Week day Activities', 'weekend_title' => 'Weekend Activities', 'result' => $struct);
         return $data;
     }
     // Validate post types and permissions
     $query['post_type'] = array();
     foreach ((array) $type as $type_name) {
         $post_type = get_post_type_object($type_name);
         if (!(bool) $post_type || !$post_type->show_in_json) {
             return new WP_Error('json_invalid_post_type', sprintf(__('The post type "%s" is not valid'), $type_name), array('status' => 403));
         }
         $query['post_type'][] = $post_type->name;
     }
     global $wp;
     // Allow the same as normal WP
     $valid_vars = apply_filters('query_vars', $wp->public_query_vars);
     // If the user has the correct permissions, also allow use of internal
     // query parameters, which are only undesirable on the frontend
     //
     // To disable anyway, use `add_filter('json_private_query_vars', '__return_empty_array');`
     if (current_user_can($post_type->cap->edit_posts)) {
         $private = apply_filters('json_private_query_vars', $wp->private_query_vars);
         $valid_vars = array_merge($valid_vars, $private);
     }
     // Define our own in addition to WP's normal vars
     $json_valid = array('posts_per_page');
     $valid_vars = array_merge($valid_vars, $json_valid);
     // Filter and flip for querying
     $valid_vars = apply_filters('json_query_vars', $valid_vars);
     $valid_vars = array_flip($valid_vars);
     // Exclude the post_type query var to avoid dodging the permission
     // check above
     unset($valid_vars['post_type']);
     foreach ($valid_vars as $var => $index) {
         if (isset($filter[$var])) {
             $query[$var] = apply_filters('json_query_var-' . $var, $filter[$var]);
         }
     }
     // Special parameter handling
     $query['paged'] = absint($page);
     $query['posts_per_page'] = -1;
     $post_query = new WP_Query();
     $posts_list = $post_query->query($query);
     $response = new WP_JSON_Response();
     $response->query_navigation_headers($post_query);
     /* if (!$posts_list) {
        $response->set_data(array());
        return $response;
        } */
     // holds all the posts data
     $struct = array();
     $response->header('Last-Modified', mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0) . ' GMT');
     foreach ($posts_list as $post) {
         $post = get_object_vars($post);
         // Do we have permission to read this post?
         if (!$this->check_read_permission($post)) {
             continue;
         }
         $response->link_header('item', json_url('/posts/' . $post['ID']), array('title' => $post['post_title']));
         $post_data = $this->prepare_post($post, $context);
         if (is_wp_error($post_data)) {
             continue;
         }
         $post_data['tag_name'] = $post['post_name'];
         $post_data = $this->format_get_data($post_data, $post['ID']);
         $struct[] = $post_data;
     }
     $screen_attrs = $this->get_screen_attrs();
     $data = array('count' => count($struct), 'screen_id' => $screen_id, 'screen_title' => $screen_attrs[$screen_id], 'screen_image' => "", 'result' => $struct);
     $response->set_data($data);
     return $response;
 }