Google Reader account for display in a sidebar widget or within pages or posts. Easily customized with friendly interface. Embed in page or post via shortcode; can always show newest, or start at post publication date! Version: 3.2 Author: Jacob M Goldman (C. Murray Consulting) Author URI: http://www.cmurrayconsulting.com Plugin: Copyright 2009 C. Murray Consulting (email : jake@cmurrayconsulting.com) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ //******************// //REQUIREMENTS CHECK// //******************// function req_check () { if(!class_exists('SimpleXmlElement')) { echo '
A version of PHP with the SimpleXML class is required. This is included with PHP 5 and newer.
'; return false; } elseif (!ini_get('allow_url_fopen') && !function_exists("curl_init")) { echo 'Host Limitation Found
Recommended Reading needs to load a foreign XML feed from Google. Your host has turned off support for "fopen" and cURL - the two most widely supported mechanisms for loading foreign information like your shared feed. Please contact your host and ask them to enable the cURL PHP module or add "allow_url_fopen" in your PHP configuration.
'; return false; } return true; } //*********// //PLUG INIT// //*********// function grs_admin_init() { register_setting('grs-options', 'gr_lastupdate'); register_setting('grs-options', 'gr_sc_lastupdate'); register_setting('grs-options', 'gr_credit'); register_setting('grs-options', 'gr_sid'); register_setting('grs-options', 'gr_num'); register_setting('grs-options', 'gr_content'); register_setting('grs-options', 'gr_trim'); register_setting('grs-options', 'gr_notes'); register_setting('grs-options', 'gr_date'); register_setting('grs-options', 'gr_datep'); register_setting('grs-options', 'gr_source'); register_setting('grs-options', 'gr_sourcep'); register_setting('grs-options', 'gr_open'); register_setting('grs-options', 'gr_notep'); register_setting('grs-options', 'gr_skipnote'); register_setting('grs-options', 'gr_sc_styles'); register_setting('grs-options', 'gr_sc_html'); register_setting('grs-options', 'gr_sc_trim'); register_setting('grs-options', 'gr_sc_strpimg'); register_setting('grs-options', 'gr_sc_simplehtml'); register_setting('grs-options', 'gr_nofollow'); register_setting('grs-options', 'gr_sc_cache'); register_setting('grs-options', 'gr_cache'); register_setting('grs-options', 'gr_publish_date'); register_setting('grs-options', 'gr_publish_upto'); } add_action( 'admin_init', 'grs_admin_init' ); //*******************// //***CORE FUNCTION***// //*******************// function google_reader_items($isshortcode = false, $maxcnt = '') { if (!req_check()) return false; //handling of posts that should only show posts older than publication date of post $gr_publish_date = ($isshortcode) ? get_option("gr_publish_date") : false; if($gr_publish_date) { $cache = get_post_meta(get_the_ID(),"_gr_cache",true); if ($cache) return $cache; //WE'RE ALREADY DONE! $post_date = get_the_time('U'); $gr_publish_upto = get_option("gr_publish_upto"); if($gr_publish_upto) { //get last post using rec reading pub date global $wpdb; $mysql_date = date ("Y-m-d H:i:s", $post_date); $last_post = $wpdb->get_row("SELECT post_date FROM $wpdb->posts WHERE post_date < '$mysql_date' AND (post_type = 'post' OR post_type = 'page') AND post_content LIKE '%[recreading%]%' ORDER BY post_date DESC LIMIT 1;", ARRAY_N); $gr_publish_upto = ($last_post[0]) ? strtotime($last_post[0]) : false; } } $gr_sid = get_option("gr_sid"); if (!$gr_sid) return 'Recommended Reading plug-in has not been configured.'; $url = "http://www.google.com/reader/public/atom/user%2F".$gr_sid."%2Fstate%2Fcom.google%2Fbroadcast"; if (function_exists("curl_init")) { //use curl - faster $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, 0); $data = curl_exec($ch); $response = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); } else { //use fopen - fallback $data = @file_get_contents($url); $response = explode(" ",$http_response_header[0],3); $response = $response[1]; } if ($response != "200") return "No Google Reader feed was found with the provided ID."; $doc = new SimpleXmlElement($data, LIBXML_NOCDATA); //basic caching handling $feedupdate = strtotime($doc->updated); $lastupdate = $isshortcode ? get_option("gr_sc_lastupdate") : get_option("gr_lastupdate"); //whether to use shortcode cache check or widget cache check if(!$lastupdate || $lastupdate < $feedupdate) { if (isset($gr_publish_upto) && $gr_publish_upto) $maxcnt = ''; //if using publish up to and it applies, set max count to all elseif (!$maxcnt) $maxcnt = get_option("gr_num"); //otherwise if it wasn't passed by shortcode, get from options $cnt = count($doc->entry); //count total number of entries in feed if (!$cnt) return "There are no items in your shared Google Reader feed."; if ($maxcnt && $maxcnt < $cnt) $cnt = $maxcnt; //if user specified number of entries (and its less than total), here's the max loop iterations $gr_open = get_option("gr_open") ? ' target="_blank"' : ' '; //HTML for opening link in new window if set to $gr_nofollow = get_option("gr_nofollow") ? ' rel="nofollow"' : ' '; //HTML for nofollow rel $gr_skipnote = get_option('gr_skipnote'); $gr_date = get_option("gr_date"); if($gr_date) $datep = get_option("gr_datep"); $gr_source = get_option("gr_source"); if ($gr_source) $sourcep = get_option("gr_sourcep"); $gr_notes = get_option("gr_notes"); if($gr_notes) $notep = get_option("gr_notep"); $gr_content = get_option("gr_content"); if ($gr_content) $desctrim = get_option("gr_trim"); if ($isshortcode) { $gr_sc_html = get_option('gr_sc_html'); $gr_sc_simplehtml = get_option('gr_sc_simplehtml'); if (get_option('gr_sc_trim')) $desctrim = ""; $gr_sc_strpimg = get_option('gr_sc_strpimg'); } $gr_cache = '
"); elseif ($gr_sc_strpimg) $desc = preg_replace('#?img[^>]*>#is','',$desc); } else { $desc = preg_replace('/&[^;]+;/','',strip_tags($desc)); if($desctrim && strlen($desc) > $desctrim) $desc = trim(substr($desc,0,$desctrim))."..."; //shorten content if shorter than defined max length } $gr_cache .= ''.$desc.''; } $gr_cache .= '
Help support continued development of Recommended Reading and other plugins.
The best thing you can do is refer someone looking for web development or strategy work to our company.
Short of that, here are other ways you can help:
| Google Reader ID [?] | |
|---|---|
| Look up my Google Reader ID | |
| Google Username | |
| Google Password | |
| Your server does not have cURL enabled. cURL is a widely supported PHP module used to load and process external web pages behind the scenes. Unfortunately, cURL support is needed to dynamically look up your ID. You may still manually find and enter your ID. Click the question mark link above for instructions. | |
You can display your Google Reader shared items on a dedicated page or post by simply typing [recreading] into the content (WordPress calls this "shortcode"). An optional attribute, 'items', can be set to the number of items you want to display; for example, [recreading items=5] to show 5 shared items.
The shortcode will use the settings above, but also has a few additional settings you can control.
| As of publish date [?] | /> |
|---|---|
| ... up to last post [?] | /> |
| Don't truncate content [?] | /> |
| ... and show HTML [?] | /> |
| ... ... but only simple tags [?] | /> |
| ... ... and hide images [?] | /> |
| Use special styles [?] | /> |