WP RSS Aggregator - Version 2.1

Version Description

Download this release

Release Info

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

Version 2.1

changelog.txt ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 2.1 (2012-09-27)
2
+ Now localised for translations
3
+ Fixed bug with date string
4
+ Fixed $link_before and $link_after, now working
5
+ Added backwards compatibility for wp_rss_aggregator() function
6
+
7
+ 2.0 (2012-09-21)
8
+ Bulk of code rewritten and refactored
9
+ Added install and upgrade functions
10
+ Added DB version setting
11
+ Feed sources now stored as Custom Post Types
12
+ Feed source list sortable ascending or descending by name
13
+ Removed days subsections in feed display
14
+ Ability to limit total number of feeds displayed
15
+ Feeds now fetched via Cron
16
+ Cron job to delete old feed items, keeps max of 50 items in DB
17
+ Now requires WordPress 3.2
18
+ updated colorbox to v1.3.20.1
19
+ Limit of 15 items max imported for each source
20
+ Fixed issue of page content displaying incorrectly after feeds
21
+
22
+
23
+ 1.1 (2012-08-13)
24
+ Now requires WordPress 3.0
25
+ More flexible fetching of images directory
26
+ Has its own top level menu item
27
+ Added settings section
28
+ Ability to open in lightbox, new window or default browser behaviour
29
+ Ability to set links as follow or no follow
30
+ Using constants for oftenly used locations
31
+ Code refactoring
32
+ Changes in file and folder structure
33
+
34
+ 1.0 (2012-01-06)
35
+ First release
css/colorbox.css ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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; max-width:none;}
14
+ .cboxIframe{width:100%; height:100%; display:block; border:0;}
15
+ #colorbox, #cboxContent, #cboxLoadedContent{box-sizing:content-box;}
16
+
17
+ /*
18
+ User Style:
19
+ Change the following styles to modify the appearance of ColorBox. They are
20
+ ordered & tabbed in a way that represents the nesting of the generated HTML.
21
+ */
22
+ #cboxOverlay{background:url(../img/colorbox/overlay.png) repeat 0 0;}
23
+ #colorbox{}
24
+ #cboxTopLeft{width:21px; height:21px; background:url(../img/colorbox/controls.png) no-repeat -101px 0;}
25
+ #cboxTopRight{width:21px; height:21px; background:url(../img/colorbox/controls.png) no-repeat -130px 0;}
26
+ #cboxBottomLeft{width:21px; height:21px; background:url(../img/colorbox/controls.png) no-repeat -101px -29px;}
27
+ #cboxBottomRight{width:21px; height:21px; background:url(../img/colorbox/controls.png) no-repeat -130px -29px;}
28
+ #cboxMiddleLeft{width:21px; background:url(../img/colorbox/controls.png) left top repeat-y;}
29
+ #cboxMiddleRight{width:21px; background:url(../img/colorbox/controls.png) right top repeat-y;}
30
+ #cboxTopCenter{height:21px; background:url(../img/colorbox/border.png) 0 0 repeat-x;}
31
+ #cboxBottomCenter{height:21px; background:url(../img/colorbox/border.png) 0 -29px repeat-x;}
32
+ #cboxContent{background:#fff; overflow:hidden;}
33
+ .cboxIframe{background:#fff;}
34
+ #cboxError{padding:50px; border:1px solid #ccc;}
35
+ #cboxLoadedContent{margin-bottom:28px;}
36
+ #cboxTitle{position:absolute; bottom:4px; left:0; text-align:center; width:100%; color:#949494;}
37
+ #cboxCurrent{position:absolute; bottom:4px; left:58px; color:#949494;}
38
+ #cboxSlideshow{position:absolute; bottom:4px; right:30px; color:#0092ef;}
39
+ #cboxPrevious{position:absolute; bottom:0; left:0; background:url(../img/colorbox/controls.png) no-repeat -75px 0; width:25px; height:25px; text-indent:-9999px;}
40
+ #cboxPrevious:hover{background-position:-75px -25px;}
41
+ #cboxNext{position:absolute; bottom:0; left:27px; background:url(../img/colorbox/controls.png) no-repeat -50px 0; width:25px; height:25px; text-indent:-9999px;}
42
+ #cboxNext:hover{background-position:-50px -25px;}
43
+ #cboxLoadingOverlay{background:url(../img/colorbox/loading_background.png) no-repeat center center;}
44
+ #cboxLoadingGraphic{background:url(../img/colorbox/loading.gif) no-repeat center center;}
45
+ #cboxClose{position:absolute; bottom:0; right:0; background:url(../img/colorbox/controls.png) no-repeat -25px 0; width:25px; height:25px; text-indent:-9999px;}
46
+ #cboxClose:hover{background-position:-25px -25px;}
47
+
48
+ /*
49
+ The following fixes a problem where IE7 and IE8 replace a PNG's alpha transparency with a black fill
50
+ when an alpha filter (opacity change) is set on the element or ancestor element. This style is not applied to or needed in IE9.
51
+ See: http://jacklmoore.com/notes/ie-transparency-problems/
52
+ */
53
+ .cboxIE #cboxTopLeft,
54
+ .cboxIE #cboxTopCenter,
55
+ .cboxIE #cboxTopRight,
56
+ .cboxIE #cboxBottomLeft,
57
+ .cboxIE #cboxBottomCenter,
58
+ .cboxIE #cboxBottomRight,
59
+ .cboxIE #cboxMiddleLeft,
60
+ .cboxIE #cboxMiddleRight {
61
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#00FFFFFF,endColorstr=#00FFFFFF);
62
+ }
css/styles.css ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ body.post-type-wprss_feed #titlediv div.inside { display: none !important; }
29
+
30
+ #misc-publishing-actions,
31
+ #minor-publishing-actions { display: none; }
32
+
33
+ #custom_meta_box .form-table th { width: 100px; }
34
+
35
+ body.post-type-wprss_feed_item .add-new-h2,
36
+ body.post-type-wprss_feed_item .tablenav select[name="m"],
37
+ body.post-type-wprss_feed_item #post-query-submit
38
+ { display: none; }
39
+
40
+ body.post-type-wprss_feed_item a.row-title {
41
+ cursor: default;
42
+ font-weight: normal;
43
+ color: #555;
44
+ }
45
+
46
+ #latest-news-cpac-settings li {
47
+ list-style: none;
48
+ line-height: 16px;
49
+ }
50
+
51
+ li.twitter a {
52
+ background: transparent url('../img/twitter.png') no-repeat 0;
53
+ padding-left: 20px;
54
+ }
55
+
56
+ li.facebook a {
57
+ background: transparent url('../img/facebook.png') no-repeat 0;
58
+ padding-left: 20px;
59
+ }
60
+
61
+ li.donate_link a:hover {
62
+ color: darkGreen;
63
+ }
64
+
65
+ /*.rss-aggregator_page_wprss-aggregator-settings .form-table th { width: 80px; }*/
img/colorbox/border.png ADDED
Binary file
img/colorbox/controls.png ADDED
Binary file
img/colorbox/loading.gif ADDED
Binary file
img/colorbox/loading_background.png ADDED
Binary file
img/colorbox/overlay.png ADDED
Binary file
img/facebook.png ADDED
Binary file
img/icon-adminmenu16-sprite.png ADDED
Binary file
img/icon-adminpage32.png ADDED
Binary file
img/twitter.png ADDED
Binary file
inc/activation.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Plugin activation procedure
4
+ *
5
+ * @since 1.0
6
+ */
7
+ function wprss_activate() {
8
+ // Activates the plugin and checks for compatible version of WordPress
9
+ if ( version_compare( get_bloginfo( 'version' ), '3.2', '<' ) ) {
10
+ deactivate_plugins ( basename( __FILE__ )); // Deactivate plugin
11
+ wp_die( __('This plugin requires WordPress version 3.2 or higher.') );
12
+ }
13
+ wprss_schedule_fetch_feeds_cron();
14
+ }
inc/admin-options.php ADDED
@@ -0,0 +1,193 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Plugin administration related functions
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
+ * @package WPRSSAggregator
10
+ */
11
+
12
+
13
+ /**
14
+ * Custom Post Type Icon for Admin Menu & Post Screen
15
+ * @since 2.0
16
+ */
17
+ add_action( 'admin_head', 'wprss_custom_post_type_icon' );
18
+
19
+ function wprss_custom_post_type_icon() {
20
+ ?>
21
+ <style>
22
+ /* Post Screen - 32px */
23
+ .icon32-posts-wprss_feed {
24
+ background: transparent url( <?php echo WPRSS_IMG . 'icon-adminpage32.png'; ?> ) no-repeat left top !important;
25
+ }
26
+ /* Post Screen - 32px */
27
+ .icon32-posts-wprss_feed_item {
28
+ background: transparent url( <?php echo WPRSS_IMG . 'icon-adminpage32.png'; ?> ) no-repeat left top !important;
29
+ }
30
+ </style>
31
+ <?php }
32
+
33
+
34
+ /**
35
+ * Register menu and submenus
36
+ * @since 2.0
37
+ */
38
+
39
+ // Add the admin options pages as submenus to the Feed CPT
40
+ add_action( 'admin_menu', 'wprss_register_menu_pages' );
41
+
42
+ function wprss_register_menu_pages() {
43
+
44
+ //create submenu items
45
+ add_submenu_page( 'edit.php?post_type=wprss_feed', __( 'WP RSS Aggregator Settings', 'wprss' ), __( 'Settings', 'wprss' ), 'manage_options', 'wprss-aggregator-settings', 'wprss_settings_page' );
46
+ }
47
+
48
+
49
+ /**
50
+ * Register and define options and settings
51
+ * @since 2.0
52
+ * @todo add option for cron frequency
53
+ */
54
+
55
+ add_action( 'admin_init', 'wprss_admin_init' );
56
+
57
+ function wprss_admin_init() {
58
+ register_setting( 'wprss_options', 'wprss_options' );
59
+ add_settings_section( 'wprss_main', '', 'wprss_section_text', 'wprss' );
60
+
61
+ register_setting( 'wprss_settings', 'wprss_settings' );
62
+
63
+
64
+ add_settings_section( 'wprss-settings-main', '', 'wprss_settings_section_text', 'wprss-aggregator-settings' );
65
+
66
+ add_settings_field( 'wprss-settings-open-dd', __( 'Open links behaviour', 'wprss' ),
67
+ 'wprss_setting_open_dd', 'wprss-aggregator-settings', 'wprss-settings-main');
68
+
69
+ add_settings_field( 'wprss-settings-follow-dd', __( 'Set links as', 'wprss' ),
70
+ 'wprss_setting_follow_dd', 'wprss-aggregator-settings', 'wprss-settings-main');
71
+
72
+ add_settings_field( 'wprss-settings-feed-limit', __( 'Feed limit', 'wprss' ),
73
+ 'wprss_setting_feed_limit', 'wprss-aggregator-settings', 'wprss-settings-main');
74
+
75
+ }
76
+
77
+
78
+ /**
79
+ * Build the plugin settings page, used to save general settings like whether a link should be follow or no follow
80
+ * @since 1.1
81
+ */
82
+ function wprss_settings_page() {
83
+ ?>
84
+ <div class="wrap">
85
+ <?php screen_icon( 'wprss-aggregator' ); ?>
86
+
87
+ <h2><?php _e( 'WP RSS Aggregator Settings' ); ?></h2>
88
+
89
+ <form action="options.php" method="post">
90
+ <?php settings_fields( 'wprss_settings' ) ?>
91
+ <?php do_settings_sections( 'wprss-aggregator-settings' ); ?>
92
+ <p class="submit"><input type="submit" value="<?php _e( 'Save Settings', 'wprss' ); ?>" name="submit" class="button-primary"></p>
93
+ </form>
94
+ </div>
95
+ <?php
96
+ }
97
+
98
+
99
+ // Draw the section header
100
+ function wprss_settings_section_text() {
101
+ // echo '<p>Enter your settings here.</p>';
102
+ }
103
+
104
+
105
+ /**
106
+ * Follow or No Follow dropdown
107
+ * @since 1.1
108
+ */
109
+ function wprss_setting_follow_dd() {
110
+ $options = get_option( 'wprss_settings' );
111
+ $items = array(
112
+ __( 'No follow', 'wprss' ),
113
+ __( 'Follow', 'wprss' )
114
+ );
115
+ echo "<select id='follow-dd' name='wprss_settings[follow_dd]'>";
116
+ foreach( $items as $item ) {
117
+ $selected = ( $options['follow_dd'] == $item) ? 'selected="selected"' : '';
118
+ echo "<option value='$item' $selected>$item</option>";
119
+ }
120
+ echo "</select>";
121
+ }
122
+
123
+
124
+ /**
125
+ * Link open setting dropdown
126
+ * @since 1.1
127
+ */
128
+ function wprss_setting_open_dd() {
129
+ $options = get_option( 'wprss_settings' );
130
+ $items = array(
131
+ __( 'Lightbox', 'wprss' ),
132
+ __( 'New window', 'wprss' ),
133
+ __( 'None', 'wprss' )
134
+ );
135
+ echo "<select id='open-dd' name='wprss_settings[open_dd]'>";
136
+ foreach( $items as $item ) {
137
+ $selected = ( $options['open_dd'] == $item) ? 'selected="selected"' : '';
138
+ echo "<option value='$item' $selected>$item</option>";
139
+ }
140
+ echo "</select>";
141
+ }
142
+
143
+
144
+ /**
145
+ * Set limit for feeds on frontend
146
+ * @since 2.0
147
+ */
148
+ function wprss_setting_feed_limit() {
149
+ $options = get_option( 'wprss_settings' );
150
+ // echo the field
151
+
152
+ echo "<input id='feed-limit' name='wprss_settings[feed_limit]' type='text' value='$options[feed_limit]' />";
153
+ }
154
+
155
+
156
+ /**
157
+ * Set body class for admin screens
158
+ * http://www.kevinleary.net/customizing-wordpress-admin-css-javascript/
159
+ * @since 2.0
160
+ */
161
+ function wprss_base_admin_body_class( $classes )
162
+ {
163
+ // Current action
164
+ if ( is_admin() && isset($_GET['action']) ) {
165
+ $classes .= 'action-'.$_GET['action'];
166
+ }
167
+ // Current post ID
168
+ if ( is_admin() && isset($_GET['post']) ) {
169
+ $classes .= ' ';
170
+ $classes .= 'post-'.$_GET['post'];
171
+ }
172
+ // New post type & listing page
173
+ if ( isset($_GET['post_type']) ) $post_type = $_GET['post_type'];
174
+ if ( isset($post_type) ) {
175
+ $classes .= ' ';
176
+ $classes .= 'post-type-'.$post_type;
177
+ }
178
+ // Editting a post type
179
+ if ( isset( $_GET['post'] ) ) {
180
+ $post_query = $_GET['post'];
181
+ }
182
+ if ( isset($post_query) ) {
183
+ $current_post_edit = get_post($post_query);
184
+ $current_post_type = $current_post_edit->post_type;
185
+ if ( !empty($current_post_type) ) {
186
+ $classes .= ' ';
187
+ $classes .= 'post-type-'.$current_post_type;
188
+ }
189
+ }
190
+ // Return the $classes array
191
+ return $classes;
192
+ }
193
+ add_filter('admin_body_class', 'wprss_base_admin_body_class');
inc/cron-jobs.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Contains all the cron jobs in use by WP RSS Aggregator
4
+ *
5
+ * @package WPRSSAggregator
6
+ */
7
+
8
+
9
+ /**
10
+ * Creates the cron to fetch feeds every hour
11
+ *
12
+ * @since 2.0
13
+ */
14
+ function wprss_schedule_fetch_feeds_cron() {
15
+
16
+ // verify event has not been scheduled
17
+ if ( ! wp_next_scheduled( 'wprss_fetch_feeds_hook' ) ) {
18
+ // Schedule to run hourly
19
+ wp_schedule_event( time(), 'hourly', 'wprss_fetch_feeds_hook' );
20
+ }
21
+
22
+ add_action( 'wprss_fetch_feeds_hook', 'wprss_fetch_all_feed_items' );
23
+ }
24
+
25
+
26
+ /**
27
+ * Creates the cron to truncate wprss_feed_item posts daily
28
+ *
29
+ * @since 2.0
30
+ */
31
+ function wprss_schedule_truncate_posts_cron() {
32
+
33
+ // verify event has not been scheduled
34
+ if ( ! wp_next_scheduled( 'wprss_truncate_posts_hook') ) {
35
+ // Schedule to run daily
36
+ wp_schedule_event( time(), 'daily', 'wprss_truncate_posts_hook' );
37
+ }
38
+
39
+ add_action( 'wprss_truncate_posts_hook', 'wprss_truncate_posts' );
40
+ }
41
+
42
+
43
+ //add_filter( 'cron_schedules', 'wprss_cron_add_weekly' );
44
+ /**
45
+ * Not actually used at the moment, might use later on for custom scheduling
46
+ *
47
+ * @since 2.0
48
+ */
49
+ function wprss_cron_add_weekly( $schedules ) {
50
+ // Adds once weekly to the existing schedules.
51
+ $schedules['weekly'] = array(
52
+ 'interval' => 60, // 60*60*24*7
53
+ 'display' => __( 'Once Weekly' )
54
+ );
55
+ return $schedules;
56
+ }
inc/custom-post-types.php ADDED
@@ -0,0 +1,641 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Contains all custom post type related functions
4
+ *
5
+ * @package WPRSSAggregator
6
+ */
7
+
8
+
9
+ add_action( 'init', 'wprss_register_post_types' );
10
+ /**
11
+ * Create Custom Post Types wprss_feed and wprss_feed_item
12
+ *
13
+ * @since 2.0
14
+ */
15
+ function wprss_register_post_types() {
16
+
17
+ // Set up labels for the 'wprss_feed' post type
18
+ $labels = apply_filters( 'wprss_feed_post_type_labels', array(
19
+ 'name' => __( 'Feed Sources', 'wprss' ),
20
+ 'singular_name' => __( 'Feed', 'wprss' ),
21
+ 'add_new' => __( 'Add New Feed Source', 'wprss' ),
22
+ 'all_items' => __( 'All Feed Sources', 'wprss' ),
23
+ 'add_new_item' => __( 'Add New Feed Source', 'wprss' ),
24
+ 'edit_item' => __( 'Edit Feed Source', 'wprss' ),
25
+ 'new_item' => __( 'New Feed Source', 'wprss' ),
26
+ 'view_item' => __( 'View Feed Source', 'wprss' ),
27
+ 'search_items' => __( 'Search Feeds', 'wprss' ),
28
+ 'not_found' => __( 'No Feed Sources Found', 'wprss' ),
29
+ 'not_found_in_trash' => __( 'No Feed Sources Found In Trash', 'wprss' ),
30
+ 'menu_name' => __( 'RSS Aggregator', 'wprss' )
31
+ )
32
+ );
33
+
34
+ // Set up the arguments for the 'wprss_feed' post type
35
+ $feed_args = apply_filters( 'wprss_feed_post_type_args', array(
36
+ 'public' => true,
37
+ 'query_var' => 'feed_source',
38
+ 'menu_position' => 100,
39
+ 'menu_icon' => WPRSS_IMG . 'icon-adminmenu16-sprite.png',
40
+ 'show_in_menu' => true,
41
+ 'supports' => array( 'title' ),
42
+ 'rewrite' => array(
43
+ 'slug' => 'feeds',
44
+ 'with_front' => false
45
+ ),
46
+ 'labels' => $labels
47
+ )
48
+ );
49
+
50
+ // Register the 'wprss_feed' post type
51
+ register_post_type( 'wprss_feed', $feed_args );
52
+
53
+ // Set up labels for the 'wprss_feed_item' post type
54
+ $labels = apply_filters( 'wprss_feed_item_post_type_labels', array(
55
+ 'name' => __( 'Imported Feeds', 'wprss' ),
56
+ 'singular_name' => __( 'Imported Feed', 'wprss' ),
57
+ 'all_items' => __( 'Imported Feeds', 'wprss' ),
58
+ 'view_item' => __( 'View Imported Feed', 'wprss' ),
59
+ 'search_items' => __( 'Search Imported Feeds', 'wprss' ),
60
+ 'not_found' => __( 'No Imported Feeds Found', 'wprss' ),
61
+ 'not_found_in_trash' => __( 'No Imported Feeds Found In Trash', 'wprss' )
62
+ )
63
+ );
64
+
65
+ // Set up the arguments for the 'wprss_feed_item' post type
66
+ $feed_item_args = apply_filters( 'wprss_feed_item_post_type_args', array(
67
+ 'public' => true,
68
+ 'query_var' => 'feed_item',
69
+ 'show_in_menu' => 'edit.php?post_type=wprss_feed',
70
+ 'rewrite' => array(
71
+ 'slug' => 'feeds/items',
72
+ 'with_front' => false,
73
+ ),
74
+ 'labels' => $labels
75
+ )
76
+ );
77
+
78
+ // Register the 'feed_item' post type
79
+ register_post_type( 'wprss_feed_item', $feed_item_args );
80
+ }
81
+
82
+
83
+ add_filter( 'manage_edit-wprss_feed_columns', 'wprss_set_custom_columns');
84
+ /**
85
+ * Set up the custom columns for the wprss_feed list
86
+ *
87
+ * @since 2.0
88
+ */
89
+ function wprss_set_custom_columns( $columns ) {
90
+
91
+ $columns = array (
92
+ 'cb' => '<input type="checkbox" />',
93
+ 'title' => __( 'Name', 'wprss' ),
94
+ 'url' => __( 'URL', 'wprss' ),
95
+ 'description' => __( 'Description', 'wprss' ),
96
+ );
97
+ return $columns;
98
+ }
99
+
100
+
101
+ add_action( "manage_wprss_feed_posts_custom_column", "wprss_show_custom_columns", 10, 2 );
102
+ /**
103
+ * Show up the custom columns for the wprss_feed list
104
+ *
105
+ * @since 2.0
106
+ */
107
+ function wprss_show_custom_columns( $column, $post_id ) {
108
+
109
+ switch ( $column ) {
110
+ case 'url':
111
+ $url = get_post_meta( $post_id, 'wprss_url', true);
112
+ echo '<a href="' . esc_url($url) . '">' . esc_url($url) . '</a>';
113
+ break;
114
+ case 'description':
115
+ $description = get_post_meta( $post_id, 'wprss_description', true);
116
+ echo esc_html( $description );
117
+ break;
118
+ }
119
+ }
120
+
121
+
122
+ /**
123
+ * Make the custom columns sortable
124
+ *
125
+ * @since 2.0
126
+ */
127
+ function wprss_sortable_columns() {
128
+ return array(
129
+ // meta column id => sortby value used in query
130
+ 'title' => 'title',
131
+ );
132
+ }
133
+
134
+
135
+ add_filter( 'manage_edit-wprss_feed_item_columns', 'wprss_set_feed_item_custom_columns');
136
+ /**
137
+ * Set up the custom columns for the wprss_feed source list
138
+ *
139
+ * @since 2.0
140
+ */
141
+ function wprss_set_feed_item_custom_columns( $columns ) {
142
+
143
+ $columns = array (
144
+ 'cb' => '<input type="checkbox" />',
145
+ 'title' => __( 'Name', 'wprss' ),
146
+ 'permalink' => __( 'Permalink', 'wprss' ),
147
+ 'publishdate' => __( 'Date published', 'wprss' ),
148
+ 'source' => __( 'Source', 'wprss' )
149
+ );
150
+ return $columns;
151
+ }
152
+
153
+
154
+ add_action( "manage_wprss_feed_item_posts_custom_column", "wprss_show_feed_item_custom_columns", 10, 2 );
155
+ /**
156
+ * Show up the custom columns for the wprss_feed list
157
+ *
158
+ * @since 2.0
159
+ */
160
+ function wprss_show_feed_item_custom_columns( $column, $post_id ) {
161
+
162
+ switch ( $column ) {
163
+ case "permalink":
164
+ $url = get_post_meta( $post_id, 'wprss_item_permalink', true);
165
+ echo '<a href="' . $url . '">' . $url. '</a>';
166
+ break;
167
+
168
+ case "publishdate":
169
+ $publishdate = date( 'Y-m-d H:i:s', get_post_meta( get_the_ID(), 'wprss_item_date', true ) ) ;
170
+ echo $publishdate;
171
+ break;
172
+
173
+ case "source":
174
+ $query = new WP_Query();
175
+ $source = '<a href="' . get_edit_post_link( get_post_meta( $post_id, 'wprss_feed_id', true ) ) . '">' . get_the_title( get_post_meta( $post_id, 'wprss_feed_id', true ) ) . '</a>';
176
+ echo $source;
177
+ break;
178
+ }
179
+ }
180
+
181
+
182
+ add_filter( "manage_edit-wprss_feed_item_sortable_columns", "wprss_feed_item_sortable_columns" );
183
+ /**
184
+ * Make the custom columns sortable
185
+ *
186
+ * @since 2.0
187
+ */
188
+ function wprss_feed_item_sortable_columns() {
189
+ return array(
190
+ // meta column id => sortby value used in query
191
+ 'publishdate' => 'publishdate',
192
+ 'source' => 'source'
193
+ );
194
+ }
195
+
196
+
197
+ add_action( 'pre_get_posts', 'wprss_feed_item_orderby' );
198
+ /**
199
+ * Change ordering of posts on wprss_feed_item screen
200
+ *
201
+ * @since 2.0
202
+ */
203
+ function wprss_feed_item_orderby( $query ) {
204
+ if( ! is_admin() )
205
+ return;
206
+
207
+ $post_type = $query->get('post_type');
208
+
209
+ // If we're on the feed listing admin page
210
+ if ( $post_type == 'wprss_feed_item') {
211
+ // Set general orderby to date the feed item was published
212
+ $query->set('orderby','publishdate');
213
+ // If user clicks on the reorder link, implement reordering
214
+ $orderby = $query->get( 'orderby');
215
+ if( 'publishdate' == $orderby ) {
216
+ $query->set( 'meta_key', 'wprss_item_date' );
217
+ $query->set( 'orderby', 'meta_value_num' );
218
+ }
219
+ }
220
+ }
221
+
222
+
223
+ add_action( 'add_meta_boxes', 'wprss_add_meta_boxes');
224
+ /**
225
+ * Set up the input boxes for the wprss_feed post type
226
+ *
227
+ * @since 2.0
228
+ */
229
+ function wprss_add_meta_boxes() {
230
+ global $wprss_meta_fields;
231
+
232
+ // Remove the default WordPress Publish box, because we will be using custom ones
233
+ remove_meta_box( 'submitdiv', 'wprss_feed', 'side' );
234
+ add_meta_box(
235
+ 'submitdiv',
236
+ __( 'Save Feed Source', 'wprss' ),
237
+ 'post_submit_meta_box',
238
+ 'wprss_feed',
239
+ 'side',
240
+ 'low');
241
+
242
+ /* add_meta_box(
243
+ 'wprss-save-link-side-meta',
244
+ 'Save Feed Source',
245
+ 'wprss_save_feed_source_meta_box',
246
+ 'wprss_feed',
247
+ 'side',
248
+ 'high'
249
+ );
250
+
251
+ add_meta_box(
252
+ 'wprss-save-link-bottom-meta',
253
+ __( 'Save Feed Source', 'wprss' ),
254
+ 'wprss_save_feed_source_meta_box',
255
+ 'wprss_feed',
256
+ 'normal',
257
+ 'low'
258
+ );*/
259
+
260
+ add_meta_box(
261
+ 'wprss-help-meta',
262
+ __( 'WP RSS Aggregator Help', 'wprss' ),
263
+ 'wprss_help_meta_box',
264
+ 'wprss_feed',
265
+ 'side',
266
+ 'low'
267
+ );
268
+
269
+ add_meta_box(
270
+ 'wprss-like-meta',
271
+ __( 'Like this plugin?', 'wprss' ),
272
+ 'wprss_like_meta_box',
273
+ 'wprss_feed',
274
+ 'side',
275
+ 'low'
276
+ );
277
+
278
+ add_meta_box(
279
+ 'wprss-follow-meta',
280
+ __( 'Follow us', 'wprss' ),
281
+ 'wprss_follow_meta_box',
282
+ 'wprss_feed',
283
+ 'side',
284
+ 'low'
285
+ );
286
+
287
+ add_meta_box(
288
+ 'custom_meta_box', // $id
289
+ __( 'Feed Source Details', 'wprss' ), // $title
290
+ 'wprss_show_meta_box', // $callback
291
+ 'wprss_feed', // $page
292
+ 'normal', // $context
293
+ 'high'); // $priority
294
+
295
+
296
+ add_meta_box(
297
+ 'preview_meta_box', // $id
298
+ __( 'Feed Preview', 'wprss' ), // $title
299
+ 'wprss_preview_meta_box', // $callback
300
+ 'wprss_feed', // $page
301
+ 'normal', // $context
302
+ 'low'); // $priority
303
+ }
304
+
305
+
306
+ /**
307
+ * Set up fields for the meta box
308
+ *
309
+ * @since 2.0
310
+ */
311
+ function wprss_custom_fields() {
312
+ $prefix = 'wprss_';
313
+
314
+ // Field Array
315
+ $wprss_meta_fields['url'] = array(
316
+ 'label' => __( 'URL', 'wprss' ),
317
+ 'desc' => __( 'Enter feed URL (including http://)', 'wprss' ),
318
+ 'id' => $prefix.'url',
319
+ 'type' => 'text'
320
+ );
321
+
322
+ $wprss_meta_fields['description'] = array(
323
+ 'label' => __( 'Description', 'wprss' ),
324
+ 'desc' => __( 'A short description about this feed source (optional)', 'wprss' ),
325
+ 'id' => $prefix.'description',
326
+ 'type' => 'textarea'
327
+ );
328
+
329
+ // for extensibility, allows more meta fields to be added
330
+ return apply_filters( 'wprss_fields', $wprss_meta_fields );
331
+ }
332
+
333
+
334
+ /**
335
+ * Set up the meta box for the wprss_feed post type
336
+ *
337
+ * @since 2.0
338
+ */
339
+ function wprss_show_meta_box() {
340
+ global $post;
341
+ $meta_fields = wprss_custom_fields();
342
+
343
+ // Use nonce for verification
344
+ echo '<input type="hidden" name="wprss_meta_box_nonce" value="' . wp_create_nonce( basename( __FILE__ ) ) . '" />';
345
+
346
+ // Begin the field table and loop
347
+ echo '<table class="form-table">';
348
+ foreach ( $meta_fields as $field ) {
349
+ // get value of this field if it exists for this post
350
+ $meta = get_post_meta( $post->ID, $field['id'], true );
351
+ // begin a table row with
352
+ echo '<tr>
353
+ <th><label for="' . $field['id'] . '">' . $field['label'] . '</label></th>
354
+ <td>';
355
+
356
+ switch( $field['type'] ) {
357
+
358
+ // text
359
+ case 'text':
360
+ echo '<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$meta.'" size="55" />
361
+ <br /><span class="description">'.$field['desc'].'</span>';
362
+ break;
363
+
364
+ // textarea
365
+ case 'textarea':
366
+ echo '<textarea name="'.$field['id'].'" id="'.$field['id'].'" cols="60" rows="4">'.$meta.'</textarea>
367
+ <br /><span class="description">'.$field['desc'].'</span>';
368
+ break;
369
+
370
+ // checkbox
371
+ case 'checkbox':
372
+ echo '<input type="checkbox" name="'.$field['id'].'" id="'.$field['id'].'" ',$meta ? ' checked="checked"' : '','/>
373
+ <label for="'.$field['id'].'">'.$field['desc'].'</label>';
374
+ break;
375
+
376
+ // select
377
+ case 'select':
378
+ echo '<select name="'.$field['id'].'" id="'.$field['id'].'">';
379
+ foreach ($field['options'] as $option) {
380
+ echo '<option', $meta == $option['value'] ? ' selected="selected"' : '', ' value="'.$option['value'].'">'.$option['label'].'</option>';
381
+ }
382
+ echo '</select><br /><span class="description">'.$field['desc'].'</span>';
383
+ break;
384
+
385
+ } //end switch
386
+ echo '</td></tr>';
387
+ } // end foreach
388
+ echo '</table>'; // end table
389
+ }
390
+
391
+
392
+ add_action( 'save_post', 'wprss_save_custom_fields' );
393
+ /**
394
+ * Save the custom fields
395
+ *
396
+ * @since 2.0
397
+ */
398
+ function wprss_save_custom_fields( $post_id ) {
399
+ $meta_fields = wprss_custom_fields();
400
+
401
+ // verify nonce
402
+ if ( ! wp_verify_nonce( $_POST[ 'wprss_meta_box_nonce' ], basename( __FILE__ ) ) )
403
+ return $post_id;
404
+
405
+ // check autosave
406
+ if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE)
407
+ return $post_id;
408
+
409
+ // check permissions
410
+ if ( 'page' == $_POST[ 'post_type' ] ) {
411
+ if ( ! current_user_can( 'edit_page', $post_id ) )
412
+ return $post_id;
413
+ } elseif ( ! current_user_can( 'edit_post', $post_id ) ) {
414
+ return $post_id;
415
+ }
416
+
417
+ // loop through fields and save the data
418
+ foreach ( $meta_fields as $field ) {
419
+ $old = get_post_meta( $post_id, $field[ 'id' ], true );
420
+ $new = $_POST[ $field[ 'id' ] ];
421
+ if ( $new && $new != $old ) {
422
+ update_post_meta( $post_id, $field[ 'id' ], $new );
423
+ } elseif ( '' == $new && $old ) {
424
+ delete_post_meta( $post_id, $field[ 'id' ], $old );
425
+ }
426
+ } // end foreach
427
+ }
428
+
429
+
430
+ /**
431
+ * Generate the Save Feed Source meta box
432
+ *
433
+ * @since 2.0
434
+ */
435
+ function wprss_save_feed_source_meta_box() {
436
+ global $post;
437
+
438
+ // insert nonce??
439
+
440
+ echo '<input type="submit" name="publish" id="publish" class="button-primary" value="Save" tabindex="5" accesskey="s">';
441
+
442
+ /**
443
+ * Check if user has disabled trash, in that case he can only delete feed sources permanently,
444
+ * else he can deactivate them. By default, if not modified in wp_config.php, EMPTY_TRASH_DAYS is set to 30.
445
+ */
446
+ if ( current_user_can( "delete_post", $post->ID ) ) {
447
+ if ( ! EMPTY_TRASH_DAYS )
448
+ $delete_text = __('Delete Permanently', 'wprss' );
449
+ else
450
+ $delete_text = __('Move to Trash', 'wprss' );
451
+
452
+ echo '&nbsp;&nbsp;<a class="submitdelete deletion" href="' . get_delete_post_link( $post->ID ) . '">' . $delete_text . '</a>';
453
+ }
454
+ }
455
+
456
+
457
+ /**
458
+ * Generate a preview of the latest 5 posts from the feed source being added/edited
459
+ *
460
+ * @since 2.0
461
+ */
462
+ function wprss_preview_meta_box() {
463
+ global $post;
464
+ $feed_url = get_post_meta( $post->ID, 'wprss_url', true );
465
+
466
+ if( ! empty( $feed_url ) ) {
467
+ $feed = fetch_feed( $feed_url );
468
+ if ( ! is_wp_error( $feed ) ) {
469
+ $items = $feed->get_items();
470
+
471
+ echo '<h4>Latest 5 feeds available from ' . get_the_title() . '</h4>';
472
+ $count = 0;
473
+ $feedlimit = 5;
474
+ foreach ( $items as $item ) {
475
+ echo '<ul>';
476
+ echo '<li>' . $item->get_title() . '</li>';
477
+ echo '</ul>';
478
+ if( ++$count == $feedlimit ) break; //break if count is met
479
+ }
480
+ }
481
+ else _e( '<strong>Invalid feed URL</strong> - Double check the feed source URL setting above.', 'wprss' );
482
+ }
483
+
484
+ else _e( 'No feed URL defined yet', 'wprss' );
485
+ }
486
+
487
+
488
+ /**
489
+ * Generate Help meta box
490
+ *
491
+ * @since 2.0
492
+ *
493
+ */
494
+ function wprss_help_meta_box() {
495
+ echo '<p><strong>';
496
+ _e( 'Need help?', 'wprss' );
497
+ echo '</strong> <a target="_blank" href="http://wordpress.org/support/plugin/wp-rss-aggregator">';
498
+ _e( 'Check out the support forum', 'wprss' );
499
+ echo '</a></p>';
500
+ }
501
+
502
+ /**
503
+ * Generate Like this plugin meta box
504
+ *
505
+ * @since 2.0
506
+ *
507
+ */
508
+ function wprss_like_meta_box() { ?>
509
+ <p><?php _e( 'Why not do any or all of the following', 'wprss' ) ?>:</p>
510
+ <ul>
511
+ <li><a href="http://wordpress.org/extend/plugins/wp-rss-aggregator/"><?php _e( 'Give it a 5 star rating on WordPress.org.', 'wprss' ) ?></a></li>
512
+ <li class="donate_link"><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=X9GP6BL4BLXBJ"><?php _e('Donate a token of your appreciation.', 'wprss' ); ?></a></li>
513
+ </ul>
514
+ </p>
515
+ <?php }
516
+
517
+
518
+ /**
519
+ * Generate Like this plugin meta box
520
+ *
521
+ * @since 2.0
522
+ *
523
+ */
524
+ function wprss_follow_meta_box() {
525
+ ?>
526
+ <ul>
527
+ <li class="twitter"><a href="http://twitter.com/wpmayor"><?php _e( 'Follow WP Mayor on Twitter.', 'wprss' ) ?></a></li>
528
+ <li class="facebook"><a href="https://www.facebook.com/wpmayor"><?php _e( 'Like WP Mayor on Facebook.', 'wprss' ) ?></a></li>
529
+
530
+ </ul>
531
+ <?php }
532
+
533
+
534
+ add_filter( 'post_updated_messages', 'wprss_feed_updated_messages' );
535
+ /**
536
+ * Change default notification message when new feed is added or updated
537
+ *
538
+ * @since 2.0
539
+ */
540
+ function wprss_feed_updated_messages( $messages ) {
541
+ global $post, $post_ID;
542
+
543
+ $messages[ 'wprss_feed' ] = array(
544
+ 0 => '', // Unused. Messages start at index 1.
545
+ 1 => __( 'Feed source updated. ', 'wprss' ),
546
+ 2 => __( 'Custom field updated.', 'wprss' ),
547
+ 3 => __( 'Custom field deleted.', 'wprss' ),
548
+ 4 => __( 'Feed source updated.', 'wprss' ),
549
+ 5 => '',
550
+ 6 => __( 'Feed source saved.', 'wprss' ),
551
+ 7 => __( 'Feed source saved.', 'wprss' ),
552
+ 8 => __( 'Feed source submitted.', 'wprss' ),
553
+ 9 => '',
554
+ 10 => __( 'Feed source updated.', 'wprss' )
555
+ );
556
+
557
+ return $messages;
558
+ }
559
+
560
+
561
+ add_filter( 'post_row_actions', 'wprss_remove_row_actions', 10, 1 );
562
+ /**
563
+ * Remove actions row for imported feed items, we don't want them to be editable or viewable
564
+ *
565
+ * @since 2.0
566
+ */
567
+ function wprss_remove_row_actions( $actions )
568
+ {
569
+ if ( get_post_type() === 'wprss_feed_item' ) {
570
+ unset( $actions[ 'edit' ] );
571
+ unset( $actions[ 'view' ] );
572
+ //unset( $actions[ 'trash' ] );
573
+ unset( $actions[ 'inline hide-if-no-js' ] );
574
+ }
575
+ return $actions;
576
+ }
577
+
578
+
579
+ add_filter( 'bulk_actions-edit-wprss_feed_item', 'wprss_custom_bulk_actions' );
580
+ /**
581
+ * Remove bulk action link to edit imported feed items
582
+ *
583
+ * @since 2.0
584
+ */
585
+ function wprss_custom_bulk_actions( $actions ){
586
+ unset( $actions[ 'edit' ] );
587
+ return $actions;
588
+ }
589
+
590
+
591
+ add_action( 'admin_footer-edit.php', 'wprss_remove_a_from_feed_title' );
592
+ /**
593
+ * Remove hyperlink from imported feed titles in list posts screen
594
+ *
595
+ * @since 2.0
596
+ */
597
+ function wprss_remove_a_from_feed_title() {
598
+ if ( 'edit-wprss_feed_item' !== get_current_screen()->id )
599
+ return;
600
+ ?>
601
+
602
+ <script type="text/javascript">
603
+ jQuery('table.wp-list-table a.row-title').contents().unwrap();
604
+ </script>
605
+ <?php
606
+ }
607
+
608
+
609
+ add_action( 'add_meta_boxes', 'wprss_remove_meta_boxes', 100 );
610
+ /**
611
+ * Remove unneeded meta boxes from add feed source screen
612
+ *
613
+ * @since 2.0
614
+ */
615
+ function wprss_remove_meta_boxes() {
616
+ if ( 'wprss_feed' !== get_current_screen()->id ) return;
617
+ remove_meta_box( 'sharing_meta', 'wprss_feed' ,'advanced' );
618
+ remove_meta_box( 'content-permissions-meta-box', 'wprss_feed' ,'advanced' );
619
+ remove_meta_box( 'wpseo_meta', 'wprss_feed' ,'normal' );
620
+ remove_meta_box( 'theme-layouts-post-meta-box', 'wprss_feed' ,'side' );
621
+ remove_meta_box( 'post-stylesheets', 'wprss_feed' ,'side' );
622
+ remove_meta_box( 'hybrid-core-post-template', 'wprss_feed' ,'side' );
623
+ remove_meta_box( 'trackbacksdiv22', 'wprss_feed' ,'advanced' );
624
+ remove_action( 'post_submitbox_start', 'fpp_post_submitbox_start_action' );
625
+
626
+ }
627
+
628
+
629
+ add_filter( 'gettext', 'wprss_change_publish_button', 10, 2 );
630
+ /**
631
+ * Modify 'Publish' button text
632
+ *
633
+ * @since 2.0
634
+ */
635
+ function wprss_change_publish_button( $translation, $text ) {
636
+ if ( 'wprss_feed' == get_post_type())
637
+ if ( $text == 'Publish' )
638
+ return __( 'Publish Feed', 'wprss' );
639
+
640
+ return $translation;
641
+ }
inc/deactivation.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Plugin deactivation procedure
4
+ * @since 1.0
5
+ */
6
+ function wprss_deactivate() {
7
+ // on deactivation remove the cron job
8
+ if ( wp_next_scheduled( 'wprss_cron_hook' ) )
9
+ wp_clear_scheduled_hook( 'wprss_cron_hook' );
10
+ }
inc/shortcodes.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Set up shortcodes and call the main function for output
4
+ *
5
+ * @since 1.0
6
+ */
7
+ function wprss_shortcode( $atts ) {
8
+ if ( !empty ($atts) ) {
9
+ foreach ( $atts as $key => &$val ) {
10
+ $val = html_entity_decode($val);
11
+ }
12
+ }
13
+ ob_start(); //start an output buffer to output of the following function
14
+ wprss_display_feed_items( $atts );
15
+ return ob_get_clean(); //return the current buffer and clear it
16
+ }
17
+
18
+ // Register shortcodes
19
+ add_shortcode( 'wp_rss_aggregator', 'wprss_shortcode');
20
+ add_shortcode( 'wp-rss-aggregator', 'wprss_shortcode');
inc/update.php ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Contains all the functions related to updating the plugin from
4
+ * one version to another
5
+ *
6
+ * @package WPRSSAggregator
7
+ */
8
+
9
+ add_action( 'init', 'wprss_version_check' );
10
+ /**
11
+ * Checks the version number and runs install or update functions if needed.
12
+ *
13
+ * @since 2.0
14
+ */
15
+ function wprss_version_check() {
16
+
17
+ // Get the old database version.
18
+ $old_db_version = get_option( 'wprss_db_version' );
19
+
20
+ // Get the plugin settings.
21
+ $settings = get_option( 'wprss_settings' );
22
+
23
+ // Get the plugin options
24
+ $options = get_option( 'wprss_options' );
25
+
26
+ // For fresh installs
27
+ // If there is no old database version and no settings, run the install.
28
+ if ( empty( $old_db_version ) && false === $settings && false === $options ) {
29
+ wprss_install();
30
+ }
31
+
32
+ // For version 1.0 to 2.0
33
+ // If there is no old database version and no settings, but only options
34
+ elseif ( empty( $old_db_version ) && false === $settings && !empty( $options ) ) {
35
+ wp_clear_scheduled_hook( 'wprss_generate_hook' );
36
+ wprss_install();
37
+ wprss_migrate();
38
+ wprss_fetch_all_feed_items();
39
+ }
40
+
41
+ // For version 1.1 to 2.0
42
+ // If there is no old database version, but only settings and options
43
+ elseif ( empty( $old_db_version ) && !empty( $settings ) && !empty( $options ) ) {
44
+ wp_clear_scheduled_hook( 'wprss_generate_hook' );
45
+ wprss_update();
46
+ wprss_migrate();
47
+ wprss_fetch_all_feed_items();
48
+ }
49
+
50
+ // For any future versions where DB changes
51
+ // If the old version is less than the new version, run the update.
52
+ elseif ( intval( $old_db_version ) < intval( WPRSS_DB_VERSION ) ) {
53
+ wprss_update();
54
+ wprss_fetch_all_feed_items();
55
+ }
56
+ }
57
+
58
+
59
+ /**
60
+ * Adds the plugin settings on install.
61
+ *
62
+ * @since 2.0
63
+ */
64
+ function wprss_install() {
65
+
66
+ // Add the database version setting.
67
+ add_option( 'wprss_db_version', WPRSS_DB_VERSION );
68
+
69
+ // Add the default plugin settings.
70
+ add_option( 'wprss_settings', wprss_get_default_settings() );
71
+ }
72
+
73
+
74
+ /**
75
+ * Updates plugin settings if there are new settings to add.
76
+ *
77
+ * @since 2.0
78
+ */
79
+ function wprss_update() {
80
+
81
+ // Update the database version setting.
82
+ update_option( 'wprss_db_version', WPRSS_DB_VERSION );
83
+
84
+ // Get the settings from the database.
85
+ $settings = get_option( 'wprss_settings' );
86
+
87
+ // Get the default plugin settings.
88
+ $default_settings = wprss_get_default_settings();
89
+
90
+ // Loop through each of the default plugin settings.
91
+ foreach ( $default_settings as $setting_key => $setting_value ) {
92
+
93
+ // If the setting didn't previously exist, add the default value to the $settings array.
94
+ if ( ! isset( $settings[ $setting_key ] ) )
95
+ $settings[ $setting_key ] = $setting_value;
96
+ }
97
+
98
+ // Update the plugin settings.
99
+ update_option( 'wprss_settings', $settings );
100
+ }
101
+
102
+
103
+ /**
104
+ * Migrates the feed sources from the wprss_options field to the wp_posts table
105
+ *
106
+ * @since 2.0
107
+ */
108
+ function wprss_migrate() {
109
+
110
+ // Get the plugin options
111
+ $options = get_option( 'wprss_options' );
112
+
113
+ $feed_sources = array_chunk( $options, 2 );
114
+
115
+ foreach ( $feed_sources as $feed_source ) {
116
+ $feed_title = $feed_source[0];
117
+ $feed_url = $feed_source[1];
118
+
119
+ // Create post object
120
+ $feed_item = array(
121
+ 'post_title' => $feed_title,
122
+ 'post_content' => '',
123
+ 'post_status' => 'publish',
124
+ 'post_type' => 'wprss_feed'
125
+ );
126
+
127
+ $inserted_ID = wp_insert_post( $feed_item, $wp_error );
128
+ // insert post meta
129
+ update_post_meta( $inserted_ID, 'wprss_url', $feed_url );
130
+ }
131
+ // delete unneeded option
132
+ delete_option( 'wprss_options' );
133
+ }
134
+
135
+
136
+ /**
137
+ * Returns an array of the default plugin settings. These are only used on initial setup.
138
+ *
139
+ * @since 2.0
140
+ */
141
+ function wprss_get_default_settings() {
142
+
143
+ // Set up the default plugin settings
144
+ $settings = array(
145
+
146
+ // from version 1.1
147
+ 'open_dd' => __( 'New window' ),
148
+ 'follow_dd' => __( 'No follow' ),
149
+ // from version 2.0
150
+ 'feed_limit' => 10
151
+ );
152
+
153
+ // Return the default settings
154
+ return $settings;
155
+ }
js/custom.js ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ jQuery( document ).ready( function() {
2
+ jQuery( 'a.colorbox' ).colorbox(
3
+ {iframe:true, width:'80%', height:'80%'}
4
+ );
5
+ });
js/jquery.colorbox-min.js ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ // ColorBox v1.3.20.1 - jQuery lightbox plugin
2
+ // (c) 2012 Jack Moore - jacklmoore.com
3
+ // License: http://www.opensource.org/licenses/mit-license.php
4
+ (function(e,t,n){function G(n,r,i){var o=t.createElement(n);return r&&(o.id=s+r),i&&(o.style.cssText=i),e(o)}function Y(e){var t=T.length,n=(U+e)%t;return n<0?t+n:n}function Z(e,t){return Math.round((/%/.test(e)?(t==="x"?tt():nt())/100:1)*parseInt(e,10))}function et(e){return B.photo||/\.(gif|png|jp(e|g|eg)|bmp|ico)((#|\?).*)?$/i.test(e)}function tt(){return n.innerWidth||N.width()}function nt(){return n.innerHeight||N.height()}function rt(){var t,n=e.data(R,i);n==null?(B=e.extend({},r),console&&console.log&&console.log("Error: cboxElement missing settings object")):B=e.extend({},n);for(t in B)e.isFunction(B[t])&&t.slice(0,2)!=="on"&&(B[t]=B[t].call(R));B.rel=B.rel||R.rel||"nofollow",B.href=B.href||e(R).attr("href"),B.title=B.title||R.title,typeof B.href=="string"&&(B.href=e.trim(B.href))}function it(t,n){e.event.trigger(t),n&&n.call(R)}function st(){var e,t=s+"Slideshow_",n="click."+s,r,i,o;B.slideshow&&T[1]?(r=function(){M.text(B.slideshowStop).unbind(n).bind(f,function(){if(B.loop||T[U+1])e=setTimeout(J.next,B.slideshowSpeed)}).bind(a,function(){clearTimeout(e)}).one(n+" "+l,i),g.removeClass(t+"off").addClass(t+"on"),e=setTimeout(J.next,B.slideshowSpeed)},i=function(){clearTimeout(e),M.text(B.slideshowStart).unbind([f,a,l,n].join(" ")).one(n,function(){J.next(),r()}),g.removeClass(t+"on").addClass(t+"off")},B.slideshowAuto?r():i()):g.removeClass(t+"off "+t+"on")}function ot(t){V||(R=t,rt(),T=e(R),U=0,B.rel!=="nofollow"&&(T=e("."+o).filter(function(){var t=e.data(this,i),n;return t&&(n=t.rel||this.rel),n===B.rel}),U=T.index(R),U===-1&&(T=T.add(R),U=T.length-1)),W||(W=X=!0,g.show(),B.returnFocus&&e(R).blur().one(c,function(){e(this).focus()}),m.css({opacity:+B.opacity,cursor:B.overlayClose?"pointer":"auto"}).show(),B.w=Z(B.initialWidth,"x"),B.h=Z(B.initialHeight,"y"),J.position(),d&&N.bind("resize."+v+" scroll."+v,function(){m.css({width:tt(),height:nt(),top:N.scrollTop(),left:N.scrollLeft()})}).trigger("resize."+v),it(u,B.onOpen),H.add(A).hide(),P.html(B.close).show()),J.load(!0))}function ut(){!g&&t.body&&(Q=!1,N=e(n),g=G(K).attr({id:i,"class":p?s+(d?"IE6":"IE"):""}).hide(),m=G(K,"Overlay",d?"position:absolute":"").hide(),L=G(K,"LoadingOverlay").add(G(K,"LoadingGraphic")),y=G(K,"Wrapper"),b=G(K,"Content").append(C=G(K,"LoadedContent","width:0; height:0; overflow:hidden"),A=G(K,"Title"),O=G(K,"Current"),_=G(K,"Next"),D=G(K,"Previous"),M=G(K,"Slideshow").bind(u,st),P=G(K,"Close")),y.append(G(K).append(G(K,"TopLeft"),w=G(K,"TopCenter"),G(K,"TopRight")),G(K,!1,"clear:left").append(E=G(K,"MiddleLeft"),b,S=G(K,"MiddleRight")),G(K,!1,"clear:left").append(G(K,"BottomLeft"),x=G(K,"BottomCenter"),G(K,"BottomRight"))).find("div div").css({"float":"left"}),k=G(K,!1,"position:absolute; width:9999px; visibility:hidden; display:none"),H=_.add(D).add(O).add(M),e(t.body).append(m,g.append(y,k)))}function at(){return g?(Q||(Q=!0,j=w.height()+x.height()+b.outerHeight(!0)-b.height(),F=E.width()+S.width()+b.outerWidth(!0)-b.width(),I=C.outerHeight(!0),q=C.outerWidth(!0),g.css({"padding-bottom":j,"padding-right":F}),_.click(function(){J.next()}),D.click(function(){J.prev()}),P.click(function(){J.close()}),m.click(function(){B.overlayClose&&J.close()}),e(t).bind("keydown."+s,function(e){var t=e.keyCode;W&&B.escKey&&t===27&&(e.preventDefault(),J.close()),W&&B.arrowKey&&T[1]&&(t===37?(e.preventDefault(),D.click()):t===39&&(e.preventDefault(),_.click()))}),e("."+o,t).live("click",function(e){e.which>1||e.shiftKey||e.altKey||e.metaKey||(e.preventDefault(),ot(this))})),!0):!1}var r={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",xhrError:"This content failed to load.",imgError:"This image failed to load.",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},i="colorbox",s="cbox",o=s+"Element",u=s+"_open",a=s+"_load",f=s+"_complete",l=s+"_cleanup",c=s+"_closed",h=s+"_purge",p=!e.support.opacity&&!e.support.style,d=p&&!n.XMLHttpRequest,v=s+"_IE6",m,g,y,b,w,E,S,x,T,N,C,k,L,A,O,M,_,D,P,H,B,j,F,I,q,R,U,z,W,X,V,$,J,K="div",Q;if(e.colorbox)return;e(ut),J=e.fn[i]=e[i]=function(t,n){var s=this;t=t||{},ut();if(at()){if(!s[0]){if(s.selector)return s;s=e("<a/>"),t.open=!0}n&&(t.onComplete=n),s.each(function(){e.data(this,i,e.extend({},e.data(this,i)||r,t))}).addClass(o),(e.isFunction(t.open)&&t.open.call(s)||t.open)&&ot(s[0])}return s},J.position=function(e,t){function f(e){w[0].style.width=x[0].style.width=b[0].style.width=e.style.width,b[0].style.height=E[0].style.height=S[0].style.height=e.style.height}var n,r=0,i=0,o=g.offset(),u,a;N.unbind("resize."+s),g.css({top:-9e4,left:-9e4}),u=N.scrollTop(),a=N.scrollLeft(),B.fixed&&!d?(o.top-=u,o.left-=a,g.css({position:"fixed"})):(r=u,i=a,g.css({position:"absolute"})),B.right!==!1?i+=Math.max(tt()-B.w-q-F-Z(B.right,"x"),0):B.left!==!1?i+=Z(B.left,"x"):i+=Math.round(Math.max(tt()-B.w-q-F,0)/2),B.bottom!==!1?r+=Math.max(nt()-B.h-I-j-Z(B.bottom,"y"),0):B.top!==!1?r+=Z(B.top,"y"):r+=Math.round(Math.max(nt()-B.h-I-j,0)/2),g.css({top:o.top,left:o.left}),e=g.width()===B.w+q&&g.height()===B.h+I?0:e||0,y[0].style.width=y[0].style.height="9999px",n={width:B.w+q,height:B.h+I,top:r,left:i},e===0&&g.css(n),g.dequeue().animate(n,{duration:e,complete:function(){f(this),X=!1,y[0].style.width=B.w+q+F+"px",y[0].style.height=B.h+I+j+"px",B.reposition&&setTimeout(function(){N.bind("resize."+s,J.position)},1),t&&t()},step:function(){f(this)}})},J.resize=function(e){W&&(e=e||{},e.width&&(B.w=Z(e.width,"x")-q-F),e.innerWidth&&(B.w=Z(e.innerWidth,"x")),C.css({width:B.w}),e.height&&(B.h=Z(e.height,"y")-I-j),e.innerHeight&&(B.h=Z(e.innerHeight,"y")),!e.innerHeight&&!e.height&&(C.css({height:"auto"}),B.h=C.height()),C.css({height:B.h}),J.position(B.transition==="none"?0:B.speed))},J.prep=function(t){function o(){return B.w=B.w||C.width(),B.w=B.mw&&B.mw<B.w?B.mw:B.w,B.w}function u(){return B.h=B.h||C.height(),B.h=B.mh&&B.mh<B.h?B.mh:B.h,B.h}if(!W)return;var n,r=B.transition==="none"?0:B.speed;C.remove(),C=G(K,"LoadedContent").append(t),C.hide().appendTo(k.show()).css({width:o(),overflow:B.scrolling?"auto":"hidden"}).css({height:u()}).prependTo(b),k.hide(),e(z).css({"float":"none"}),d&&e("select").not(g.find("select")).filter(function(){return this.style.visibility!=="hidden"}).css({visibility:"hidden"}).one(l,function(){this.style.visibility="inherit"}),n=function(){function y(){p&&g[0].style.removeAttribute("filter")}var t,n,o=T.length,u,a="frameBorder",l="allowTransparency",c,d,v,m;if(!W)return;c=function(){clearTimeout($),L.detach().hide(),it(f,B.onComplete)},p&&z&&C.fadeIn(100),A.html(B.title).add(C).show();if(o>1){typeof B.current=="string"&&O.html(B.current.replace("{current}",U+1).replace("{total}",o)).show(),_[B.loop||U<o-1?"show":"hide"]().html(B.next),D[B.loop||U?"show":"hide"]().html(B.previous),B.slideshow&&M.show();if(B.preloading){t=[Y(-1),Y(1)];while(n=T[t.pop()])m=e.data(n,i),m&&m.href?(d=m.href,e.isFunction(d)&&(d=d.call(n))):d=n.href,et(d)&&(v=new Image,v.src=d)}}else H.hide();B.iframe?(u=G("iframe")[0],a in u&&(u[a]=0),l in u&&(u[l]="true"),u.name=s+ +(new Date),B.fastIframe?c():e(u).one("load",c),u.src=B.href,B.scrolling||(u.scrolling="no"),e(u).addClass(s+"Iframe").appendTo(C).one(h,function(){u.src="//about:blank"})):c(),B.transition==="fade"?g.fadeTo(r,1,y):y()},B.transition==="fade"?g.fadeTo(r,0,function(){J.position(0,n)}):J.position(r,n)},J.load=function(t){var n,r,i=J.prep;X=!0,z=!1,R=T[U],t||rt(),it(h),it(a,B.onLoad),B.h=B.height?Z(B.height,"y")-I-j:B.innerHeight&&Z(B.innerHeight,"y"),B.w=B.width?Z(B.width,"x")-q-F:B.innerWidth&&Z(B.innerWidth,"x"),B.mw=B.w,B.mh=B.h,B.maxWidth&&(B.mw=Z(B.maxWidth,"x")-q-F,B.mw=B.w&&B.w<B.mw?B.w:B.mw),B.maxHeight&&(B.mh=Z(B.maxHeight,"y")-I-j,B.mh=B.h&&B.h<B.mh?B.h:B.mh),n=B.href,$=setTimeout(function(){L.show().appendTo(b)},100),B.inline?(G(K).hide().insertBefore(e(n)[0]).one(h,function(){e(this).replaceWith(C.children())}),i(e(n))):B.iframe?i(" "):B.html?i(B.html):et(n)?(e(z=new Image).addClass(s+"Photo").error(function(){B.title=!1,i(G(K,"Error").html(B.imgError))}).load(function(){var e;z.onload=null,B.scalePhotos&&(r=function(){z.height-=z.height*e,z.width-=z.width*e},B.mw&&z.width>B.mw&&(e=(z.width-B.mw)/z.width,r()),B.mh&&z.height>B.mh&&(e=(z.height-B.mh)/z.height,r())),B.h&&(z.style.marginTop=Math.max(B.h-z.height,0)/2+"px"),T[1]&&(B.loop||T[U+1])&&(z.style.cursor="pointer",z.onclick=function(){J.next()}),p&&(z.style.msInterpolationMode="bicubic"),setTimeout(function(){i(z)},1)}),setTimeout(function(){z.src=n},1)):n&&k.load(n,B.data,function(t,n,r){i(n==="error"?G(K,"Error").html(B.xhrError):e(this).contents())})},J.next=function(){!X&&T[1]&&(B.loop||T[U+1])&&(U=Y(1),J.load())},J.prev=function(){!X&&T[1]&&(B.loop||U)&&(U=Y(-1),J.load())},J.close=function(){W&&!V&&(V=!0,W=!1,it(l,B.onCleanup),N.unbind("."+s+" ."+v),m.fadeTo(200,0),g.stop().fadeTo(300,0,function(){g.add(m).css({opacity:1,cursor:"auto"}).hide(),it(h),C.remove(),setTimeout(function(){V=!1,it(c,B.onClosed)},1)}))},J.remove=function(){e([]).add(g).add(m).remove(),g=null,e("."+o).removeData(i).removeClass(o).die()},J.element=function(){return e(R)},J.settings=r})(jQuery,document,this);
lang/default.mo ADDED
Binary file
lang/default.po ADDED
@@ -0,0 +1,272 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: wprss\n"
4
+ "POT-Creation-Date: 2012-09-25 12:09+0100\n"
5
+ "PO-Revision-Date: 2012-09-25 13:52+0100\n"
6
+ "Last-Translator: \n"
7
+ "Language-Team: \n"
8
+ "MIME-Version: 1.0\n"
9
+ "Content-Type: text/plain; charset=UTF-8\n"
10
+ "Content-Transfer-Encoding: 8bit\n"
11
+ "X-Generator: Poedit 1.5.3\n"
12
+ "X-Poedit-KeywordsList: _;__;_e\n"
13
+ "X-Poedit-Basepath: ../\n"
14
+ "X-Poedit-SearchPath-0: .\n"
15
+
16
+ #: wp-rss-aggregator.php:152
17
+ msgid "Enter feed name here (e.g. WP Mayor)"
18
+ msgstr ""
19
+
20
+ #: wp-rss-aggregator.php:394
21
+ msgid "No feed items found"
22
+ msgstr ""
23
+
24
+ #: inc/activation.php:11
25
+ msgid "This plugin requires WordPress version 3.2 or higher."
26
+ msgstr ""
27
+
28
+ #: inc/admin-options.php:45 inc/admin-options.php:88
29
+ msgid "WP RSS Aggregator Settings"
30
+ msgstr ""
31
+
32
+ #: inc/admin-options.php:45
33
+ msgid "Settings"
34
+ msgstr ""
35
+
36
+ #: inc/admin-options.php:67
37
+ msgid "Open links behaviour"
38
+ msgstr ""
39
+
40
+ #: inc/admin-options.php:70
41
+ msgid "Set links as"
42
+ msgstr ""
43
+
44
+ #: inc/admin-options.php:73
45
+ msgid "Feed limit"
46
+ msgstr ""
47
+
48
+ #: inc/admin-options.php:93
49
+ msgid "Save Settings"
50
+ msgstr ""
51
+
52
+ #: inc/admin-options.php:113
53
+ msgid "No follow"
54
+ msgstr ""
55
+
56
+ #: inc/admin-options.php:114
57
+ msgid "Follow"
58
+ msgstr ""
59
+
60
+ #: inc/admin-options.php:132
61
+ msgid "Lightbox"
62
+ msgstr ""
63
+
64
+ #: inc/admin-options.php:133
65
+ msgid "New window"
66
+ msgstr ""
67
+
68
+ #: inc/admin-options.php:134
69
+ msgid "None"
70
+ msgstr ""
71
+
72
+ #: inc/cron-jobs.php:53
73
+ msgid "Once Weekly"
74
+ msgstr ""
75
+
76
+ #: inc/custom-post-types.php:30
77
+ msgid "Feed Sources"
78
+ msgstr ""
79
+
80
+ #: inc/custom-post-types.php:31
81
+ msgid "Feed"
82
+ msgstr ""
83
+
84
+ #: inc/custom-post-types.php:32 inc/custom-post-types.php:34
85
+ msgid "Add New Feed Source"
86
+ msgstr ""
87
+
88
+ #: inc/custom-post-types.php:33
89
+ msgid "All Feed Sources"
90
+ msgstr ""
91
+
92
+ #: inc/custom-post-types.php:35
93
+ msgid "Edit Feed Source"
94
+ msgstr ""
95
+
96
+ #: inc/custom-post-types.php:36
97
+ msgid "New Feed Source"
98
+ msgstr ""
99
+
100
+ #: inc/custom-post-types.php:37
101
+ msgid "View Feed Source"
102
+ msgstr ""
103
+
104
+ #: inc/custom-post-types.php:38
105
+ msgid "Search Feeds"
106
+ msgstr ""
107
+
108
+ #: inc/custom-post-types.php:39
109
+ msgid "No Feed Sources Found"
110
+ msgstr ""
111
+
112
+ #: inc/custom-post-types.php:40
113
+ msgid "No Feed Sources Found In Trash"
114
+ msgstr ""
115
+
116
+ #: inc/custom-post-types.php:41
117
+ msgid "RSS Aggregator"
118
+ msgstr ""
119
+
120
+ #: inc/custom-post-types.php:58 inc/custom-post-types.php:60
121
+ msgid "Imported Feeds"
122
+ msgstr ""
123
+
124
+ #: inc/custom-post-types.php:59
125
+ msgid "Imported Feed"
126
+ msgstr ""
127
+
128
+ #: inc/custom-post-types.php:61
129
+ msgid "View Imported Feed"
130
+ msgstr ""
131
+
132
+ #: inc/custom-post-types.php:62
133
+ msgid "Search Imported Feeds"
134
+ msgstr ""
135
+
136
+ #: inc/custom-post-types.php:63
137
+ msgid "No Imported Feeds Found"
138
+ msgstr ""
139
+
140
+ #: inc/custom-post-types.php:64
141
+ msgid "No Imported Feeds Found In Trash"
142
+ msgstr ""
143
+
144
+ #: inc/custom-post-types.php:83 inc/custom-post-types.php:135
145
+ msgid "Name"
146
+ msgstr ""
147
+
148
+ #: inc/custom-post-types.php:84 inc/custom-post-types.php:306
149
+ msgid "URL"
150
+ msgstr ""
151
+
152
+ #: inc/custom-post-types.php:85 inc/custom-post-types.php:313
153
+ msgid "Description"
154
+ msgstr ""
155
+
156
+ #: inc/custom-post-types.php:136
157
+ msgid "Permalink"
158
+ msgstr ""
159
+
160
+ #: inc/custom-post-types.php:137
161
+ msgid "Date published"
162
+ msgstr ""
163
+
164
+ #: inc/custom-post-types.php:138
165
+ msgid "Source"
166
+ msgstr ""
167
+
168
+ #: inc/custom-post-types.php:226
169
+ msgid "Save Feed Source"
170
+ msgstr ""
171
+
172
+ #: inc/custom-post-types.php:252
173
+ msgid "WP RSS Aggregator Help"
174
+ msgstr ""
175
+
176
+ #: inc/custom-post-types.php:261
177
+ msgid "Like this plugin?"
178
+ msgstr ""
179
+
180
+ #: inc/custom-post-types.php:270
181
+ msgid "Follow us"
182
+ msgstr ""
183
+
184
+ #: inc/custom-post-types.php:279
185
+ msgid "Feed Source Details"
186
+ msgstr ""
187
+
188
+ #: inc/custom-post-types.php:288
189
+ msgid "Feed Preview"
190
+ msgstr ""
191
+
192
+ #: inc/custom-post-types.php:307
193
+ msgid "Enter feed URL (including http://)"
194
+ msgstr ""
195
+
196
+ #: inc/custom-post-types.php:314
197
+ msgid "A short description about this feed source (optional)"
198
+ msgstr ""
199
+
200
+ #: inc/custom-post-types.php:438
201
+ msgid "Delete Permanently"
202
+ msgstr ""
203
+
204
+ #: inc/custom-post-types.php:440
205
+ msgid "Move to Trash"
206
+ msgstr ""
207
+
208
+ #: inc/custom-post-types.php:471
209
+ msgid ""
210
+ "<strong>Invalid feed URL</strong> - Double check the feed source URL setting "
211
+ "above."
212
+ msgstr ""
213
+
214
+ #: inc/custom-post-types.php:474
215
+ msgid "No feed URL defined yet"
216
+ msgstr ""
217
+
218
+ #: inc/custom-post-types.php:486
219
+ msgid "Need help?"
220
+ msgstr ""
221
+
222
+ #: inc/custom-post-types.php:488
223
+ msgid "Check out the support forum"
224
+ msgstr ""
225
+
226
+ #: inc/custom-post-types.php:499
227
+ msgid "Why not do any or all of the following"
228
+ msgstr ""
229
+
230
+ #: inc/custom-post-types.php:501
231
+ msgid "Give it a 5 star rating on WordPress.org."
232
+ msgstr ""
233
+
234
+ #: inc/custom-post-types.php:502
235
+ msgid "Donate a token of your appreciation."
236
+ msgstr ""
237
+
238
+ #: inc/custom-post-types.php:517
239
+ msgid "Follow WP Mayor on Twitter."
240
+ msgstr ""
241
+
242
+ #: inc/custom-post-types.php:518
243
+ msgid "Like WP Mayor on Facebook."
244
+ msgstr ""
245
+
246
+ #: inc/custom-post-types.php:535
247
+ msgid "Feed source updated. "
248
+ msgstr ""
249
+
250
+ #: inc/custom-post-types.php:536
251
+ msgid "Custom field updated."
252
+ msgstr ""
253
+
254
+ #: inc/custom-post-types.php:537
255
+ msgid "Custom field deleted."
256
+ msgstr ""
257
+
258
+ #: inc/custom-post-types.php:538 inc/custom-post-types.php:544
259
+ msgid "Feed source updated."
260
+ msgstr ""
261
+
262
+ #: inc/custom-post-types.php:540 inc/custom-post-types.php:541
263
+ msgid "Feed source saved."
264
+ msgstr ""
265
+
266
+ #: inc/custom-post-types.php:542
267
+ msgid "Feed source submitted."
268
+ msgstr ""
269
+
270
+ #: inc/custom-post-types.php:628
271
+ msgid "Publish Feed"
272
+ msgstr ""
readme.txt ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === WP RSS Aggregator ===
2
+ Contributors: jeangalea
3
+ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=X9GP6BL4BLXBJ
4
+ Plugin URI: http://wordpress.org/extend/plugins/wp-rss-aggregator/
5
+ Tags: rss, feeds, aggregation, aggregator, import, feed aggregator, rss aggregator
6
+ Requires at least: 3.3
7
+ Tested up to: 3.4
8
+ Stable tag: 2.1
9
+ Imports and merges multiple RSS Feeds using SimplePie. Outputs feeds sorted by date (latest first).
10
+
11
+ == Description ==
12
+
13
+ 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.
14
+ 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.
15
+
16
+ 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.
17
+ You can call the function from within the theme or even use a shortcode with parameters.
18
+
19
+ = Demo =
20
+ The plugin can be seen in use on the [WPMayor.com WordPress News page](http://www.wpmayor.com/wordpress-news/)
21
+
22
+ = Credit =
23
+ Created by Jean Galea. Need a [WordPress Freelance Developer](http://www.jeangalea.com/services/wordpress-consultancy-development/)?
24
+
25
+ == Installation ==
26
+
27
+ 1. Upload the `wp-rss-aggregator` folder to the `/wp-content/plugins/` directory
28
+ 2. Activate the WP RSS Aggregator plugin through the 'Plugins' menu in WordPress
29
+ 3. Configure the plugin by going to the `RSS Aggregator` menu item that appears in your dashboard menu.
30
+ 3. Use the shortcode in your posts or pages: `[wp_rss_aggregator]`
31
+
32
+ The parameters accepted are:
33
+
34
+ * links_before
35
+ * links_after
36
+ * link_before
37
+ * link_after
38
+
39
+ An example of a shortcode with parameters:
40
+ `[wp_rss_aggregator link_before='<li class="feed-link">' link_after='</li>']`
41
+ It is advisable to use the 'HTML' view of the editor when inserting the shortcode with paramters.
42
+
43
+ An example of a function call from within the template files:
44
+ `
45
+ <?php
46
+ wprss_display_feed_items( $args = array(
47
+ 'links_before' => '<ul>',
48
+ 'links_after' => '</ul>',
49
+ 'link_before' => '<li>',
50
+ 'link_after' => '</li>'
51
+ ));
52
+ ?>
53
+ `
54
+
55
+ OR
56
+
57
+ `<?php do_shortcode('[wp-rss-aggregator]'); ?>`
58
+
59
+ You can also set whether the feed links should open in a new window, current window or even a lightbox, via the settings panel.
60
+
61
+ The settings panel also has an option to set links as nofollow for SEO purposes.
62
+
63
+ Since version 2.0 you can also specify the number of feed items shown on the frontend.
64
+
65
+ == Frequently Asked Questions ==
66
+ = How can I output the feeds in my theme? =
67
+
68
+ You can either call the function directly within the theme:
69
+ `<?php wprss_display_feed_items(); ?>`
70
+
71
+ Or use the shortcode in your posts and pages:
72
+ [wp_rss_aggregator]
73
+
74
+ == Screenshots ==
75
+
76
+ 1. The output of this plugin on the frontend, as seen on www.wpmayor.com.
77
+
78
+ 2. Feed sources list.
79
+
80
+ 3. Adding a new feed source.
81
+
82
+ 4. Imported feeds.
83
+
84
+ 5. Plugin settings page.
85
+
86
+ == Changelog ==
87
+
88
+ = Version 2.1 (2012-09-27) =
89
+ * Now localised for translations
90
+ * Fixed bug with date string
91
+ * Fixed $link_before and $link_after, now working
92
+ * Added backwards compatibility for wp_rss_aggregator() function
93
+
94
+ = Version 2.0 (2012-09-21) =
95
+ * Bulk of code rewritten and refactored
96
+ * Added install and upgrade functions
97
+ * Added DB version setting
98
+ * Feed sources now stored as Custom Post Types
99
+ * Feed source list sortable ascending or descending by name
100
+ * Removed days subsections in feed display
101
+ * Ability to limit total number of feeds displayed
102
+ * Feeds now fetched via Cron
103
+ * Cron job to delete old feed items, keeps max of 50 items in DB
104
+ * Now requires WordPress 3.2
105
+ * Updated colorbox to v1.3.20.1
106
+ * Limit of 15 items max imported for each source
107
+ * Fixed issue of page content displaying incorrectly after feeds
108
+
109
+
110
+ = Version 1.1 (2012-08-13) =
111
+ * Now requires WordPress 3.0
112
+ * More flexible fetching of images directory
113
+ * Has its own top level menu item
114
+ * Added settings section
115
+ * Ability to open in lightbox, new window or default browser behaviour
116
+ * Ability to set links as follow or no follow
117
+ * Using constants for oftenly used locations
118
+ * Code refactoring
119
+ * Changes in file and folder structure
120
+
121
+
122
+ = Version 1.0 (2012-01-06) =
123
+ * Initial release.
screenshot-1.png ADDED
Binary file
screenshot-2.png ADDED
Binary file
screenshot-3.png ADDED
Binary file
screenshot-4.png ADDED
Binary file
screenshot-5.png ADDED
Binary file
uninstall.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // If uninstall not called from WordPress exit
3
+ if( ! defined( 'WP_UNINSTALL_PLUGIN' ) )
4
+ exit ();
5
+
6
+ // Delete option from options table
7
+ delete_option( 'wprss_options' );
8
+ delete_option( 'wprss_settings' );
9
+ delete_option( 'wprss_db_version' );
10
+
wp-rss-aggregator.php ADDED
@@ -0,0 +1,496 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: WP RSS Aggregator
4
+ Plugin URI: http://wordpress.org/extend/plugins/wp-rss-aggregator/
5
+ Description: Imports and merges multiple RSS Feeds using SimplePie
6
+ Version: 2.1
7
+ Author: Jean Galea
8
+ Author URI: http://www.jeangalea.com
9
+ License: GPLv3
10
+ */
11
+
12
+ /*
13
+ Copyright 2011-2012 Jean Galea (email : jean@jpgalea.com)
14
+ This program is free software; you can redistribute it and/or modify
15
+ it under the terms of the GNU General Public License as published by
16
+ the Free Software Foundation; either version 2 of the License, or
17
+ (at your option) any later version.
18
+
19
+ This program is distributed in the hope that it will be useful,
20
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
+ GNU General Public License for more details.
23
+
24
+ You should have received a copy of the GNU General Public License
25
+ along with this program; if not, write to the Free Software
26
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27
+ */
28
+
29
+ /*
30
+ @version 2.1
31
+ @author Jean Galea <info@jeangalea.com>
32
+ @copyright Copyright (c) 2012, Jean Galea
33
+ @link http://www.jeangalea.com/
34
+ @license http://www.gnu.org/licenses/gpl.html
35
+ */
36
+
37
+
38
+ /**
39
+ * Define constants used by the plugin.
40
+ *
41
+ * We're not checking if constants are defined before setting them, as the prefix 'wprss' pretty
42
+ * much eliminates the possibility of them being set before. If there is a reasonable chance
43
+ * that they would have been set earlier or by another plugin, it's better to check before
44
+ * setting them via if !(defined).
45
+ *
46
+ */
47
+
48
+ /* Set the version number of the plugin. */
49
+ define( 'WPRSS_VERSION', '2.1', true );
50
+
51
+ /* Set the database version number of the plugin. */
52
+ define( 'WPRSS_DB_VERSION', 2 );
53
+
54
+ /* Set the plugin prefix */
55
+ define( 'WPRSS_PREFIX', 'wprss', true );
56
+
57
+ /* Set constant path to the plugin directory. */
58
+ define( 'WPRSS_DIR', plugin_dir_path( __FILE__ ) );
59
+
60
+ /* Set constant URI to the plugin URL. */
61
+ define( 'WPRSS_URI', plugin_dir_url( __FILE__ ) );
62
+
63
+ /* Set the constant path to the plugin's javascript directory. */
64
+ define( 'WPRSS_JS', WPRSS_URI . trailingslashit( 'js' ), true );
65
+
66
+ /* Set the constant path to the plugin's CSS directory. */
67
+ define( 'WPRSS_CSS', WPRSS_URI . trailingslashit( 'css' ), true );
68
+
69
+ /* Set the constant path to the plugin's images directory. */
70
+ define( 'WPRSS_IMG', WPRSS_URI . trailingslashit( 'img' ), true );
71
+
72
+ /* Set the constant path to the plugin's includes directory. */
73
+ define( 'WPRSS_INC', WPRSS_DIR . trailingslashit( 'inc' ), true );
74
+
75
+
76
+ /**
77
+ * Load required files.
78
+ */
79
+
80
+ /* Load the activation functions file. */
81
+ require_once ( WPRSS_INC . 'activation.php' );
82
+
83
+ /* Load the deactivation functions file. */
84
+ require_once ( WPRSS_INC . 'deactivation.php' );
85
+
86
+ /* Load install, upgrade and migration code. */
87
+ require_once ( WPRSS_INC . 'update.php' );
88
+
89
+ /* Load the shortcodes functions file. */
90
+ require_once ( WPRSS_INC . 'shortcodes.php' );
91
+
92
+ /* Load the admin functions file. */
93
+ require_once ( WPRSS_INC . 'admin-options.php' );
94
+
95
+ /* Load the custom post types and taxonomies. */
96
+ require_once ( WPRSS_INC . 'custom-post-types.php' );
97
+
98
+ /* Load the cron job scheduling functions. */
99
+ require_once ( WPRSS_INC . 'cron-jobs.php' );
100
+
101
+ add_action( 'init', 'wprss_schedule_fetch_feeds_cron' );
102
+ add_action( 'init', 'wprss_schedule_truncate_posts_cron' );
103
+
104
+
105
+ add_action( 'init', 'wprss_init' );
106
+ /**
107
+ * Initialise the plugin
108
+ *
109
+ * @since 2.0
110
+ */
111
+ function wprss_init() {
112
+ register_activation_hook( WPRSS_INC . 'activation.php', 'wprss_activate' );
113
+ register_deactivation_hook( WPRSS_INC . 'deactivation.php', 'wprss_deactivate' );
114
+ } // end wprss_int
115
+
116
+
117
+ add_action( 'plugins_loaded', 'wprss_load_textdomain' );
118
+ /**
119
+ * Loads the plugin's translated strings.
120
+ *
121
+ * @since 2.1
122
+ */
123
+ function wprss_load_textdomain() {
124
+ load_plugin_textdomain( 'wprss', false, plugin_basename( __FILE__ ) . '/lang/' );
125
+ }
126
+
127
+
128
+ add_action( 'admin_enqueue_scripts', 'wprss_admin_scripts_styles' );
129
+ /**
130
+ * Insert required scripts, styles and filters on the admin side
131
+ *
132
+ * @since 2.0
133
+ */
134
+ function wprss_admin_scripts_styles() {
135
+ // Only load scripts if we are on this plugin's options or settings pages (admin)
136
+ if ( isset( $_GET['page'] ) && ( $_GET['page'] == 'wprss-aggregator' || $_GET['page'] == 'wprss-aggregator-settings' ) ) {
137
+ wp_enqueue_style( 'styles', WPRSS_CSS . 'styles.css' );
138
+ }
139
+
140
+ // Only load scripts if we are on wprss_feed add post or edit post screens
141
+ $screen = get_current_screen();
142
+
143
+ if ( ( 'post' === $screen->base || 'edit' === $screen->base ) && ( 'wprss_feed' === $screen->post_type || 'wprss_feed_item' === $screen->post_type ) ) {
144
+ wp_enqueue_style( 'styles', WPRSS_CSS . 'styles.css' );
145
+ if ( 'post' === $screen->base && 'wprss_feed' === $screen->post_type ) {
146
+ // Change text on post screen from 'Enter title here' to 'Enter feed name here'
147
+ add_filter( 'enter_title_here', 'wprss_change_title_text' );
148
+ }
149
+ }
150
+ } // end wprss_admin_scripts_styles
151
+
152
+
153
+ /**
154
+ * Change title on wprss_feed post type screen
155
+ *
156
+ * @since 2.0
157
+ */
158
+ function wprss_change_title_text() {
159
+ return __( 'Enter feed name here (e.g. WP Mayor)', 'wprss' );
160
+ } // end wprss_change_title_text
161
+
162
+
163
+ add_action( 'wp_head', 'wprss_head_scripts_styles' );
164
+ /**
165
+ * Scripts and styles to be inserted into <head> section in front end
166
+ *
167
+ * @since 2.0
168
+ */
169
+ function wprss_head_scripts_styles() {
170
+ wp_enqueue_style( 'colorbox', WPRSS_CSS . 'colorbox.css' );
171
+ wp_enqueue_script( 'jquery.colorbox-min', WPRSS_JS .'jquery.colorbox-min.js', array('jquery') );
172
+ wp_enqueue_script( 'custom', WPRSS_JS .'custom.js', array('jquery','jquery.colorbox-min') );
173
+ } // end wprss_head_scripts_styles
174
+
175
+
176
+ /**
177
+ * Change the default feed cache recreation period to 2 hours
178
+ *
179
+ * @since 2.1
180
+ */
181
+ function wprss_return_7200( $seconds )
182
+ {
183
+ return 7200;
184
+ }
185
+
186
+
187
+ /**
188
+ * Fetches feed items from sources provided
189
+ *
190
+ * @since 2.0
191
+ */
192
+ function wprss_fetch_all_feed_items( ) {
193
+
194
+ // Get all feed sources
195
+ $feed_sources = new WP_Query( array(
196
+ 'post_type' => 'wprss_feed',
197
+ 'post_status' => 'publish',
198
+ 'posts_per_page' => -1,
199
+ ) );
200
+
201
+ if( $feed_sources->have_posts() ) {
202
+ /* Start by getting one feed source, we will cycle through them one by one,
203
+ fetching feed items and adding them to the database in each pass */
204
+ while ( $feed_sources->have_posts() ) {
205
+ $feed_sources->the_post();
206
+
207
+ $feed_ID = get_the_ID();
208
+ $feed_url = get_post_meta( get_the_ID(), 'wprss_url', true );
209
+
210
+ // Use the URL custom field to fetch the feed items for this source
211
+ if( !empty( $feed_url ) ) {
212
+ add_filter( 'wp_feed_cache_transient_lifetime' , 'wprss_return_7200' );
213
+ $feed = fetch_feed( $feed_url );
214
+ remove_filter( 'wp_feed_cache_transient_lifetime' , 'wprss_return_7200' );
215
+ if ( !is_wp_error( $feed ) ) {
216
+ // Figure out how many total items there are, but limit it to 10.
217
+ $maxitems = $feed->get_item_quantity(10);
218
+
219
+ // Build an array of all the items, starting with element 0 (first element).
220
+ $items = $feed->get_items( 0, $maxitems );
221
+ }
222
+ }
223
+
224
+ if ( ! empty( $items ) ) {
225
+ // Gather the permalinks of existing feed item's related to this feed source
226
+ global $wpdb;
227
+ $existing_permalinks = $wpdb->get_col(
228
+ "SELECT meta_value
229
+ FROM $wpdb->postmeta
230
+ WHERE meta_key = 'wprss_item_permalink'
231
+ AND post_id IN ( SELECT post_id FROM $wpdb->postmeta WHERE meta_value = $feed_ID)
232
+ ");
233
+
234
+ foreach ( $items as $item ) {
235
+
236
+ // Check if newly fetched item already present in existing feed item item,
237
+ // if not insert it into wp_posts and insert post meta.
238
+ if ( ! ( in_array( $item->get_permalink(), $existing_permalinks ) ) ) {
239
+ // Create post object
240
+ $feed_item = array(
241
+ 'post_title' => $item->get_title(),
242
+ 'post_content' => '',
243
+ 'post_status' => 'publish',
244
+ 'post_type' => 'wprss_feed_item'
245
+ );
246
+ $inserted_ID = wp_insert_post( $feed_item );
247
+
248
+ update_post_meta( $inserted_ID, 'wprss_item_permalink', $item->get_permalink() );
249
+ update_post_meta( $inserted_ID, 'wprss_item_description', $item->get_description() );
250
+ update_post_meta( $inserted_ID, 'wprss_item_date', $item->get_date( 'U' ) ); // Save as Unix timestamp format
251
+ update_post_meta( $inserted_ID, 'wprss_feed_id', $feed_ID);
252
+ } //end if
253
+ } //end foreach
254
+ } // end if
255
+ } // end $feed_sources while loop
256
+ wp_reset_postdata(); // Restore the $post global to the current post in the main query
257
+ // } // end if
258
+ } // end if
259
+ } // end wprss_fetch_all_feed_items
260
+
261
+
262
+ add_action('wp_insert_post', 'wprss_fetch_feed_items');
263
+ /**
264
+ * Fetches feed items from sources provided
265
+ *
266
+ * @since 2.0
267
+ */
268
+ function wprss_fetch_feed_items( $post_id ) {
269
+
270
+ // Get current post that triggered the hook, $post_id passed via the hook
271
+ $post = get_post( $post_id );
272
+
273
+ if( ( $post->post_type == 'wprss_feed' ) && ( $post->post_status == 'publish' ) ) {
274
+
275
+ // Get all feed sources
276
+ $feed_sources = new WP_Query( array(
277
+ 'post_type' => 'wprss_feed',
278
+ 'post_status' => 'publish',
279
+ 'posts_per_page' => -1,
280
+ ) );
281
+
282
+ if( $feed_sources->have_posts() ) {
283
+ // Start by getting one feed source, we will cycle through them one by one,
284
+ // fetching feed items and adding them to the database in each pass
285
+ while ( $feed_sources->have_posts() ) {
286
+ $feed_sources->the_post();
287
+
288
+ $feed_ID = get_the_ID();
289
+ $feed_url = get_post_meta( get_the_ID(), 'wprss_url', true );
290
+
291
+ // Use the URL custom field to fetch the feed items for this source
292
+ if( ! empty( $feed_url ) ) {
293
+ add_filter( 'wp_feed_cache_transient_lifetime' , 'wprss_return_7200' );
294
+ $feed = fetch_feed( $feed_url );
295
+ remove_filter( 'wp_feed_cache_transient_lifetime' , 'wprss_return_7200' );
296
+ if ( ! is_wp_error( $feed ) ) {
297
+ // Figure out how many total items there are, but limit it to 10.
298
+ $maxitems = $feed->get_item_quantity(10);
299
+
300
+ // Build an array of all the items, starting with element 0 (first element).
301
+ $items = $feed->get_items(0, $maxitems);
302
+ }
303
+ }
304
+
305
+ if ( ! empty( $items ) ) {
306
+ // Gather the permalinks of existing feed item's related to this feed source
307
+ global $wpdb;
308
+ $existing_permalinks = $wpdb->get_col(
309
+ "SELECT meta_value
310
+ FROM $wpdb->postmeta
311
+ WHERE meta_key = 'wprss_item_permalink'
312
+ AND post_id IN ( SELECT post_id FROM $wpdb->postmeta WHERE meta_value = $feed_ID)
313
+ ");
314
+
315
+ foreach ( $items as $item ) {
316
+
317
+ // Check if newly fetched item already present in existing feed item item,
318
+ // if not insert it into wp_postsm and insert post meta.
319
+ if ( ! ( in_array( $item->get_permalink(), $existing_permalinks ) ) ) {
320
+ // Create post object
321
+ $feed_item = array(
322
+ 'post_title' => $item->get_title(),
323
+ 'post_content' => '',
324
+ 'post_status' => 'publish',
325
+ 'post_type' => 'wprss_feed_item'
326
+ );
327
+ $inserted_ID = wp_insert_post( $feed_item );
328
+
329
+ update_post_meta( $inserted_ID, 'wprss_item_permalink', $item->get_permalink() );
330
+ update_post_meta( $inserted_ID, 'wprss_item_description', $item->get_description() );
331
+ update_post_meta( $inserted_ID, 'wprss_item_date', $item->get_date( 'U' ) ); // Save as Unix timestamp format
332
+ update_post_meta( $inserted_ID, 'wprss_feed_id', $feed_ID);
333
+ } //end if
334
+ } //end foreach
335
+ } // end if
336
+ } // end $feed_sources while loop
337
+ wp_reset_postdata(); // Restore the $post global to the current post in the main query
338
+ } // end if
339
+ } // end if
340
+ } // end wprss_fetch_feed_items
341
+
342
+
343
+ /**
344
+ * Redirects to wprss_display_feed_items
345
+ * It is used for backwards compatibility to versions < 2.0
346
+ *
347
+ * @since 2.1
348
+ */
349
+ function wp_rss_aggregator( $args = array() ) {
350
+ wprss_display_feed_items( $args );
351
+ }
352
+
353
+
354
+ /**
355
+ * Display feed items on the front end (via shortcode or function)
356
+ *
357
+ * @since 2.0
358
+ */
359
+ function wprss_display_feed_items( $args = array() ) {
360
+ $defaults = array(
361
+ 'links_before' => '<ul>',
362
+ 'links_after' => '</ul>',
363
+ 'link_before' => '<li>',
364
+ 'link_after' => '</li>'
365
+ );
366
+
367
+ $settings = get_option( 'wprss_settings' );
368
+ $class = '';
369
+ $open_setting = '';
370
+ $follow_setting = '';
371
+
372
+ switch ( $settings['open_dd'] ) {
373
+
374
+ case 'Lightbox' :
375
+ $class = 'class="colorbox"';
376
+ break;
377
+
378
+ case 'New window' :
379
+ $open_setting = 'target="_blank"';
380
+ break;
381
+ }
382
+
383
+ switch ( $settings['follow_dd'] ) {
384
+
385
+ case 'No follow' :
386
+ $follow_setting = 'rel="nofollow"';
387
+ break;
388
+ }
389
+
390
+ // Parse incoming $args into an array and merge it with $defaults
391
+ $args = wp_parse_args( $args, $defaults );
392
+ // Declare each item in $args as its own variable
393
+ extract( $args, EXTR_SKIP );
394
+
395
+ // Arguments for the next query to fetch all feed items
396
+ $feed_items_args = array(
397
+ 'post_type' => 'wprss_feed_item',
398
+ 'posts_per_page' => $settings['feed_limit'],
399
+ 'orderby' => 'meta_value',
400
+ 'meta_key' => 'wprss_item_date',
401
+ 'order' => 'DESC',
402
+ );
403
+
404
+ // Query to get all feed items for display
405
+ $feed_items = new WP_Query( apply_filters( 'wprss_display_feed_items_query', $feed_items_args ) );
406
+
407
+ if( $feed_items->have_posts() ) {
408
+ echo "$links_before\n";
409
+ while ( $feed_items->have_posts() ) {
410
+ $feed_items->the_post();
411
+ $permalink = get_post_meta( get_the_ID(), 'wprss_item_permalink', true );
412
+ $feed_source_id = get_post_meta( get_the_ID(), 'wprss_feed_id', true );
413
+ $source_name = get_the_title( $feed_source_id );
414
+
415
+ // convert from Unix timestamp
416
+ $date = date( 'Y-m-d', intval( get_post_meta( get_the_ID(), 'wprss_item_date', true ) ) );
417
+ echo "\t\t" . "$link_before" . '<a ' . $class . $open_setting . ' ' . $follow_setting . ' href="'. $permalink . '">'. get_the_title(). '</a><br>' . "\n";
418
+ echo "\t\t".'<span class="feed-source">' . __( "Source: ") . $source_name . ' | ' . $date . '</span>' . "$link_after" . "\n\n";
419
+ }
420
+ echo "\t\t $links_after";
421
+ echo paginate_links();
422
+
423
+ wp_reset_postdata();
424
+
425
+ } else {
426
+ _e( 'No feed items found', 'wprss' );
427
+ }
428
+ } // end wprss_display_feed_items
429
+
430
+
431
+ add_action( 'trash_wprss_feed', 'wprss_delete_feed_items' );
432
+ /**
433
+ * Delete feed items on trashing of corresponding feed source
434
+ *
435
+ * @since 2.0
436
+ */
437
+ function wprss_delete_feed_items() {
438
+ global $post;
439
+
440
+ $args = array(
441
+ 'post_type' => 'wprss_feed_item',
442
+ 'meta_key' => 'wprss_feed_id',
443
+ 'meta_value_num' => $post->ID,
444
+ 'posts_per_page' => -1
445
+ );
446
+
447
+ $feed_items = new WP_Query( $args );
448
+
449
+ if ( $feed_items->have_posts() ) :
450
+ while ( $feed_items->have_posts() ) : $feed_items->the_post();
451
+ $postid = get_the_ID();
452
+
453
+ $purge = wp_delete_post( $postid, true );
454
+ endwhile;
455
+ endif;
456
+
457
+ wp_reset_postdata();
458
+ } // end wprss_delete_feed_items
459
+
460
+
461
+ /**
462
+ * Delete old feed items from the database to avoid bloat
463
+ *
464
+ * @since 2.0
465
+ */
466
+ function wprss_truncate_posts() {
467
+ global $wpdb;
468
+
469
+ // Set your threshold of max posts and post_type name
470
+ $threshold = 50;
471
+ $post_type = 'wprss_feed_item';
472
+
473
+ // Query post type
474
+ // $wpdb query allows me to select specific columns instead of grabbing the entire post object.
475
+ $query = "
476
+ SELECT ID, post_title FROM $wpdb->posts
477
+ WHERE post_type = '$post_type'
478
+ AND post_status = 'publish'
479
+ ORDER BY post_modified DESC
480
+ ";
481
+ $results = $wpdb->get_results( $query );
482
+
483
+ // Check if there are any results
484
+ if ( count( $results ) ){
485
+ foreach ( $results as $post ) {
486
+ $i++;
487
+
488
+ // Skip any posts within our threshold
489
+ if ( $i <= $threshold )
490
+ continue;
491
+
492
+ // Let the WordPress API do the heavy lifting for cleaning up entire post trails
493
+ $purge = wp_delete_post( $post->ID, true );
494
+ }
495
+ }
496
+ } // end wprss_truncate_posts