diff options
author | Mike Crute <mcrute@gmail.com> | 2012-04-19 13:43:47 -0400 |
---|---|---|
committer | Mike Crute <mcrute@gmail.com> | 2012-04-19 13:43:47 -0400 |
commit | b6cf43baab010d181601bb6aaae62dbab646203d (patch) | |
tree | b37ac3641a35dafd1fd5a16e3fc13152b31c561b /reader_shared.php | |
download | wordpress_plugins-master.tar.bz2 wordpress_plugins-master.tar.xz wordpress_plugins-master.zip |
Diffstat (limited to 'reader_shared.php')
-rw-r--r-- | reader_shared.php | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/reader_shared.php b/reader_shared.php new file mode 100644 index 0000000..f3be003 --- /dev/null +++ b/reader_shared.php | |||
@@ -0,0 +1,68 @@ | |||
1 | <?php | ||
2 | /* | ||
3 | Plugin Name: Google Reader Shared | ||
4 | Plugin URI: http://mike.crute.org/ | ||
5 | Description: A sidebar add-in for Google Reader shared items. | ||
6 | Version: 1.0 | ||
7 | Author: Mike Crute | ||
8 | Author URI: http://mike.crute.org/ | ||
9 | */ | ||
10 | |||
11 | // Format the plugin page | ||
12 | if (is_plugin_page()) { | ||
13 | if (isset($_POST['update_reader'])) { | ||
14 | update_option('GoogleReader_FeedURL', $_POST['url']); | ||
15 | update_option('GoogleReader_NumDisplay', $_POST['numdisp']); | ||
16 | update_option('GoogleReader_CSSClass', $_POST['cssclass']); | ||
17 | echo('<div class="updated"><p>Options changes saved.</p></div>'); | ||
18 | } | ||
19 | ?> | ||
20 | <div class="wrap"> | ||
21 | <h2>Google Reader Shared Items Options</h2> | ||
22 | |||
23 | <form method="post"> | ||
24 | <fieldset class="options"> | ||
25 | <p><strong>Google Reader</strong></p> | ||
26 | |||
27 | <label for="url">Feed URL:</label> | ||
28 | <input name="url" type="text" id="url" value="<?php echo get_option('GoogleReader_FeedURL'); ?>" /> | ||
29 | |||
30 | <label for="numdisp">Number to Display (max is 20):</label> | ||
31 | <input name="numdisp" type="text" id="numdisp" value="<?php echo get_option('GoogleReader_NumDisplay'); ?>" /> | ||
32 | |||
33 | <label for="cssclass">CSS Class:</label> | ||
34 | <input name="cssclass" type="text" id="cssclass" value="<?php echo get_option('GoogleReader_CSSClass'); ?>" /> | ||
35 | </fieldset> | ||
36 | |||
37 | <p><div class="submit"><input type="submit" name="update_reader" value="Save Settings" style="font-weight:bold;" /></div></p> | ||
38 | </form> | ||
39 | </div> | ||
40 | <?php | ||
41 | } | ||
42 | |||
43 | else { | ||
44 | function readerShared() { | ||
45 | $feedurl = trim(get_option('GoogleReader_FeedURL')); | ||
46 | $display = trim(get_option('GoogleReader_NumDisplay')); | ||
47 | $class = trim(get_option('GoogleReader_CSSClass')); | ||
48 | |||
49 | printf('<ul%s>', ($class != '') ? " class=\"$class\"" : ''); | ||
50 | $feed = simplexml_load_file($feedurl); | ||
51 | $loopcount = 0; | ||
52 | |||
53 | foreach ($feed->entry as $item) { | ||
54 | if ($loopcount < $display) { | ||
55 | printf('<li><a href="%s" rel="nofollow">%s - %s</a></li>',$item->link[1]['href'],$item->title,$item->source->title); | ||
56 | $loopcount++; | ||
57 | } | ||
58 | } | ||
59 | echo('</ul>'); | ||
60 | } | ||
61 | } | ||
62 | |||
63 | function readerShared_Menu() { | ||
64 | add_options_page('Google Reader Shared Options', 'Google Reader', 9, basename(__FILE__)); | ||
65 | } | ||
66 | |||
67 | add_action('admin_menu', 'readerShared_Menu'); | ||
68 | ?> \ No newline at end of file | ||