WP RSS Aggregator - Version 1.1

Version Description

Download this release

Release Info

Developer jeangalea
Plugin Icon 128x128 WP RSS Aggregator
Version 1.1
Comparing to
See all releases

Version 1.1

changelog.txt ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 1.1 (2012-08-13)
2
+ Now requires WordPress 3.0
3
+ More flexible fetching of images directory
4
+ Has its own top level menu item
5
+ Added settings section
6
+ Ability to open in lightbox, new window or default browser behaviour
7
+ Ability to set links as follow or no follow
8
+ Using constants for oftenly used locations
9
+ Code refactoring
10
+ Changes in file and folder structure
11
+
12
+ 1.0 (2012-01-06)
13
+ First release
css/colorbox.css ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ ColorBox Core Style:
3
+ The following CSS is consistent between example themes and should not be altered.
4
+ */
5
+ #colorbox, #cboxOverlay, #cboxWrapper{position:absolute; top:0; left:0; z-index:9999; overflow:hidden;}
6
+ #cboxOverlay{position:fixed; width:100%; height:100%;}
7
+ #cboxMiddleLeft, #cboxBottomLeft{clear:left;}
8
+ #cboxContent{position:relative;}
9
+ #cboxLoadedContent{overflow:auto;}
10
+ #cboxTitle{margin:0;}
11
+ #cboxLoadingOverlay, #cboxLoadingGraphic{position:absolute; top:0; left:0; width:100%; height:100%;}
12
+ #cboxPrevious, #cboxNext, #cboxClose, #cboxSlideshow{cursor:pointer;}
13
+ .cboxPhoto{float:left; margin:auto; border:0; display:block;}
14
+ .cboxIframe{width:100%; height:100%; display:block; border:0;}
15
+
16
+ /*
17
+ User Style:
18
+ Change the following styles to modify the appearance of ColorBox. They are
19
+ ordered & tabbed in a way that represents the nesting of the generated HTML.
20
+ */
21
+ #cboxOverlay{background:#000;}
22
+ #colorbox{}
23
+ #cboxTopLeft{width:14px; height:14px; background:url(images/controls.png) no-repeat 0 0;}
24
+ #cboxTopCenter{height:14px; background:url(images/border.png) repeat-x top left;}
25
+ #cboxTopRight{width:14px; height:14px; background:url(images/controls.png) no-repeat -36px 0;}
26
+ #cboxBottomLeft{width:14px; height:43px; background:url(images/controls.png) no-repeat 0 -32px;}
27
+ #cboxBottomCenter{height:43px; background:url(images/border.png) repeat-x bottom left;}
28
+ #cboxBottomRight{width:14px; height:43px; background:url(images/controls.png) no-repeat -36px -32px;}
29
+ #cboxMiddleLeft{width:14px; background:url(images/controls.png) repeat-y -175px 0;}
30
+ #cboxMiddleRight{width:14px; background:url(images/controls.png) repeat-y -211px 0;}
31
+ #cboxContent{background:#fff; overflow:visible;}
32
+ .cboxIframe{background:#fff;}
33
+ #cboxError{padding:50px; border:1px solid #ccc;}
34
+ #cboxLoadedContent{margin-bottom:5px;}
35
+ #cboxLoadingOverlay{background:url(images/loading_background.png) no-repeat center center;}
36
+ #cboxLoadingGraphic{background:url(images/loading.gif) no-repeat center center;}
37
+ #cboxTitle{position:absolute; bottom:-25px; left:0; text-align:center; width:100%; font-weight:bold; color:#7C7C7C;}
38
+ #cboxCurrent{position:absolute; bottom:-25px; left:58px; font-weight:bold; color:#7C7C7C;}
39
+
40
+ #cboxPrevious, #cboxNext, #cboxClose, #cboxSlideshow{position:absolute; bottom:-29px; background:url(images/controls.png) no-repeat 0px 0px; width:23px; height:23px; text-indent:-9999px;}
41
+ #cboxPrevious{left:0px; background-position: -51px -25px;}
42
+ #cboxPrevious:hover{background-position:-51px 0px;}
43
+ #cboxNext{left:27px; background-position:-75px -25px;}
44
+ #cboxNext:hover{background-position:-75px 0px;}
45
+ #cboxClose{right:0; background-position:-100px -25px;}
46
+ #cboxClose:hover{background-position:-100px 0px;}
47
+
48
+ .cboxSlideshow_on #cboxSlideshow{background-position:-125px 0px; right:27px;}
49
+ .cboxSlideshow_on #cboxSlideshow:hover{background-position:-150px 0px;}
50
+ .cboxSlideshow_off #cboxSlideshow{background-position:-150px -25px; right:27px;}
51
+ .cboxSlideshow_off #cboxSlideshow:hover{background-position:-125px 0px;}
css/styles.css ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .wprss-input {
2
+ background: none repeat scroll 0 0 #EAF2FA;
3
+ margin-bottom: 20px;
4
+ padding-bottom: 10px;
5
+ padding-left: 10px;
6
+ padding-top: 10px;
7
+ width: 600px;
8
+ }
9
+
10
+ .wprss-input p { line-height: 28px; }
11
+
12
+ .wprss-input label {
13
+ float: left;
14
+ width: 95px !important;
15
+ }
16
+
17
+ .wprss-input input {
18
+ height: 28px;
19
+ margin-bottom: 0;
20
+ padding: 0 0 0 5px;
21
+ width: 400px;
22
+ }
23
+
24
+ #icon-wprss-aggregator {
25
+ background: transparent url( '../img/icon-adminpage32.png' ) no-repeat !important;
26
+ }
27
+
28
+ /*.rss-aggregator_page_wprss-aggregator-settings .form-table th { width: 80px; }*/
img/add.png ADDED
Binary file
img/icon-adminmenu16-sprite.png ADDED
Binary file
img/icon-adminpage32.png ADDED
Binary file
img/remove.png ADDED
Binary file
inc/activation.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php /**
2
+ * Plugin activation procedure
3
+ */
4
+
5
+ function wprss_activate() {
6
+ // Activates the plugin and checks for compatible version of WordPress
7
+ if ( version_compare( get_bloginfo( 'version' ), '3.0', '<' ) ) {
8
+ deactivate_plugins ( basename( __FILE__ )); // Deactivate plugin
9
+ wp_die( "This plugin requires WordPress version 3.0 or higher." );
10
+ }
11
+
12
+ if ( !wp_next_scheduled( 'wprss_generate_hook' ) ) {
13
+ // Schedule to run hourly
14
+ wp_schedule_event( time(), 'hourly', 'wprss_generate_hook' );
15
+ }
16
+
17
+ add_action( 'wprss_generate_hook', 'wp_rss_aggregator' );
18
+ }
19
+ ?>
inc/admin-options.php ADDED
@@ -0,0 +1,172 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Plugin administration page
4
+ *
5
+ * Note: Wording of options and settings is confusing, due to the plugin originally only having
6
+ * an 'options' page to enter feed sources, and now needing two screens, one for feed sources and one for
7
+ * general settings. Might implement something cleaner in the future.
8
+ */
9
+
10
+ // Add the admin options and settings pages
11
+
12
+ add_action( 'admin_menu', 'wprss_add_page' );
13
+
14
+ function wprss_add_page() {
15
+ add_menu_page( 'RSS Aggregator', 'RSS Aggregator', 'manage_options', 'wprss-aggregator',
16
+ 'wprss_options_page', WPRSS_IMG . '/icon-adminmenu16-sprite.png' );
17
+
18
+ add_submenu_page( 'wprss-aggregator', 'WP RSS Aggregator Settings', 'Settings', 'manage_options',
19
+ 'wprss-aggregator-settings', 'wprss_settings_page' );
20
+ }
21
+
22
+
23
+ /**
24
+ * Register and define options and settings
25
+ */
26
+
27
+ add_action( 'admin_init', 'wprss_admin_init' );
28
+
29
+ function wprss_admin_init() {
30
+ register_setting( 'wprss_options', 'wprss_options' );
31
+ add_settings_section( 'wprss_main', '', 'wprss_section_text', 'wprss' );
32
+
33
+ register_setting( 'wprss_settings', 'wprss_settings' );
34
+
35
+
36
+ add_settings_section( 'wprss-settings-main', '', 'wprss_settings_section_text', 'wprss-aggregator-settings' );
37
+
38
+ add_settings_field( 'wprss-settings-open-dd', 'Open links behaviour',
39
+ 'wprss_setting_open_dd', 'wprss-aggregator-settings', 'wprss-settings-main');
40
+
41
+ add_settings_field( 'wprss-settings-follow-dd', 'Set links as',
42
+ 'wprss_setting_follow_dd', 'wprss-aggregator-settings', 'wprss-settings-main');
43
+ }
44
+
45
+
46
+ /**
47
+ * Draw options page, used for adding feeds
48
+ */
49
+
50
+ function wprss_options_page() {
51
+ ?>
52
+ <div class="wrap">
53
+ <?php screen_icon( 'wprss-aggregator' ); ?>
54
+
55
+
56
+ <h2>WP RSS Aggregator Feed Sources</h2>
57
+ <div id="options">
58
+ <form action="options.php" method="post">
59
+ <?php
60
+
61
+ settings_fields( 'wprss_options' );
62
+ do_settings_sections( 'wprss' );
63
+ $options = get_option( 'wprss_options' );
64
+ if ( !empty($options) ) {
65
+ $size = count($options);
66
+ for ( $i = 1; $i <= $size; $i++ ) {
67
+ if( $i % 2 == 0 ) continue;
68
+ echo "<div class='wprss-input'>";
69
+
70
+ $key = key( $options );
71
+
72
+ echo "<p><label class='textinput' for='$key'>" . wprss_convert_key( $key ) . "</label>
73
+ <input id='$key' class='wprss-input' size='100' name='wprss_options[$key]' type='text' value='$options[$key]' /></p>";
74
+
75
+ next( $options );
76
+
77
+ $key = key( $options );
78
+
79
+ echo "<p><label class='textinput' for='$key'>" . wprss_convert_key( $key ) . "</label>
80
+ <input id='$key' class='wprss-input' size='100' name='wprss_options[$key]' type='text' value='$options[$key]' /></p>";
81
+
82
+ next( $options );
83
+ echo "</div>";
84
+
85
+ }
86
+ }
87
+
88
+ ?>
89
+ <div id="buttons"><a href="#" id="add"><img src="<?php echo WPRSS_IMG; ?>/add.png"></a>
90
+ <a href="#" id="remove"><img src="<?php echo WPRSS_IMG; ?>/remove.png"></a></div>
91
+ <p class="submit"><input type="submit" value="Save Settings" name="submit" class="button-primary"></p>
92
+
93
+ </form>
94
+ </div> <!-- end options -->
95
+ </div> <!-- end wrap -->
96
+ <?php
97
+ }
98
+
99
+
100
+
101
+
102
+
103
+ /**
104
+ * Explain the options section
105
+ */
106
+
107
+ function wprss_section_text() {
108
+ echo '<p>Enter a name and URL for each of your feeds. The name is used just for your reference.</p>';
109
+ }
110
+
111
+
112
+
113
+
114
+
115
+
116
+
117
+
118
+
119
+
120
+
121
+ /**
122
+ * Build the plugin settings page, used to save general settings like whether a link should be follow or no follow
123
+ */
124
+
125
+ function wprss_settings_page() {
126
+ ?>
127
+ <div class="wrap">
128
+ <?php screen_icon( 'wprss-aggregator' ); ?>
129
+
130
+ <h2>WP RSS Aggregator Settings</h2>
131
+
132
+ <form action="options.php" method="post">
133
+ <?php settings_fields( 'wprss_settings' ) ?>
134
+ <?php do_settings_sections( 'wprss-aggregator-settings' ); ?>
135
+ <p class="submit"><input type="submit" value="Save Settings" name="submit" class="button-primary"></p>
136
+ </form>
137
+ </div>
138
+ <?php
139
+ }
140
+
141
+
142
+ // Draw the section header
143
+ function wprss_settings_section_text() {
144
+ // echo '<p>Enter your settings here.</p>';
145
+ }
146
+
147
+ // Follow or No Follow Dropdown
148
+ function wprss_setting_follow_dd() {
149
+ $options = get_option( 'wprss_settings' );
150
+ $items = array( "No follow", "Follow" );
151
+ echo "<select id='follow-dd' name='wprss_settings[follow_dd]'>";
152
+ foreach( $items as $item ) {
153
+ $selected = ( $options['follow_dd'] == $item) ? 'selected="selected"' : '';
154
+ echo "<option value='$item' $selected>$item</option>";
155
+ }
156
+ echo "</select>";
157
+ }
158
+
159
+ // Link open setting Dropdown
160
+ function wprss_setting_open_dd() {
161
+ $options = get_option( 'wprss_settings' );
162
+ $items = array( "Lightbox", "New window", "None" );
163
+ echo "<select id='open-dd' name='wprss_settings[open_dd]'>";
164
+ foreach( $items as $item ) {
165
+ $selected = ( $options['open_dd'] == $item) ? 'selected="selected"' : '';
166
+ echo "<option value='$item' $selected>$item</option>";
167
+ }
168
+ echo "</select>";
169
+ }
170
+
171
+
172
+ ?>
inc/deactivation.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Plugin deactivation procedure
4
+ */
5
+
6
+
7
+ function wprss_deactivate() {
8
+ // on deactivation remove the cron job
9
+ if ( wp_next_scheduled( 'wprss_generate_hook' ) )
10
+ wp_clear_scheduled_hook( 'wprss_generate_hook' );
11
+ }
12
+ ?>
inc/shortcodes.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Set up shortcodes and call the main function for output
4
+ */
5
+
6
+ // Register shortcodes
7
+ add_shortcode( 'wp_rss_aggregator', 'wprss_shortcode');
8
+ add_shortcode( 'wp-rss-aggregator', 'wprss_shortcode');
9
+
10
+ function wprss_shortcode( $atts ) {
11
+ if ( !empty ($atts) ) {
12
+ foreach ( $atts as $key => &$val ) {
13
+ $val = html_entity_decode($val);
14
+ }
15
+ }
16
+ wp_rss_aggregator( $atts );
17
+ }
18
+ ?>
js/add-remove.js ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ JQuery code to add or remove option fields
3
+ */
4
+
5
+
6
+ jQuery(function() { // when document has loaded
7
+
8
+ var i = jQuery('input.wprss-input').size(); // check how many input exists on the document and add 1 for the add command to work
9
+ i = (i / 2) + 1;
10
+
11
+ jQuery('a#add').click(function() { // when you click the add link
12
+ jQuery( "<div class='wprss-input'><p><label class='textinput' for='feed_name_" + i + "'>Feed name " + i + "</label>" +
13
+ "<input id='feed_name_" + i + "' class='wprss-input' size='100' name='wprss_options[feed_name_" + i + "]' type='text' value='' /></p>" +
14
+ "<p><label class='textinput' for='feed_url_" + i + "'>Feed URL " + i + "</label>" +
15
+ "<input id='feed_url_" + i + "' class='wprss-input' size='100' name='wprss_options[feed_url_" + i + "]' type='text' value='' /></p></div>")
16
+ .fadeIn('slow').insertBefore('div#buttons');
17
+ // append (add) a new input to the document.
18
+ // if you have the input inside a form, change body to form in the appendTo
19
+ i++; //after the click i will be i = 3 if you click again i will be i = 4
20
+ });
21
+
22
+ jQuery('a#remove').click(function() { // similar to the previous, when you click remove link
23
+ if(i > 1) { // if you have at least 1 input on the form
24
+ jQuery('div.wprss-input:last').remove(); //remove the last input
25
+ i--; //deduct 1 from i so if i = 3, after i--, i will be i = 2
26
+ }
27
+ });
28
+
29
+ jQuery('a.reset').click(function() {
30
+ while(i > 2) { // while you have more than 1 input on the page
31
+ //jQuery('input.wprss-input:last').remove(); // remove inputs
32
+ jQuery('div.wprss-input:last').remove(); // remove inputs
33
+ i--;
34
+ }
35
+ });
36
+
37
+ });
38
+
js/jquery.colorbox-min.js ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ // ColorBox v1.3.19 - jQuery lightbox plugin
2
+ // (c) 2011 Jack Moore - jacklmoore.com
3
+ // License: http://www.opensource.org/licenses/mit-license.php
4
+ (function(a,b,c){function Z(c,d,e){var g=b.createElement(c);return d&&(g.id=f+d),e&&(g.style.cssText=e),a(g)}function $(a){var b=y.length,c=(Q+a)%b;return c<0?b+c:c}function _(a,b){return Math.round((/%/.test(a)?(b==="x"?z.width():z.height())/100:1)*parseInt(a,10))}function ba(a){return K.photo||/\.(gif|png|jpe?g|bmp|ico)((#|\?).*)?$/i.test(a)}function bb(){var b;K=a.extend({},a.data(P,e));for(b in K)a.isFunction(K[b])&&b.slice(0,2)!=="on"&&(K[b]=K[b].call(P));K.rel=K.rel||P.rel||"nofollow",K.href=K.href||a(P).attr("href"),K.title=K.title||P.title,typeof K.href=="string"&&(K.href=a.trim(K.href))}function bc(b,c){a.event.trigger(b),c&&c.call(P)}function bd(){var a,b=f+"Slideshow_",c="click."+f,d,e,g;K.slideshow&&y[1]?(d=function(){F.text(K.slideshowStop).unbind(c).bind(j,function(){if(K.loop||y[Q+1])a=setTimeout(W.next,K.slideshowSpeed)}).bind(i,function(){clearTimeout(a)}).one(c+" "+k,e),r.removeClass(b+"off").addClass(b+"on"),a=setTimeout(W.next,K.slideshowSpeed)},e=function(){clearTimeout(a),F.text(K.slideshowStart).unbind([j,i,k,c].join(" ")).one(c,function(){W.next(),d()}),r.removeClass(b+"on").addClass(b+"off")},K.slideshowAuto?d():e()):r.removeClass(b+"off "+b+"on")}function be(b){U||(P=b,bb(),y=a(P),Q=0,K.rel!=="nofollow"&&(y=a("."+g).filter(function(){var b=a.data(this,e).rel||this.rel;return b===K.rel}),Q=y.index(P),Q===-1&&(y=y.add(P),Q=y.length-1)),S||(S=T=!0,r.show(),K.returnFocus&&a(P).blur().one(l,function(){a(this).focus()}),q.css({opacity:+K.opacity,cursor:K.overlayClose?"pointer":"auto"}).show(),K.w=_(K.initialWidth,"x"),K.h=_(K.initialHeight,"y"),W.position(),o&&z.bind("resize."+p+" scroll."+p,function(){q.css({width:z.width(),height:z.height(),top:z.scrollTop(),left:z.scrollLeft()})}).trigger("resize."+p),bc(h,K.onOpen),J.add(D).hide(),I.html(K.close).show()),W.load(!0))}function bf(){!r&&b.body&&(Y=!1,z=a(c),r=Z(X).attr({id:e,"class":n?f+(o?"IE6":"IE"):""}).hide(),q=Z(X,"Overlay",o?"position:absolute":"").hide(),s=Z(X,"Wrapper"),t=Z(X,"Content").append(A=Z(X,"LoadedContent","width:0; height:0; overflow:hidden"),C=Z(X,"LoadingOverlay").add(Z(X,"LoadingGraphic")),D=Z(X,"Title"),E=Z(X,"Current"),G=Z(X,"Next"),H=Z(X,"Previous"),F=Z(X,"Slideshow").bind(h,bd),I=Z(X,"Close")),s.append(Z(X).append(Z(X,"TopLeft"),u=Z(X,"TopCenter"),Z(X,"TopRight")),Z(X,!1,"clear:left").append(v=Z(X,"MiddleLeft"),t,w=Z(X,"MiddleRight")),Z(X,!1,"clear:left").append(Z(X,"BottomLeft"),x=Z(X,"BottomCenter"),Z(X,"BottomRight"))).find("div div").css({"float":"left"}),B=Z(X,!1,"position:absolute; width:9999px; visibility:hidden; display:none"),J=G.add(H).add(E).add(F),a(b.body).append(q,r.append(s,B)))}function bg(){return r?(Y||(Y=!0,L=u.height()+x.height()+t.outerHeight(!0)-t.height(),M=v.width()+w.width()+t.outerWidth(!0)-t.width(),N=A.outerHeight(!0),O=A.outerWidth(!0),r.css({"padding-bottom":L,"padding-right":M}),G.click(function(){W.next()}),H.click(function(){W.prev()}),I.click(function(){W.close()}),q.click(function(){K.overlayClose&&W.close()}),a(b).bind("keydown."+f,function(a){var b=a.keyCode;S&&K.escKey&&b===27&&(a.preventDefault(),W.close()),S&&K.arrowKey&&y[1]&&(b===37?(a.preventDefault(),H.click()):b===39&&(a.preventDefault(),G.click()))}),a("."+g,b).live("click",function(a){a.which>1||a.shiftKey||a.altKey||a.metaKey||(a.preventDefault(),be(this))})),!0):!1}var d={transition:"elastic",speed:300,width:!1,initialWidth:"600",innerWidth:!1,maxWidth:!1,height:!1,initialHeight:"450",innerHeight:!1,maxHeight:!1,scalePhotos:!0,scrolling:!0,inline:!1,html:!1,iframe:!1,fastIframe:!0,photo:!1,href:!1,title:!1,rel:!1,opacity:.9,preloading:!0,current:"image {current} of {total}",previous:"previous",next:"next",close:"close",open:!1,returnFocus:!0,reposition:!0,loop:!0,slideshow:!1,slideshowAuto:!0,slideshowSpeed:2500,slideshowStart:"start slideshow",slideshowStop:"stop slideshow",onOpen:!1,onLoad:!1,onComplete:!1,onCleanup:!1,onClosed:!1,overlayClose:!0,escKey:!0,arrowKey:!0,top:!1,bottom:!1,left:!1,right:!1,fixed:!1,data:undefined},e="colorbox",f="cbox",g=f+"Element",h=f+"_open",i=f+"_load",j=f+"_complete",k=f+"_cleanup",l=f+"_closed",m=f+"_purge",n=!a.support.opacity&&!a.support.style,o=n&&!c.XMLHttpRequest,p=f+"_IE6",q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X="div",Y;if(a.colorbox)return;a(bf),W=a.fn[e]=a[e]=function(b,c){var f=this;b=b||{},bf();if(bg()){if(!f[0]){if(f.selector)return f;f=a("<a/>"),b.open=!0}c&&(b.onComplete=c),f.each(function(){a.data(this,e,a.extend({},a.data(this,e)||d,b))}).addClass(g),(a.isFunction(b.open)&&b.open.call(f)||b.open)&&be(f[0])}return f},W.position=function(a,b){function i(a){u[0].style.width=x[0].style.width=t[0].style.width=a.style.width,t[0].style.height=v[0].style.height=w[0].style.height=a.style.height}var c=0,d=0,e=r.offset(),g=z.scrollTop(),h=z.scrollLeft();z.unbind("resize."+f),r.css({top:-9e4,left:-9e4}),K.fixed&&!o?(e.top-=g,e.left-=h,r.css({position:"fixed"})):(c=g,d=h,r.css({position:"absolute"})),K.right!==!1?d+=Math.max(z.width()-K.w-O-M-_(K.right,"x"),0):K.left!==!1?d+=_(K.left,"x"):d+=Math.round(Math.max(z.width()-K.w-O-M,0)/2),K.bottom!==!1?c+=Math.max(z.height()-K.h-N-L-_(K.bottom,"y"),0):K.top!==!1?c+=_(K.top,"y"):c+=Math.round(Math.max(z.height()-K.h-N-L,0)/2),r.css({top:e.top,left:e.left}),a=r.width()===K.w+O&&r.height()===K.h+N?0:a||0,s[0].style.width=s[0].style.height="9999px",r.dequeue().animate({width:K.w+O,height:K.h+N,top:c,left:d},{duration:a,complete:function(){i(this),T=!1,s[0].style.width=K.w+O+M+"px",s[0].style.height=K.h+N+L+"px",K.reposition&&setTimeout(function(){z.bind("resize."+f,W.position)},1),b&&b()},step:function(){i(this)}})},W.resize=function(a){S&&(a=a||{},a.width&&(K.w=_(a.width,"x")-O-M),a.innerWidth&&(K.w=_(a.innerWidth,"x")),A.css({width:K.w}),a.height&&(K.h=_(a.height,"y")-N-L),a.innerHeight&&(K.h=_(a.innerHeight,"y")),!a.innerHeight&&!a.height&&(A.css({height:"auto"}),K.h=A.height()),A.css({height:K.h}),W.position(K.transition==="none"?0:K.speed))},W.prep=function(b){function g(){return K.w=K.w||A.width(),K.w=K.mw&&K.mw<K.w?K.mw:K.w,K.w}function h(){return K.h=K.h||A.height(),K.h=K.mh&&K.mh<K.h?K.mh:K.h,K.h}if(!S)return;var c,d=K.transition==="none"?0:K.speed;A.remove(),A=Z(X,"LoadedContent").append(b),A.hide().appendTo(B.show()).css({width:g(),overflow:K.scrolling?"auto":"hidden"}).css({height:h()}).prependTo(t),B.hide(),a(R).css({"float":"none"}),o&&a("select").not(r.find("select")).filter(function(){return this.style.visibility!=="hidden"}).css({visibility:"hidden"}).one(k,function(){this.style.visibility="inherit"}),c=function(){function q(){n&&r[0].style.removeAttribute("filter")}var b,c,g=y.length,h,i="frameBorder",k="allowTransparency",l,o,p;if(!S)return;l=function(){clearTimeout(V),C.hide(),bc(j,K.onComplete)},n&&R&&A.fadeIn(100),D.html(K.title).add(A).show();if(g>1){typeof K.current=="string"&&E.html(K.current.replace("{current}",Q+1).replace("{total}",g)).show(),G[K.loop||Q<g-1?"show":"hide"]().html(K.next),H[K.loop||Q?"show":"hide"]().html(K.previous),K.slideshow&&F.show();if(K.preloading){b=[$(-1),$(1)];while(c=y[b.pop()])o=a.data(c,e).href||c.href,a.isFunction(o)&&(o=o.call(c)),ba(o)&&(p=new Image,p.src=o)}}else J.hide();K.iframe?(h=Z("iframe")[0],i in h&&(h[i]=0),k in h&&(h[k]="true"),h.name=f+ +(new Date),K.fastIframe?l():a(h).one("load",l),h.src=K.href,K.scrolling||(h.scrolling="no"),a(h).addClass(f+"Iframe").appendTo(A).one(m,function(){h.src="//about:blank"})):l(),K.transition==="fade"?r.fadeTo(d,1,q):q()},K.transition==="fade"?r.fadeTo(d,0,function(){W.position(0,c)}):W.position(d,c)},W.load=function(b){var c,d,e=W.prep;T=!0,R=!1,P=y[Q],b||bb(),bc(m),bc(i,K.onLoad),K.h=K.height?_(K.height,"y")-N-L:K.innerHeight&&_(K.innerHeight,"y"),K.w=K.width?_(K.width,"x")-O-M:K.innerWidth&&_(K.innerWidth,"x"),K.mw=K.w,K.mh=K.h,K.maxWidth&&(K.mw=_(K.maxWidth,"x")-O-M,K.mw=K.w&&K.w<K.mw?K.w:K.mw),K.maxHeight&&(K.mh=_(K.maxHeight,"y")-N-L,K.mh=K.h&&K.h<K.mh?K.h:K.mh),c=K.href,V=setTimeout(function(){C.show()},100),K.inline?(Z(X).hide().insertBefore(a(c)[0]).one(m,function(){a(this).replaceWith(A.children())}),e(a(c))):K.iframe?e(" "):K.html?e(K.html):ba(c)?(a(R=new Image).addClass(f+"Photo").error(function(){K.title=!1,e(Z(X,"Error").text("This image could not be loaded"))}).load(function(){var a;R.onload=null,K.scalePhotos&&(d=function(){R.height-=R.height*a,R.width-=R.width*a},K.mw&&R.width>K.mw&&(a=(R.width-K.mw)/R.width,d()),K.mh&&R.height>K.mh&&(a=(R.height-K.mh)/R.height,d())),K.h&&(R.style.marginTop=Math.max(K.h-R.height,0)/2+"px"),y[1]&&(K.loop||y[Q+1])&&(R.style.cursor="pointer",R.onclick=function(){W.next()}),n&&(R.style.msInterpolationMode="bicubic"),setTimeout(function(){e(R)},1)}),setTimeout(function(){R.src=c},1)):c&&B.load(c,K.data,function(b,c,d){e(c==="error"?Z(X,"Error").text("Request unsuccessful: "+d.statusText):a(this).contents())})},W.next=function(){!T&&y[1]&&(K.loop||y[Q+1])&&(Q=$(1),W.load())},W.prev=function(){!T&&y[1]&&(K.loop||Q)&&(Q=$(-1),W.load())},W.close=function(){S&&!U&&(U=!0,S=!1,bc(k,K.onCleanup),z.unbind("."+f+" ."+p),q.fadeTo(200,0),r.stop().fadeTo(300,0,function(){r.add(q).css({opacity:1,cursor:"auto"}).hide(),bc(m),A.remove(),setTimeout(function(){U=!1,bc(l,K.onClosed)},1)}))},W.remove=function(){a([]).add(r).add(q).remove(),r=null,a("."+g).removeData(e).removeClass(g).die()},W.element=function(){return a(P)},W.settings=d})(jQuery,document,this);
readme.txt ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === WP RSS Aggregator ===
2
+ Contributors: jeangalea
3
+ Donate link: http://www.jeangalea.com
4
+ Tags: rss, feeds, aggregation, aggregator, import
5
+ Requires at least: 3.0
6
+ Tested up to: 3.3.1
7
+ Stable tag: 1.1
8
+ Imports and merges multiple RSS Feeds using SimplePie. Outputs feeds sorted by date (latest first).
9
+
10
+ == Description ==
11
+
12
+ WP RSS Aggregator helps you create a feed reader on your WordPress site. It works in a similar fashion to RSS readers like for example Netvibes.
13
+ You can add any number of feeds through an administration panel, the plugin will then pull all the feeds from these sites, merge them and sort them by date.
14
+
15
+ The output will be organised like this:
16
+
17
+ * Today
18
+ * Yesterday
19
+ * 2 Days ago
20
+ * More than 2 days ago
21
+
22
+ The plugin uses SimplePie for the feed operations. The actual news feeds are not stored in your databases but only cached for faster response times.
23
+ You can call the function from within the theme or even use a shortcode with parameters.
24
+
25
+ = Demo =
26
+ The plugin can be seen in use on the [WPMayor.com WordPress News page](http://www.wpmayor.com/wordpress-news/)
27
+
28
+ = Credit =
29
+ Created by Jean Galea. Need a [Web Developer](http://www.jeangalea.com/services/wordpress-consultancy-development/)?
30
+
31
+ == Installation ==
32
+
33
+ 1. Upload the `wp-rss-aggregator` folder to the `/wp-content/plugins/` directory
34
+ 2. Activate the WP RSS Aggregator plugin through the 'Plugins' menu in WordPress
35
+ 3. Configure the plugin by going to the `RSS Aggregator` menu item that appears in your dashboard menu.
36
+ 3. Use the shortcode in your posts or pages: `[wp_rss_aggregator]`
37
+
38
+ The parameters accepted are:
39
+
40
+ * date_before
41
+ * date_after
42
+ * links_befor
43
+ * links_after
44
+ * link_before
45
+ * link_after
46
+
47
+ An example of a shortcode with parameters:
48
+ `[wp_rss_aggregator date_before='<h2>' date_after='</h2>']`
49
+ It is advisable to use the 'HTML' view of the editor when inserting the shortcode with paramters.
50
+
51
+
52
+ An example of a function call from within the template files:
53
+ `<?php
54
+ wp_rss_aggregator(
55
+ 'date_before' => '<h3>',
56
+ 'date_after' => '</h3>',
57
+ 'links_before' => '<ul>',
58
+ 'links_after' => '</ul>',
59
+ 'link_before' => '<li>',
60
+ 'link_after' => '</li>'
61
+ );
62
+ ?>`
63
+
64
+ You can also set whether the feed links should open in a new window, current window or even a lightbox, via the settings panel.
65
+
66
+ The settings panel also has an option to set links as nofollow for SEO purposes.
67
+
68
+ == Frequently Asked Questions ==
69
+ = How can I output the feeds in my theme? =
70
+
71
+ You can either call the function directly within the theme:
72
+ `<?php wp_rss_aggregator(); ?>`
73
+
74
+ Or use the shortcode in your posts and pages:
75
+ [wp_rss_aggregator]
76
+
77
+ == Screenshots ==
78
+
79
+ 1. The output of this plugin on the frontend, as seen on www.wpmayor.com.
80
+
81
+ 2. Admin administration panel.
82
+
83
+ 3. The settings page.
84
+
85
+ == Changelog ==
86
+
87
+
88
+ = Version 1.1 (2012-08-13) =
89
+ * Now requires WordPress 3.0
90
+ * More flexible fetching of images directory
91
+ * Has its own top level menu item
92
+ * Added settings section
93
+ * Ability to open in lightbox, new window or default browser behaviour
94
+ * Ability to set links as follow or no follow
95
+ * Using constants for oftenly used locations
96
+ * Code refactoring
97
+ * Changes in file and folder structure
98
+
99
+
100
+ = Version 1.0 (2012-01-06) =
101
+ * Initial release.
102
+
screenshot-1.png ADDED
Binary file
screenshot-2.png ADDED
Binary file
screenshot-3.png ADDED
Binary file
uninstall.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // If uninstall not called from WordPress exit
3
+ if( !defined( 'WP_UNINSTALL_PLUGIN' ) )
4
+ exit ();
5
+ // Delete option from options table
6
+ delete_option( 'wprss_options' );
7
+ //
8
+ ?>
wp-rss-aggregator.php ADDED
@@ -0,0 +1,236 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: WP RSS Aggregator
4
+ Plugin URI: http://www.jeangalea.com
5
+ Description: Imports and merges multiple RSS Feeds using SimplePie
6
+ Version: 1.1
7
+ Author: Jean Galea
8
+ Author URI: http://www.jeangalea.com
9
+ License: GPLv2
10
+ */
11
+
12
+ /* Copyright 2011-2012 Jean Galea (email : jean@jpgalea.com)
13
+ This program is free software; you can redistribute it and/or modify
14
+ it under the terms of the GNU General Public License as published by
15
+ the Free Software Foundation; either version 2 of the License, or
16
+ (at your option) any later version.
17
+
18
+ This program is distributed in the hope that it will be useful,
19
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ GNU General Public License for more details.
22
+
23
+ You should have received a copy of the GNU General Public License
24
+ along with this program; if not, write to the Free Software
25
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26
+ */
27
+
28
+ // Define constants for ease of updating/modification later on in the lifespan of the plugin
29
+ define( 'WPRSS_VERSION', '1.1', true );
30
+ define( 'WPRSS_JS', plugins_url( 'js', __FILE__ ) , true );
31
+ define( 'WPRSS_CSS', plugins_url( 'css', __FILE__ ) , true );
32
+ define( 'WPRSS_IMG', plugins_url( 'img', __FILE__ ) , true );
33
+ define( 'WPRSS_INC', plugins_url( 'inc', __FILE__ ) , true );
34
+ define( 'WPRSS_PATH', plugin_dir_path( __FILE__ ), true );
35
+
36
+
37
+ /**
38
+ * Initialisation of the plugin
39
+ */
40
+
41
+ add_action( 'init', 'wprss_init' );
42
+
43
+ function wprss_init() {
44
+
45
+ require ( WPRSS_PATH . 'inc/activation.php' );
46
+ require ( WPRSS_PATH . 'inc/deactivation.php' );
47
+ require ( WPRSS_PATH . 'inc/shortcodes.php' );
48
+ require ( WPRSS_PATH . 'inc/admin-options.php' );
49
+
50
+ register_activation_hook( WPRSS_INC . '/activation.php', 'wprss_activate' );
51
+ register_deactivation_hook( WPRSS_INC . '/deactivation.php', 'wprss_deactivate' );
52
+
53
+ add_action ( 'wp_head', 'wprss_head_output' );
54
+
55
+ wp_enqueue_style( 'colorbox', WPRSS_CSS . '/colorbox.css' );
56
+ wp_enqueue_script( 'jquery.colorbox-min', WPRSS_JS .'/jquery.colorbox-min.js', array('jquery') );
57
+
58
+ // Only load scripts if we are on this plugin's options or settings pages (admin)
59
+ if ( isset( $_GET['page'] ) && ( $_GET['page'] == 'wprss-aggregator' | $_GET['page'] == 'wprss-aggregator-settings' ) ) {
60
+ wp_enqueue_style( 'styles', WPRSS_CSS . '/styles.css' );
61
+ }
62
+
63
+ // Only load scripts if we are on this plugin's options page (admin)
64
+ if ( isset( $_GET['page'] ) && $_GET['page'] == 'wprss-aggregator' ) {
65
+ wp_enqueue_script( 'jquery' );
66
+ wp_enqueue_script( 'add-remove', WPRSS_JS . '/add-remove.js' );
67
+ }
68
+ }
69
+
70
+
71
+ /**
72
+ * jQuery code to trigger Colorbox for links, goes in the <head> section on frontend
73
+ */
74
+
75
+ function wprss_head_output() {
76
+ echo "
77
+ <script type='text/javascript'>
78
+ jQuery( document ).ready( function() {
79
+ jQuery( 'a.colorbox' ).colorbox(
80
+ {iframe:true, width:'80%', height:'80%'}
81
+ );
82
+ });
83
+ </script>";
84
+ }
85
+
86
+
87
+
88
+ /**
89
+ * Convert from field name to user-friendly name
90
+ */
91
+
92
+ function wprss_convert_key( $key ) {
93
+ if ( strpos( $key, 'feed_name_' ) === 0 ) {
94
+ $label = str_replace( 'feed_name_', 'Feed name ', $key );
95
+ }
96
+
97
+ else if ( strpos( $key, 'feed_url_' ) === 0 ) {
98
+ $label = str_replace( 'feed_url_', 'Feed URL ', $key );
99
+ }
100
+ return $label;
101
+ }
102
+
103
+
104
+ /**
105
+ * Get feeds and output the aggregation
106
+ */
107
+
108
+ function wp_rss_aggregator( $args = array() ) {
109
+
110
+ $defaults = array(
111
+ 'date_before' => '<h3>',
112
+ 'date_after' => '</h3>',
113
+ 'links_before' => '<ul>',
114
+ 'links_after' => '</ul>',
115
+ 'link_before' => '<li>',
116
+ 'link_after' => '</li>'
117
+ );
118
+
119
+ // Parse incoming $args into an array and merge it with $defaults
120
+ $args = wp_parse_args( $args, $defaults );
121
+ // Declare each item in $args as its own variable
122
+ extract( $args, EXTR_SKIP );
123
+
124
+ $wprss_options = get_option( 'wprss_options', 'option not found' );
125
+
126
+ foreach ( $wprss_options as $key => $value ) {
127
+ if ( strpos( $key, 'feed_url_' ) === 0 ) {
128
+ $feed_uris[] = $value;
129
+ }
130
+ }
131
+
132
+ if ( !empty( $feed_uris ) ) {
133
+ // update feeds every hour else serve from cache
134
+ function wprss_hourly_feed() { return 3600; }
135
+ add_filter( 'wp_feed_cache_transient_lifetime', 'wprss_hourly_feed' );
136
+ $feed = fetch_feed( $feed_uris );
137
+ }
138
+ else echo 'No feed defined';
139
+ remove_filter( 'wp_feed_cache_transient_lifetime', 'wprss_hourly_feed' );
140
+
141
+ $items = $feed->get_items();
142
+ $items_today = array();
143
+ $items_yesterday = array();
144
+ $items_two_days_ago = array();
145
+ $items_older = array();
146
+
147
+
148
+ foreach ( $items as $item ):
149
+ $item_date = $item->get_date('l jS F (Y-m-d)');
150
+ if ( $item_date == date('l jS F (Y-m-d)', strtotime('today') ) ) {
151
+ $items_today[] = $item;
152
+ }
153
+ else if ( $item_date == date('l jS F (Y-m-d)', strtotime('yesterday') ) ) {
154
+ $items_yesterday[] = $item;
155
+ }
156
+ else if ( $item_date == date('l jS F (Y-m-d)', strtotime('-2 days') ) ) {
157
+ $items_two_days_ago[] = $item;
158
+ }
159
+ else {
160
+ $items_older[] = $item;
161
+ }
162
+ endforeach;
163
+
164
+ $settings = get_option( 'wprss_settings' );
165
+ $class = '';
166
+ $open_setting = '';
167
+ $follow_setting = '';
168
+
169
+ switch ( $settings['open_dd'] ) {
170
+
171
+ case 'Lightbox' :
172
+ $class = 'class="colorbox"';
173
+ break;
174
+
175
+ case 'New window' :
176
+ $open_setting = 'target="_blank"';
177
+ break;
178
+ }
179
+
180
+ switch ( $settings['follow_dd'] ) {
181
+
182
+ case 'No follow' :
183
+ $follow_setting = 'rel="nofollow"';
184
+ break;
185
+ }
186
+
187
+
188
+ if ( !empty( $items_today ) ) {
189
+ echo $date_before . 'Today' . $date_after;
190
+ echo $links_before;
191
+ foreach ( $items_today as $item ) {
192
+ echo $link_before . '<a ' . $class . $open_setting . $follow_setting . 'href="' . $item->get_permalink() .'">'. $item->get_title(). ' '. '</a>';
193
+ echo '<br><span class="feed-source">Source: '.$item->get_feed()->get_title()/* . ' | ' . $item->get_date('l jS F').''*/ . '</span>';
194
+ echo $link_after;
195
+ }
196
+ echo $links_after;
197
+ }
198
+
199
+ if ( !empty( $items_yesterday ) ) {
200
+ echo $date_before . 'Yesterday' . $date_after;
201
+ echo $links_before;
202
+ foreach ( $items_yesterday as $item ) {
203
+ echo '<li><a ' . $class . $open_setting . $follow_setting . 'href="' . $item->get_permalink() .'">'. $item->get_title(). ' '. '</a>';
204
+ echo '<br><span class="feed-source">Source: '.$item->get_feed()->get_title()/* . ' | ' . $item->get_date('l jS F').''*/ . '</span>';
205
+ echo $link_after;
206
+ }
207
+ echo $links_after;
208
+ }
209
+
210
+ if ( !empty( $items_two_days_ago ) ) {
211
+ echo $date_before . '2 days ago' . $date_after;
212
+ echo $links_before;
213
+ foreach ( $items_two_days_ago as $item ) {
214
+ echo '<li><a ' . $class . $open_setting . $follow_setting . 'href="' . $item->get_permalink() .'">'. $item->get_title(). ' '. '</a>';
215
+ echo '<br><span class="feed-source">Source: '.$item->get_feed()->get_title()/* . ' | ' . $item->get_date('l jS F').''*/ . '</span>';
216
+ echo $link_after;
217
+ }
218
+ echo $links_after;
219
+ }
220
+ if ( !empty( $items_older ) ) {
221
+ echo $date_before . 'More than 2 days ago' . $date_after;
222
+ echo $links_before;
223
+ foreach ( $items_older as $item ) {
224
+ echo '<li><a ' . $class . $open_setting . $follow_setting . 'href="' . $item->get_permalink() .'">'. $item->get_title(). ' '. '</a>';
225
+ echo '<br><span class="feed-source">Source: '.$item->get_feed()->get_title() . ' | ' . $item->get_date('l jS F').'</span>';
226
+ echo $link_after;
227
+ }
228
+ echo $links_after;
229
+
230
+ }
231
+ }
232
+
233
+ // use just for testing - runs on each wp load
234
+ //add_action( 'wp_loaded', 'wp_rss_aggregator' );
235
+
236
+ ?>