WP RSS Aggregator - Version 3.1.1

Version Description

Download this release

Release Info

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

Version 3.1.1

Files changed (55) hide show
  1. changelog.txt +84 -0
  2. css/admin-styles.css +194 -0
  3. css/colorbox.css +93 -0
  4. css/styles.css +14 -0
  5. images/colorbox/border.png +0 -0
  6. images/colorbox/controls.png +0 -0
  7. images/colorbox/ie6/borderBottomCenter.png +0 -0
  8. images/colorbox/ie6/borderBottomLeft.png +0 -0
  9. images/colorbox/ie6/borderBottomRight.png +0 -0
  10. images/colorbox/ie6/borderMiddleLeft.png +0 -0
  11. images/colorbox/ie6/borderMiddleRight.png +0 -0
  12. images/colorbox/ie6/borderTopCenter.png +0 -0
  13. images/colorbox/ie6/borderTopLeft.png +0 -0
  14. images/colorbox/ie6/borderTopRight.png +0 -0
  15. images/colorbox/loading.gif +0 -0
  16. images/colorbox/loading_background.png +0 -0
  17. images/colorbox/overlay.png +0 -0
  18. images/facebook.png +0 -0
  19. images/icon-adminmenu16-sprite.png +0 -0
  20. images/icon-adminpage32.png +0 -0
  21. images/twitter.png +0 -0
  22. includes/OPML.php +230 -0
  23. includes/OPMLParser.php +52 -0
  24. includes/admin-ajax-notice.php +78 -0
  25. includes/admin-debugging.php +100 -0
  26. includes/admin-display.php +258 -0
  27. includes/admin-import-export.php +161 -0
  28. includes/admin-metaboxes.php +322 -0
  29. includes/admin-options.php +541 -0
  30. includes/admin.php +111 -0
  31. includes/cron-jobs.php +80 -0
  32. includes/custom-feed.php +56 -0
  33. includes/custom-post-types.php +98 -0
  34. includes/deprecated-functions.php +83 -0
  35. includes/feed-display-new-categories.php +245 -0
  36. includes/feed-display.php +213 -0
  37. includes/feed-processing.php +406 -0
  38. includes/libraries/WP_Logging.php +360 -0
  39. includes/libraries/browser.php +1082 -0
  40. includes/misc-functions.php +30 -0
  41. includes/scripts.php +115 -0
  42. includes/shortcodes.php +20 -0
  43. includes/system-info.php +140 -0
  44. includes/update.php +211 -0
  45. js/admin-custom.js +69 -0
  46. js/custom.js +7 -0
  47. js/jquery.colorbox-min.js +6 -0
  48. languages/default.mo +0 -0
  49. languages/default.po +272 -0
  50. languages/it.mo +0 -0
  51. languages/it.po +274 -0
  52. readme.txt +179 -0
  53. templates/wprss.css +9 -0
  54. uninstall.php +11 -0
  55. wp-rss-aggregator.php +195 -0
changelog.txt ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 3.1.1 (2013-06-06)
2
+ Fixed bug: Incompatibility with some other plugins due to function missing namespace
3
+
4
+ 3.1 (2013-06-06)
5
+ New feature: Option to set the number of feed items imported from every feed (default 5)
6
+ New feature: Import and Export aggregator settings and feed sources
7
+ New feature: Debugging page allowing manual feed refresh and feed reset
8
+ Enhanced: Faster handling of restoring sources from trash when feed limit is 0
9
+ Fixed bug: Limiter on number of overall feeds stored not working
10
+ Fixed bug: Incompatibility issue with Foobox plugin fixed
11
+ Fixed bug: Duplicate feeds sometimes imported
12
+
13
+ 3.0 (2013-03-16)
14
+ New feature: Option to select cron frequency
15
+ New feature: Code extensibility added to be compatible with add-ons
16
+ New feature: Option to set a limit to the number of feeds stored (previously 50, hard coded)
17
+ New feature: Option to define the format of the date shown below each feed item
18
+ New feature: Option to show or hide source of feed item
19
+ New feature: Option to show or hide publish date of feed item
20
+ New feature: Option to set text preceding publish date
21
+ New feature: Option to set text preceding source of feed item
22
+ New feature: Option to link title or not
23
+ New feature: Limit of 5 items imported for each source instead of 10
24
+ Enhanced: Performance improvement when publishing new feeds in admin
25
+ Enhanced: Query tuning for better performance
26
+ Enhanced: Major code rewrite, refactoring and inclusion of hooks
27
+ Enhanced: Updated Colorbox to v1.4.1
28
+ Enhanced: Better security implementations
29
+ Enhanced: Better feed preview display
30
+ Fixed bug: Deletion of items upon source deletion not working properly
31
+ Requires: WordPress 3.3
32
+
33
+ 2.2.3 (2012-11-01)
34
+ Fixed bug: Tab navigation preventing typing in input boxes
35
+ Removed: Feeds showing up in internal linking pop up
36
+
37
+ 2.2.2 (2012-10-30)
38
+ Removed: Feeds showing up in site search results
39
+ Enhanced: Better tab button navigation when adding a new feed
40
+ Enhanced: Better guidance when a feed URL is invalid
41
+
42
+ 2.2.1 (2012-10-17)
43
+ Fixed bug: wprss_feed_source_order assumes everyone is an admin
44
+
45
+ 2.2 (2012-10-01)
46
+ New feature: Italian translation added
47
+ Enhanced: Feed source order changed to alphabetical
48
+ Fixed bug: repeated entries when having a non-valid feed source
49
+ Fixed bug: all imported feeds deleted upon trashing a single feed source
50
+
51
+ 2.1 (2012-09-27)
52
+ New feature: Now localised for translations
53
+ Fixed bug: with date string
54
+ Fixed bug: $link_before and $link_after, now working
55
+ Enhanced: Added backwards compatibility for wp_rss_aggregator() function
56
+
57
+ 2.0 (2012-09-21)
58
+ Bulk of code rewritten and refactored
59
+ Added install and upgrade functions
60
+ Added DB version setting
61
+ Feed sources now stored as Custom Post Types
62
+ Feed source list sortable ascending or descending by name
63
+ Removed days subsections in feed display
64
+ Ability to limit total number of feeds displayed
65
+ Feeds now fetched via Cron
66
+ Cron job to delete old feed items, keeps max of 50 items in DB
67
+ Now requires WordPress 3.2
68
+ updated colorbox to v1.3.20.1
69
+ Limit of 15 items max imported for each source
70
+ Fixed issue of page content displaying incorrectly after feeds
71
+
72
+ 1.1 (2012-08-13)
73
+ Now requires WordPress 3.0
74
+ More flexible fetching of images directory
75
+ Has its own top level menu item
76
+ Added settings section
77
+ Ability to open in lightbox, new window or default browser behaviour
78
+ Ability to set links as follow or no follow
79
+ Using constants for oftenly used locations
80
+ Code refactoring
81
+ Changes in file and folder structure
82
+
83
+ 1.0 (2012-01-06)
84
+ First release
css/admin-styles.css ADDED
@@ -0,0 +1,194 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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( '../images/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('../images/twitter.png') no-repeat 0;
53
+ padding-left: 20px;
54
+ }
55
+
56
+ li.facebook a {
57
+ background: transparent url('../images/facebook.png') no-repeat 0;
58
+ padding-left: 20px;
59
+ }
60
+
61
+ li.donate_link a:hover {
62
+ color: darkGreen;
63
+ }
64
+
65
+ #preview_meta_box ul {
66
+ list-style: disc;
67
+ margin-left: 16px;
68
+ }
69
+
70
+ #preview_meta_box .invalid-feed-url {
71
+ color: red;
72
+ }
73
+
74
+ #preview_meta_box .rss-date {
75
+ color: #666;
76
+
77
+ }
78
+
79
+ /*.rss-aggregator_page_wprss-aggregator-settings .form-table th { width: 80px; }*/
80
+
81
+
82
+ /* For excerpts and thumbnails admin screens */
83
+ .wprss_feed_page_wprss-aggregator-settings input,
84
+ .wprss_feed_page_wprss-aggregator-settings input[type="checkbox"],
85
+ .wprss_feed_page_wprss-aggregator-settings input[type="radio"] {
86
+ margin-right: 8px;
87
+ }
88
+
89
+ input#default-thumbnail { width: 300px; }
90
+
91
+ input#thumbnails-height,
92
+ input#thumbnails-width {
93
+ /*width: 29px;*/
94
+ }
95
+
96
+
97
+ /* Red Button */
98
+
99
+ .wp-core-ui .button-red {
100
+ background-color: #9B2124;
101
+ background-image: -webkit-gradient(linear, left top, left bottom, from(#C5292E), to(#9B2124));
102
+ background-image: -webkit-linear-gradient(top, #C5292E, #9B2124);
103
+ background-image: -moz-linear-gradient(top, #C5292E, #9B2124);
104
+ background-image: -ms-linear-gradient(top, #C5292E, #9B2124);
105
+ background-image: -o-linear-gradient(top, #C5292E, #9B2124);
106
+ background-image: linear-gradient(to bottom, #C5292E, #9B2124);
107
+ border-color: #9B2124;
108
+ border-bottom-color: #8D1F21;
109
+ -webkit-box-shadow: inset 0 1px 0 rgba(120,200,230,0.5);
110
+ box-shadow: inset 0 1px 0 rgba(120,200,230,0.5);
111
+ color: #fff;
112
+ text-decoration: none;
113
+ text-shadow: 0 1px 0 rgba(0,0,0,0.1);
114
+ /*float: right;*/
115
+ }
116
+
117
+ .wp-core-ui .button-red.hover,
118
+ .wp-core-ui .button-red:hover,
119
+ .wp-core-ui .button-red.focus,
120
+ .wp-core-ui .button-red:focus {
121
+ background-color: #B72629;
122
+ background-image: -webkit-gradient(linear, left top, left bottom, from(#D22E30), to(#9B2124));
123
+ background-image: -webkit-linear-gradient(top, #D22E30, #9B2124);
124
+ background-image: -moz-linear-gradient(top, #D22E30, #9B2124);
125
+ background-image: -ms-linear-gradient(top, #D22E30, #9B2124);
126
+ background-image: -o-linear-gradient(top, #D22E30, #9B2124);
127
+ background-image: linear-gradient(to bottom, #D22E30, #9B2124);
128
+ border-color: #7F1C1F;
129
+ -webkit-box-shadow: inset 0 1px 0 rgba(120,200,230,0.6);
130
+ box-shadow: inset 0 1px 0 rgba(120,200,230,0.6);
131
+ color: #fff;
132
+ text-shadow: 0 -1px 0 rgba(0,0,0,0.3);
133
+ }
134
+
135
+ .wp-core-ui .button-red.focus,
136
+ .wp-core-ui .button-red:focus {
137
+ border-color: #500F0E;
138
+ -webkit-box-shadow: inset 0 1px 0 rgba(120,200,230,0.6), 1px 1px 2px rgba(0,0,0,0.4);
139
+ box-shadow: inset 0 1px 0 rgba(120,200,230,0.6), 1px 1px 2px rgba(0,0,0,0.4);
140
+ }
141
+
142
+ .wp-core-ui .button-red.active,
143
+ .wp-core-ui .button-red.active:hover,
144
+ .wp-core-ui .button-red.active:focus,
145
+ .wp-core-ui .button-red:active {
146
+ background: #7F1C1F;
147
+ background-image: -webkit-gradient(linear, left top, left bottom, from(#9B2124), to(#B72629));
148
+ background-image: -webkit-linear-gradient(top, #9B2124, #B72629);
149
+ background-image: -moz-linear-gradient(top, #9B2124, #B72629);
150
+ background-image: -ms-linear-gradient(top, #9B2124, #B72629);
151
+ background-image: -o-linear-gradient(top, #9B2124, #B72629);
152
+ background-image: linear-gradient(to bottom, #9B2124, #B72629);
153
+ border-color: #601312 #AE2426 #AE2426 #AE2426;
154
+ color: rgba(255,255,255,0.95);
155
+ -webkit-box-shadow: inset 0 1px 0 rgba(0,0,0,0.1);
156
+ box-shadow: inset 0 1px 0 rgba(0,0,0,0.1);
157
+ text-shadow: 0 1px 0 rgba(0,0,0,0.1);
158
+ }
159
+
160
+ .wp-core-ui .button-red[disabled],
161
+ .wp-core-ui .button-red:disabled,
162
+ .wp-core-ui .button-red-disabled {
163
+ color: #E79496 !important;
164
+ background: #BA292B !important;
165
+ border-color: #7F1C1F !important;
166
+ -webkit-box-shadow: none !important;
167
+ box-shadow: none !important;
168
+ text-shadow: 0 -1px 0 rgba(0,0,0,0.1) !important;
169
+ cursor: default;
170
+ }
171
+
172
+ #system-info-textarea {
173
+ width: 800px;
174
+ height: 400px;
175
+ font-family: Menlo, Monaco, monospace;
176
+ background: none;
177
+ white-space: pre;
178
+ overflow: auto;
179
+ display: block;
180
+ }
181
+
182
+
183
+
184
+ /* Excerpts and Thumbnails */
185
+
186
+ input#thumbnails-height,
187
+ input#thumbnails-width {
188
+ margin-right: 2px;
189
+ }
190
+
191
+ label[for=thumbnails-height],
192
+ label[for=thumbnails-width] {
193
+ margin-left: 8px;
194
+ }
css/colorbox.css ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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; -webkit-overflow-scrolling: touch;}
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; -moz-box-sizing:content-box; -webkit-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(../images/colorbox/overlay.png) repeat 0 0;}
23
+ #colorbox{outline:0;}
24
+ #cboxTopLeft{width:21px; height:21px; background:url(../images/colorbox/controls.png) no-repeat -101px 0;}
25
+ #cboxTopRight{width:21px; height:21px; background:url(../images/colorbox/controls.png) no-repeat -130px 0;}
26
+ #cboxBottomLeft{width:21px; height:21px; background:url(../images/colorbox/controls.png) no-repeat -101px -29px;}
27
+ #cboxBottomRight{width:21px; height:21px; background:url(../images/colorbox/controls.png) no-repeat -130px -29px;}
28
+ #cboxMiddleLeft{width:21px; background:url(../images/colorbox/controls.png) left top repeat-y;}
29
+ #cboxMiddleRight{width:21px; background:url(../images/colorbox/controls.png) right top repeat-y;}
30
+ #cboxTopCenter{height:21px; background:url(../images/colorbox/border.png) 0 0 repeat-x;}
31
+ #cboxBottomCenter{height:21px; background:url(../images/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
+ #cboxLoadingOverlay{background:url(../images/colorbox/loading_background.png) no-repeat center center;}
39
+ #cboxLoadingGraphic{background:url(../images/colorbox/loading.gif) no-repeat center center;}
40
+
41
+ /* these elements are buttons, and may need to have additional styles reset to avoid unwanted base styles */
42
+ #cboxPrevious, #cboxNext, #cboxSlideshow, #cboxClose {border:0; padding:0; margin:0; overflow:visible; width:auto; background:none; }
43
+
44
+ /* avoid outlines on :active (mouseclick), but preserve outlines on :focus (tabbed navigating) */
45
+ #cboxPrevious:active, #cboxNext:active, #cboxSlideshow:active, #cboxClose:active {outline:0;}
46
+
47
+ #cboxSlideshow{position:absolute; bottom:4px; right:30px; color:#0092ef;}
48
+ #cboxPrevious{position:absolute; bottom:0; left:0; background:url(../images/colorbox/controls.png) no-repeat -75px 0; width:25px; height:25px; text-indent:-9999px;}
49
+ #cboxPrevious:hover{background-position:-75px -25px;}
50
+ #cboxNext{position:absolute; bottom:0; left:27px; background:url(../images/colorbox/controls.png) no-repeat -50px 0; width:25px; height:25px; text-indent:-9999px;}
51
+ #cboxNext:hover{background-position:-50px -25px;}
52
+ #cboxClose{position:absolute; bottom:0; right:0; background:url(../images/colorbox/controls.png) no-repeat -25px 0; width:25px; height:25px; text-indent:-9999px;}
53
+ #cboxClose:hover{background-position:-25px -25px;}
54
+
55
+ /*
56
+ The following fixes a problem where IE7 and IE8 replace a PNG's alpha transparency with a black fill
57
+ when an alpha filter (opacity change) is set on the element or ancestor element. This style is not applied to or needed in IE9.
58
+ See: http://jacklmoore.com/notes/ie-transparency-problems/
59
+ */
60
+ .cboxIE #cboxTopLeft,
61
+ .cboxIE #cboxTopCenter,
62
+ .cboxIE #cboxTopRight,
63
+ .cboxIE #cboxBottomLeft,
64
+ .cboxIE #cboxBottomCenter,
65
+ .cboxIE #cboxBottomRight,
66
+ .cboxIE #cboxMiddleLeft,
67
+ .cboxIE #cboxMiddleRight {
68
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#00FFFFFF,endColorstr=#00FFFFFF);
69
+ }
70
+
71
+ /*
72
+ The following provides PNG transparency support for IE6
73
+ Feel free to remove this and the /ie6/ directory if you have dropped IE6 support.
74
+ */
75
+ .cboxIE6 #cboxTopLeft{background:url(../images/colorbox/ie6/borderTopLeft.png);}
76
+ .cboxIE6 #cboxTopCenter{background:url(../images/colorbox/ie6/borderTopCenter.png);}
77
+ .cboxIE6 #cboxTopRight{background:url(../images/colorbox/ie6/borderTopRight.png);}
78
+ .cboxIE6 #cboxBottomLeft{background:url(../images/colorbox/ie6/borderBottomLeft.png);}
79
+ .cboxIE6 #cboxBottomCenter{background:url(../images/colorbox/ie6/borderBottomCenter.png);}
80
+ .cboxIE6 #cboxBottomRight{background:url(../images/colorbox/ie6/borderBottomRight.png);}
81
+ .cboxIE6 #cboxMiddleLeft{background:url(../images/colorbox/ie6/borderMiddleLeft.png);}
82
+ .cboxIE6 #cboxMiddleRight{background:url(../images/colorbox/ie6/borderMiddleRight.png);}
83
+
84
+ .cboxIE6 #cboxTopLeft,
85
+ .cboxIE6 #cboxTopCenter,
86
+ .cboxIE6 #cboxTopRight,
87
+ .cboxIE6 #cboxBottomLeft,
88
+ .cboxIE6 #cboxBottomCenter,
89
+ .cboxIE6 #cboxBottomRight,
90
+ .cboxIE6 #cboxMiddleLeft,
91
+ .cboxIE6 #cboxMiddleRight {
92
+ _behavior: expression(this.src = this.src ? this.src : this.currentStyle.backgroundImage.split('"')[1], this.style.background = "none", this.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=" + this.src + ", sizingMethod='scale')");
93
+ }
css/styles.css ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ li.feed-item { margin-bottom: 10px; }
2
+
3
+ .thumbnail-excerpt {
4
+ overflow:hidden;
5
+ margin-bottom: 5px;
6
+ }
7
+
8
+ .thumbnail-excerpt img {
9
+ max-width:100%; float:left; margin-top: 0.5em; margin-right:10px;
10
+ }
11
+
12
+ div.source-date { clear: both; }
13
+
14
+ span.feed-source { font-size: 90%; }
images/colorbox/border.png ADDED
Binary file
images/colorbox/controls.png ADDED
Binary file
images/colorbox/ie6/borderBottomCenter.png ADDED
Binary file
images/colorbox/ie6/borderBottomLeft.png ADDED
Binary file
images/colorbox/ie6/borderBottomRight.png ADDED
Binary file
images/colorbox/ie6/borderMiddleLeft.png ADDED
Binary file
images/colorbox/ie6/borderMiddleRight.png ADDED
Binary file
images/colorbox/ie6/borderTopCenter.png ADDED
Binary file
images/colorbox/ie6/borderTopLeft.png ADDED
Binary file
images/colorbox/ie6/borderTopRight.png ADDED
Binary file
images/colorbox/loading.gif ADDED
Binary file
images/colorbox/loading_background.png ADDED
Binary file
images/colorbox/overlay.png ADDED
Binary file
images/facebook.png ADDED
Binary file
images/icon-adminmenu16-sprite.png ADDED
Binary file
images/icon-adminpage32.png ADDED
Binary file
images/twitter.png ADDED
Binary file
includes/OPML.php ADDED
@@ -0,0 +1,230 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Adapted from the Feast plugin by Ryan McCue https://github.com/rmccue/Feast
5
+ */
6
+
7
+ if ( ! class_exists( 'WP_Importer' ) ) {
8
+ $class_wp_importer = ABSPATH . 'wp-admin/includes/class-wp-importer.php';
9
+ if ( file_exists( $class_wp_importer ) )
10
+ require $class_wp_importer;
11
+ }
12
+
13
+ //add_action( 'admin_init', 'bootstrap' );
14
+ /**
15
+ * OPML-to-WPRSS importer
16
+ *
17
+ * @package Lilina
18
+ */
19
+ class WPRSS_Import_OPML extends WP_Importer {
20
+ public static function bootstrap() {
21
+ $importer = new WPRSS_Import_OPML();
22
+ register_importer( 'wprss-opml', 'WP RSS Aggregator - OPML', __( 'Import <strong>feeds</strong> from an OPML export file.', 'wprss' ), array( $importer, 'dispatch' ) );
23
+ }
24
+
25
+ /**
26
+ * Registered callback function for the WordPress Importer
27
+ *
28
+ * Manages the three separate stages of the WXR import process
29
+ */
30
+ public function dispatch() {
31
+ $this->header();
32
+
33
+ $step = empty( $_GET['step'] ) ? 0 : (int) $_GET['step'];
34
+ switch($step) {
35
+ case 0:
36
+ $this->introduction();
37
+ break;
38
+ case 1:
39
+ check_admin_referer( 'import-upload' );
40
+ if ( $this->handle_upload() ) {
41
+ $file = get_attached_file( $this->id );
42
+ set_time_limit(0);
43
+ $this->import( $file );
44
+ }
45
+ break;
46
+ }
47
+
48
+ $this->footer();
49
+ }
50
+
51
+ protected function introduction() {
52
+ echo '<div class="narrow">';
53
+ echo '<p>'.__( 'Howdy! Upload your OPML file and we&#8217;ll import your feeds into this site.', 'feast' ).'</p>';
54
+ echo '<p>'.__( 'Choose an OPML (.xml) file to upload, then click Upload file and import.', 'feast' ).'</p>';
55
+ wp_import_upload_form( 'admin.php?import=wprss-opml&amp;step=1' );
56
+ echo '</div>';
57
+ }
58
+
59
+ /**
60
+ * Handles the WXR upload and initial parsing of the file to prepare for
61
+ * displaying author import options
62
+ *
63
+ * @return bool False if error uploading or invalid file, true otherwise
64
+ */
65
+ protected function handle_upload() {
66
+ $file = wp_import_handle_upload();
67
+
68
+ if ( isset( $file['error'] ) ) {
69
+ echo '<p><strong>' . __( 'Sorry, there has been an error.', 'wprss' ) . '</strong><br />';
70
+ echo esc_html( $file['error'] ) . '</p>';
71
+ return false;
72
+ } else if ( ! file_exists( $file['file'] ) ) {
73
+ echo '<p><strong>' . __( 'Sorry, there has been an error.', 'wprss' ) . '</strong><br />';
74
+ printf( __( 'The export file could not be found at <code>%s</code>. It is likely that this was caused by a permissions problem.', 'wprss' ), esc_html( $file['file'] ) );
75
+ echo '</p>';
76
+ return false;
77
+ }
78
+
79
+ $this->id = (int) $file['id'];
80
+ return true;
81
+ }
82
+
83
+ /**
84
+ * The main controller for the actual import stage.
85
+ *
86
+ * @param string $file Path to the WXR file for importing
87
+ */
88
+ protected function import( $file ) {
89
+ add_filter( 'http_request_timeout', array( &$this, 'bump_request_timeout' ) );
90
+
91
+ $this->import_start( $file );
92
+
93
+ wp_suspend_cache_invalidation( true );
94
+ $this->process_feeds();
95
+ wp_suspend_cache_invalidation( false );
96
+
97
+ $this->import_end();
98
+ }
99
+
100
+ /**
101
+ * Parses the WXR file and prepares us for the task of processing parsed data
102
+ *
103
+ * @param string $file Path to the WXR file for importing
104
+ */
105
+ protected function import_start( $file ) {
106
+ if ( ! is_file( $file ) ) {
107
+ echo '<p><strong>' . __( 'Sorry, there has been an error.', 'feast' ) . '</strong><br />';
108
+ echo __( 'The file does not exist, please try again.', 'feast' ) . '</p>';
109
+ $this->footer();
110
+ die();
111
+ }
112
+
113
+ $import_data = $this->parse( file_get_contents( $file ) );
114
+
115
+ if ( is_wp_error( $import_data ) ) {
116
+ echo '<p><strong>' . __( 'Sorry, there has been an error.', 'feast' ) . '</strong><br />';
117
+ echo esc_html( $import_data->get_error_message() ) . '</p>';
118
+ $this->footer();
119
+ die();
120
+ }
121
+
122
+ $this->feeds = $import_data;
123
+
124
+ do_action( 'wprss_import_start' );
125
+ }
126
+
127
+ /**
128
+ * Parse an OPML file
129
+ *
130
+ * @param string $file Path to OPML file for parsing
131
+ * @return array Information gathered from the OPML file
132
+ */
133
+ protected function parse( $data ) {
134
+ $parsed = new WPRSS_OPMLParser( $data );
135
+
136
+ if ( ! empty( $parsed->error ) || empty( $parsed->data ) ) {
137
+ return new WP_Error( 'wprss_import_opml_failedparse', sprintf( __( 'The OPML file could not be read. The parser said: %s', 'wprss' ), $parsed->error ) );
138
+ }
139
+
140
+ return $this->massage_data( $parsed->data );
141
+ }
142
+
143
+ /**
144
+ * Transform the result of the parsed OPML into corrected data
145
+ *
146
+ * @return array
147
+ */
148
+ protected function massage_data( $feeds, $category = array() ) {
149
+ $parsed = array();
150
+
151
+ foreach ( $feeds as $name => $feed ) {
152
+ if ( ! isset( $feed['xmlurl'] ) ) {
153
+ if ( ! empty( $name ) )
154
+ array_push( $category, $name );
155
+
156
+ $feed = $this->massage_data($feed, $new_cat);
157
+ $parsed = array_merge($parsed, $feed);
158
+ }
159
+ else {
160
+ $parsed[] = array(
161
+ 'url' => $feed['xmlurl'],
162
+ 'title' => $feed['title'],
163
+ 'category' => $category
164
+ );
165
+ }
166
+ }
167
+
168
+ return $parsed;
169
+ }
170
+
171
+ /**
172
+ * Create new posts based on import information
173
+ *
174
+ * Posts marked as having a parent which doesn't exist will become top level items.
175
+ * Doesn't create a new post if: the post type doesn't exist, the given post ID
176
+ * is already noted as imported or a post with the same title and date already exists.
177
+ * Note that new/updated terms, comments and meta are imported for the last of the above.
178
+ */
179
+ protected function process_feeds() {
180
+ foreach ( $this->feeds as $feed ) {
181
+ $data = array(
182
+ 'name' => $feed['title'],
183
+ 'content' => '',
184
+ 'excerpt' => '',
185
+ 'feast_feed_url' => $feed['url'],
186
+ 'feast_sp' => fetch_feed($feed['url']),
187
+ );
188
+ $feed_obj = Feast_Feed::create($data);
189
+ }
190
+
191
+ unset( $this->feeds );
192
+ }
193
+
194
+ /**
195
+ * Performs post-import cleanup of files and the cache
196
+ */
197
+ protected function import_end() {
198
+ wp_import_cleanup( $this->id );
199
+
200
+ wp_cache_flush();
201
+
202
+ echo '<p>' . __( 'All done.', 'wprss' ) . ' <a href="' . admin_url() . '">' . __( 'Have fun!', 'wprss' ) . '</a>' . '</p>';
203
+
204
+ do_action( 'wprss_import_end' );
205
+ }
206
+
207
+ /**
208
+ * Display import page title
209
+ */
210
+ protected function header() {
211
+ echo '<div class="wrap">';
212
+ screen_icon();
213
+ echo '<h2>' . __( 'Import OPML', 'wprss' ) . '</h2>';
214
+ }
215
+
216
+ /**
217
+ * Close div.wrap
218
+ */
219
+ protected function footer() {
220
+ echo '</div>';
221
+ }
222
+
223
+ /**
224
+ * Added to http_request_timeout filter to force timeout at 60 seconds during import
225
+ * @return int 60
226
+ */
227
+ public function bump_request_timeout() {
228
+ return 60;
229
+ }
230
+ }
includes/OPMLParser.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class WPRSS_OPMLParser {
4
+ public $data = array();
5
+ public $raw = '';
6
+ public $error = '';
7
+
8
+ public function __construct( $raw_data ) {
9
+ $this->raw = $raw_data;
10
+ // Create an XML parser
11
+ try {
12
+ $xml_parser = new SimpleXMLElement( $this->raw, LIBXML_NOERROR );
13
+
14
+ $this->data = $this->loop( $xml_parser->body->outline );
15
+ }
16
+ catch ( Exception $e ) {
17
+ $this->error = $e->getMessage();
18
+ return;
19
+ }
20
+ }
21
+
22
+ protected function loop( $element ) {
23
+ $data = array();
24
+
25
+ foreach ($element as $element) {
26
+ if ( $element['type'] == 'rss' || isset( $element['xmlUrl'] ) ) {
27
+ $data[] = $this->format( $element );
28
+ }
29
+ elseif ( $element->outline ) {
30
+ $data[ (string) $element['text'] ] = $this->loop( $element->outline );
31
+ }
32
+ }
33
+
34
+ return $data;
35
+ }
36
+
37
+ /**
38
+ * Return an array from a supplied SimpleXMLElement object
39
+ *
40
+ * @param SimpleXMLElement $element
41
+ * @return array
42
+ */
43
+ protected function format( $element ) {
44
+ return array(
45
+ 'htmlurl' => (string) $element['htmlUrl'],
46
+ 'xmlurl' => (string) $element['xmlUrl'],
47
+ 'text' => (string) $element['text'],
48
+ 'title' => (string) $element['title'],
49
+ 'description' => (string) $element['description'],
50
+ );
51
+ }
52
+ }
includes/admin-ajax-notice.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Serves up a notice to leave a review for this plugin
5
+ *
6
+ * @link http://wp.tutsplus.com/tutorials/creative-coding/a-primer-on-ajax-in-the-wordpress-dashboard-requesting-and-responding/
7
+ * @link http://wptheming.com/2011/08/admin-notices-in-wordpress/
8
+ *
9
+ * @since 3.0
10
+ *
11
+ */
12
+
13
+
14
+ add_action( 'admin_init', 'wprss_admin_notice' );
15
+ /**
16
+ * Serves up a notice to leave a review for this plugin
17
+ *
18
+ * @since 3.0
19
+ */
20
+ function wprss_admin_notice() {
21
+ global $pagenow, $typenow;
22
+ if ( empty( $typenow ) && !empty( $_GET['post'] ) ) {
23
+ $post = get_post( $_GET['post'] );
24
+ $typenow = $post->post_type;
25
+ }
26
+ $notices_settings = get_option( 'wprss_settings_notices' );
27
+
28
+ // Display the admin notice only if it hasn't been hidden and we are on a screen of WP RSS Aggregator
29
+ if ( ( false == $notices_settings ) && ( ( $typenow == 'wprss_feed' ) || ( $typenow == 'wprss_feed_item' ) ) ) {
30
+ add_action( 'admin_notices', 'wprss_display_admin_notice' );
31
+ }
32
+
33
+ }
34
+
35
+
36
+ /**
37
+ * Renders the administration notice. Also renders a hidden nonce used for security when processing the Ajax request.
38
+ *
39
+ * @since 3.0
40
+ */
41
+ function wprss_display_admin_notice() {
42
+
43
+ $html = '<div id="ajax-notification" class="updated">';
44
+ $html .= '<p>';
45
+ $html .= __( 'If you like this RSS Aggregator plugin, please <a target="_blank" href="http://wordpress.org/support/view/plugin-reviews/wp-rss-aggregator">give it a good rating and leave a review</a>. Your feedback will help me improve this plugin further. Thank you. <a href="javascript:;"
46
+ id="dismiss-ajax-notification" style="float:right;">Dismiss this notification</a>', 'wprss' );
47
+ $html .= '</p>';
48
+ $html .= '<span id="ajax-notification-nonce" class="hidden">' . wp_create_nonce( 'ajax-notification-nonce' ) . '</span>';
49
+ $html .= '</div><!-- /.updated -->';
50
+
51
+ echo $html;
52
+ }
53
+
54
+
55
+ add_action( 'wp_ajax_wprss_hide_admin_notification', 'wprss_hide_admin_notification' );
56
+ /**
57
+ * JavaScript callback used to hide the administration notice when the 'Dismiss' anchor is clicked on the front end.
58
+ *
59
+ * @since 3.0
60
+ */
61
+ function wprss_hide_admin_notification() {
62
+
63
+ // First, check the nonce to make sure it matches what we created when displaying the message.
64
+ // If not, we won't do anything.
65
+ if( wp_verify_nonce( $_REQUEST['nonce'], 'ajax-notification-nonce' ) ) {
66
+
67
+ // If the update to the option is successful, send 1 back to the browser;
68
+ // Otherwise, send 0.
69
+ $general_settings = get_option( 'wprss_settings_notices' );
70
+ $general_settings = true;
71
+
72
+ if( update_option( 'wprss_settings_notices', $general_settings ) ) {
73
+ die( '1' );
74
+ } else {
75
+ die( '0' );
76
+ }
77
+ }
78
+ }
includes/admin-debugging.php ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Plugin debugging
4
+ *
5
+ * @package WPRSSAggregator
6
+ * @subpackage Includes
7
+ * @since 3.0
8
+ * @author Jean Galea <info@jeangalea.com>
9
+ * @copyright Copyright(c) 2012-2013, Jean Galea
10
+ * @link http://www.wpmayor.com
11
+ * @license http://www.gnu.org/licenses/gpl.html
12
+ */
13
+
14
+ //allow redirection, even if my theme starts to send output to the browser
15
+ add_action( 'admin_init', 'wprss_do_output_buffer' );
16
+ function wprss_do_output_buffer() {
17
+ ob_start();
18
+ }
19
+
20
+ /**
21
+ * Build the debugging page
22
+ *
23
+ * @since 3.0
24
+ */
25
+ function wprss_debugging_page_display() {
26
+ // If page loading after having clicked 'Update all fields'
27
+ if ( isset( $_POST['update-feeds'] ) && check_admin_referer( 'wprss-update-feed-items' ) ) {
28
+ wprss_fetch_insert_all_feed_items();
29
+ wp_redirect( "edit.php?post_type=wprss_feed&page=wprss-debugging&debug_message=1" );
30
+ }
31
+
32
+ // If page loading after having clicked 'Delete and re-import all fields'
33
+ else if ( isset( $_POST['reimport-feeds'] ) && check_admin_referer( 'wprss-delete-import-feed-items' ) ) {
34
+ wprss_feed_reset();
35
+ wp_redirect( "edit.php?post_type=wprss_feed&page=wprss-debugging&debug_message=2" );
36
+ }
37
+ ?>
38
+
39
+ <div class="wrap">
40
+ <?php screen_icon( 'wprss-aggregator' ); ?>
41
+
42
+ <h2><?php _e( 'Debugging', 'wprss' ); ?></h2>
43
+ <?php
44
+ if ( isset( $_GET['debug_message'] )) {//&& ( check_admin_referer( 'wprss-delete-import-feed-items' ) || check_admin_referer( 'wprss-update-feed-items' ) ) ) {
45
+ $message = $_GET['debug_message'];
46
+
47
+ switch ( $message ) {
48
+ case 1 :
49
+ wprss_debugging_admin_notice_update_feeds();
50
+ break;
51
+ case 2 :
52
+ wprss_debugging_admin_notice_reimport_feeds();
53
+ break;
54
+ }
55
+ } ?>
56
+ <h3><?php _e( 'Update All Feeds Now', 'wprss' ); ?></h3>
57
+ <p><?php _e( 'Click the blue button to update all feed items now. This will check all feed sources for any new feed items.', 'wprss' ); ?>
58
+ <br><?php _e( 'Existing feed items will not be modified.', 'wprss' ); ?>
59
+ </p>
60
+ <p><?php _e( '<strong>Note:</strong> This might take more than a few seconds if you have many feed sources.', 'wprss' ); ?></p>
61
+
62
+ <form action="edit.php?post_type=wprss_feed&page=wprss-debugging" method="post">
63
+
64
+ <?php wp_nonce_field( 'wprss-update-feed-items' );
65
+ submit_button( __( 'Update all feeds', 'wprss' ), 'primary', 'update-feeds', true ); ?>
66
+
67
+ </form>
68
+
69
+ <h3><?php _e( 'Delete and Re-import Feeds', 'wprss' ); ?></h3>
70
+ <p><?php _e( 'Click the red button to delete all imported feed items and re-import them.', 'wprss' ); ?></p>
71
+ <p><?php _e( '<em><strong>Note:</strong> This is a server-intensive process and should only be used when instructed to by support staff.</em>', 'wprss' ); ?></p>
72
+
73
+ <form action="edit.php?post_type=wprss_feed&page=wprss-debugging" method="post">
74
+
75
+ <?php wp_nonce_field( 'wprss-delete-import-feed-items' );
76
+ submit_button( __( 'Delete and Re-import all feeds', 'wprss' ), 'button-red', 'reimport-feeds', true ); ?>
77
+
78
+ </form>
79
+ <?php wprss_system_info(); ?>
80
+ </div>
81
+ <?php
82
+ }
83
+
84
+ /**
85
+ * Output admin notice that feeds have been updated successfully
86
+ *
87
+ * @since 3.0
88
+ */
89
+ function wprss_debugging_admin_notice_update_feeds() {
90
+ echo '<div class="updated"><p>Feeds have been updated successfully.</p></div>';
91
+ }
92
+
93
+ /**
94
+ * Output admin notice that feeds have been deleted and re-imported successfully
95
+ *
96
+ * @since 3.0
97
+ */
98
+ function wprss_debugging_admin_notice_reimport_feeds() {
99
+ echo '<div class="updated"><p>Feeds deleted and re-imported successfully.</p></div>';
100
+ }
includes/admin-display.php ADDED
@@ -0,0 +1,258 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ add_filter( 'manage_edit-wprss_feed_columns', 'wprss_set_feed_custom_columns');
4
+ /**
5
+ * Set up the custom columns for the wprss_feed list
6
+ *
7
+ * @since 2.0
8
+ */
9
+ function wprss_set_feed_custom_columns( $columns ) {
10
+
11
+ $columns = array(
12
+ 'cb' => '<input type="checkbox" />',
13
+ 'title' => __( 'Name', 'wprss' ),
14
+ 'url' => __( 'URL', 'wprss' ),
15
+ 'description' => __( 'Description', 'wprss' ),
16
+ );
17
+ return apply_filters( 'wprss_set_feed_custom_columns', $columns );
18
+ }
19
+
20
+
21
+ add_action( "manage_wprss_feed_posts_custom_column", "wprss_show_custom_columns", 10, 2 );
22
+ /**
23
+ * Show up the custom columns for the wprss_feed list
24
+ *
25
+ * @since 2.0
26
+ */
27
+ function wprss_show_custom_columns( $column, $post_id ) {
28
+
29
+ switch ( $column ) {
30
+ case 'url':
31
+ $url = get_post_meta( $post_id, 'wprss_url', true);
32
+ echo '<a href="' . esc_url($url) . '">' . esc_url($url) . '</a>';
33
+ break;
34
+ case 'description':
35
+ $description = get_post_meta( $post_id, 'wprss_description', true);
36
+ echo esc_html( $description );
37
+ break;
38
+ }
39
+ }
40
+
41
+
42
+ /**
43
+ * Make the custom columns sortable for wprss_feed post type
44
+ *
45
+ * @since 2.0
46
+ */
47
+ function wprss_feed_sortable_columns() {
48
+ $sortable_columns = array(
49
+ // meta column id => sortby value used in query
50
+ 'title' => 'title',
51
+ );
52
+ return apply_filters( 'wprss_feed_sortable_columns', $sortable_columns );
53
+ }
54
+
55
+
56
+ add_action( 'pre_get_posts', 'wprss_feed_source_order' );
57
+ /**
58
+ * Change order of feed sources to alphabetical ascending according to feed name
59
+ *
60
+ * @since 2.2
61
+ */
62
+ function wprss_feed_source_order( $query ) {
63
+ if ( ! is_admin() ) {
64
+ return;
65
+ }
66
+
67
+ $post_type = $query->get('post_type');
68
+
69
+ if ( $post_type == 'wprss_feed' ) {
70
+ /* Post Column: e.g. title */
71
+ if ( $query->get( 'orderby' ) == '' ) {
72
+ $query->set( 'orderby', 'title' );
73
+ }
74
+ /* Post Order: ASC / DESC */
75
+ if( $query->get( 'order' ) == '' ){
76
+ $query->set( 'order', 'ASC' );
77
+ }
78
+ }
79
+ }
80
+
81
+
82
+ add_filter( 'manage_edit-wprss_feed_item_columns', 'wprss_set_feed_item_custom_columns');
83
+ /**
84
+ * Set up the custom columns for the wprss_feed source list
85
+ *
86
+ * @since 2.0
87
+ */
88
+ function wprss_set_feed_item_custom_columns( $columns ) {
89
+
90
+ $columns = array (
91
+ 'cb' => '<input type="checkbox" />',
92
+ 'title' => __( 'Name', 'wprss' ),
93
+ 'permalink' => __( 'Permalink', 'wprss' ),
94
+ 'publishdate' => __( 'Date published', 'wprss' ),
95
+ 'source' => __( 'Source', 'wprss' )
96
+ );
97
+ return apply_filters( 'wprss_set_feed_item_custom_columns', $columns );
98
+ }
99
+
100
+
101
+ add_action( "manage_wprss_feed_item_posts_custom_column", "wprss_show_feed_item_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_feed_item_custom_columns( $column, $post_id ) {
108
+
109
+ switch ( $column ) {
110
+ case "permalink":
111
+ $url = get_post_meta( $post_id, 'wprss_item_permalink', true);
112
+ echo '<a href="' . $url . '">' . $url. '</a>';
113
+ break;
114
+
115
+ case "publishdate":
116
+ $publishdate = date( 'Y-m-d H:i:s', get_post_meta( get_the_ID(), 'wprss_item_date', true ) ) ;
117
+ echo $publishdate;
118
+ break;
119
+
120
+ case "source":
121
+ $query = new WP_Query();
122
+ $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>';
123
+ echo $source;
124
+ break;
125
+ }
126
+ }
127
+
128
+
129
+ add_filter( "manage_edit-wprss_feed_item_sortable_columns", "wprss_feed_item_sortable_columns" );
130
+ /**
131
+ * Make the custom columns sortable
132
+ *
133
+ * @since 2.0
134
+ */
135
+ function wprss_feed_item_sortable_columns() {
136
+ $sortable_columns = array(
137
+ // meta column id => sortby value used in query
138
+ 'publishdate' => 'publishdate',
139
+ 'source' => 'source'
140
+ );
141
+ return apply_filters( 'wprss_feed_item_sortable_columns', $sortable_columns );
142
+ }
143
+
144
+
145
+ add_action( 'pre_get_posts', 'wprss_feed_item_orderby' );
146
+ /**
147
+ * Change ordering of posts on wprss_feed_item screen
148
+ *
149
+ * @since 2.0
150
+ */
151
+ function wprss_feed_item_orderby( $query ) {
152
+ if( ! is_admin() )
153
+ return;
154
+
155
+ $post_type = $query->get('post_type');
156
+
157
+ // If we're on the feed listing admin page
158
+ if ( $post_type == 'wprss_feed_item') {
159
+ // Set general orderby to date the feed item was published
160
+ $query->set('orderby','publishdate');
161
+ // If user clicks on the reorder link, implement reordering
162
+ $orderby = $query->get( 'orderby');
163
+ if( 'publishdate' == $orderby ) {
164
+ $query->set( 'meta_key', 'wprss_item_date' );
165
+ $query->set( 'orderby', 'meta_value_num' );
166
+ }
167
+ }
168
+ }
169
+
170
+
171
+ add_filter( 'post_updated_messages', 'wprss_feed_updated_messages' );
172
+ /**
173
+ * Change default notification message when new feed is added or updated
174
+ *
175
+ * @since 2.0
176
+ */
177
+ function wprss_feed_updated_messages( $messages ) {
178
+ global $post, $post_ID;
179
+
180
+ $messages[ 'wprss_feed' ] = array(
181
+ 0 => '', // Unused. Messages start at index 1.
182
+ 1 => __( 'Feed source updated. ', 'wprss' ),
183
+ 2 => __( 'Custom field updated.', 'wprss' ),
184
+ 3 => __( 'Custom field deleted.', 'wprss' ),
185
+ 4 => __( 'Feed source updated.', 'wprss' ),
186
+ 5 => '',
187
+ 6 => __( 'Feed source saved.', 'wprss' ),
188
+ 7 => __( 'Feed source saved.', 'wprss' ),
189
+ 8 => __( 'Feed source submitted.', 'wprss' ),
190
+ 9 => '',
191
+ 10 => __( 'Feed source updated.', 'wprss' )
192
+ );
193
+
194
+ return apply_filters( 'wprss_feed_updated_messages', $messages );
195
+ }
196
+
197
+
198
+ add_filter( 'post_row_actions', 'wprss_remove_row_actions', 10, 1 );
199
+ /**
200
+ * Remove actions row for imported feed items, we don't want them to be editable or viewable
201
+ *
202
+ * @since 2.0
203
+ */
204
+ function wprss_remove_row_actions( $actions )
205
+ {
206
+ if ( get_post_type() === 'wprss_feed_item' ) {
207
+ unset( $actions[ 'edit' ] );
208
+ unset( $actions[ 'view' ] );
209
+ //unset( $actions[ 'trash' ] );
210
+ unset( $actions[ 'inline hide-if-no-js' ] );
211
+ }
212
+ return apply_filters( 'wprss_remove_row_actions', $actions );
213
+ }
214
+
215
+
216
+ add_filter( 'bulk_actions-edit-wprss_feed_item', 'wprss_custom_feed_item_bulk_actions' );
217
+ /**
218
+ * Remove bulk action link to edit imported feed items
219
+ *
220
+ * @since 2.0
221
+ */
222
+ function wprss_custom_feed_item_bulk_actions( $actions ){
223
+ unset( $actions[ 'edit' ] );
224
+ return apply_filters( 'wprss_custom_feed_item_bulk_actions', $actions );
225
+ }
226
+
227
+
228
+ add_action( 'admin_footer-edit.php', 'wprss_remove_a_from_feed_title' );
229
+ /**
230
+ * Remove hyperlink from imported feed titles in list posts screen
231
+ *
232
+ * @since 2.0
233
+ */
234
+ function wprss_remove_a_from_feed_title() {
235
+ if ( 'edit-wprss_feed_item' !== get_current_screen()->id )
236
+ return;
237
+ ?>
238
+
239
+ <script type="text/javascript">
240
+ jQuery('table.wp-list-table a.row-title').contents().unwrap();
241
+ </script>
242
+ <?php
243
+ }
244
+
245
+
246
+ add_filter( 'gettext', 'wprss_change_publish_button_text', 10, 2 );
247
+ /**
248
+ * Modify 'Publish' button text when adding a new feed source
249
+ *
250
+ * @since 2.0
251
+ */
252
+ function wprss_change_publish_button_text( $translation, $text ) {
253
+ if ( 'wprss_feed' == get_post_type()) {
254
+ if ( $text == 'Publish' )
255
+ return __( 'Publish Feed', 'wprss' );
256
+ }
257
+ return apply_filters( 'wprss_change_publish_button_text', $translation );
258
+ }
includes/admin-import-export.php ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Build the import/export settings page, used to import and export the plugin's settings
4
+ * Based on http://wp.tutsplus.com/tutorials/creative-coding/creating-a-simple-backuprestore-settings-feature/
5
+ *
6
+ * @since 3.1
7
+ */
8
+
9
+
10
+ add_action( 'admin_init', 'wp_rss_aggregator_export', 1 );
11
+ /**
12
+ * Handles exporting of aggregator settings
13
+ *
14
+ * @since 3.1
15
+ */
16
+ function wp_rss_aggregator_export() {
17
+ if ( isset( $_POST['export'] ) && check_admin_referer( 'wprss-settings-export' ) ) {
18
+ $blogname = str_replace( " ", "", get_option( 'blogname' ) );
19
+ $date = date( "m-d-Y" );
20
+ $json_name = $blogname . "-" . $date; // Naming the filename that will be generated.
21
+
22
+ header( 'Content-Description: File Transfer' );
23
+ header( "Content-Type: text/json; charset=" . get_option( 'blog_charset' ) );
24
+ header( "Content-Disposition: attachment; filename=$json_name.json" );
25
+ wp_rss_set_export_data();
26
+ die();
27
+ }
28
+ }
29
+
30
+
31
+ /**
32
+ * Gathers relevant options, encodes them in Json and echoes the file
33
+ *
34
+ * @since 3.1
35
+ */
36
+ function wp_rss_set_export_data() {
37
+ $options = apply_filters(
38
+ 'wprss_fields_export',
39
+ array( 'wprss_settings_general' => get_option( 'wprss_settings_general' ) )
40
+ );
41
+ $json_file = json_encode( $options );
42
+
43
+ foreach ( $options as $key => $value ) {
44
+ $value = maybe_unserialize( $value );
45
+ $need_options[ $key ] = $value;
46
+ }
47
+ $json_file = json_encode( $need_options ); // Encode data into json data
48
+ echo $json_file;
49
+ die();
50
+ }
51
+
52
+
53
+ /**
54
+ * Notice for a successful export
55
+ *
56
+ * @since 3.1
57
+ */
58
+ function wp_rss_aggregator_export_notice() {
59
+ echo '<div class="updated"><p>All options are export successfully.</p></div>';
60
+
61
+ }
62
+
63
+
64
+ /**
65
+ * Notice for a successful import
66
+ *
67
+ * @since 3.1
68
+ */
69
+ function wp_rss_aggregator_import_notice1() {
70
+ echo '<div class="updated"><p>' . __( 'All options are restored successfully.', 'wprss' ) . '</p></div>';
71
+
72
+ }
73
+
74
+
75
+ /**
76
+ * Notice for an unsuccessful import
77
+ *
78
+ * @since 3.1
79
+ */
80
+ function wp_rss_aggregator_import_notice2() {
81
+ echo '<div class="error"><p>' . __( 'Invalid file or file size too big.', 'wprss' ) . '</p></div>';
82
+
83
+ }
84
+
85
+
86
+ add_action( 'admin_init', 'wp_rss_aggregator_import' );
87
+ /**
88
+ * Handles the importing of settings
89
+ *
90
+ * @since 3.1
91
+ */
92
+ function wp_rss_aggregator_import(){
93
+ global $pagenow;
94
+ if( $pagenow == 'admin.php' ) {
95
+ //Hope this plugin don't use admin.php for anything
96
+ return;
97
+ }
98
+ if ( isset( $_FILES['import'] ) && check_admin_referer( 'wprss-settings-import' ) ) {
99
+ if ( $_FILES['import']['error'] > 0) {
100
+ wp_die( "Error during import" );
101
+ } else {
102
+ $file_name = $_FILES['import']['name'];
103
+ $file_ext = strtolower( end( explode( ".", $file_name ) ) );
104
+ $file_size = $_FILES['import']['size'];
105
+ if ( ( $file_ext == "json" ) && ( $file_size < 500000 ) ) {
106
+ $encode_options = file_get_contents( $_FILES['import']['tmp_name'] );
107
+ $options = json_decode( $encode_options, true );
108
+ foreach ( $options as $key => $value ) {
109
+ update_option( $key, $value );
110
+ }
111
+ add_action( 'admin_notices', 'wp_rss_aggregator_import_notice1' );
112
+ }
113
+ else {
114
+ add_action( 'admin_notices', 'wp_rss_aggregator_import_notice2' );
115
+ }
116
+ }
117
+ }
118
+ }
119
+
120
+
121
+ /**
122
+ * Handles the import/export page display
123
+ *
124
+ * @since 3.1
125
+ */
126
+ function wprss_import_export_settings_page_display() {
127
+ if ( !isset( $_POST['export'] ) ) { ?>
128
+ <div class="wrap">
129
+ <?php screen_icon( 'wprss-aggregator' ); ?>
130
+ <h2><?php _e( 'Import & Export Settings', 'wprss' ); ?></h2>
131
+
132
+ <h3><?php _e( 'Export Settings', 'wprss' ); ?></h3>
133
+ <p><?php _e( 'Click the <strong>Export Settings</strong> button to generate a file containing all the settings used by WP RSS Aggregator', 'wprss' ); ?></p>
134
+ <p><?php _e( 'After exporting, you can either use the backup file to restore your settings to this site or to another WordPress site.</p>', 'wprss' ); ?></p>
135
+ <form method="post">
136
+ <p class="submit">
137
+ <?php wp_nonce_field( 'wprss-settings-export' ); ?>
138
+ <input type="submit" name="export" value="<?php _e( 'Export Settings', 'wprss' ); ?>" class="button" />
139
+ </p>
140
+ </form>
141
+
142
+ <h3><?php _e( 'Import Settings', 'wprss' ); ?></h3>
143
+ <p><?php _e( 'Click the <strong>Choose file</strong> button and choose a backup file.', 'wprss' ); ?></p>
144
+ <p><?php _e( 'Press the <strong>Import Settings</strong> button, and WordPress will do the rest for you.', 'wprss' ); ?></p>
145
+ <form method='post' enctype='multipart/form-data'>
146
+ <p class="submit">
147
+ <?php wp_nonce_field( 'wprss-settings-import' ); ?>
148
+ <input type='file' name='import' />
149
+ <input type='submit' name='import' value="<?php _e( 'Import Settings', 'wprss' ); ?>" class="button" />
150
+ </p>
151
+ </form>
152
+
153
+ <h3><?php _e( 'Importing/Exporting Feed Sources', 'wprss' ); ?></h3>
154
+ <p><?php _e( 'To import/export your feed sources, please use the standard WordPress <a href="' . get_admin_url() . 'import.php">Import</a> and <a href="' . get_admin_url() . 'export.php">Export</a> functionality.', 'wprss' ); ?></p>
155
+ <p><?php _e( 'On the <a href="' . get_admin_url() . 'export.php">Export</a> page, check the <strong>Feed Sources</strong> radio button and click the <strong>Download Export File</strong> button. WordPress will then create an XML file containing all the feed sources.', 'wprss' ); ?></p>
156
+ <p><?php _e( 'On the <a href="' . get_admin_url() . 'import.php">Import</a> page, choose the previously created file and click the <strong>Upload file and import</strong> button.', 'wprss' ); ?></p>
157
+
158
+ </div>
159
+ <?php
160
+ }
161
+ }
includes/admin-metaboxes.php ADDED
@@ -0,0 +1,322 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ add_action( 'add_meta_boxes', 'wprss_add_meta_boxes');
4
+ /**
5
+ * Set up the input boxes for the wprss_feed post type
6
+ *
7
+ * @since 2.0
8
+ */
9
+ function wprss_add_meta_boxes() {
10
+ global $wprss_meta_fields;
11
+
12
+ // Remove the default WordPress Publish box, because we will be using custom ones
13
+ remove_meta_box( 'submitdiv', 'wprss_feed', 'side' );
14
+
15
+ add_meta_box(
16
+ 'submitdiv', // $id
17
+ __( 'Save Feed Source', 'wprss' ), // $title
18
+ 'post_submit_meta_box', // $callback
19
+ 'wprss_feed', // $page
20
+ 'side', // $context
21
+ 'low' // $priority
22
+ );
23
+
24
+ add_meta_box(
25
+ 'custom_meta_box',
26
+ __( 'Feed Source Details', 'wprss' ),
27
+ 'wprss_show_meta_box_callback',
28
+ 'wprss_feed',
29
+ 'normal',
30
+ 'high'
31
+ );
32
+
33
+ add_meta_box(
34
+ 'wprss-help-meta',
35
+ __( 'WP RSS Aggregator Help', 'wprss' ),
36
+ 'wprss_help_meta_box_callback',
37
+ 'wprss_feed',
38
+ 'side',
39
+ 'low'
40
+ );
41
+
42
+ add_meta_box(
43
+ 'wprss-like-meta',
44
+ __( 'Like this plugin?', 'wprss' ),
45
+ 'wprss_like_meta_box_callback',
46
+ 'wprss_feed',
47
+ 'side',
48
+ 'low'
49
+ );
50
+
51
+ add_meta_box(
52
+ 'wprss-follow-meta',
53
+ __( 'Follow us', 'wprss' ),
54
+ 'wprss_follow_meta_box_callback',
55
+ 'wprss_feed',
56
+ 'side',
57
+ 'low'
58
+ );
59
+
60
+ add_meta_box(
61
+ 'preview_meta_box',
62
+ __( 'Feed Preview', 'wprss' ),
63
+ 'wprss_preview_meta_box_callback',
64
+ 'wprss_feed',
65
+ 'normal',
66
+ 'low'
67
+ );
68
+ }
69
+
70
+
71
+ /**
72
+ * Set up fields for the meta box for the wprss_feed post type
73
+ *
74
+ * @since 2.0
75
+ */
76
+ function wprss_get_custom_fields() {
77
+ $prefix = 'wprss_';
78
+
79
+ // Field Array
80
+ $wprss_meta_fields[ 'url' ] = array(
81
+ 'label' => __( 'URL', 'wprss' ),
82
+ 'desc' => __( 'Enter feed URL (including http://)', 'wprss' ),
83
+ 'id' => $prefix .'url',
84
+ 'type' => 'text'
85
+ );
86
+
87
+ $wprss_meta_fields[' description' ] = array(
88
+ 'label' => __( 'Description', 'wprss' ),
89
+ 'desc' => __( 'A short description about this feed source (optional)', 'wprss' ),
90
+ 'id' => $prefix .'description',
91
+ 'type' => 'textarea'
92
+ );
93
+
94
+ // for extensibility, allows more meta fields to be added
95
+ return apply_filters( 'wprss_fields', $wprss_meta_fields );
96
+ }
97
+
98
+
99
+ /**
100
+ * Set up the meta box for the wprss_feed post type
101
+ *
102
+ * @since 2.0
103
+ */
104
+ function wprss_show_meta_box_callback() {
105
+ global $post;
106
+ $meta_fields = wprss_get_custom_fields();
107
+
108
+ // Use nonce for verification
109
+ wp_nonce_field( basename( __FILE__ ), 'wprss_meta_box_nonce' );
110
+
111
+ // Begin the field table and loop
112
+ echo '<table class="form-table">';
113
+
114
+ foreach ( $meta_fields as $field ) {
115
+
116
+ // get value of this field if it exists for this post
117
+ $meta = get_post_meta( $post->ID, $field['id'], true );
118
+ // begin a table row with
119
+ echo '<tr>
120
+ <th><label for="' . $field['id'] . '">' . $field['label'] . '</label></th>
121
+ <td>';
122
+
123
+ switch( $field['type'] ) {
124
+
125
+ // text
126
+ case 'text':
127
+ echo '<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'. esc_attr( $meta ) .'" size="55" />
128
+ <br><span class="description">'.$field['desc'].'</span>';
129
+ break;
130
+
131
+ // textarea
132
+ case 'textarea':
133
+ echo '<textarea name="'.$field['id'].'" id="'.$field['id'].'" cols="60" rows="4">'. esc_attr( $meta ) .'</textarea>
134
+ <br><span class="description">'.$field['desc'].'</span>';
135
+ break;
136
+
137
+ // checkbox
138
+ case 'checkbox':
139
+ echo '<input type="checkbox" name="'.$field['id'].'" id="'.$field['id'].'" ', esc_attr( $meta ) ? ' checked="checked"' : '','/>
140
+ <label for="'.$field['id'].'">'.$field['desc'].'</label>';
141
+ break;
142
+
143
+ // select
144
+ case 'select':
145
+ echo '<select name="'.$field['id'].'" id="'.$field['id'].'">';
146
+ foreach ($field['options'] as $option) {
147
+ echo '<option', $meta == $option['value'] ? ' selected="selected"' : '', ' value="'.$option['value'].'">'.$option['label'].'</option>';
148
+ }
149
+ echo '</select><br><span class="description">'.$field['desc'].'</span>';
150
+ break;
151
+
152
+ } //end switch
153
+ echo '</td></tr>';
154
+ } // end foreach
155
+ echo '</table>'; // end table
156
+ }
157
+
158
+
159
+ add_action( 'save_post', 'wprss_save_custom_fields', 10, 2 );
160
+ /**
161
+ * Save the custom fields
162
+ *
163
+ * @since 2.0
164
+ */
165
+ function wprss_save_custom_fields( $post_id, $post ) {
166
+ $meta_fields = wprss_get_custom_fields();
167
+
168
+ /* Verify the nonce before proceeding. */
169
+ if ( !isset( $_POST['wprss_meta_box_nonce'] ) || !wp_verify_nonce( $_POST['wprss_meta_box_nonce'], basename( __FILE__ ) ) )
170
+ return $post_id;
171
+
172
+ /* Get the post type object. */
173
+ $post_type = get_post_type_object( $post->post_type );
174
+
175
+ /* Check if the current user has permission to edit the post. */
176
+ if ( !current_user_can( $post_type->cap->edit_post, $post_id ) )
177
+ return $post_id;
178
+
179
+ /* // Stop WP from clearing custom fields on autosave - maybe not needed
180
+ if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
181
+ return;
182
+
183
+ // Prevent quick edit from clearing custom fields - maybe not needed
184
+ if (defined('DOING_AJAX') && DOING_AJAX)
185
+ return; */
186
+
187
+ /** Bail out if running an autosave, ajax or a cron */
188
+ if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
189
+ return;
190
+ if ( defined( 'DOING_AJAX' ) && DOING_AJAX )
191
+ return;
192
+ if ( defined( 'DOING_CRON' ) && DOING_CRON )
193
+ return;
194
+
195
+ // loop through fields and save the data
196
+ foreach ( $meta_fields as $field ) {
197
+ $old = get_post_meta( $post_id, $field[ 'id' ], true );
198
+ $new = $_POST[ $field[ 'id' ] ];
199
+ if ( $new && $new != $old ) {
200
+ update_post_meta( $post_id, $field[ 'id' ], $new );
201
+ } elseif ( '' == $new && $old ) {
202
+ delete_post_meta( $post_id, $field[ 'id' ], $old );
203
+ }
204
+ } // end foreach
205
+ }
206
+
207
+
208
+ /**
209
+ * Generate a preview of the latest 5 posts from the feed source being added/edited
210
+ *
211
+ * @since 2.0
212
+ */
213
+ function wprss_preview_meta_box_callback() {
214
+ global $post;
215
+ $feed_url = get_post_meta( $post->ID, 'wprss_url', true );
216
+
217
+ if( ! empty( $feed_url ) ) {
218
+ $feed = fetch_feed( $feed_url );
219
+ if ( ! is_wp_error( $feed ) ) {
220
+ $items = $feed->get_items();
221
+ // Figure out how many total items there are, but limit it to 5.
222
+ $maxitems = $feed->get_item_quantity(5);
223
+
224
+ // Build an array of all the items, starting with element 0 (first element).
225
+ $items = $feed->get_items( 0, $maxitems );
226
+ echo '<h4>Latest 5 feeds available from ' . get_the_title() . '</h4>';
227
+ echo '<ul>';
228
+ foreach ( $items as $item ) {
229
+ // Get human date (comment if you want to use non human date)
230
+ $item_date = human_time_diff( $item->get_date('U'), current_time('timestamp')).' '.__( 'ago', 'rc_mdm' );
231
+ // Start displaying item content within a <li> tag
232
+ echo '<li>';
233
+ // create item link
234
+ //echo '<a href="'.esc_url( $item->get_permalink() ).'" title="'.$item_date.'">';
235
+ // Get item title
236
+ echo esc_html( $item->get_title() );
237
+ //echo '</a>';
238
+ // Display date
239
+ echo ' <div class="rss-date"><small>'.$item_date.'</small></div>';
240
+ // End <li> tag
241
+ echo '</li>';
242
+ }
243
+ echo '</ul>';
244
+ }
245
+ else _e( '<span class="invalid-feed-url"><strong>Invalid feed URL</strong> - Double check the feed source URL setting above.</span>
246
+ <p>Not sure where to find the RSS feed on a website?
247
+ <a target="_blank" href="http://webtrends.about.com/od/webfeedsyndicationrss/ss/rss_howto.htm">Click here</a> for a visual guide' , 'wprss' );
248
+ }
249
+
250
+ else _e( 'No feed URL defined yet', 'wprss' );
251
+ }
252
+
253
+
254
+ /**
255
+ * Generate Help meta box
256
+ *
257
+ * @since 2.0
258
+ *
259
+ */
260
+ function wprss_help_meta_box_callback() {
261
+ echo '<p><strong>';
262
+ _e( 'Need help?', 'wprss' );
263
+ echo '</strong> <a target="_blank" href="http://wordpress.org/support/plugin/wp-rss-aggregator">';
264
+ _e( 'Check out the support forum', 'wprss' );
265
+ echo '</a></p>';
266
+ }
267
+
268
+ /**
269
+ * Generate Like this plugin meta box
270
+ *
271
+ * @since 2.0
272
+ *
273
+ */
274
+ function wprss_like_meta_box_callback() { ?>
275
+ <p><?php _e( 'Why not do any or all of the following', 'wprss' ) ?>:</p>
276
+ <ul>
277
+ <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>
278
+ <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>
279
+ </ul>
280
+ </p>
281
+ <?php }
282
+
283
+
284
+ /**
285
+ * Generate Like this plugin meta box
286
+ *
287
+ * @since 2.0
288
+ *
289
+ */
290
+ function wprss_follow_meta_box_callback() {
291
+ ?>
292
+ <ul>
293
+ <li class="twitter"><a href="http://twitter.com/wpmayor"><?php _e( 'Follow WP Mayor on Twitter.', 'wprss' ) ?></a></li>
294
+ <li class="facebook"><a href="https://www.facebook.com/wpmayor"><?php _e( 'Like WP Mayor on Facebook.', 'wprss' ) ?></a></li>
295
+ </ul>
296
+ <?php }
297
+
298
+
299
+ add_action( 'add_meta_boxes', 'wprss_remove_meta_boxes', 100 );
300
+ /**
301
+ * Remove unneeded meta boxes from add feed source screen
302
+ *
303
+ * @since 2.0
304
+ */
305
+ function wprss_remove_meta_boxes() {
306
+ if ( 'wprss_feed' !== get_current_screen()->id ) return;
307
+ // Remove meta boxes of other plugins that tend to appear on all posts
308
+ remove_meta_box( 'wpseo_meta', 'wprss_feed' ,'normal' );
309
+ remove_meta_box( 'postpsp', 'wprss_feed' ,'normal' );
310
+ remove_meta_box( 'su_postmeta', 'wprss_feed' ,'normal' );
311
+ remove_meta_box( 'woothemes-settings', 'wprss_feed' ,'normal' );
312
+ remove_meta_box( 'wpcf-post-relationship', 'wprss_feed' ,'normal' );
313
+ remove_meta_box( 'sharing_meta', 'wprss_feed' ,'advanced' );
314
+ remove_meta_box( 'content-permissions-meta-box', 'wprss_feed' ,'advanced' );
315
+ remove_meta_box( 'theme-layouts-post-meta-box', 'wprss_feed' ,'side' );
316
+ remove_meta_box( 'post-stylesheets', 'wprss_feed' ,'side' );
317
+ remove_meta_box( 'hybrid-core-post-template', 'wprss_feed' ,'side' );
318
+ remove_meta_box( 'wpcf-marketing', 'wprss_feed' ,'side' );
319
+ remove_meta_box( 'trackbacksdiv22', 'wprss_feed' ,'advanced' );
320
+ remove_meta_box( 'aiosp', 'wprss_feed' ,'advanced' );
321
+ remove_action( 'post_submitbox_start', 'fpp_post_submitbox_start_action' );
322
+ }
includes/admin-options.php ADDED
@@ -0,0 +1,541 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Plugin settings 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 WP PRSS Aggregator
10
+ */
11
+
12
+ add_action( 'admin_init', 'wprss_admin_init' );
13
+ /**
14
+ * Register and define options and settings
15
+ * @since 2.0
16
+ * @todo add option for cron frequency
17
+ *
18
+ * Note: In the future might change to
19
+ * the way EDD builds the settings pages, cleaner method.
20
+ */
21
+ function wprss_admin_init() {
22
+
23
+ register_setting(
24
+ 'wprss_settings_general', // A settings group name.
25
+ 'wprss_settings_general', // The name of an option to sanitize and save.
26
+ 'wprss_settings_general_validate' // A callback function that sanitizes the option's value.
27
+ );
28
+
29
+ add_settings_section(
30
+ 'wprss_settings_general_section', // ID used to identify this section and with which to register options
31
+ __( 'General plugin settings', 'wprss' ), // Section title that shows within <H3> tags
32
+ 'wprss_settings_general_callback', // Callback function that echoes some explanations
33
+ 'wprss_settings_general' // Settings page on which to show this section
34
+ );
35
+
36
+ add_settings_section(
37
+ 'wprss_settings_styles_section',
38
+ __( 'Styles', 'wprss' ),
39
+ 'wprss_settings_styles_callback',
40
+ 'wprss_settings_general'
41
+ );
42
+
43
+ add_settings_field(
44
+ 'wprss-settings-open-dd', // ID used to identify the field
45
+ __( 'Open links behaviour', 'wprss' ), // Text printed next to the field
46
+ 'wprss_setting_open_dd_callback', // Callback function that echoes the field
47
+ 'wprss_settings_general', // Settings page on which to show this field
48
+ 'wprss_settings_general_section' // Section of the settings page on which to show this field
49
+ );
50
+
51
+ add_settings_field(
52
+ 'wprss-settings-follow-dd',
53
+ __( 'Set links as', 'wprss' ),
54
+ 'wprss_setting_follow_dd_callback',
55
+ 'wprss_settings_general',
56
+ 'wprss_settings_general_section'
57
+ );
58
+
59
+ add_settings_field(
60
+ 'wprss-settings-feed-limit',
61
+ __( 'Feed display limit', 'wprss' ),
62
+ 'wprss_setting_feed_limit_callback',
63
+ 'wprss_settings_general',
64
+ 'wprss_settings_general_section'
65
+ );
66
+
67
+ add_settings_field(
68
+ 'wprss-settings-date-format',
69
+ __( 'Date format', 'wprss' ),
70
+ 'wprss_setting_date_format_callback',
71
+ 'wprss_settings_general',
72
+ 'wprss_settings_general_section'
73
+ );
74
+
75
+ add_settings_field(
76
+ 'wprss-settings-limit-feed-items-db',
77
+ __( 'Limit feed items stored', 'wprss' ),
78
+ 'wprss_setting_limit_feed_items_callback',
79
+ 'wprss_settings_general',
80
+ 'wprss_settings_general_section'
81
+ );
82
+
83
+ add_settings_field(
84
+ 'wprss-settings-limit-feed-items-imported',
85
+ __( 'Limit feed items per feed', 'wprss' ),
86
+ 'wprss_setting_limit_feed_items_imported_callback',
87
+ 'wprss_settings_general',
88
+ 'wprss_settings_general_section'
89
+ );
90
+
91
+ add_settings_field(
92
+ 'wprss-settings-cron-interval',
93
+ __( 'Cron interval', 'wprss' ),
94
+ 'wprss_setting_cron_interval_callback',
95
+ 'wprss_settings_general',
96
+ 'wprss_settings_general_section'
97
+ );
98
+
99
+ add_settings_field(
100
+ 'wprss-settings-title-link-enable',
101
+ __( 'Link title', 'wprss' ),
102
+ 'wprss_setting_title_link_callback',
103
+ 'wprss_settings_general',
104
+ 'wprss_settings_general_section'
105
+ );
106
+
107
+ add_settings_field(
108
+ 'wprss-settings-source-enable',
109
+ __( 'Show source', 'wprss' ),
110
+ 'wprss_setting_source_enable_callback',
111
+ 'wprss_settings_general',
112
+ 'wprss_settings_general_section'
113
+ );
114
+
115
+ add_settings_field(
116
+ 'wprss-settings-text-preceding-source',
117
+ __( 'Text preceding source', 'wprss' ),
118
+ 'wprss_setting_text_preceding_source_callback',
119
+ 'wprss_settings_general',
120
+ 'wprss_settings_general_section'
121
+ );
122
+
123
+ add_settings_field(
124
+ 'wprss-settings-date-enable',
125
+ __( 'Show date', 'wprss' ),
126
+ 'wprss_setting_date_enable_callback',
127
+ 'wprss_settings_general',
128
+ 'wprss_settings_general_section'
129
+ );
130
+
131
+ add_settings_field(
132
+ 'wprss-settings-text-preceding-date',
133
+ __( 'Text preceding date', 'wprss' ),
134
+ 'wprss_setting_text_preceding_date_callback',
135
+ 'wprss_settings_general',
136
+ 'wprss_settings_general_section'
137
+ );
138
+
139
+ add_settings_field(
140
+ 'wprss-settings-styles-disable',
141
+ __( 'Disable Styles', 'wprss' ),
142
+ 'wprss_setting_styles_disable_callback',
143
+ 'wprss_settings_general',
144
+ 'wprss_settings_styles_section'
145
+ );
146
+
147
+ do_action( 'wprss_admin_init' );
148
+ }
149
+
150
+
151
+ /**
152
+ * Build the plugin settings page, used to save general settings like whether a link should be follow or no follow
153
+ * @since 1.1
154
+ */
155
+ function wprss_settings_page_display() {
156
+ ?>
157
+ <div class="wrap">
158
+ <?php screen_icon( 'wprss-aggregator' ); ?>
159
+
160
+ <h2><?php _e( 'WP RSS Aggregator Settings', 'wprss' ); ?></h2>
161
+
162
+ <?php settings_errors(); ?>
163
+
164
+ <?php $active_tab = isset( $_GET['tab'] ) ? $_GET['tab'] : 'general_settings'; ?>
165
+
166
+ <?php
167
+
168
+ $tabs = apply_filters(
169
+ 'wprss_options_tabs',
170
+ array(
171
+ 'General' => array(
172
+ 'label' => __( 'General', 'wprss' ),
173
+ 'slug' => 'general_settings',
174
+ )
175
+ )
176
+ );
177
+
178
+ if ( is_plugin_active( 'wp-rss-excerpts-thumbnails/wp-rss-excerpts-thumbnails.php' ) ) {
179
+ // Might be a better idea to grey out the tabs when the addon is not activated, and use
180
+ // an action hook to insert the code relative to sections of addon. ?>
181
+ <h2 class="nav-tab-wrapper">
182
+ <?php
183
+ foreach ( $tabs as $tab => $tab_property ) { ?>
184
+ <a href="?post_type=wprss_feed&page=wprss-aggregator-settings&tab=<?php echo esc_attr( $tab_property['slug'] ); ?>"
185
+ class="nav-tab <?php echo $active_tab == $tab_property['slug'] ? 'nav-tab-active' : ''; ?>"><?php echo esc_html( $tab_property['label'] ); ?></a>
186
+ <?php } ?>
187
+ <?php } ?>
188
+ </h2>
189
+
190
+ <form action="options.php" method="post">
191
+
192
+ <?php
193
+ if ( is_plugin_active( 'wp-rss-excerpts-thumbnails/wp-rss-excerpts-thumbnails.php' ) ) {
194
+ if ( $active_tab == 'general_settings' ) {
195
+ settings_fields( 'wprss_settings_general' );
196
+ do_settings_sections( 'wprss_settings_general' );
197
+ }
198
+
199
+ do_action( 'wprss_add_settings_fields_sections', $active_tab );
200
+ }
201
+ else {
202
+ settings_fields( 'wprss_settings_general' );
203
+ do_settings_sections( 'wprss_settings_general' );
204
+ }
205
+ submit_button( __( 'Save Settings', 'wprss' ) );
206
+ ?>
207
+ </form>
208
+ </div>
209
+ <?php
210
+ }
211
+
212
+
213
+ /**
214
+ * General settings section header
215
+ * @since 3.0
216
+ */
217
+ function wprss_settings_general_callback() {
218
+ echo '<p>' . __( 'These are the general settings for WP RSS Aggregator.', 'wprss' ) . '</p>';
219
+ }
220
+
221
+
222
+ /**
223
+ * General settings section header
224
+ * @since 3.0
225
+ */
226
+ function wprss_settings_styles_callback() {
227
+ echo '<p>' . __( 'If you would like to disable all styles used in this plugin, tick the checkbox.', 'wprss' ) . '</p>';
228
+ }
229
+
230
+
231
+ /**
232
+ * Follow or No Follow dropdown
233
+ * @since 1.1
234
+ */
235
+ function wprss_setting_follow_dd_callback() {
236
+ $options = get_option( 'wprss_settings_general' );
237
+ $items = array(
238
+ __( 'No follow', 'wprss' ),
239
+ __( 'Follow', 'wprss' )
240
+ );
241
+ echo "<select id='follow-dd' name='wprss_settings_general[follow_dd]'>";
242
+ foreach( $items as $item ) {
243
+ $selected = ( $options['follow_dd'] == $item) ? 'selected="selected"' : '';
244
+ echo "<option value='$item' $selected>$item</option>";
245
+ }
246
+ echo "</select>";
247
+ }
248
+
249
+
250
+ /**
251
+ * Link open setting dropdown
252
+ * @since 1.1
253
+ */
254
+ function wprss_setting_open_dd_callback() {
255
+ $options = get_option( 'wprss_settings_general' );
256
+ $items = array(
257
+ __( 'Lightbox', 'wprss' ),
258
+ __( 'New window', 'wprss' ),
259
+ __( 'None', 'wprss' )
260
+ );
261
+ echo "<select id='open-dd' name='wprss_settings_general[open_dd]'>";
262
+ foreach( $items as $item ) {
263
+ $selected = ( $options['open_dd'] == $item ) ? 'selected="selected"' : '';
264
+ echo "<option value='$item' $selected>$item</option>";
265
+ }
266
+ echo "</select>";
267
+ }
268
+
269
+
270
+ /**
271
+ * Set limit for feeds on frontend
272
+ * @since 2.0
273
+ */
274
+ function wprss_setting_feed_limit_callback() {
275
+ $options = get_option( 'wprss_settings_general' );
276
+ echo "<input id='feed-limit' name='wprss_settings_general[feed_limit]' type='text' value='{$options['feed_limit']}' />";
277
+ echo "<label for='feed-limit'>Enter the number of feeds to display on the front end</label>";
278
+ }
279
+
280
+
281
+ /**
282
+ * Set date format
283
+ * @since 3.0
284
+ */
285
+ function wprss_setting_date_format_callback() {
286
+ $options = get_option( 'wprss_settings_general' );
287
+ echo "<input id='date-format' name='wprss_settings_general[date_format]' type='text' value='{$options['date_format']}' />";
288
+ echo "<label for='date-format'>Date formatting, using the <a href='http://codex.wordpress.org/Formatting_Date_and_Time'>PHP date formats</a></label>";
289
+ }
290
+
291
+
292
+ /**
293
+ * Limit number of feed items stored
294
+ * @since 3.0
295
+ */
296
+ function wprss_setting_limit_feed_items_callback() {
297
+ $options = get_option( 'wprss_settings_general' );
298
+ echo "<input id='limit-feed-items-db' name='wprss_settings_general[limit_feed_items_db]' type='text' value='{$options['limit_feed_items_db']}' />";
299
+ echo "<label for='limit-feed-items-db'>Enter the maximum number of feeds to store in the database; enter 0 for unlimited feed items</label>";
300
+ }
301
+
302
+
303
+ /**
304
+ * Limit number of feed items imported per feed
305
+ * @since 3.1
306
+ */
307
+ function wprss_setting_limit_feed_items_imported_callback() {
308
+ $options = get_option( 'wprss_settings_general' );
309
+ echo "<input id='limit-feed-items-imported' name='wprss_settings_general[limit_feed_items_imported]' type='text' value='{$options['limit_feed_items_imported']}' />";
310
+ echo "<label for='limit-feed-items-imported'>Enter the maximum number of feeds to import per feed</label>";
311
+ }
312
+
313
+
314
+ /**
315
+ * Gets a sorted (according to interval) list of the cron schedules
316
+ * @since 3.0
317
+ */
318
+ function wprss_get_schedules() {
319
+ $schedules = wp_get_schedules();
320
+ uasort( $schedules, create_function( '$a,$b', 'return $a["interval"]-$b["interval"];' ) );
321
+ return $schedules;
322
+ }
323
+
324
+
325
+ /**
326
+ * Cron interval dropdown callback
327
+ * @since 3.0
328
+ */
329
+ function wprss_setting_cron_interval_callback() {
330
+ $options = get_option( 'wprss_settings_general' );
331
+ $current = $options['cron_interval'];
332
+
333
+ $schedules = wprss_get_schedules();
334
+ // Set the allowed Cron schedules, we don't want any intervals that can lead to issues with server load
335
+ $wprss_schedules = apply_filters(
336
+ 'wprss_schedules',
337
+ array( 'fifteen_min', 'thirty_min', 'hourly', 'two_hours', 'twicedaily', 'daily' )
338
+ );
339
+ echo "<select id='cron-interval' name='wprss_settings_general[cron_interval]'>";
340
+ foreach( $schedules as $schedule_name => $schedule_data ) {
341
+ if ( in_array( $schedule_name, $wprss_schedules ) ) { ?>
342
+ <option value="<?php echo $schedule_name; ?>" <?php selected( $current, $schedule_name ); ?> >
343
+ <?php echo $schedule_data['display']; ?> (<?php echo wprss_interval( $schedule_data['interval'] ); ?>)
344
+ </option>
345
+ <?php } ?>
346
+ <?php } ?>
347
+ </select><?php
348
+ }
349
+
350
+
351
+ /**
352
+ * Enable linked title
353
+ * @since 3.0
354
+ */
355
+ function wprss_setting_title_link_callback( $args ) {
356
+ $options = get_option( 'wprss_settings_general' );
357
+ echo "<input id='title-link' name='wprss_settings_general[title_link]' type='checkbox' value='1' " . checked( 1, $options['title_link'], false ) . " />";
358
+ echo "<label for='title-link'>Check this box to enable linked titles</label>";
359
+ }
360
+
361
+
362
+ /**
363
+ * Enable source
364
+ * @since 3.0
365
+ */
366
+ function wprss_setting_source_enable_callback( $args ) {
367
+ $options = get_option( 'wprss_settings_general' );
368
+ echo "<input id='source-enable' name='wprss_settings_general[source_enable]' type='checkbox' value='1' " . checked( 1, $options['source_enable'], false ) . " />";
369
+ echo "<label for='source-enable'>Check this box to enable feed source display</label>";
370
+ }
371
+
372
+
373
+ /**
374
+ * Set text preceding source
375
+ * @since 3.0
376
+ */
377
+ function wprss_setting_text_preceding_source_callback() {
378
+ $options = get_option( 'wprss_settings_general' );
379
+ echo "<input id='text-preceding-source' name='wprss_settings_general[text_preceding_source]' type='text' value='{$options['text_preceding_source']}' />";
380
+ echo "<label for='text-preceding-source'>Enter the text you want shown before the feed item's source</label>";
381
+ }
382
+ /**
383
+ * Enable date
384
+ * @since 3.0
385
+ */
386
+ function wprss_setting_date_enable_callback( $args ) {
387
+ $options = get_option( 'wprss_settings_general' );
388
+ echo "<input id='date-enable' name='wprss_settings_general[date_enable]' type='checkbox' value='1' " . checked( 1, $options['date_enable'], false ) . " />";
389
+ echo "<label for='date-enable'>Check this box to enable display of date published</label>";
390
+ }
391
+
392
+ /**
393
+ * Set text preceding date
394
+ * @since 3.0
395
+ */
396
+ function wprss_setting_text_preceding_date_callback() {
397
+ $options = get_option( 'wprss_settings_general' );
398
+ echo "<input id='text-preceding-date' name='wprss_settings_general[text_preceding_date]' type='text' value='{$options['text_preceding_date']}' />";
399
+ echo "<label for='text-preceding-date'>Enter the text you want shown before the feed item's publish date</label>";
400
+ }
401
+
402
+ /**
403
+ * Disable styles
404
+ * @since 3.0
405
+ */
406
+ function wprss_setting_styles_disable_callback( $args ) {
407
+ $options = get_option( 'wprss_settings_general' );
408
+ echo "<input id='styles-disable' name='wprss_settings_general[styles_disable]' type='checkbox' value='1' " . checked( 1, $options['styles_disable'], false ) . " />";
409
+ echo "<label for='styles-disable'>Check this box to disable all plugin styles</label>";
410
+ echo "<p class='description'>You will then be responsible for providing your own CSS styles.</p>";
411
+ }
412
+
413
+
414
+ /**
415
+ * Pretty-prints the difference in two times.
416
+ *
417
+ * @since 3.0
418
+ * @param time $older_date
419
+ * @param time $newer_date
420
+ * @return string The pretty time_since value
421
+ * @link http://wordpress.org/extend/plugins/wp-crontrol/
422
+ */
423
+ function wprss_time_since( $older_date, $newer_date ) {
424
+ return wprss_interval( $newer_date - $older_date );
425
+ }
426
+
427
+ /**
428
+ * Calculates difference between times
429
+ *
430
+ * Taken from the WP-Crontrol plugin
431
+ * @link http://wordpress.org/extend/plugins/wp-crontrol/
432
+ * @since 3.0
433
+ *
434
+ */
435
+ function wprss_interval( $since ) {
436
+ // array of time period chunks
437
+ $chunks = array(
438
+ array(60 * 60 * 24 * 365 , _n_noop('%s year', '%s years', 'crontrol')),
439
+ array(60 * 60 * 24 * 30 , _n_noop('%s month', '%s months', 'crontrol')),
440
+ array(60 * 60 * 24 * 7, _n_noop('%s week', '%s weeks', 'crontrol')),
441
+ array(60 * 60 * 24 , _n_noop('%s day', '%s days', 'crontrol')),
442
+ array(60 * 60 , _n_noop('%s hour', '%s hours', 'crontrol')),
443
+ array(60 , _n_noop('%s minute', '%s minutes', 'crontrol')),
444
+ array( 1 , _n_noop('%s second', '%s seconds', 'crontrol')),
445
+ );
446
+
447
+
448
+ if( $since <= 0 ) {
449
+ return __( 'now', 'wprss' );
450
+ }
451
+
452
+ // we only want to output two chunks of time here, eg:
453
+ // x years, xx months
454
+ // x days, xx hours
455
+ // so there's only two bits of calculation below:
456
+
457
+ // step one: the first chunk
458
+ for ($i = 0, $j = count($chunks); $i < $j; $i++)
459
+ {
460
+ $seconds = $chunks[$i][0];
461
+ $name = $chunks[$i][1];
462
+
463
+ // finding the biggest chunk (if the chunk fits, break)
464
+ if (($count = floor($since / $seconds)) != 0)
465
+ {
466
+ break;
467
+ }
468
+ }
469
+
470
+ // set output var
471
+ $output = sprintf(_n($name[0], $name[1], $count, 'wprss'), $count);
472
+
473
+ // step two: the second chunk
474
+ if ($i + 1 < $j)
475
+ {
476
+ $seconds2 = $chunks[$i + 1][0];
477
+ $name2 = $chunks[$i + 1][1];
478
+
479
+ if (($count2 = floor(($since - ($seconds * $count)) / $seconds2)) != 0)
480
+ {
481
+ // add to output var
482
+ $output .= ' '.sprintf(_n($name2[0], $name2[1], $count2, 'wprss'), $count2);
483
+ }
484
+ }
485
+
486
+ return $output;
487
+ }
488
+
489
+
490
+ /**
491
+ * Validate inputs from the general settings page
492
+ * @since 3.0
493
+ */
494
+ function wprss_settings_general_validate( $input ) {
495
+ $options = get_option( 'wprss_settings_general' );
496
+ $current_cron_interval = $options['cron_interval'];
497
+
498
+ // Create our array for storing the validated options
499
+ $output = array();
500
+
501
+ // Loop through each of the incoming options
502
+ foreach( $input as $key => $value ) {
503
+
504
+ // Check to see if the current option has a value. If so, process it.
505
+ if( isset( $input[ $key ] ) ) {
506
+
507
+ // Strip all HTML and PHP tags and properly handle quoted strings
508
+ $output[ $key ] = strip_tags( stripslashes( $input[ $key ] ) );
509
+
510
+ } // end if
511
+
512
+ } // end foreach
513
+
514
+ if ( ! isset( $input['title_link'] ) || $input['title_link'] != '1' )
515
+ $output['title_link'] = 0;
516
+ else
517
+ $output['title_link'] = 1;
518
+
519
+ if ( ! isset( $input['source_enable'] ) || $input['source_enable'] != '1' )
520
+ $output['source_enable'] = 0;
521
+ else
522
+ $output['source_enable'] = 1;
523
+
524
+ if ( ! isset( $input['date_enable'] ) || $input['date_enable'] != '1' )
525
+ $output['date_enable'] = 0;
526
+ else
527
+ $output['date_enable'] = 1;
528
+
529
+ if ( ! isset( $input['styles_disable'] ) || $input['styles_disable'] != '1' )
530
+ $output['styles_disable'] = 0;
531
+ else
532
+ $output['styles_disable'] = 1;
533
+
534
+ if ( $input['cron_interval'] != $current_cron_interval ) {
535
+ wp_clear_scheduled_hook( 'wprss_fetch_all_feeds_hook' );
536
+ wp_schedule_event( time(), $input['cron_interval'], 'wprss_fetch_all_feeds_hook' );
537
+ }
538
+
539
+ // Return the array processing any additional functions filtered by this action
540
+ return apply_filters( 'wprss_settings_general_validate', $output, $input );
541
+ }
includes/admin.php ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Plugin administration related functions
4
+ *
5
+ * @package WPRSSAggregator
6
+ */
7
+
8
+
9
+ add_action( 'admin_head', 'wprss_custom_post_type_icon' );
10
+ /**
11
+ * Custom Post Type Icon for Admin Menu & Post Screen
12
+ * @since 2.0
13
+ */
14
+ function wprss_custom_post_type_icon() {
15
+ ?>
16
+ <style>
17
+ /* Post Screen - 32px */
18
+ .icon32-posts-wprss_feed {
19
+ background: transparent url( <?php echo WPRSS_IMG . 'icon-adminpage32.png'; ?> ) no-repeat left top !important;
20
+ }
21
+ /* Post Screen - 32px */
22
+ .icon32-posts-wprss_feed_item {
23
+ background: transparent url( <?php echo WPRSS_IMG . 'icon-adminpage32.png'; ?> ) no-repeat left top !important;
24
+ }
25
+ </style>
26
+ <?php }
27
+
28
+
29
+ add_action( 'admin_menu', 'wprss_register_menu_pages' );
30
+ /**
31
+ * Register menu and submenus
32
+ * @since 2.0
33
+ */
34
+
35
+ // Add the admin options pages as submenus to the Feed CPT
36
+ function wprss_register_menu_pages() {
37
+
38
+ //create submenu items
39
+ add_submenu_page( 'edit.php?post_type=wprss_feed', __( 'WP RSS Aggregator Settings', 'wprss' ), __( 'Settings', 'wprss' ), 'manage_options', 'wprss-aggregator-settings', 'wprss_settings_page_display' );
40
+ add_submenu_page( 'edit.php?post_type=wprss_feed', __( 'Export & Import Settings', 'wprss' ), __( 'Import & Export', 'wprss' ), 'manage_options', 'wprss-import-export-settings', 'wprss_import_export_settings_page_display' );
41
+ add_submenu_page( 'edit.php?post_type=wprss_feed', __( 'Debugging', 'wprss' ), __( 'Debugging', 'wprss' ), 'manage_options', 'wprss-debugging', 'wprss_debugging_page_display' );
42
+ }
43
+
44
+
45
+ add_filter('admin_body_class', 'wprss_base_admin_body_class');
46
+ /**
47
+ * Set body class for admin screens
48
+ * http://www.kevinleary.net/customizing-wordpress-admin-css-javascript/
49
+ * @since 2.0
50
+ */
51
+ function wprss_base_admin_body_class( $classes )
52
+ {
53
+ // Current action
54
+ if ( is_admin() && isset($_GET['action']) ) {
55
+ $classes .= 'action-'.$_GET['action'];
56
+ }
57
+ // Current post ID
58
+ if ( is_admin() && isset($_GET['post']) ) {
59
+ $classes .= ' ';
60
+ $classes .= 'post-'.$_GET['post'];
61
+ }
62
+ // New post type & listing page
63
+ if ( isset($_GET['post_type']) ) $post_type = $_GET['post_type'];
64
+ if ( isset($post_type) ) {
65
+ $classes .= ' ';
66
+ $classes .= 'post-type-'.$post_type;
67
+ }
68
+ // Editting a post type
69
+ if ( isset( $_GET['post'] ) ) {
70
+ $post_query = $_GET['post'];
71
+ }
72
+ if ( isset($post_query) ) {
73
+ $current_post_edit = get_post($post_query);
74
+ $current_post_type = $current_post_edit->post_type;
75
+ if ( !empty($current_post_type) ) {
76
+ $classes .= ' ';
77
+ $classes .= 'post-type-'.$current_post_type;
78
+ }
79
+ }
80
+ // Return the $classes array
81
+ return $classes;
82
+ }
83
+
84
+
85
+ /**
86
+ * Change title on wprss_feed post type screen
87
+ *
88
+ * @since 2.0
89
+ * @return void
90
+ */
91
+ function wprss_change_title_text() {
92
+ return __( 'Enter feed name here (e.g. WP Mayor)', 'wprss' );
93
+ }
94
+
95
+
96
+ add_filter( 'plugin_action_links', 'wprss_plugin_action_links', 10, 2 );
97
+ /**
98
+ * Add Settings action link in plugin listing
99
+ *
100
+ * @since 3.0
101
+ * @param array $action_links
102
+ * @param string $plugin_file
103
+ * @return array
104
+ */
105
+ function wprss_plugin_action_links( $action_links, $plugin_file ) {
106
+ if ( $plugin_file == plugin_basename( __FILE__ ) ) {
107
+ $settings_link = '<a href="' . get_admin_url() . 'edit.php?post_type=wprss_feed&page=wprss-aggregator-settings">' . __("Settings") . '</a>';
108
+ array_unshift( $action_links, $settings_link );
109
+ }
110
+ return $action_links;
111
+ }
includes/cron-jobs.php ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Contains all the cron jobs in use by WP RSS Aggregator
4
+ *
5
+ * @package WPRSSAggregator
6
+ */
7
+
8
+
9
+ add_action( 'init', 'wprss_schedule_fetch_all_feeds_cron' );
10
+ /**
11
+ * Creates the cron to fetch feeds every hour
12
+ *
13
+ * @since 2.0
14
+ */
15
+ function wprss_schedule_fetch_all_feeds_cron() {
16
+
17
+ $options = get_option( 'wprss_settings_general' );
18
+
19
+ $cron_interval = $options['cron_interval'];
20
+
21
+ // verify event has not been scheduled
22
+ if ( ! wp_next_scheduled( 'wprss_fetch_all_feeds_hook' ) ) {
23
+ // Schedule to run hourly
24
+ wp_schedule_event( time(), $cron_interval, 'wprss_fetch_all_feeds_hook' );
25
+ }
26
+
27
+ add_action( 'wprss_fetch_all_feeds_hook', 'wprss_fetch_insert_all_feed_items' );
28
+ }
29
+
30
+
31
+ add_action( 'init', 'wprss_schedule_truncate_posts_cron' );
32
+ /**
33
+ * Creates the cron to truncate wprss_feed_item posts daily
34
+ *
35
+ * @since 2.0
36
+ */
37
+ function wprss_schedule_truncate_posts_cron() {
38
+
39
+ // verify event has not been scheduled
40
+ if ( ! wp_next_scheduled( 'wprss_truncate_posts_hook') ) {
41
+ // Schedule to run daily
42
+ wp_schedule_event( time(), 'daily', 'wprss_truncate_posts_hook' );
43
+ }
44
+
45
+ add_action( 'wprss_truncate_posts_hook', 'wprss_truncate_posts' );
46
+ }
47
+
48
+
49
+ // filter to add new possible frequencies to the cron
50
+ add_filter( 'cron_schedules', 'wprss_filter_cron_schedules' );
51
+ /**
52
+ * Adding a few more handy cron schedules to the default ones
53
+ * @since 3.0
54
+ */
55
+ function wprss_filter_cron_schedules( $schedules) {
56
+ $frequencies = array(
57
+ 'five_min' => array(
58
+ 'interval' => 300,
59
+ 'display' => __( 'Once every five minutes', 'wprss' )
60
+ ),
61
+ 'ten_min' => array(
62
+ 'interval' => 600,
63
+ 'display' => __( 'Once every ten minutes', 'wprss' )
64
+ ),
65
+ 'fifteen_min' => array(
66
+ 'interval' => 900,
67
+ 'display' => __( 'Once every fifteen minutes', 'wprss' )
68
+ ),
69
+ 'thirty_min' => array(
70
+ 'interval' => 1800,
71
+ 'display' => __( 'Once every thirty minutes', 'wprss' )
72
+ ),
73
+ 'two_hours' => array(
74
+ 'interval' => 7200,
75
+ 'display' => __( 'Once every two hours', 'wprss' )
76
+ ),
77
+ );
78
+
79
+ return array_merge( $schedules, $frequencies );
80
+ }
includes/custom-feed.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Function to create a custom feed with the latest imported feed items
4
+ *
5
+ * @package WP RSS Aggregator
6
+ * @todo needs implementation, not currently used
7
+ */
8
+
9
+
10
+ add_filter( 'init', 'wprss_addfeed_add_feed' );
11
+ /**
12
+ * Adds feed named 'wprss'
13
+ *
14
+ * @since 3.0
15
+ */
16
+ function wprss_addfeed_add_feed() {
17
+ add_feed( 'wprss', 'wprss_addfeed_do_feed' );
18
+ }
19
+
20
+
21
+ /**
22
+ * Echo the feed
23
+ *
24
+ * @since 3.0
25
+ */
26
+ function wprss_addfeed_do_feed( $in ) {
27
+ // Make custom query to get latest feed items
28
+ query_posts( array(
29
+ 'post_type' => 'wprss_feed_item',
30
+ 'post_status' => 'publish'
31
+ )
32
+ );
33
+
34
+ // Send content header and start ATOM output
35
+ header('Content-Type: application/atom+xml');
36
+ echo '<?xml version="1.0" encoding="' . get_option('blog_charset') . '"?' . '>';
37
+ ?>
38
+ <feed xmlns="http://www.w3.org/2005/Atom">
39
+ <title type="text">Latest imported feed items on <?php bloginfo_rss('name'); ?></title>
40
+ <?php
41
+ // Start the Loop
42
+ while ( have_posts() ) : the_post();
43
+ ?>
44
+ <entry>
45
+ <title><![CDATA[<?php the_title_rss(); ?>]]></title>
46
+ <link href="<?php the_permalink_rss(); ?>" />
47
+ <published><?php echo get_post_time( 'Y-m-d\TH:i:s\Z' ); ?></published>
48
+ <content type="html"><![CDATA[<?php the_content(); ?>]]></content>
49
+ </entry>
50
+ <?php
51
+ // End of the Loop
52
+ endwhile;
53
+ ?>
54
+ </feed>
55
+ <?php
56
+ }
includes/custom-post-types.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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(
19
+ 'wprss_feed_post_type_labels',
20
+ array(
21
+ 'name' => __( 'Feed Sources', 'wprss' ),
22
+ 'singular_name' => __( 'Feed', 'wprss' ),
23
+ 'add_new' => __( 'Add New Feed Source', 'wprss' ),
24
+ 'all_items' => __( 'All Feed Sources', 'wprss' ),
25
+ 'add_new_item' => __( 'Add New Feed Source', 'wprss' ),
26
+ 'edit_item' => __( 'Edit Feed Source', 'wprss' ),
27
+ 'new_item' => __( 'New Feed Source', 'wprss' ),
28
+ 'view_item' => __( 'View Feed Source', 'wprss' ),
29
+ 'search_items' => __( 'Search Feeds', 'wprss' ),
30
+ 'not_found' => __( 'No Feed Sources Found', 'wprss' ),
31
+ 'not_found_in_trash' => __( 'No Feed Sources Found In Trash', 'wprss' ),
32
+ 'menu_name' => __( 'RSS Aggregator', 'wprss' )
33
+ )
34
+ );
35
+
36
+ // Set up the arguments for the 'wprss_feed' post type
37
+ $feed_args = apply_filters(
38
+ 'wprss_feed_post_type_args',
39
+ array(
40
+ 'exclude_from_search' => true,
41
+ 'publicly_querable' => false,
42
+ 'show_in_nav_menus' => false,
43
+ 'show_in_admin_bar' => true,
44
+ 'public' => false,
45
+ 'show_ui' => true,
46
+ 'query_var' => 'feed_source',
47
+ 'menu_position' => 100,
48
+ 'menu_icon' => WPRSS_IMG . 'icon-adminmenu16-sprite.png',
49
+ 'show_in_menu' => true,
50
+ 'rewrite' => array(
51
+ 'slug' => 'feeds',
52
+ 'with_front' => false
53
+ ),
54
+ 'supports' => array( 'title' ),
55
+ 'labels' => $labels
56
+ )
57
+ );
58
+
59
+ // Register the 'wprss_feed' post type
60
+ register_post_type( 'wprss_feed', $feed_args );
61
+
62
+ // Set up labels for the 'wprss_feed_item' post type
63
+ $labels = apply_filters(
64
+ 'wprss_feed_item_post_type_labels',
65
+ array(
66
+ 'name' => __( 'Imported Feeds', 'wprss' ),
67
+ 'singular_name' => __( 'Imported Feed', 'wprss' ),
68
+ 'all_items' => __( 'Imported Feeds', 'wprss' ),
69
+ 'view_item' => __( 'View Imported Feed', 'wprss' ),
70
+ 'search_items' => __( 'Search Imported Feeds', 'wprss' ),
71
+ 'not_found' => __( 'No Imported Feeds Found', 'wprss' ),
72
+ 'not_found_in_trash' => __( 'No Imported Feeds Found In Trash', 'wprss' )
73
+ )
74
+ );
75
+
76
+ // Set up the arguments for the 'wprss_feed_item' post type
77
+ $feed_item_args = apply_filters(
78
+ 'wprss_feed_item_post_type_args',
79
+ array(
80
+ 'exclude_from_search' => true,
81
+ 'publicly_querable' => false,
82
+ 'show_in_nav_menus' => false,
83
+ 'show_in_admin_bar' => true,
84
+ 'public' => false,
85
+ 'show_ui' => true,
86
+ 'query_var' => 'feed_item',
87
+ 'show_in_menu' => 'edit.php?post_type=wprss_feed',
88
+ 'rewrite' => array(
89
+ 'slug' => 'feeds/items',
90
+ 'with_front' => false,
91
+ ),
92
+ 'labels' => $labels
93
+ )
94
+ );
95
+
96
+ // Register the 'feed_item' post type
97
+ register_post_type( 'wprss_feed_item', $feed_item_args );
98
+ }
includes/deprecated-functions.php ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Fetches feed items from sources provided
5
+ * DEPRECATED - JUST FOR REFERENCE
6
+ *
7
+ * @since 2.0
8
+ * @deprecated 3.0
9
+ */
10
+ function wprss_fetch_all_feed_items( ) {
11
+
12
+ // Get all feed sources
13
+ $feed_sources = new WP_Query( array(
14
+ 'post_type' => 'wprss_feed',
15
+ 'post_status' => 'publish',
16
+ 'posts_per_page' => -1,
17
+ ) );
18
+
19
+ if( $feed_sources->have_posts() ) {
20
+ /* Start by getting one feed source, we will cycle through them one by one,
21
+ fetching feed items and adding them to the database in each pass */
22
+ while ( $feed_sources->have_posts() ) {
23
+ $feed_sources->the_post();
24
+
25
+ $feed_ID = get_the_ID();
26
+ $feed_url = get_post_meta( get_the_ID(), 'wprss_url', true );
27
+
28
+ // Use the URL custom field to fetch the feed items for this source
29
+ if( !empty( $feed_url ) ) {
30
+
31
+ add_filter( 'wp_feed_cache_transient_lifetime' , 'wprss_return_7200' );
32
+ //$feed = fetch_feed( $feed_url );
33
+ $feed = wprss_fetch_feed( $feed_url );
34
+ remove_filter( 'wp_feed_cache_transient_lifetime' , 'wprss_return_7200' );
35
+
36
+ // $feed->strip_htmltags( array_merge( $feed->strip_htmltags, array('h1', 'a', 'img') ) );
37
+
38
+ if ( !is_wp_error( $feed ) ) {
39
+ // Figure out how many total items there are, but limit it to 10.
40
+ $maxitems = $feed->get_item_quantity(10);
41
+
42
+ // Build an array of all the items, starting with element 0 (first element).
43
+ $items = $feed->get_items( 0, $maxitems );
44
+ }
45
+ else { return; }
46
+ }
47
+
48
+ if ( ! empty( $items ) ) {
49
+ // Gather the permalinks of existing feed item's related to this feed source
50
+ global $wpdb;
51
+ $existing_permalinks = $wpdb->get_col(
52
+ "SELECT meta_value
53
+ FROM $wpdb->postmeta
54
+ WHERE meta_key = 'wprss_item_permalink'
55
+ AND post_id IN ( SELECT post_id FROM $wpdb->postmeta WHERE meta_value = $feed_ID)
56
+ ");
57
+
58
+ foreach ( $items as $item ) {
59
+ // Check if newly fetched item already present in existing feed item item,
60
+ // if not insert it into wp_posts and insert post meta.
61
+ if ( ! ( in_array( $item->get_permalink(), $existing_permalinks ) ) ) {
62
+ // Create post object
63
+ $feed_item = array(
64
+ 'post_title' => $item->get_title(),
65
+ 'post_content' => '',
66
+ 'post_status' => 'publish',
67
+ 'post_type' => 'wprss_feed_item'
68
+ );
69
+ $inserted_ID = wp_insert_post( $feed_item );
70
+ wprss_items_create_post_meta( $inserted_ID, $item, $feed_ID );
71
+ } //end if
72
+ } //end foreach
73
+ } // end if
74
+ } // end $feed_sources while loop
75
+ wp_reset_postdata(); // Restore the $post global to the current post in the main query
76
+ // } // end if
77
+ } // end if
78
+ }
79
+
80
+ // For testing query speed
81
+ // $time_start = microtime( true );
82
+ // wp_die(number_format( microtime( true ) - $time_start, 10 ));
83
+
includes/feed-display-new-categories.php ADDED
@@ -0,0 +1,245 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Feed display related functions
4
+ *
5
+ * @package WPRSSAggregator
6
+ */
7
+
8
+
9
+ /**
10
+ * Retrieve settings and prepare them for use in the display function
11
+ *
12
+ * @since 3.0
13
+ */
14
+ function wprss_get_display_settings( $settings ) {
15
+
16
+ switch ( $settings['open_dd'] ) {
17
+
18
+ case 'Lightbox' :
19
+ $display_settings['open'] = 'class="colorbox"';
20
+ break;
21
+
22
+ case 'New window' :
23
+ $display_settings['open'] = 'target="_blank"';
24
+ break;
25
+ }
26
+
27
+ switch ( $settings['follow_dd'] ) {
28
+
29
+ case 'No follow' :
30
+ $display_settings['follow'] = 'rel="nofollow"';
31
+ break;
32
+ }
33
+
34
+ do_action( 'wprss_get_settings' );
35
+
36
+ return $display_settings;
37
+ }
38
+
39
+
40
+ /**
41
+ * Merges the default arguments with the user set arguments
42
+ *
43
+ * @since 3.0
44
+ */
45
+ function wprss_get_args( $args ) {
46
+ // Default shortcode/function arguments for displaying feed items
47
+ $default_args = apply_filters(
48
+ 'default_args',
49
+ array(
50
+ 'links_before' => '<ul class="rss-aggregator">',
51
+ 'links_after' => '</ul>',
52
+ 'link_before' => '<li class="feed-item">',
53
+ 'link_after' => '</li>'
54
+ )
55
+ );
56
+
57
+ // Parse incoming $args into an array and merge it with $default_args
58
+ $args = wp_parse_args( $args, $default_args );
59
+
60
+ return $args;
61
+ }
62
+
63
+
64
+ /**
65
+ * Prepares and builds the query for fetching the feed items
66
+ *
67
+ * @since 3.0
68
+ */
69
+ function wprss_get_feed_items_query( $args, $settings ) {
70
+ extract( $args, EXTR_SKIP );
71
+
72
+ if ( isset( $category) ) {
73
+ // wp_die('category found');
74
+ $category_id = get_cat_ID( $category );
75
+
76
+ $the_query = new WP_Query( array(
77
+ 'post_type' => 'wprss_feed',
78
+ 'feed_category' => $category_id
79
+ ) );
80
+
81
+ $items = array();
82
+
83
+ while ( $the_query->have_posts() ) : $the_query->the_post();
84
+ $all_feed_items = get_posts( array(
85
+ 'post_type' => 'wprss_feed_item',
86
+ 'posts_per_page' => $settings['feed_limit'],
87
+ 'orderby' => 'meta_value',
88
+ 'meta_key' => 'wprss_item_date',
89
+ 'order' => 'DESC'
90
+ ) );
91
+
92
+ $feed_items = array_merge( $items, $all_feed_items );
93
+ endwhile;
94
+
95
+ wp_reset_postdata();
96
+ }
97
+
98
+
99
+ // Arguments for the next query to fetch all feed items
100
+ else {
101
+ $feed_items_args = apply_filters(
102
+ 'wprss_display_feed_items_query',
103
+ array(
104
+ 'post_type' => 'wprss_feed_item',
105
+ 'posts_per_page' => $settings['feed_limit'],
106
+ 'orderby' => 'meta_value',
107
+ 'meta_key' => 'wprss_item_date',
108
+ 'order' => 'DESC'
109
+ )
110
+ );
111
+
112
+ // Query to get all feed items for display
113
+ $feed_items = new WP_Query( $feed_items_args );
114
+ }
115
+
116
+ return $feed_items;
117
+ }
118
+
119
+
120
+ add_action( 'wprss_display_template', 'wprss_default_display_template', 10, 3 );
121
+ /**
122
+ * Default template for feed items display
123
+ *
124
+ * @since 3.0
125
+ */
126
+ function wprss_default_display_template( $display_settings, $args, $feed_items ) {
127
+
128
+ $general_settings = get_option( 'wprss_settings_general' );
129
+ $excerpts_settings = get_option( 'wprss_settings_excerpts' );
130
+ $thumbnails_settings = get_option( 'wprss_settings_thumbnails' );
131
+ // Declare each item in $args as its own variable
132
+ //print_r($args);
133
+ extract( $args, EXTR_SKIP );
134
+
135
+ $output = '';
136
+
137
+ if( $feed_items->have_posts() ) {
138
+
139
+ $output .= "$links_before";
140
+
141
+ while ( $feed_items->have_posts() ) {
142
+ $feed_items->the_post();
143
+ $permalink = get_post_meta( get_the_ID(), 'wprss_item_permalink', true );
144
+ $feed_source_id = get_post_meta( get_the_ID(), 'wprss_feed_id', true );
145
+ $source_name = get_the_title( $feed_source_id );
146
+ do_action( 'wprss_get_post_data' );
147
+
148
+ // convert from Unix timestamp
149
+ $date = date( $general_settings['date_format'], intval( get_post_meta( get_the_ID(), 'wprss_item_date', true ) ) );
150
+
151
+ if ( $general_settings['title_link'] == 1 ) {
152
+ $output .= "$link_before" . '<a ' . $display_settings['open'] . ' ' . $display_settings['follow'] . ' href="'. $permalink . '">'. get_the_title(). '</a>';
153
+ }
154
+ else {
155
+ $output .= get_the_title();
156
+ }
157
+
158
+ if ( ( $general_settings['source_enable'] == 1 ) && ( $general_settings['date_enable'] == 1 ) ) {
159
+ $output .= '<div class="source-date"><span class="feed-source">' .
160
+ ( !empty( $general_settings['text_preceding_source'] ) ? $general_settings['text_preceding_source'] . ' ' : '' ) . $source_name . ' | ' .
161
+ ( !empty( $general_settings['text_preceding_date'] ) ? $general_settings['text_preceding_date'] . ' ' : '' ) . $date .
162
+ '</span></div>' . "$link_after";
163
+ }
164
+
165
+ else if ( ( $general_settings['source_enable'] == 1 ) && ( $general_settings['date_enable'] == 0 ) ) {
166
+ $output .= '<div class="source-date"><span class="feed-source">' .
167
+ ( !empty( $general_settings['text_preceding_source'] ) ? $general_settings['text_preceding_source'] . ' ' : '' ) . $source_name .
168
+ '</span></div>' . "$link_after";
169
+ }
170
+
171
+ else if ( ( $general_settings['source_enable'] == 0 ) && ( $general_settings['date_enable'] == 1 ) ) {
172
+ $output .= '<div class="source-date"><span class="feed-source">' .
173
+ ( !empty( $general_settings['text_preceding_date'] ) ? $general_settings['text_preceding_date'] . ' ' : '' ) . $date .
174
+ '</span></div>' . "$link_after";
175
+ }
176
+
177
+ else {}
178
+
179
+ }
180
+ $output .= "$links_after";
181
+ $output = apply_filters( 'feed_output', $output );
182
+
183
+ echo $output;
184
+
185
+ // echo paginate_links();
186
+
187
+ wp_reset_postdata();
188
+
189
+ } else {
190
+ $output = apply_filters( 'no_feed_items_found', __( 'No feed items found.', 'wprss' ) );
191
+ echo $output;
192
+ }
193
+ }
194
+
195
+
196
+ /**
197
+ * Display feed items on the front end (via shortcode or function)
198
+ *
199
+ * @since 2.0
200
+ */
201
+ function wprss_display_feed_items( $args = array() ) {
202
+ $settings = get_option( 'wprss_settings_general' );
203
+ $display_settings = wprss_get_display_settings( $settings );
204
+ $args = wprss_get_args( $args );
205
+ $feed_items = wprss_get_feed_items_query( $args, $settings );
206
+ do_action( 'wprss_display_template', $display_settings, $args, $feed_items );
207
+ }
208
+
209
+
210
+ /**
211
+ * Redirects to wprss_display_feed_items
212
+ * It is used for backwards compatibility to versions < 2.0
213
+ *
214
+ * @since 2.1
215
+ */
216
+ function wp_rss_aggregator( $args = array() ) {
217
+ wprss_display_feed_items( $args );
218
+ }
219
+
220
+
221
+ /**
222
+ * Limits a phrase/content to a defined number of words
223
+ *
224
+ * NOT BEING USED as we're using the native WP function, although the native one strips tags, so I'll
225
+ * probably revisit this one again soon.
226
+ *
227
+ * @since 3.0
228
+ * @param string $words
229
+ * @param integer $limit
230
+ * @param string $append
231
+ * @return string
232
+ */
233
+ function wprss_limit_words( $words, $limit, $append = '' ) {
234
+ /* Add 1 to the specified limit becuase arrays start at 0 */
235
+ $limit = $limit + 1;
236
+ /* Store each individual word as an array element
237
+ up to the limit */
238
+ $words = explode( ' ', $words, $limit );
239
+ /* Shorten the array by 1 because that final element will be the sum of all the words after the limit */
240
+ array_pop( $words );
241
+ /* Implode the array for output, and append an ellipse */
242
+ $words = implode( ' ', $words ) . $append;
243
+ /* Return the result */
244
+ return rtrim( $words );
245
+ }
includes/feed-display.php ADDED
@@ -0,0 +1,213 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Feed display related functions
4
+ *
5
+ * @package WPRSSAggregator
6
+ */
7
+
8
+
9
+ /**
10
+ * Retrieve settings and prepare them for use in the display function
11
+ *
12
+ * @since 3.0
13
+ */
14
+ function wprss_get_display_settings( $settings ) {
15
+
16
+ switch ( $settings['open_dd'] ) {
17
+
18
+ case 'Lightbox' :
19
+ $display_settings['open'] = 'class="colorbox"';
20
+ break;
21
+
22
+ case 'New window' :
23
+ $display_settings['open'] = 'target="_blank"';
24
+ break;
25
+ }
26
+
27
+ switch ( $settings['follow_dd'] ) {
28
+
29
+ case 'No follow' :
30
+ $display_settings['follow'] = 'rel="nofollow"';
31
+ break;
32
+ }
33
+
34
+ do_action( 'wprss_get_settings' );
35
+
36
+ return $display_settings;
37
+ }
38
+
39
+
40
+ /**
41
+ * Merges the default arguments with the user set arguments
42
+ *
43
+ * @since 3.0
44
+ */
45
+ function wprss_get_args( $args ) {
46
+ // Default shortcode/function arguments for displaying feed items
47
+ $default_args = apply_filters(
48
+ 'default_args',
49
+ array(
50
+ 'links_before' => '<ul class="rss-aggregator">',
51
+ 'links_after' => '</ul>',
52
+ 'link_before' => '<li class="feed-item">',
53
+ 'link_after' => '</li>'
54
+ )
55
+ );
56
+
57
+ // Parse incoming $args into an array and merge it with $default_args
58
+ $args = wp_parse_args( $args, $default_args );
59
+
60
+ return $args;
61
+ }
62
+
63
+
64
+ /**
65
+ * Prepares and builds the query for fetching the feed items
66
+ *
67
+ * @since 3.0
68
+ */
69
+ function wprss_get_feed_items_query( $settings ) {
70
+ // Arguments for the next query to fetch all feed items
71
+ $feed_items_args = apply_filters(
72
+ 'wprss_display_feed_items_query',
73
+ array(
74
+ 'post_type' => 'wprss_feed_item',
75
+ 'posts_per_page' => $settings['feed_limit'],
76
+ 'orderby' => 'meta_value',
77
+ 'meta_key' => 'wprss_item_date',
78
+ 'order' => 'DESC'
79
+ )
80
+ );
81
+
82
+ // Query to get all feed items for display
83
+ $feed_items = new WP_Query( $feed_items_args );
84
+
85
+ return $feed_items;
86
+ }
87
+
88
+
89
+ add_action( 'wprss_display_template', 'wprss_default_display_template', 10, 3 );
90
+ /**
91
+ * Default template for feed items display
92
+ *
93
+ * @since 3.0
94
+ */
95
+ function wprss_default_display_template( $display_settings, $args, $feed_items ) {
96
+
97
+ $general_settings = get_option( 'wprss_settings_general' );
98
+ $excerpts_settings = get_option( 'wprss_settings_excerpts' );
99
+ $thumbnails_settings = get_option( 'wprss_settings_thumbnails' );
100
+ // Declare each item in $args as its own variable
101
+ extract( $args, EXTR_SKIP );
102
+
103
+ $output = '';
104
+
105
+ if( $feed_items->have_posts() ) {
106
+
107
+ $output .= "$links_before";
108
+
109
+ while ( $feed_items->have_posts() ) {
110
+ $feed_items->the_post();
111
+ $permalink = get_post_meta( get_the_ID(), 'wprss_item_permalink', true );
112
+ $feed_source_id = get_post_meta( get_the_ID(), 'wprss_feed_id', true );
113
+ $source_name = get_the_title( $feed_source_id );
114
+ do_action( 'wprss_get_post_data' );
115
+
116
+ // convert from Unix timestamp
117
+ $date = date( $general_settings['date_format'], intval( get_post_meta( get_the_ID(), 'wprss_item_date', true ) ) );
118
+
119
+ if ( $general_settings['title_link'] == 1 ) {
120
+ $output .= "$link_before" . '<a ' . $display_settings['open'] . ' ' . $display_settings['follow'] . ' href="'. $permalink . '">'. get_the_title(). '</a>';
121
+ }
122
+ else {
123
+ $output .= get_the_title();
124
+ }
125
+
126
+ if ( ( $general_settings['source_enable'] == 1 ) && ( $general_settings['date_enable'] == 1 ) ) {
127
+ $output .= '<div class="source-date"><span class="feed-source">' .
128
+ ( !empty( $general_settings['text_preceding_source'] ) ? $general_settings['text_preceding_source'] . ' ' : '' ) . $source_name . ' | ' .
129
+ ( !empty( $general_settings['text_preceding_date'] ) ? $general_settings['text_preceding_date'] . ' ' : '' ) . $date .
130
+ '</span></div>' . "$link_after";
131
+ }
132
+
133
+ else if ( ( $general_settings['source_enable'] == 1 ) && ( $general_settings['date_enable'] == 0 ) ) {
134
+ $output .= '<div class="source-date"><span class="feed-source">' .
135
+ ( !empty( $general_settings['text_preceding_source'] ) ? $general_settings['text_preceding_source'] . ' ' : '' ) . $source_name .
136
+ '</span></div>' . "$link_after";
137
+ }
138
+
139
+ else if ( ( $general_settings['source_enable'] == 0 ) && ( $general_settings['date_enable'] == 1 ) ) {
140
+ $output .= '<div class="source-date"><span class="feed-source">' .
141
+ ( !empty( $general_settings['text_preceding_date'] ) ? $general_settings['text_preceding_date'] . ' ' : '' ) . $date .
142
+ '</span></div>' . "$link_after";
143
+ }
144
+
145
+ else {}
146
+
147
+ }
148
+ $output .= "$links_after";
149
+ $output = apply_filters( 'feed_output', $output );
150
+
151
+ echo $output;
152
+
153
+ // echo paginate_links();
154
+
155
+ wp_reset_postdata();
156
+
157
+ } else {
158
+ $output = apply_filters( 'no_feed_items_found', __( 'No feed items found.', 'wprss' ) );
159
+ echo $output;
160
+ }
161
+ }
162
+
163
+
164
+ /**
165
+ * Display feed items on the front end (via shortcode or function)
166
+ *
167
+ * @since 2.0
168
+ */
169
+ function wprss_display_feed_items( $args = array() ) {
170
+ $settings = get_option( 'wprss_settings_general' );
171
+ $display_settings = wprss_get_display_settings( $settings );
172
+ $args = wprss_get_args( $args );
173
+ $feed_items = wprss_get_feed_items_query( $settings );
174
+ do_action( 'wprss_display_template', $display_settings, $args, $feed_items );
175
+ }
176
+
177
+
178
+ /**
179
+ * Redirects to wprss_display_feed_items
180
+ * It is used for backwards compatibility to versions < 2.0
181
+ *
182
+ * @since 2.1
183
+ */
184
+ function wp_rss_aggregator( $args = array() ) {
185
+ wprss_display_feed_items( $args );
186
+ }
187
+
188
+
189
+ /**
190
+ * Limits a phrase/content to a defined number of words
191
+ *
192
+ * NOT BEING USED as we're using the native WP function, although the native one strips tags, so I'll
193
+ * probably revisit this one again soon.
194
+ *
195
+ * @since 3.0
196
+ * @param string $words
197
+ * @param integer $limit
198
+ * @param string $append
199
+ * @return string
200
+ */
201
+ function wprss_limit_words( $words, $limit, $append = '' ) {
202
+ /* Add 1 to the specified limit becuase arrays start at 0 */
203
+ $limit = $limit + 1;
204
+ /* Store each individual word as an array element
205
+ up to the limit */
206
+ $words = explode( ' ', $words, $limit );
207
+ /* Shorten the array by 1 because that final element will be the sum of all the words after the limit */
208
+ array_pop( $words );
209
+ /* Implode the array for output, and append an ellipse */
210
+ $words = implode( ' ', $words ) . $append;
211
+ /* Return the result */
212
+ return rtrim( $words );
213
+ }
includes/feed-processing.php ADDED
@@ -0,0 +1,406 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Feed processing related functions
4
+ *
5
+ * @package WPRSSAggregator
6
+ */
7
+
8
+
9
+ /**
10
+ * Change the default feed cache recreation period to 2 hours
11
+ *
12
+ * Probably not needed since we are now disabling caching altogether
13
+ *
14
+ * @since 2.1
15
+ */
16
+ function wprss_feed_cache_lifetime( $seconds )
17
+ {
18
+ return 1; // one second
19
+ }
20
+
21
+
22
+ /**
23
+ * Disable caching of feeds in transients, we don't need it as we are storing them in the wp_posts table
24
+ *
25
+ * @since 3.0
26
+ */
27
+ function wprss_do_not_cache_feeds( &$feed ) {
28
+ $feed->enable_cache( false );
29
+ }
30
+
31
+
32
+ /**
33
+ * Parameters for query to get all feed sources
34
+ *
35
+ * @since 3.0
36
+ */
37
+ function wprss_get_all_feed_sources() {
38
+ // Get all feed sources
39
+ $feed_sources = new WP_Query( apply_filters(
40
+ 'wprss_get_all_feed_sources',
41
+ array(
42
+ 'post_type' => 'wprss_feed',
43
+ 'post_status' => 'publish',
44
+ 'cache_results' => false, // Disable caching, used for one-off queries
45
+ 'no_found_rows' => true, // We don't need pagination, so disable it
46
+ 'posts_per_page' => -1
47
+ )
48
+ ) );
49
+ return $feed_sources;
50
+ }
51
+
52
+
53
+ /**
54
+ * Parameters for query to get feed sources
55
+ *
56
+ * @since 3.0
57
+ */
58
+ function wprss_get_feed_source() {
59
+ // Get all feed sources
60
+ $feed_sources = new WP_Query( apply_filters(
61
+ 'wprss_get_all_feed_sources',
62
+ array(
63
+ 'post_type' => 'wprss_feed',
64
+ 'post_status' => 'publish',
65
+ 'cache_results' => false, // Disable caching, used for one-off queries
66
+ 'no_found_rows' => true, // We don't need pagination, so disable it
67
+ 'posts_per_page' => -1
68
+ )
69
+ ) );
70
+ return $feed_sources;
71
+ }
72
+
73
+
74
+ /**
75
+ * Database query to get existing permalinks
76
+ *
77
+ * @since 3.0
78
+ */
79
+ function get_existing_permalinks( $feed_ID ) {
80
+ global $wpdb;
81
+
82
+ $existing_permalinks = $wpdb->get_col(
83
+ "SELECT meta_value
84
+ FROM $wpdb->postmeta
85
+ WHERE meta_key = 'wprss_item_permalink'
86
+ AND post_id IN ( SELECT post_id FROM $wpdb->postmeta WHERE meta_value = $feed_ID )"
87
+ );
88
+
89
+ return $existing_permalinks;
90
+ }
91
+
92
+
93
+ /**
94
+ * Fetch the feeds from a feed item url
95
+ *
96
+ * @since 3.0
97
+ */
98
+ function wprss_get_feed_items( $feed_url ) {
99
+ $general_settings = get_option( 'wprss_settings_general' );
100
+ $feed_item_limit = $general_settings['limit_feed_items_imported'];
101
+
102
+ // Don't fetch the feed if feed item limit is 0, there's no need, huge speed improvement
103
+ if ( $feed_item_limit == 0 ) return;
104
+
105
+ add_filter( 'wp_feed_cache_transient_lifetime' , 'wprss_feed_cache_lifetime' );
106
+
107
+ /* Disable caching of feeds */
108
+ add_action( 'wp_feed_options', 'wprss_do_not_cache_feeds' );
109
+ /* Fetch the feed from the soure URL specified */
110
+ $feed = fetch_feed( $feed_url );
111
+ /* Remove action here because we only don't want it active feed imports outside of our plugin */
112
+ remove_action( 'wp_feed_options', 'wprss_do_not_cache_feeds' );
113
+
114
+ //$feed = wprss_fetch_feed( $feed_url );
115
+ remove_filter( 'wp_feed_cache_transient_lifetime' , 'wprss_feed_cache_lifetime' );
116
+
117
+ if ( !is_wp_error( $feed ) ) {
118
+
119
+ // Figure out how many total items there are, but limit it to the number of items set in options.
120
+ $maxitems = $feed->get_item_quantity( $feed_item_limit );
121
+
122
+ if ( $maxitems == 0 ) { return; }
123
+
124
+ // Build an array of all the items, starting with element 0 (first element).
125
+ $items = $feed->get_items( 0, $maxitems );
126
+ return $items;
127
+ }
128
+
129
+ else { return; }
130
+ }
131
+
132
+
133
+ /**
134
+ * Insert a WPRSS feed item post
135
+ *
136
+ * @since 3.0
137
+ */
138
+ function wprss_items_insert_post( $items, $feed_ID ) {
139
+
140
+ // Gather the permalinks of existing feed item's related to this feed source
141
+ $existing_permalinks = get_existing_permalinks( $feed_ID );
142
+
143
+ foreach ( $items as $item ) {
144
+
145
+ // normalize permalink to pass through feed proxy URL
146
+ $permalink = $item->get_permalink();
147
+ $response = wp_remote_head( $permalink );
148
+ if ( !is_wp_error( $response ) && isset( $response['headers']['location'] ) ) {
149
+ $permalink = current( explode( '?', $response['headers']['location'] ) );
150
+ }
151
+
152
+ // Check if newly fetched item already present in existing feed items,
153
+ // if not insert it into wp_posts and insert post meta.
154
+ if ( ! ( in_array( $permalink, $existing_permalinks ) ) ) {
155
+ $feed_item = apply_filters(
156
+ 'wprss_populate_post_data',
157
+ array(
158
+ 'post_title' => $item->get_title(),
159
+ 'post_content' => '',
160
+ 'post_status' => 'publish',
161
+ 'post_type' => 'wprss_feed_item',
162
+ ),
163
+ $item
164
+ );
165
+ // Create and insert post object into the DB
166
+ $inserted_ID = wp_insert_post( $feed_item );
167
+
168
+ // Create and insert post meta into the DB
169
+ wprss_items_insert_post_meta( $inserted_ID, $item, $feed_ID, $permalink );
170
+
171
+ // Remember newly added permalink
172
+ $existing_permalinks[] = $permalink;
173
+ }
174
+ }
175
+ }
176
+
177
+
178
+ /**
179
+ * Creates meta entries for feed items while they are being imported
180
+ *
181
+ * @since 2.3
182
+ */
183
+ function wprss_items_insert_post_meta( $inserted_ID, $item, $feed_ID, $feed_url) {
184
+ update_post_meta( $inserted_ID, 'wprss_item_permalink', $feed_url );
185
+ update_post_meta( $inserted_ID, 'wprss_item_description', $item->get_description() );
186
+ update_post_meta( $inserted_ID, 'wprss_item_date', $item->get_date( 'U' ) ); // Save as Unix timestamp format
187
+ update_post_meta( $inserted_ID, 'wprss_feed_id', $feed_ID);
188
+ do_action( 'wprss_items_create_post_meta', $inserted_ID, $item, $feed_ID );
189
+ }
190
+
191
+
192
+ add_action( 'wp_insert_post', 'wprss_fetch_insert_feed_items', '', 2 );
193
+ /**
194
+ * Fetches feed items from source provided and inserts into db
195
+ *
196
+ * This function is used when inserting or untrashing a new feed source, it only gets feeds from that particular source
197
+ *
198
+ * @since 3.0
199
+ */
200
+ function wprss_fetch_insert_feed_items( $post_id, $post ) {
201
+
202
+ // Only run the rest of the function if the post is a feed source and it has just been published
203
+ if( ( $post->post_type == 'wprss_feed' ) && ( $post->post_status == 'publish' ) ) {
204
+
205
+ $feed_ID = $post_id;
206
+
207
+ $feed_url = get_post_meta( $feed_ID, 'wprss_url', true );
208
+
209
+ // Use the URL custom field to fetch the feed items for this source
210
+ if( !empty( $feed_url ) ) {
211
+ $items = wprss_get_feed_items( $feed_url );
212
+ }
213
+
214
+ if ( ! empty( $items ) ) {
215
+ wprss_items_insert_post( $items, $feed_ID );
216
+ }
217
+ wp_reset_postdata(); // Restore the $post global to the current post in the main query
218
+ }
219
+ }
220
+
221
+
222
+ /**
223
+ * Fetches all feed items from sources provided and inserts into db
224
+ *
225
+ * This function is used by the cron job or the debugging functions to get all feeds from all feed sources
226
+ *
227
+ * @since 3.0
228
+ */
229
+ function wprss_fetch_insert_all_feed_items() {
230
+
231
+ // Get all feed sources
232
+ $feed_sources = wprss_get_all_feed_sources();
233
+
234
+ if( $feed_sources->have_posts() ) {
235
+ // Start by getting one feed source, we will cycle through them one by one,
236
+ // fetching feed items and adding them to the database in each pass
237
+ while ( $feed_sources->have_posts() ) {
238
+ $feed_sources->the_post();
239
+
240
+ $feed_ID = get_the_ID();
241
+ $feed_url = get_post_meta( get_the_ID(), 'wprss_url', true );
242
+
243
+ // Use the URL custom field to fetch the feed items for this source
244
+ if( !empty( $feed_url ) ) {
245
+ $items = wprss_get_feed_items( $feed_url );
246
+ }
247
+
248
+ if ( ! empty( $items ) ) {
249
+ wprss_items_insert_post( $items, $feed_ID );
250
+ }
251
+ }
252
+ wp_reset_postdata(); // Restore the $post global to the current post in the main query
253
+ }
254
+ }
255
+
256
+
257
+ add_action( 'trash_wprss_feed', 'wprss_delete_feed_items' ); // maybe use wp_trash_post action? wp_trash_wprss_feed
258
+ /**
259
+ * Delete feed items on trashing of corresponding feed source
260
+ *
261
+ * @since 2.0
262
+ */
263
+ function wprss_delete_feed_items( $postid ) {
264
+
265
+ $args = array(
266
+ 'post_type' => 'wprss_feed_item',
267
+ // Next 3 parameters for performance, see http://thomasgriffinmedia.com/blog/2012/10/optimize-wordpress-queries
268
+ 'cache_results' => false, // Disable caching, used for one-off queries
269
+ 'no_found_rows' => true, // We don't need pagination, so disable it
270
+ 'fields' => 'ids', // Returns post IDs only
271
+ 'posts_per_page'=> -1,
272
+ 'meta_query' => array(
273
+ array(
274
+ 'key' => 'wprss_feed_id',
275
+ 'value' => $postid,
276
+ 'compare' => 'LIKE'
277
+ )
278
+ )
279
+ );
280
+
281
+ $feed_item_ids = get_posts( $args );
282
+ foreach( $feed_item_ids as $feed_item_id ) {
283
+ $purge = wp_delete_post( $feed_item_id, true ); // delete the feed item, skipping trash
284
+ }
285
+ wp_reset_postdata();
286
+ }
287
+
288
+
289
+ /**
290
+ * Delete all feed items
291
+ *
292
+ * @since 3.0
293
+ */
294
+ function wprss_delete_all_feed_items() {
295
+ $args = array(
296
+ 'post_type' => 'wprss_feed_item',
297
+ 'cache_results' => false, // Disable caching, used for one-off queries
298
+ 'no_found_rows' => true, // We don't need pagination, so disable it
299
+ 'fields' => 'ids', // Returns post IDs only
300
+ 'posts_per_page' => -1,
301
+ );
302
+
303
+ //$feed_items = new WP_Query( $args );
304
+
305
+ $feed_item_ids = get_posts( $args );
306
+ foreach( $feed_item_ids as $feed_item_id ) {
307
+ $purge = wp_delete_post( $feed_item_id, true ); // delete the feed item, skipping trash
308
+ }
309
+ wp_reset_postdata();
310
+ }
311
+
312
+
313
+ /**
314
+ * Delete old feed items from the database to avoid bloat
315
+ *
316
+ * @since 2.0
317
+ */
318
+ function wprss_truncate_posts() {
319
+ global $wpdb;
320
+ $general_settings = get_option( 'wprss_settings_general' );
321
+
322
+ if ( $general_settings['limit_feed_items_db'] == 0 ) {
323
+ return;
324
+ }
325
+
326
+ // Set your threshold of max posts and post_type name
327
+ $threshold = $general_settings['limit_feed_items_db'];
328
+ $post_type = 'wprss_feed_item';
329
+
330
+ // Query post type
331
+ // $wpdb query allows me to select specific columns instead of grabbing the entire post object.
332
+ $query = "
333
+ SELECT ID, post_title FROM $wpdb->posts
334
+ WHERE post_type = '$post_type'
335
+ AND post_status = 'publish'
336
+ ORDER BY post_modified DESC
337
+ ";
338
+ $results = $wpdb->get_results( $query );
339
+
340
+ // Check if there are any results
341
+ if ( count( $results ) ){
342
+ foreach ( $results as $post ) {
343
+ $i++;
344
+
345
+ // Skip any posts within our threshold
346
+ if ( $i <= $threshold )
347
+ continue;
348
+
349
+ // Let the WordPress API do the heavy lifting for cleaning up entire post trails
350
+ $purge = wp_delete_post( $post->ID, true );
351
+ }
352
+ }
353
+ }
354
+
355
+
356
+ /**
357
+ * Custom version of the WP fetch_feed() function, since we want custom sanitization of a feed
358
+ *
359
+ * Not being used at the moment, until we decide whether we can still use fetch_feed and modify its handling of sanitization
360
+ *
361
+ * @since 3.0
362
+ *
363
+ */
364
+ /*function wprss_fetch_feed($url) {
365
+ require_once (ABSPATH . WPINC . '/class-feed.php');
366
+
367
+ $feed = new SimplePie();
368
+
369
+ // $feed->set_sanitize_class( 'WP_SimplePie_Sanitize_KSES' );
370
+ // We must manually overwrite $feed->sanitize because SimplePie's
371
+ // constructor sets it before we have a chance to set the sanitization class
372
+ // $feed->sanitize = new WP_SimplePie_Sanitize_KSES();
373
+
374
+ $feed->set_cache_class( 'WP_Feed_Cache' );
375
+ $feed->set_file_class( 'WP_SimplePie_File' );
376
+
377
+ $feed->set_feed_url($url);
378
+ $feed->strip_htmltags(array_merge($feed->strip_htmltags, array( 'h1', 'h2', 'h3', 'h4', 'h5', 'a' )));
379
+ $feed->set_cache_duration( apply_filters( 'wp_feed_cache_transient_lifetime', 12 * HOUR_IN_SECONDS, $url ) );
380
+ do_action_ref_array( 'wp_feed_options', array( &$feed, $url ) );
381
+ $feed->init();
382
+ $feed->handle_content_type();
383
+
384
+ if ( $feed->error() )
385
+ return new WP_Error('simplepie-error', $feed->error());
386
+
387
+ return $feed;
388
+ }*/
389
+
390
+
391
+ /**
392
+ * Deletes all imported feeds and re-imports everything
393
+ *
394
+ * @since 3.0
395
+ */
396
+ function wprss_feed_reset() {
397
+ wprss_delete_all_feed_items();
398
+ wprss_fetch_insert_all_feed_items();
399
+ }
400
+
401
+ /* add_action( 'wp_feed_options', 'wprss_feed_options' );
402
+ function wprss_feed_options( $feed) {
403
+ $feed->strip_htmltags(array_merge($feed->strip_htmltags, array('h1', 'a', 'img','em')));
404
+ }
405
+
406
+ */
includes/libraries/WP_Logging.php ADDED
@@ -0,0 +1,360 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class for logging events and errors
5
+ *
6
+ * @package WP Logging Class
7
+ * @copyright Copyright (c) 2012, Pippin Williamson
8
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9
+ */
10
+
11
+ class WP_Logging {
12
+
13
+
14
+ /**
15
+ * Class constructor.
16
+ *
17
+ * @since 1.0
18
+ *
19
+ * @access public
20
+ * @return void
21
+ */
22
+ function __construct() {
23
+
24
+ // create the log post type
25
+ add_action( 'init', array( $this, 'register_post_type' ) );
26
+
27
+ // create types taxonomy and default types
28
+ add_action( 'init', array( $this, 'register_taxonomy' ) );
29
+
30
+ }
31
+
32
+
33
+ /**
34
+ * Log types
35
+ *
36
+ * Sets up the default log types and allows for new ones to be created
37
+ *
38
+ * @access private
39
+ * @since 1.0
40
+ *
41
+ * @return array
42
+ */
43
+
44
+ private function log_types() {
45
+ $terms = array(
46
+ 'error', 'event'
47
+ );
48
+
49
+ return apply_filters( 'wp_log_types', $terms );
50
+ }
51
+
52
+
53
+ /**
54
+ * Registers the wp_log Post Type
55
+ *
56
+ * @access public
57
+ * @since 1.0
58
+ *
59
+ * @uses register_post_type()
60
+ *
61
+ * @return void
62
+ */
63
+
64
+ public function register_post_type() {
65
+
66
+ /* logs post type */
67
+
68
+ $log_args = array(
69
+ 'labels' => array( 'name' => __( 'Logs', 'wp-logging' ) ),
70
+ 'public' => false,
71
+ 'query_var' => false,
72
+ 'rewrite' => false,
73
+ 'capability_type' => 'post',
74
+ 'supports' => array( 'title', 'editor' ),
75
+ 'can_export' => false
76
+ );
77
+ register_post_type( 'wp_log', apply_filters( 'wp_logging_post_type_args', $log_args ) );
78
+
79
+ }
80
+
81
+
82
+ /**
83
+ * Registers the Type Taxonomy
84
+ *
85
+ * The Type taxonomy is used to determine the type of log entry
86
+ *
87
+ * @access public
88
+ * @since 1.0
89
+ *
90
+ * @uses register_taxonomy()
91
+ * @uses term_exists()
92
+ * @uses wp_insert_term()
93
+ *
94
+ * @return void
95
+ */
96
+
97
+ public function register_taxonomy() {
98
+
99
+ register_taxonomy( 'wp_log_type', 'wp_log' );
100
+
101
+ $types = self::log_types();
102
+
103
+ foreach ( $types as $type ) {
104
+ if( ! term_exists( $type, 'wp_log_type' ) ) {
105
+ wp_insert_term( $type, 'wp_log_type' );
106
+ }
107
+ }
108
+ }
109
+
110
+
111
+ /**
112
+ * Check if a log type is valid
113
+ *
114
+ * Checks to see if the specified type is in the registered list of types
115
+ *
116
+ * @access private
117
+ * @since 1.0
118
+ *
119
+ *
120
+ * @return array
121
+ */
122
+
123
+ private function valid_type( $type ) {
124
+ return in_array( $type, self::log_types() );
125
+ }
126
+
127
+
128
+ /**
129
+ * Create new log entry
130
+ *
131
+ * This is just a simple and fast way to log something. Use self::insert_log()
132
+ * if you need to store custom meta data
133
+ *
134
+ * @access private
135
+ * @since 1.0
136
+ *
137
+ * @uses self::insert_log()
138
+ *
139
+ * @return int The ID of the new log entry
140
+ */
141
+
142
+ public static function add( $title = '', $message = '', $parent = 0, $type = null ) {
143
+
144
+ $log_data = array(
145
+ 'post_title' => $title,
146
+ 'post_content' => $message,
147
+ 'post_parent' => $parent,
148
+ 'log_type' => $type
149
+ );
150
+
151
+ return self::insert_log( $log_data );
152
+
153
+ }
154
+
155
+
156
+ /**
157
+ * Stores a log entry
158
+ *
159
+ * @access private
160
+ * @since 1.0
161
+ *
162
+ * @uses wp_parse_args()
163
+ * @uses wp_insert_post()
164
+ * @uses update_post_meta()
165
+ * @uses wp_set_object_terms()
166
+ * @uses sanitize_key()
167
+ *
168
+ * @return int The ID of the newly created log item
169
+ */
170
+
171
+ public static function insert_log( $log_data = array(), $log_meta = array() ) {
172
+
173
+ $defaults = array(
174
+ 'post_type' => 'wp_log',
175
+ 'post_status' => 'publish',
176
+ 'post_parent' => 0,
177
+ 'post_content' => '',
178
+ 'log_type' => false
179
+ );
180
+
181
+ $args = wp_parse_args( $log_data, $defaults );
182
+
183
+ do_action( 'wp_pre_insert_log' );
184
+
185
+ // store the log entry
186
+ $log_id = wp_insert_post( $args );
187
+
188
+ // set the log type, if any
189
+ if( $log_data['log_type'] && self::valid_type( $log_data['log_type'] ) ) {
190
+ wp_set_object_terms( $log_id, $log_data['log_type'], 'wp_log_type', false );
191
+ }
192
+
193
+
194
+ // set log meta, if any
195
+ if( $log_id && ! empty( $log_meta ) ) {
196
+ foreach( (array) $log_meta as $key => $meta ) {
197
+ update_post_meta( $log_id, '_wp_log_' . sanitize_key( $key ), $meta );
198
+ }
199
+ }
200
+
201
+ do_action( 'wp_post_insert_log', $log_id );
202
+
203
+ return $log_id;
204
+
205
+ }
206
+
207
+
208
+ /**
209
+ * Update and existing log item
210
+ *
211
+ * @access private
212
+ * @since 1.0
213
+ *
214
+ * @uses wp_parse_args()
215
+ * @uses wp_update_post()
216
+ * @uses update_post_meta()
217
+ *
218
+ * @return bool True if successful, false otherwise
219
+ */
220
+ public static function update_log( $log_data = array(), $log_meta = array() ) {
221
+
222
+ do_action( 'wp_pre_update_log', $log_id );
223
+
224
+ $defaults = array(
225
+ 'post_type' => 'wp_log',
226
+ 'post_status' => 'publish',
227
+ 'post_parent' => 0
228
+ );
229
+
230
+ $args = wp_parse_args( $log_data, $defaults );
231
+
232
+ // store the log entry
233
+ $log_id = wp_update_post( $args );
234
+
235
+ if( $log_id && ! empty( $log_meta ) ) {
236
+ foreach( (array) $log_meta as $key => $meta ) {
237
+ if( ! empty( $meta ) )
238
+ update_post_meta( $log_id, '_wp_log_' . sanitize_key( $key ), $meta );
239
+ }
240
+ }
241
+
242
+ do_action( 'wp_post_update_log', $log_id );
243
+
244
+ }
245
+
246
+
247
+ /**
248
+ * Easily retrieves log items for a particular object ID
249
+ *
250
+ * @access private
251
+ * @since 1.0
252
+ *
253
+ * @uses self::get_connected_logs()
254
+ *
255
+ * @return array
256
+ */
257
+
258
+ public static function get_logs( $object_id = 0, $type = null, $paged = null ) {
259
+ return self::get_connected_logs( array( 'post_parent' => $object_id, 'paged' => $paged, 'log_type' => $type ) );
260
+
261
+ }
262
+
263
+
264
+ /**
265
+ * Retrieve all connected logs
266
+ *
267
+ * Used for retrieving logs related to particular items, such as a specific purchase.
268
+ *
269
+ * @access private
270
+ * @since 1.0
271
+ *
272
+ * @uses wp_parse_args()
273
+ * @uses get_posts()
274
+ * @uses get_query_var()
275
+ * @uses self::valid_type()
276
+ *
277
+ * @return array / false
278
+ */
279
+
280
+ public static function get_connected_logs( $args = array() ) {
281
+
282
+ $defaults = array(
283
+ 'post_parent' => 0,
284
+ 'post_type' => 'wp_log',
285
+ 'posts_per_page' => 10,
286
+ 'post_status' => 'publish',
287
+ 'paged' => get_query_var( 'paged' ),
288
+ 'log_type' => false
289
+ );
290
+
291
+ $query_args = wp_parse_args( $args, $defaults );
292
+
293
+ if( $query_args['log_type'] && self::valid_type( $query_args['log_type'] ) ) {
294
+
295
+ $query_args['tax_query'] = array(
296
+ array(
297
+ 'taxonomy' => 'wp_log_type',
298
+ 'field' => 'slug',
299
+ 'terms' => $query_args['log_type']
300
+ )
301
+ );
302
+
303
+ }
304
+
305
+ $logs = get_posts( $query_args );
306
+
307
+ if( $logs )
308
+ return $logs;
309
+
310
+ // no logs found
311
+ return false;
312
+
313
+ }
314
+
315
+
316
+ /**
317
+ * Retrieves number of log entries connected to particular object ID
318
+ *
319
+ * @access private
320
+ * @since 1.0
321
+ *
322
+ * @uses WP_Query()
323
+ * @uses self::valid_type()
324
+ *
325
+ * @return int
326
+ */
327
+
328
+ public static function get_log_count( $object_id = 0, $type = null, $meta_query = null ) {
329
+
330
+ $query_args = array(
331
+ 'post_parent' => $object_id,
332
+ 'post_type' => 'wp_log',
333
+ 'posts_per_page' => -1,
334
+ 'post_status' => 'publish'
335
+ );
336
+
337
+ if( ! empty( $type ) && self::valid_type( $type ) ) {
338
+
339
+ $query_args['tax_query'] = array(
340
+ array(
341
+ 'taxonomy' => 'wp_log_type',
342
+ 'field' => 'slug',
343
+ 'terms' => $type
344
+ )
345
+ );
346
+
347
+ }
348
+
349
+ if( ! empty( $meta_query ) ) {
350
+ $query_args['meta_query'] = $meta_query;
351
+ }
352
+
353
+ $logs = new WP_Query( $query_args );
354
+
355
+ return (int) $logs->post_count;
356
+
357
+ }
358
+
359
+ }
360
+ $GLOBALS['wp_logs'] = new WP_Logging();
includes/libraries/browser.php ADDED
@@ -0,0 +1,1082 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Modified to remove var
4
+ * Chris Christoff on 12/26/2012
5
+ * Changes: Changes vars to publics
6
+ *
7
+ * Modified to work for EDD by
8
+ * Chris Christoff on 12/23/2012
9
+ * Changes: Removed the browser string return and added spacing. Also removed return HTML formatting.
10
+ *
11
+ * Modified to add formatted User Agent string for EDD System Info by
12
+ * Chris Christoff on 12/23/2012
13
+ * Changes: Split user string and add formatting so we can print a nicely
14
+ * formatted user agent string on the EDD System Info
15
+ *
16
+ * File: Browser.php
17
+ * Author: Chris Schuld (http://chrisschuld.com/)
18
+ * Last Modified: August 20th, 2010
19
+ * @version 1.9
20
+ * @package PegasusPHP
21
+ *
22
+ * Copyright (C) 2008-2010 Chris Schuld (chris@chrisschuld.com)
23
+ *
24
+ * This program is free software; you can redistribute it and/or
25
+ * modify it under the terms of the GNU General Public License as
26
+ * published by the Free Software Foundation; either version 2 of
27
+ * the License, or (at your option) any later version.
28
+ *
29
+ * This program is distributed in the hope that it will be useful,
30
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
31
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32
+ * GNU General Public License for more details at:
33
+ * http://www.gnu.org/copyleft/gpl.html
34
+ *
35
+ *
36
+ * Typical Usage:
37
+ *
38
+ * $browser = new Browser();
39
+ * if( $browser->getBrowser() == Browser::BROWSER_FIREFOX && $browser->getVersion() >= 2 ) {
40
+ * echo 'You have FireFox version 2 or greater';
41
+ * }
42
+ *
43
+ * User Agents Sampled from: http://www.useragentstring.com/
44
+ *
45
+ * This implementation is based on the original work from Gary White
46
+ * http://apptools.com/phptools/browser/
47
+ *
48
+ * UPDATES:
49
+ *
50
+ * 2010-08-20 (v1.9):
51
+ * + Added MSN Explorer Browser (legacy)
52
+ * + Added Bing/MSN Robot (Thanks Rob MacDonald)
53
+ * + Added the Android Platform (PLATFORM_ANDROID)
54
+ * + Fixed issue with Android 1.6/2.2 (Thanks Tom Hirashima)
55
+ *
56
+ * 2010-04-27 (v1.8):
57
+ * + Added iPad Support
58
+ *
59
+ * 2010-03-07 (v1.7):
60
+ * + *MAJOR* Rebuild (preg_match and other "slow" routine removal(s))
61
+ * + Almost allof Gary's original code has been replaced
62
+ * + Large PHPUNIT testing environment created to validate new releases and additions
63
+ * + Added FreeBSD Platform
64
+ * + Added OpenBSD Platform
65
+ * + Added NetBSD Platform
66
+ * + Added SunOS Platform
67
+ * + Added OpenSolaris Platform
68
+ * + Added support of the Iceweazel Browser
69
+ * + Added isChromeFrame() call to check if chromeframe is in use
70
+ * + Moved the Opera check in front of the Firefox check due to legacy Opera User Agents
71
+ * + Added the __toString() method (Thanks Deano)
72
+ *
73
+ * 2009-11-15:
74
+ * + Updated the checkes for Firefox
75
+ * + Added the NOKIA platform
76
+ * + Added Checks for the NOKIA brower(s)
77
+ *
78
+ * 2009-11-08:
79
+ * + PHP 5.3 Support
80
+ * + Added support for BlackBerry OS and BlackBerry browser
81
+ * + Added support for the Opera Mini browser
82
+ * + Added additional documenation
83
+ * + Added support for isRobot() and isMobile()
84
+ * + Added support for Opera version 10
85
+ * + Added support for deprecated Netscape Navigator version 9
86
+ * + Added support for IceCat
87
+ * + Added support for Shiretoko
88
+ *
89
+ * 2010-04-27 (v1.8):
90
+ * + Added iPad Support
91
+ *
92
+ * 2009-08-18:
93
+ * + Updated to support PHP 5.3 - removed all deprecated function calls
94
+ * + Updated to remove all double quotes (") -- converted to single quotes (')
95
+ *
96
+ * 2009-04-27:
97
+ * + Updated the IE check to remove a typo and bug (thanks John)
98
+ *
99
+ * 2009-04-22:
100
+ * + Added detection for GoogleBot
101
+ * + Added detection for the W3C Validator.
102
+ * + Added detection for Yahoo! Slurp
103
+ *
104
+ * 2009-03-14:
105
+ * + Added detection for iPods.
106
+ * + Added Platform detection for iPhones
107
+ * + Added Platform detection for iPods
108
+ *
109
+ * 2009-02-16: (Rick Hale)
110
+ * + Added version detection for Android phones.
111
+ *
112
+ * 2008-12-09:
113
+ * + Removed unused constant
114
+ *
115
+ * 2008-11-07:
116
+ * + Added Google's Chrome to the detection list
117
+ * + Added isBrowser(string) to the list of functions special thanks to
118
+ * Daniel 'mavrick' Lang for the function concept (http://mavrick.id.au)
119
+ *
120
+ *
121
+ * Gary White noted: "Since browser detection is so unreliable, I am
122
+ * no longer maintaining this script. You are free to use and or
123
+ * modify/update it as you want, however the author assumes no
124
+ * responsibility for the accuracy of the detected values."
125
+ *
126
+ * Anyone experienced with Gary's script might be interested in these notes:
127
+ *
128
+ * Added class constants
129
+ * Added detection and version detection for Google's Chrome
130
+ * Updated the version detection for Amaya
131
+ * Updated the version detection for Firefox
132
+ * Updated the version detection for Lynx
133
+ * Updated the version detection for WebTV
134
+ * Updated the version detection for NetPositive
135
+ * Updated the version detection for IE
136
+ * Updated the version detection for OmniWeb
137
+ * Updated the version detection for iCab
138
+ * Updated the version detection for Safari
139
+ * Updated Safari to remove mobile devices (iPhone)
140
+ * Added detection for iPhone
141
+ * Added detection for robots
142
+ * Added detection for mobile devices
143
+ * Added detection for BlackBerry
144
+ * Removed Netscape checks (matches heavily with firefox & mozilla)
145
+ *
146
+ */
147
+
148
+ class Browser {
149
+ public $_agent = '';
150
+ public $_browser_name = '';
151
+ public $_version = '';
152
+ public $_platform = '';
153
+ public $_os = '';
154
+ public $_is_aol = false;
155
+ public $_is_mobile = false;
156
+ public $_is_robot = false;
157
+ public $_aol_version = '';
158
+
159
+ public $BROWSER_UNKNOWN = 'unknown';
160
+ public $VERSION_UNKNOWN = 'unknown';
161
+
162
+ public $BROWSER_OPERA = 'Opera'; // Http://www.opera.com/
163
+ public $BROWSER_OPERA_MINI = 'Opera Mini'; // Http://www.opera.com/mini/
164
+ public $BROWSER_WEBTV = 'WebTV'; // Http://www.webtv.net/pc/
165
+ public $BROWSER_IE = 'Internet Explorer'; // Http://www.microsoft.com/ie/
166
+ public $BROWSER_POCKET_IE = 'Pocket Internet Explorer'; // Http://en.wikipedia.org/wiki/Internet_Explorer_Mobile
167
+ public $BROWSER_KONQUEROR = 'Konqueror'; // Http://www.konqueror.org/
168
+ public $BROWSER_ICAB = 'iCab'; // Http://www.icab.de/
169
+ public $BROWSER_OMNIWEB = 'OmniWeb'; // Http://www.omnigroup.com/applications/omniweb/
170
+ public $BROWSER_FIREBIRD = 'Firebird'; // Http://www.ibphoenix.com/
171
+ public $BROWSER_FIREFOX = 'Firefox'; // Http://www.mozilla.com/en-US/firefox/firefox.html
172
+ public $BROWSER_ICEWEASEL = 'Iceweasel'; // Http://www.geticeweasel.org/
173
+ public $BROWSER_SHIRETOKO = 'Shiretoko'; // Http://wiki.mozilla.org/Projects/shiretoko
174
+ public $BROWSER_MOZILLA = 'Mozilla'; // Http://www.mozilla.com/en-US/
175
+ public $BROWSER_AMAYA = 'Amaya'; // Http://www.w3.org/Amaya/
176
+ public $BROWSER_LYNX = 'Lynx'; // Http://en.wikipedia.org/wiki/Lynx
177
+ public $BROWSER_SAFARI = 'Safari'; // Http://apple.com
178
+ public $BROWSER_IPHONE = 'iPhone'; // Http://apple.com
179
+ public $BROWSER_IPOD = 'iPod'; // Http://apple.com
180
+ public $BROWSER_IPAD = 'iPad'; // Http://apple.com
181
+ public $BROWSER_CHROME = 'Chrome'; // Http://www.google.com/chrome
182
+ public $BROWSER_ANDROID = 'Android'; // Http://www.android.com/
183
+ public $BROWSER_GOOGLEBOT = 'GoogleBot'; // Http://en.wikipedia.org/wiki/Googlebot
184
+ public $BROWSER_SLURP = 'Yahoo! Slurp'; // Http://en.wikipedia.org/wiki/Yahoo!_Slurp
185
+ public $BROWSER_W3CVALIDATOR = 'W3C Validator'; // Http://validator.w3.org/
186
+ public $BROWSER_BLACKBERRY = 'BlackBerry'; // Http://www.blackberry.com/
187
+ public $BROWSER_ICECAT = 'IceCat'; // Http://en.wikipedia.org/wiki/GNU_IceCat
188
+ public $BROWSER_NOKIA_S60 = 'Nokia S60 OSS Browser'; // Http://en.wikipedia.org/wiki/Web_Browser_for_S60
189
+ public $BROWSER_NOKIA = 'Nokia Browser'; // * all other WAP-based browsers on the Nokia Platform
190
+ public $BROWSER_MSN = 'MSN Browser'; // Http://explorer.msn.com/
191
+ public $BROWSER_MSNBOT = 'MSN Bot'; // Http://search.msn.com/msnbot.htm
192
+ // Http://en.wikipedia.org/wiki/Msnbot (used for Bing as well)
193
+
194
+ public $BROWSER_NETSCAPE_NAVIGATOR = 'Netscape Navigator'; // Http://browser.netscape.com/ (DEPRECATED)
195
+ public $BROWSER_GALEON = 'Galeon'; // Http://galeon.sourceforge.net/ (DEPRECATED)
196
+ public $BROWSER_NETPOSITIVE = 'NetPositive'; // Http://en.wikipedia.org/wiki/NetPositive (DEPRECATED)
197
+ public $BROWSER_PHOENIX = 'Phoenix'; // Http://en.wikipedia.org/wiki/History_of_Mozilla_Firefox (DEPRECATED)
198
+
199
+ public $PLATFORM_UNKNOWN = 'unknown';
200
+ public $PLATFORM_WINDOWS = 'Windows';
201
+ public $PLATFORM_WINDOWS_CE = 'Windows CE';
202
+ public $PLATFORM_APPLE = 'Apple';
203
+ public $PLATFORM_LINUX = 'Linux';
204
+ public $PLATFORM_OS2 = 'OS/2';
205
+ public $PLATFORM_BEOS = 'BeOS';
206
+ public $PLATFORM_IPHONE = 'iPhone';
207
+ public $PLATFORM_IPOD = 'iPod';
208
+ public $PLATFORM_IPAD = 'iPad';
209
+ public $PLATFORM_BLACKBERRY = 'BlackBerry';
210
+ public $PLATFORM_NOKIA = 'Nokia';
211
+ public $PLATFORM_FREEBSD = 'FreeBSD';
212
+ public $PLATFORM_OPENBSD = 'OpenBSD';
213
+ public $PLATFORM_NETBSD = 'NetBSD';
214
+ public $PLATFORM_SUNOS = 'SunOS';
215
+ public $PLATFORM_OPENSOLARIS = 'OpenSolaris';
216
+ public $PLATFORM_ANDROID = 'Android';
217
+
218
+ public $OPERATING_SYSTEM_UNKNOWN = 'unknown';
219
+
220
+ function Browser($useragent="") {
221
+ $this->reset();
222
+ if( $useragent != "" ) {
223
+ $this->setUserAgent($useragent);
224
+ }
225
+ else {
226
+ $this->determine();
227
+ }
228
+ }
229
+
230
+ /**
231
+ * Reset all properties
232
+ */
233
+ function reset() {
234
+ $this->_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : "";
235
+ $this->_browser_name = $this->BROWSER_UNKNOWN;
236
+ $this->_version = $this->VERSION_UNKNOWN;
237
+ $this->_platform = $this->PLATFORM_UNKNOWN;
238
+ $this->_os = $this->OPERATING_SYSTEM_UNKNOWN;
239
+ $this->_is_aol = false;
240
+ $this->_is_mobile = false;
241
+ $this->_is_robot = false;
242
+ $this->_aol_version = $this->VERSION_UNKNOWN;
243
+ }
244
+
245
+ /**
246
+ * Check to see if the specific browser is valid
247
+ * @param string $browserName
248
+ * @return True if the browser is the specified browser
249
+ */
250
+ function isBrowser($browserName) { return( 0 == strcasecmp($this->_browser_name, trim($browserName))); }
251
+
252
+ /**
253
+ * The name of the browser. All return types are from the class contants
254
+ * @return string Name of the browser
255
+ */
256
+ function getBrowser() { return $this->_browser_name; }
257
+ /**
258
+ * Set the name of the browser
259
+ * @param $browser The name of the Browser
260
+ */
261
+ function setBrowser($browser) { return $this->_browser_name = $browser; }
262
+ /**
263
+ * The name of the platform. All return types are from the class contants
264
+ * @return string Name of the browser
265
+ */
266
+ function getPlatform() { return $this->_platform; }
267
+ /**
268
+ * Set the name of the platform
269
+ * @param $platform The name of the Platform
270
+ */
271
+ function setPlatform($platform) { return $this->_platform = $platform; }
272
+ /**
273
+ * The version of the browser.
274
+ * @return string Version of the browser (will only contain alpha-numeric characters and a period)
275
+ */
276
+ function getVersion() { return $this->_version; }
277
+ /**
278
+ * Set the version of the browser
279
+ * @param $version The version of the Browser
280
+ */
281
+ function setVersion($version) { $this->_version = preg_replace('/[^0-9,.,a-z,A-Z-]/','',$version); }
282
+ /**
283
+ * The version of AOL.
284
+ * @return string Version of AOL (will only contain alpha-numeric characters and a period)
285
+ */
286
+ function getAolVersion() { return $this->_aol_version; }
287
+ /**
288
+ * Set the version of AOL
289
+ * @param $version The version of AOL
290
+ */
291
+ function setAolVersion($version) { $this->_aol_version = preg_replace('/[^0-9,.,a-z,A-Z]/','',$version); }
292
+ /**
293
+ * Is the browser from AOL?
294
+ * @return boolean True if the browser is from AOL otherwise false
295
+ */
296
+ function isAol() { return $this->_is_aol; }
297
+ /**
298
+ * Is the browser from a mobile device?
299
+ * @return boolean True if the browser is from a mobile device otherwise false
300
+ */
301
+ function isMobile() { return $this->_is_mobile; }
302
+ /**
303
+ * Is the browser from a robot (ex Slurp,GoogleBot)?
304
+ * @return boolean True if the browser is from a robot otherwise false
305
+ */
306
+ function isRobot() { return $this->_is_robot; }
307
+ /**
308
+ * Set the browser to be from AOL
309
+ * @param $isAol
310
+ */
311
+ function setAol($isAol) { $this->_is_aol = $isAol; }
312
+ /**
313
+ * Set the Browser to be mobile
314
+ * @param boolean $value is the browser a mobile brower or not
315
+ */
316
+ function setMobile($value=true) { $this->_is_mobile = $value; }
317
+ /**
318
+ * Set the Browser to be a robot
319
+ * @param boolean $value is the browser a robot or not
320
+ */
321
+ function setRobot($value=true) { $this->_is_robot = $value; }
322
+ /**
323
+ * Get the user agent value in use to determine the browser
324
+ * @return string The user agent from the HTTP header
325
+ */
326
+ function getUserAgent() { return $this->_agent; }
327
+ /**
328
+ * Set the user agent value (the construction will use the HTTP header value - this will overwrite it)
329
+ * @param $agent_string The value for the User Agent
330
+ */
331
+ function setUserAgent($agent_string) {
332
+ $this->reset();
333
+ $this->_agent = $agent_string;
334
+ $this->determine();
335
+ }
336
+ /**
337
+ * Used to determine if the browser is actually "chromeframe"
338
+ * @since 1.7
339
+ * @return boolean True if the browser is using chromeframe
340
+ */
341
+ function isChromeFrame() {
342
+ return( strpos($this->_agent,"chromeframe") !== false );
343
+ }
344
+ /**
345
+ * Returns a formatted string with a summary of the details of the browser.
346
+ * @return string formatted string with a summary of the browser
347
+ */
348
+ function __toString() {
349
+ $text1 = $this->getUserAgent(); //grabs the UA (user agent) string
350
+ $UAline1 = substr($text1, 0, 32); //the first line we print should only be the first 32 characters of the UA string
351
+ $text2 = $this->getUserAgent();//now we grab it again and save it to a string
352
+ $towrapUA = str_replace($UAline1, '', $text2);//the rest of the printoff (other than first line) is equivolent
353
+ // To the whole string minus the part we printed off. IE
354
+ // User Agent: thefirst32charactersfromUAline1
355
+ // the rest of it is now stored in
356
+ // $text2 to be printed off
357
+ // But we need to add spaces before each line that is split other than line 1
358
+ $space = '';
359
+ for($i = 0; $i < 25; $i++) {
360
+ $space .= ' ';
361
+ }
362
+ // Now we split the remaining string of UA ($text2) into lines that are prefixed by spaces for formatting
363
+ $wordwrapped = chunk_split($towrapUA, 32, "\n $space");
364
+ return "Platform: {$this->getPlatform()} \n".
365
+ "Browser Name: {$this->getBrowser()} \n" .
366
+ "Browser Version: {$this->getVersion()} \n" .
367
+ "User Agent String: $UAline1 \n\t\t\t " .
368
+ "$wordwrapped";
369
+ }
370
+ /**
371
+ * Protected routine to calculate and determine what the browser is in use (including platform)
372
+ */
373
+ function determine() {
374
+ $this->checkPlatform();
375
+ $this->checkBrowsers();
376
+ $this->checkForAol();
377
+ }
378
+ /**
379
+ * Protected routine to determine the browser type
380
+ * @return boolean True if the browser was detected otherwise false
381
+ */
382
+ function checkBrowsers() {
383
+ return (
384
+ // Well-known, well-used
385
+ // Special Notes:
386
+ // (1) Opera must be checked before FireFox due to the odd
387
+ // user agents used in some older versions of Opera
388
+ // (2) WebTV is strapped onto Internet Explorer so we must
389
+ // check for WebTV before IE
390
+ // (3) (deprecated) Galeon is based on Firefox and needs to be
391
+ // tested before Firefox is tested
392
+ // (4) OmniWeb is based on Safari so OmniWeb check must occur
393
+ // before Safari
394
+ // (5) Netscape 9+ is based on Firefox so Netscape checks
395
+ // before FireFox are necessary
396
+ $this->checkBrowserWebTv() ||
397
+ $this->checkBrowserInternetExplorer() ||
398
+ $this->checkBrowserOpera() ||
399
+ $this->checkBrowserGaleon() ||
400
+ $this->checkBrowserNetscapeNavigator9Plus() ||
401
+ $this->checkBrowserFirefox() ||
402
+ $this->checkBrowserChrome() ||
403
+ $this->checkBrowserOmniWeb() ||
404
+
405
+ // Common mobile
406
+ $this->checkBrowserAndroid() ||
407
+ $this->checkBrowseriPad() ||
408
+ $this->checkBrowseriPod() ||
409
+ $this->checkBrowseriPhone() ||
410
+ $this->checkBrowserBlackBerry() ||
411
+ $this->checkBrowserNokia() ||
412
+
413
+ // Common bots
414
+ $this->checkBrowserGoogleBot() ||
415
+ $this->checkBrowserMSNBot() ||
416
+ $this->checkBrowserSlurp() ||
417
+
418
+ // WebKit base check (post mobile and others)
419
+ $this->checkBrowserSafari() ||
420
+
421
+ // Everyone else
422
+ $this->checkBrowserNetPositive() ||
423
+ $this->checkBrowserFirebird() ||
424
+ $this->checkBrowserKonqueror() ||
425
+ $this->checkBrowserIcab() ||
426
+ $this->checkBrowserPhoenix() ||
427
+ $this->checkBrowserAmaya() ||
428
+ $this->checkBrowserLynx() ||
429
+
430
+ $this->checkBrowserShiretoko() ||
431
+ $this->checkBrowserIceCat() ||
432
+ $this->checkBrowserW3CValidator() ||
433
+ $this->checkBrowserMozilla() /* Mozilla is such an open standard that you must check it last */
434
+ );
435
+ }
436
+
437
+ /**
438
+ * Determine if the user is using a BlackBerry (last updated 1.7)
439
+ * @return boolean True if the browser is the BlackBerry browser otherwise false
440
+ */
441
+ function checkBrowserBlackBerry() {
442
+ if( stripos($this->_agent,'blackberry') !== false ) {
443
+ $aresult = explode("/",stristr($this->_agent,"BlackBerry"));
444
+ $aversion = explode(' ',$aresult[1]);
445
+ $this->setVersion($aversion[0]);
446
+ $this->_browser_name = $this->BROWSER_BLACKBERRY;
447
+ $this->setMobile(true);
448
+ return true;
449
+ }
450
+ return false;
451
+ }
452
+
453
+ /**
454
+ * Determine if the user is using an AOL User Agent (last updated 1.7)
455
+ * @return boolean True if the browser is from AOL otherwise false
456
+ */
457
+ function checkForAol() {
458
+ $this->setAol(false);
459
+ $this->setAolVersion($this->VERSION_UNKNOWN);
460
+
461
+ if( stripos($this->_agent,'aol') !== false ) {
462
+ $aversion = explode(' ',stristr($this->_agent, 'AOL'));
463
+ $this->setAol(true);
464
+ $this->setAolVersion(preg_replace('/[^0-9\.a-z]/i', '', $aversion[1]));
465
+ return true;
466
+ }
467
+ return false;
468
+ }
469
+
470
+ /**
471
+ * Determine if the browser is the GoogleBot or not (last updated 1.7)
472
+ * @return boolean True if the browser is the GoogletBot otherwise false
473
+ */
474
+ function checkBrowserGoogleBot() {
475
+ if( stripos($this->_agent,'googlebot') !== false ) {
476
+ $aresult = explode('/',stristr($this->_agent,'googlebot'));
477
+ $aversion = explode(' ',$aresult[1]);
478
+ $this->setVersion(str_replace(';','',$aversion[0]));
479
+ $this->_browser_name = $this->BROWSER_GOOGLEBOT;
480
+ $this->setRobot(true);
481
+ return true;
482
+ }
483
+ return false;
484
+ }
485
+
486
+ /**
487
+ * Determine if the browser is the MSNBot or not (last updated 1.9)
488
+ * @return boolean True if the browser is the MSNBot otherwise false
489
+ */
490
+ function checkBrowserMSNBot() {
491
+ if( stripos($this->_agent,"msnbot") !== false ) {
492
+ $aresult = explode("/",stristr($this->_agent,"msnbot"));
493
+ $aversion = explode(" ",$aresult[1]);
494
+ $this->setVersion(str_replace(";","",$aversion[0]));
495
+ $this->_browser_name = $this->BROWSER_MSNBOT;
496
+ $this->setRobot(true);
497
+ return true;
498
+ }
499
+ return false;
500
+ }
501
+
502
+ /**
503
+ * Determine if the browser is the W3C Validator or not (last updated 1.7)
504
+ * @return boolean True if the browser is the W3C Validator otherwise false
505
+ */
506
+ function checkBrowserW3CValidator() {
507
+ if( stripos($this->_agent,'W3C-checklink') !== false ) {
508
+ $aresult = explode('/',stristr($this->_agent,'W3C-checklink'));
509
+ $aversion = explode(' ',$aresult[1]);
510
+ $this->setVersion($aversion[0]);
511
+ $this->_browser_name = $this->BROWSER_W3CVALIDATOR;
512
+ return true;
513
+ }
514
+ else if( stripos($this->_agent,'W3C_Validator') !== false ) {
515
+ // Some of the Validator versions do not delineate w/ a slash - add it back in
516
+ $ua = str_replace("W3C_Validator ", "W3C_Validator/", $this->_agent);
517
+ $aresult = explode('/',stristr($ua,'W3C_Validator'));
518
+ $aversion = explode(' ',$aresult[1]);
519
+ $this->setVersion($aversion[0]);
520
+ $this->_browser_name = $this->BROWSER_W3CVALIDATOR;
521
+ return true;
522
+ }
523
+ return false;
524
+ }
525
+
526
+ /**
527
+ * Determine if the browser is the Yahoo! Slurp Robot or not (last updated 1.7)
528
+ * @return boolean True if the browser is the Yahoo! Slurp Robot otherwise false
529
+ */
530
+ function checkBrowserSlurp() {
531
+ if( stripos($this->_agent,'slurp') !== false ) {
532
+ $aresult = explode('/',stristr($this->_agent,'Slurp'));
533
+ $aversion = explode(' ',$aresult[1]);
534
+ $this->setVersion($aversion[0]);
535
+ $this->_browser_name = $this->BROWSER_SLURP;
536
+ $this->setRobot(true);
537
+ $this->setMobile(false);
538
+ return true;
539
+ }
540
+ return false;
541
+ }
542
+
543
+ /**
544
+ * Determine if the browser is Internet Explorer or not (last updated 1.7)
545
+ * @return boolean True if the browser is Internet Explorer otherwise false
546
+ */
547
+ function checkBrowserInternetExplorer() {
548
+
549
+ // Test for v1 - v1.5 IE
550
+ if( stripos($this->_agent,'microsoft internet explorer') !== false ) {
551
+ $this->setBrowser($this->BROWSER_IE);
552
+ $this->setVersion('1.0');
553
+ $aresult = stristr($this->_agent, '/');
554
+ if( preg_match('/308|425|426|474|0b1/i', $aresult) ) {
555
+ $this->setVersion('1.5');
556
+ }
557
+ return true;
558
+ }
559
+ // Test for versions > 1.5
560
+ else if( stripos($this->_agent,'msie') !== false && stripos($this->_agent,'opera') === false ) {
561
+ // See if the browser is the odd MSN Explorer
562
+ if( stripos($this->_agent,'msnb') !== false ) {
563
+ $aresult = explode(' ',stristr(str_replace(';','; ',$this->_agent),'MSN'));
564
+ $this->setBrowser( $this->BROWSER_MSN );
565
+ $this->setVersion(str_replace(array('(',')',';'),'',$aresult[1]));
566
+ return true;
567
+ }
568
+ $aresult = explode(' ',stristr(str_replace(';','; ',$this->_agent),'msie'));
569
+ $this->setBrowser( $this->BROWSER_IE );
570
+ $this->setVersion(str_replace(array('(',')',';'),'',$aresult[1]));
571
+ return true;
572
+ }
573
+ // Test for Pocket IE
574
+ else if( stripos($this->_agent,'mspie') !== false || stripos($this->_agent,'pocket') !== false ) {
575
+ $aresult = explode(' ',stristr($this->_agent,'mspie'));
576
+ $this->setPlatform( $this->PLATFORM_WINDOWS_CE );
577
+ $this->setBrowser( $this->BROWSER_POCKET_IE );
578
+ $this->setMobile(true);
579
+
580
+ if( stripos($this->_agent,'mspie') !== false ) {
581
+ $this->setVersion($aresult[1]);
582
+ }
583
+ else {
584
+ $aversion = explode('/',$this->_agent);
585
+ $this->setVersion($aversion[1]);
586
+ }
587
+ return true;
588
+ }
589
+ return false;
590
+ }
591
+
592
+ /**
593
+ * Determine if the browser is Opera or not (last updated 1.7)
594
+ * @return boolean True if the browser is Opera otherwise false
595
+ */
596
+ function checkBrowserOpera() {
597
+ if( stripos($this->_agent,'opera mini') !== false ) {
598
+ $resultant = stristr($this->_agent, 'opera mini');
599
+ if( preg_match('/\//',$resultant) ) {
600
+ $aresult = explode('/',$resultant);
601
+ $aversion = explode(' ',$aresult[1]);
602
+ $this->setVersion($aversion[0]);
603
+ }
604
+ else {
605
+ $aversion = explode(' ',stristr($resultant,'opera mini'));
606
+ $this->setVersion($aversion[1]);
607
+ }
608
+ $this->_browser_name = $this->BROWSER_OPERA_MINI;
609
+ $this->setMobile(true);
610
+ return true;
611
+ }
612
+ else if( stripos($this->_agent,'opera') !== false ) {
613
+ $resultant = stristr($this->_agent, 'opera');
614
+ if( preg_match('/Version\/(10.*)$/',$resultant,$matches) ) {
615
+ $this->setVersion($matches[1]);
616
+ }
617
+ else if( preg_match('/\//',$resultant) ) {
618
+ $aresult = explode('/',str_replace("("," ",$resultant));
619
+ $aversion = explode(' ',$aresult[1]);
620
+ $this->setVersion($aversion[0]);
621
+ }
622
+ else {
623
+ $aversion = explode(' ',stristr($resultant,'opera'));
624
+ $this->setVersion(isset($aversion[1])?$aversion[1]:"");
625
+ }
626
+ $this->_browser_name = $this->BROWSER_OPERA;
627
+ return true;
628
+ }
629
+ return false;
630
+ }
631
+
632
+ /**
633
+ * Determine if the browser is Chrome or not (last updated 1.7)
634
+ * @return boolean True if the browser is Chrome otherwise false
635
+ */
636
+ function checkBrowserChrome() {
637
+ if( stripos($this->_agent,'Chrome') !== false ) {
638
+ $aresult = explode('/',stristr($this->_agent,'Chrome'));
639
+ $aversion = explode(' ',$aresult[1]);
640
+ $this->setVersion($aversion[0]);
641
+ $this->setBrowser($this->BROWSER_CHROME);
642
+ return true;
643
+ }
644
+ return false;
645
+ }
646
+
647
+
648
+ /**
649
+ * Determine if the browser is WebTv or not (last updated 1.7)
650
+ * @return boolean True if the browser is WebTv otherwise false
651
+ */
652
+ function checkBrowserWebTv() {
653
+ if( stripos($this->_agent,'webtv') !== false ) {
654
+ $aresult = explode('/',stristr($this->_agent,'webtv'));
655
+ $aversion = explode(' ',$aresult[1]);
656
+ $this->setVersion($aversion[0]);
657
+ $this->setBrowser($this->BROWSER_WEBTV);
658
+ return true;
659
+ }
660
+ return false;
661
+ }
662
+
663
+ /**
664
+ * Determine if the browser is NetPositive or not (last updated 1.7)
665
+ * @return boolean True if the browser is NetPositive otherwise false
666
+ */
667
+ function checkBrowserNetPositive() {
668
+ if( stripos($this->_agent,'NetPositive') !== false ) {
669
+ $aresult = explode('/',stristr($this->_agent,'NetPositive'));
670
+ $aversion = explode(' ',$aresult[1]);
671
+ $this->setVersion(str_replace(array('(',')',';'),'',$aversion[0]));
672
+ $this->setBrowser($this->BROWSER_NETPOSITIVE);
673
+ return true;
674
+ }
675
+ return false;
676
+ }
677
+
678
+ /**
679
+ * Determine if the browser is Galeon or not (last updated 1.7)
680
+ * @return boolean True if the browser is Galeon otherwise false
681
+ */
682
+ function checkBrowserGaleon() {
683
+ if( stripos($this->_agent,'galeon') !== false ) {
684
+ $aresult = explode(' ',stristr($this->_agent,'galeon'));
685
+ $aversion = explode('/',$aresult[0]);
686
+ $this->setVersion($aversion[1]);
687
+ $this->setBrowser($this->BROWSER_GALEON);
688
+ return true;
689
+ }
690
+ return false;
691
+ }
692
+
693
+ /**
694
+ * Determine if the browser is Konqueror or not (last updated 1.7)
695
+ * @return boolean True if the browser is Konqueror otherwise false
696
+ */
697
+ function checkBrowserKonqueror() {
698
+ if( stripos($this->_agent,'Konqueror') !== false ) {
699
+ $aresult = explode(' ',stristr($this->_agent,'Konqueror'));
700
+ $aversion = explode('/',$aresult[0]);
701
+ $this->setVersion($aversion[1]);
702
+ $this->setBrowser($this->BROWSER_KONQUEROR);
703
+ return true;
704
+ }
705
+ return false;
706
+ }
707
+
708
+ /**
709
+ * Determine if the browser is iCab or not (last updated 1.7)
710
+ * @return boolean True if the browser is iCab otherwise false
711
+ */
712
+ function checkBrowserIcab() {
713
+ if( stripos($this->_agent,'icab') !== false ) {
714
+ $aversion = explode(' ',stristr(str_replace('/',' ',$this->_agent),'icab'));
715
+ $this->setVersion($aversion[1]);
716
+ $this->setBrowser($this->BROWSER_ICAB);
717
+ return true;
718
+ }
719
+ return false;
720
+ }
721
+
722
+ /**
723
+ * Determine if the browser is OmniWeb or not (last updated 1.7)
724
+ * @return boolean True if the browser is OmniWeb otherwise false
725
+ */
726
+ function checkBrowserOmniWeb() {
727
+ if( stripos($this->_agent,'omniweb') !== false ) {
728
+ $aresult = explode('/',stristr($this->_agent,'omniweb'));
729
+ $aversion = explode(' ',isset($aresult[1])?$aresult[1]:"");
730
+ $this->setVersion($aversion[0]);
731
+ $this->setBrowser($this->BROWSER_OMNIWEB);
732
+ return true;
733
+ }
734
+ return false;
735
+ }
736
+
737
+ /**
738
+ * Determine if the browser is Phoenix or not (last updated 1.7)
739
+ * @return boolean True if the browser is Phoenix otherwise false
740
+ */
741
+ function checkBrowserPhoenix() {
742
+ if( stripos($this->_agent,'Phoenix') !== false ) {
743
+ $aversion = explode('/',stristr($this->_agent,'Phoenix'));
744
+ $this->setVersion($aversion[1]);
745
+ $this->setBrowser($this->BROWSER_PHOENIX);
746
+ return true;
747
+ }
748
+ return false;
749
+ }
750
+
751
+ /**
752
+ * Determine if the browser is Firebird or not (last updated 1.7)
753
+ * @return boolean True if the browser is Firebird otherwise false
754
+ */
755
+ function checkBrowserFirebird() {
756
+ if( stripos($this->_agent,'Firebird') !== false ) {
757
+ $aversion = explode('/',stristr($this->_agent,'Firebird'));
758
+ $this->setVersion($aversion[1]);
759
+ $this->setBrowser($this->BROWSER_FIREBIRD);
760
+ return true;
761
+ }
762
+ return false;
763
+ }
764
+
765
+ /**
766
+ * Determine if the browser is Netscape Navigator 9+ or not (last updated 1.7)
767
+ * NOTE: (http://browser.netscape.com/ - Official support ended on March 1st, 2008)
768
+ * @return boolean True if the browser is Netscape Navigator 9+ otherwise false
769
+ */
770
+ function checkBrowserNetscapeNavigator9Plus() {
771
+ if( stripos($this->_agent,'Firefox') !== false && preg_match('/Navigator\/([^ ]*)/i',$this->_agent,$matches) ) {
772
+ $this->setVersion($matches[1]);
773
+ $this->setBrowser($this->BROWSER_NETSCAPE_NAVIGATOR);
774
+ return true;
775
+ }
776
+ else if( stripos($this->_agent,'Firefox') === false && preg_match('/Netscape6?\/([^ ]*)/i',$this->_agent,$matches) ) {
777
+ $this->setVersion($matches[1]);
778
+ $this->setBrowser($this->BROWSER_NETSCAPE_NAVIGATOR);
779
+ return true;
780
+ }
781
+ return false;
782
+ }
783
+
784
+ /**
785
+ * Determine if the browser is Shiretoko or not (https://wiki.mozilla.org/Projects/shiretoko) (last updated 1.7)
786
+ * @return boolean True if the browser is Shiretoko otherwise false
787
+ */
788
+ function checkBrowserShiretoko() {
789
+ if( stripos($this->_agent,'Mozilla') !== false && preg_match('/Shiretoko\/([^ ]*)/i',$this->_agent,$matches) ) {
790
+ $this->setVersion($matches[1]);
791
+ $this->setBrowser($this->BROWSER_SHIRETOKO);
792
+ return true;
793
+ }
794
+ return false;
795
+ }
796
+
797
+ /**
798
+ * Determine if the browser is Ice Cat or not (http://en.wikipedia.org/wiki/GNU_IceCat) (last updated 1.7)
799
+ * @return boolean True if the browser is Ice Cat otherwise false
800
+ */
801
+ function checkBrowserIceCat() {
802
+ if( stripos($this->_agent,'Mozilla') !== false && preg_match('/IceCat\/([^ ]*)/i',$this->_agent,$matches) ) {
803
+ $this->setVersion($matches[1]);
804
+ $this->setBrowser($this->BROWSER_ICECAT);
805
+ return true;
806
+ }
807
+ return false;
808
+ }
809
+
810
+ /**
811
+ * Determine if the browser is Nokia or not (last updated 1.7)
812
+ * @return boolean True if the browser is Nokia otherwise false
813
+ */
814
+ function checkBrowserNokia() {
815
+ if( preg_match("/Nokia([^\/]+)\/([^ SP]+)/i",$this->_agent,$matches) ) {
816
+ $this->setVersion($matches[2]);
817
+ if( stripos($this->_agent,'Series60') !== false || strpos($this->_agent,'S60') !== false ) {
818
+ $this->setBrowser($this->BROWSER_NOKIA_S60);
819
+ }
820
+ else {
821
+ $this->setBrowser( $this->BROWSER_NOKIA );
822
+ }
823
+ $this->setMobile(true);
824
+ return true;
825
+ }
826
+ return false;
827
+ }
828
+
829
+ /**
830
+ * Determine if the browser is Firefox or not (last updated 1.7)
831
+ * @return boolean True if the browser is Firefox otherwise false
832
+ */
833
+ function checkBrowserFirefox() {
834
+ if( stripos($this->_agent,'safari') === false ) {
835
+ if( preg_match("/Firefox[\/ \(]([^ ;\)]+)/i",$this->_agent,$matches) ) {
836
+ $this->setVersion($matches[1]);
837
+ $this->setBrowser($this->BROWSER_FIREFOX);
838
+ return true;
839
+ }
840
+ else if( preg_match("/Firefox$/i",$this->_agent,$matches) ) {
841
+ $this->setVersion("");
842
+ $this->setBrowser($this->BROWSER_FIREFOX);
843
+ return true;
844
+ }
845
+ }
846
+ return false;
847
+ }
848
+
849
+ /**
850
+ * Determine if the browser is Firefox or not (last updated 1.7)
851
+ * @return boolean True if the browser is Firefox otherwise false
852
+ */
853
+ function checkBrowserIceweasel() {
854
+ if( stripos($this->_agent,'Iceweasel') !== false ) {
855
+ $aresult = explode('/',stristr($this->_agent,'Iceweasel'));
856
+ $aversion = explode(' ',$aresult[1]);
857
+ $this->setVersion($aversion[0]);
858
+ $this->setBrowser($this->BROWSER_ICEWEASEL);
859
+ return true;
860
+ }
861
+ return false;
862
+ }
863
+ /**
864
+ * Determine if the browser is Mozilla or not (last updated 1.7)
865
+ * @return boolean True if the browser is Mozilla otherwise false
866
+ */
867
+ function checkBrowserMozilla() {
868
+ if( stripos($this->_agent,'mozilla') !== false && preg_match('/rv:[0-9].[0-9][a-b]?/i',$this->_agent) && stripos($this->_agent,'netscape') === false) {
869
+ $aversion = explode(' ',stristr($this->_agent,'rv:'));
870
+ preg_match('/rv:[0-9].[0-9][a-b]?/i',$this->_agent,$aversion);
871
+ $this->setVersion(str_replace('rv:','',$aversion[0]));
872
+ $this->setBrowser($this->BROWSER_MOZILLA);
873
+ return true;
874
+ }
875
+ else if( stripos($this->_agent,'mozilla') !== false && preg_match('/rv:[0-9]\.[0-9]/i',$this->_agent) && stripos($this->_agent,'netscape') === false ) {
876
+ $aversion = explode('',stristr($this->_agent,'rv:'));
877
+ $this->setVersion(str_replace('rv:','',$aversion[0]));
878
+ $this->setBrowser($this->BROWSER_MOZILLA);
879
+ return true;
880
+ }
881
+ else if( stripos($this->_agent,'mozilla') !== false && preg_match('/mozilla\/([^ ]*)/i',$this->_agent,$matches) && stripos($this->_agent,'netscape') === false ) {
882
+ $this->setVersion($matches[1]);
883
+ $this->setBrowser($this->BROWSER_MOZILLA);
884
+ return true;
885
+ }
886
+ return false;
887
+ }
888
+
889
+ /**
890
+ * Determine if the browser is Lynx or not (last updated 1.7)
891
+ * @return boolean True if the browser is Lynx otherwise false
892
+ */
893
+ function checkBrowserLynx() {
894
+ if( stripos($this->_agent,'lynx') !== false ) {
895
+ $aresult = explode('/',stristr($this->_agent,'Lynx'));
896
+ $aversion = explode(' ',(isset($aresult[1])?$aresult[1]:""));
897
+ $this->setVersion($aversion[0]);
898
+ $this->setBrowser($this->BROWSER_LYNX);
899
+ return true;
900
+ }
901
+ return false;
902
+ }
903
+
904
+ /**
905
+ * Determine if the browser is Amaya or not (last updated 1.7)
906
+ * @return boolean True if the browser is Amaya otherwise false
907
+ */
908
+ function checkBrowserAmaya() {
909
+ if( stripos($this->_agent,'amaya') !== false ) {
910
+ $aresult = explode('/',stristr($this->_agent,'Amaya'));
911
+ $aversion = explode(' ',$aresult[1]);
912
+ $this->setVersion($aversion[0]);
913
+ $this->setBrowser($this->BROWSER_AMAYA);
914
+ return true;
915
+ }
916
+ return false;
917
+ }
918
+
919
+ /**
920
+ * Determine if the browser is Safari or not (last updated 1.7)
921
+ * @return boolean True if the browser is Safari otherwise false
922
+ */
923
+ function checkBrowserSafari() {
924
+ if( stripos($this->_agent,'Safari') !== false && stripos($this->_agent,'iPhone') === false && stripos($this->_agent,'iPod') === false ) {
925
+ $aresult = explode('/',stristr($this->_agent,'Version'));
926
+ if( isset($aresult[1]) ) {
927
+ $aversion = explode(' ',$aresult[1]);
928
+ $this->setVersion($aversion[0]);
929
+ }
930
+ else {
931
+ $this->setVersion($this->VERSION_UNKNOWN);
932
+ }
933
+ $this->setBrowser($this->BROWSER_SAFARI);
934
+ return true;
935
+ }
936
+ return false;
937
+ }
938
+
939
+ /**
940
+ * Determine if the browser is iPhone or not (last updated 1.7)
941
+ * @return boolean True if the browser is iPhone otherwise false
942
+ */
943
+ function checkBrowseriPhone() {
944
+ if( stripos($this->_agent,'iPhone') !== false ) {
945
+ $aresult = explode('/',stristr($this->_agent,'Version'));
946
+ if( isset($aresult[1]) ) {
947
+ $aversion = explode(' ',$aresult[1]);
948
+ $this->setVersion($aversion[0]);
949
+ }
950
+ else {
951
+ $this->setVersion($this->VERSION_UNKNOWN);
952
+ }
953
+ $this->setMobile(true);
954
+ $this->setBrowser($this->BROWSER_IPHONE);
955
+ return true;
956
+ }
957
+ return false;
958
+ }
959
+
960
+ /**
961
+ * Determine if the browser is iPod or not (last updated 1.7)
962
+ * @return boolean True if the browser is iPod otherwise false
963
+ */
964
+ function checkBrowseriPad() {
965
+ if( stripos($this->_agent,'iPad') !== false ) {
966
+ $aresult = explode('/',stristr($this->_agent,'Version'));
967
+ if( isset($aresult[1]) ) {
968
+ $aversion = explode(' ',$aresult[1]);
969
+ $this->setVersion($aversion[0]);
970
+ }
971
+ else {
972
+ $this->setVersion($this->VERSION_UNKNOWN);
973
+ }
974
+ $this->setMobile(true);
975
+ $this->setBrowser($this->BROWSER_IPAD);
976
+ return true;
977
+ }
978
+ return false;
979
+ }
980
+
981
+ /**
982
+ * Determine if the browser is iPod or not (last updated 1.7)
983
+ * @return boolean True if the browser is iPod otherwise false
984
+ */
985
+ function checkBrowseriPod() {
986
+ if( stripos($this->_agent,'iPod') !== false ) {
987
+ $aresult = explode('/',stristr($this->_agent,'Version'));
988
+ if( isset($aresult[1]) ) {
989
+ $aversion = explode(' ',$aresult[1]);
990
+ $this->setVersion($aversion[0]);
991
+ }
992
+ else {
993
+ $this->setVersion($this->VERSION_UNKNOWN);
994
+ }
995
+ $this->setMobile(true);
996
+ $this->setBrowser($this->BROWSER_IPOD);
997
+ return true;
998
+ }
999
+ return false;
1000
+ }
1001
+
1002
+ /**
1003
+ * Determine if the browser is Android or not (last updated 1.7)
1004
+ * @return boolean True if the browser is Android otherwise false
1005
+ */
1006
+ function checkBrowserAndroid() {
1007
+ if( stripos($this->_agent,'Android') !== false ) {
1008
+ $aresult = explode(' ',stristr($this->_agent,'Android'));
1009
+ if( isset($aresult[1]) ) {
1010
+ $aversion = explode(' ',$aresult[1]);
1011
+ $this->setVersion($aversion[0]);
1012
+ }
1013
+ else {
1014
+ $this->setVersion($this->VERSION_UNKNOWN);
1015
+ }
1016
+ $this->setMobile(true);
1017
+ $this->setBrowser($this->BROWSER_ANDROID);
1018
+ return true;
1019
+ }
1020
+ return false;
1021
+ }
1022
+
1023
+ /**
1024
+ * Determine the user's platform (last updated 1.7)
1025
+ */
1026
+ function checkPlatform() {
1027
+ if( stripos($this->_agent, 'windows') !== false ) {
1028
+ $this->_platform = $this->PLATFORM_WINDOWS;
1029
+ }
1030
+ else if( stripos($this->_agent, 'iPad') !== false ) {
1031
+ $this->_platform = $this->PLATFORM_IPAD;
1032
+ }
1033
+ else if( stripos($this->_agent, 'iPod') !== false ) {
1034
+ $this->_platform = $this->PLATFORM_IPOD;
1035
+ }
1036
+ else if( stripos($this->_agent, 'iPhone') !== false ) {
1037
+ $this->_platform = $this->PLATFORM_IPHONE;
1038
+ }
1039
+ elseif( stripos($this->_agent, 'mac') !== false ) {
1040
+ $this->_platform = $this->PLATFORM_APPLE;
1041
+ }
1042
+ elseif( stripos($this->_agent, 'android') !== false ) {
1043
+ $this->_platform = $this->PLATFORM_ANDROID;
1044
+ }
1045
+ elseif( stripos($this->_agent, 'linux') !== false ) {
1046
+ $this->_platform = $this->PLATFORM_LINUX;
1047
+ }
1048
+ else if( stripos($this->_agent, 'Nokia') !== false ) {
1049
+ $this->_platform = $this->PLATFORM_NOKIA;
1050
+ }
1051
+ else if( stripos($this->_agent, 'BlackBerry') !== false ) {
1052
+ $this->_platform = $this->PLATFORM_BLACKBERRY;
1053
+ }
1054
+ elseif( stripos($this->_agent,'FreeBSD') !== false ) {
1055
+ $this->_platform = $this->PLATFORM_FREEBSD;
1056
+ }
1057
+ elseif( stripos($this->_agent,'OpenBSD') !== false ) {
1058
+ $this->_platform = $this->PLATFORM_OPENBSD;
1059
+ }
1060
+ elseif( stripos($this->_agent,'NetBSD') !== false ) {
1061
+ $this->_platform = $this->PLATFORM_NETBSD;
1062
+ }
1063
+ elseif( stripos($this->_agent, 'OpenSolaris') !== false ) {
1064
+ $this->_platform = $this->PLATFORM_OPENSOLARIS;
1065
+ }
1066
+ elseif( stripos($this->_agent, 'SunOS') !== false ) {
1067
+ $this->_platform = $this->PLATFORM_SUNOS;
1068
+ }
1069
+ elseif( stripos($this->_agent, 'OS\/2') !== false ) {
1070
+ $this->_platform = $this->PLATFORM_OS2;
1071
+ }
1072
+ elseif( stripos($this->_agent, 'BeOS') !== false ) {
1073
+ $this->_platform = $this->PLATFORM_BEOS;
1074
+ }
1075
+ elseif( stripos($this->_agent, 'win') !== false ) {
1076
+ $this->_platform = $this->PLATFORM_WINDOWS;
1077
+ }
1078
+
1079
+ }
1080
+ }
1081
+
1082
+ ?>
includes/misc-functions.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WPRSS Let To Num
4
+ *
5
+ * Does Size Conversions
6
+ *
7
+ * @since 3.1
8
+ * @author Chris Christoff
9
+ * @return $ret
10
+ */
11
+ function wprss_let_to_num( $v ) {
12
+ $l = substr( $v, -1 );
13
+ $ret = substr( $v, 0, -1 );
14
+
15
+ switch ( strtoupper( $l ) ) {
16
+ case 'P':
17
+ $ret *= 1024;
18
+ case 'T':
19
+ $ret *= 1024;
20
+ case 'G':
21
+ $ret *= 1024;
22
+ case 'M':
23
+ $ret *= 1024;
24
+ case 'K':
25
+ $ret *= 1024;
26
+ break;
27
+ }
28
+
29
+ return $ret;
30
+ }
includes/scripts.php ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Scripts
4
+ *
5
+ * @package WPRSSAggregator
6
+ */
7
+
8
+
9
+ add_action( 'admin_enqueue_scripts', 'wprss_admin_scripts_styles' );
10
+ /**
11
+ * Insert required scripts, styles and filters on the admin side
12
+ *
13
+ * @since 2.0
14
+ */
15
+ function wprss_admin_scripts_styles() {
16
+
17
+ // Only load scripts if we are on this plugin's options or settings pages (admin)
18
+ if ( isset( $_GET['page'] ) && ( $_GET['page'] == 'wprss-aggregator' || $_GET['page'] == 'wprss-aggregator-settings'
19
+ || $_GET['page'] == 'wprss-import-export-settings' || $_GET['page'] == 'wprss-debugging' ) ) {
20
+ wp_enqueue_style( 'styles', WPRSS_CSS . 'admin-styles.css' );
21
+ }
22
+
23
+ // Only load scripts if we are on wprss_feed add post or edit post screens
24
+ $screen = get_current_screen();
25
+
26
+ if ( ( 'post' === $screen->base || 'edit' === $screen->base || 'wprss-debugging' === $screen->base ) && ( 'wprss_feed' === $screen->post_type
27
+ || 'wprss_feed_item' === $screen->post_type ) ) {
28
+ wp_enqueue_style( 'admin-styles', WPRSS_CSS . 'admin-styles.css' );
29
+ wp_enqueue_script( 'admin-custom', WPRSS_JS .'admin-custom.js', array('jquery') );
30
+ if ( 'post' === $screen->base && 'wprss_feed' === $screen->post_type ) {
31
+ // Change text on post screen from 'Enter title here' to 'Enter feed name here'
32
+ add_filter( 'enter_title_here', 'wprss_change_title_text' );
33
+ }
34
+ }
35
+
36
+ do_action( 'wprss_admin_scripts_styles' );
37
+ } // end wprss_admin_scripts_styles
38
+
39
+
40
+ add_action( 'wp_enqueue_scripts', 'wprss_load_scripts' );
41
+ /**
42
+ * Enqueues the required scripts.
43
+ *
44
+ * @since 3.0
45
+ */
46
+ function wprss_load_scripts() {
47
+ wp_enqueue_script( 'jquery.colorbox-min', WPRSS_JS . 'jquery.colorbox-min.js', array( 'jquery' ) );
48
+ wp_enqueue_script( 'custom', WPRSS_JS . 'custom.js', array( 'jquery', 'jquery.colorbox-min' ) );
49
+ do_action( 'wprss_register_scripts' );
50
+ } // end wprss_head_scripts_styles
51
+
52
+
53
+ /**
54
+ * Returns the path to the WPRSS templates directory
55
+ *
56
+ * @since 3.0
57
+ * @return string
58
+ */
59
+ function wprss_get_templates_dir() {
60
+ return WPRSS_DIR . 'templates';
61
+ }
62
+
63
+
64
+ /**
65
+ * Returns the URL to the WPRSS templates directory
66
+ *
67
+ * @since 3.0
68
+ * @return string
69
+ */
70
+ function wprss_get_templates_uri() {
71
+ return WPRSS_URI . 'templates';
72
+ }
73
+
74
+
75
+ add_action( 'wp_enqueue_scripts', 'wprss_register_styles' );
76
+ /**
77
+ * Register front end CSS styling files
78
+ * Inspiration from Easy Digital Downloads
79
+ *
80
+ * @since 3.0
81
+ */
82
+ function wprss_register_styles() {
83
+
84
+ $general_settings = get_option( 'wprss_settings_general' );
85
+
86
+ if( $general_settings['styles_disable'] == 1 )
87
+ return;
88
+ wp_enqueue_style( 'colorbox', WPRSS_CSS . 'colorbox.css', array(), '1.4.1' );
89
+ wp_enqueue_style( 'styles', WPRSS_CSS . 'styles.css', array(), '' );
90
+
91
+ /* If using DISABLE CSS option:
92
+ global $edd_options;
93
+
94
+ if( isset( $edd_options['disable_styles'] ) )
95
+ return;
96
+
97
+ */
98
+
99
+ /* $file = 'wprss.css';
100
+
101
+ // Check child theme first
102
+ if ( file_exists( trailingslashit( get_stylesheet_directory() ) . 'wprss_templates/' . $file ) ) {
103
+ $url = trailingslashit( get_stylesheet_directory_uri() ) . 'wprss_templates/' . $file;
104
+
105
+ // Check parent theme next
106
+ } elseif ( file_exists( trailingslashit( get_template_directory() ) . 'wprss_templates/' . $file ) ) {
107
+ $url = trailingslashit( get_template_directory_uri() ) . 'wprss_templates/' . $file;
108
+
109
+ // Check theme compatibility last
110
+ } elseif ( file_exists( trailingslashit( wprss_get_templates_dir() ) . $file ) ) {
111
+ $url = trailingslashit( wprss_get_templates_uri() ) . $file;
112
+ }
113
+
114
+ wp_enqueue_style( 'wprss-styles', $url, WPRSS_VERSION );*/
115
+ }
includes/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');
includes/system-info.php ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * System information
4
+ *
5
+ * @package WPRSSAggregator
6
+ * @subpackage Includes
7
+ * @since 3.1
8
+ * @author Jean Galea <info@jeangalea.com>
9
+ * @copyright Copyright(c) 2012-2013, Jean Galea. Adapted from Easy Digital Downloads by Pippin Williamson
10
+ * @link http://www.wpmayor.com
11
+ * @license http://www.gnu.org/licenses/gpl.html
12
+ */
13
+
14
+ /**
15
+ * Generate the system information
16
+ *
17
+ * @since 3.1
18
+ */
19
+ function wprss_system_info() {
20
+ global $wpdb;
21
+
22
+ if ( ! class_exists( 'Browser' ) )
23
+ require_once WPRSS_DIR . 'includes/libraries/browser.php';
24
+
25
+ $browser = new Browser();
26
+ ?>
27
+ <h3><?php _e( 'System Information', 'wprss' ) ?></h3>
28
+ <form action="<?php echo esc_url( admin_url( 'edit.php?post_type=wprss_feed&page=wprss-debugging' ) ); ?>" method="post">
29
+ <textarea readonly="readonly" onclick="this.focus();this.select()" id="system-info-textarea" name="wprss-sysinfo" title="<?php _e( 'To copy the system info, click below then press Ctrl + C (PC) or Cmd + C (Mac).', 'wprss' ); ?>">
30
+ ### Begin System Info ###
31
+
32
+ ## Please include this information when posting support requests ##
33
+
34
+ Multi-site: <?php echo is_multisite() ? 'Yes' . "\n" : 'No' . "\n" ?>
35
+
36
+ SITE_URL: <?php echo site_url() . "\n"; ?>
37
+ HOME_URL: <?php echo home_url() . "\n"; ?>
38
+
39
+ Plugin Version: <?php echo WPRSS_VERSION . "\n"; ?>
40
+ WordPress Version: <?php echo get_bloginfo( 'version' ) . "\n"; ?>
41
+
42
+ <?php echo $browser ; ?>
43
+
44
+ PHP Version: <?php echo PHP_VERSION . "\n"; ?>
45
+ MySQL Version: <?php echo mysql_get_server_info() . "\n"; ?>
46
+ Web Server Info: <?php echo $_SERVER['SERVER_SOFTWARE'] . "\n"; ?>
47
+
48
+ PHP Safe Mode: <?php echo ini_get( 'safe_mode' ) ? "Yes" : "No\n"; ?>
49
+ PHP Memory Limit: <?php echo ini_get( 'memory_limit' ) . "\n"; ?>
50
+ PHP Post Max Size: <?php echo ini_get( 'post_max_size' ) . "\n"; ?>
51
+ PHP Time Limit: <?php echo ini_get( 'max_execution_time' ) . "\n"; ?>
52
+
53
+ WP_DEBUG: <?php echo defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' . "\n" : 'Disabled' . "\n" : 'Not set' . "\n" ?>
54
+
55
+ WP Table Prefix: <?php echo "Length: ". strlen( $wpdb->prefix ); echo " Status:"; if ( strlen( $wpdb->prefix )>16 ) {echo " ERROR: Too Long";} else {echo " Acceptable";} echo "\n"; ?>
56
+
57
+ Show On Front: <?php echo get_option( 'show_on_front' ) . "\n" ?>
58
+ Page On Front: <?php $id = get_option( 'page_on_front' ); echo get_the_title( $id ) . ' #' . $id . "\n" ?>
59
+ Page For Posts: <?php $id = get_option( 'page_on_front' ); echo get_the_title( $id ) . ' #' . $id . "\n" ?>
60
+
61
+ Session: <?php echo isset( $_SESSION ) ? 'Enabled' : 'Disabled'; ?><?php echo "\n"; ?>
62
+ Session Name: <?php echo esc_html( ini_get( 'session.name' ) ); ?><?php echo "\n"; ?>
63
+ Cookie Path: <?php echo esc_html( ini_get( 'session.cookie_path' ) ); ?><?php echo "\n"; ?>
64
+ Save Path: <?php echo esc_html( ini_get( 'session.save_path' ) ); ?><?php echo "\n"; ?>
65
+ Use Cookies: <?php echo ini_get( 'session.use_cookies' ) ? 'On' : 'Off'; ?><?php echo "\n"; ?>
66
+ Use Only Cookies: <?php echo ini_get( 'session.use_only_cookies' ) ? 'On' : 'Off'; ?><?php echo "\n"; ?>
67
+
68
+ UPLOAD_MAX_FILESIZE: <?php if ( function_exists( 'phpversion' ) ) echo ( wprss_let_to_num( ini_get( 'upload_max_filesize' ) )/( 1024*1024 ) )."MB"; ?><?php echo "\n"; ?>
69
+ POST_MAX_SIZE: <?php if ( function_exists( 'phpversion' ) ) echo ( wprss_let_to_num( ini_get( 'post_max_size' ) )/( 1024*1024 ) )."MB"; ?><?php echo "\n"; ?>
70
+ WordPress Memory Limit: <?php echo ( wprss_let_to_num( WP_MEMORY_LIMIT )/( 1024*1024 ) )."MB"; ?><?php echo "\n"; ?>
71
+ DISPLAY ERRORS: <?php echo ( ini_get( 'display_errors' ) ) ? 'On (' . ini_get( 'display_errors' ) . ')' : 'N/A'; ?><?php echo "\n"; ?>
72
+ FSOCKOPEN: <?php echo ( function_exists( 'fsockopen' ) ) ? __( 'Your server supports fsockopen.', 'wprss' ) : __( 'Your server does not support fsockopen.', 'wprss' ); ?><?php echo "\n"; ?>
73
+
74
+ ACTIVE PLUGINS:
75
+
76
+ <?php
77
+ $plugins = get_plugins();
78
+ $active_plugins = get_option( 'active_plugins', array() );
79
+
80
+ foreach ( $plugins as $plugin_path => $plugin ):
81
+ // If the plugin isn't active, don't show it.
82
+ if ( ! in_array( $plugin_path, $active_plugins ) ) {
83
+ $inactive_plugins[] = $plugin;
84
+ continue;
85
+ }
86
+
87
+ echo $plugin['Name']; ?>: <?php echo $plugin['Version'] ."\n";
88
+
89
+ endforeach; ?>
90
+
91
+ DEACTIVATED PLUGINS:
92
+
93
+ <?php
94
+
95
+ foreach ( $inactive_plugins as $inactive_plugin ):
96
+
97
+ echo $inactive_plugin['Name']; ?>: <?php echo $inactive_plugin['Version'] ."\n";
98
+
99
+ endforeach; ?>
100
+
101
+ CURRENT THEME:
102
+
103
+ <?php
104
+ if ( get_bloginfo( 'version' ) < '3.4' ) {
105
+ $theme_data = get_theme_data( get_stylesheet_directory() . '/style.css' );
106
+ echo $theme_data['Name'] . ': ' . $theme_data['Version'];
107
+ } else {
108
+ $theme_data = wp_get_theme();
109
+ echo $theme_data->Name . ': ' . $theme_data->Version;
110
+ }
111
+ ?>
112
+
113
+
114
+ ### End System Info ###
115
+ </textarea>
116
+ <p class="submit">
117
+ <input type="hidden" name="wprss-action" value="download_sysinfo" />
118
+ <?php submit_button( __( 'Download System Info File', 'wprss' ), 'primary', 'wprss-download-sysinfo', false ); ?>
119
+ </p>
120
+ </form>
121
+
122
+ <?php
123
+ }
124
+
125
+ /**
126
+ * Generates the System Info Download File
127
+ *
128
+ * @since 3.1
129
+ * @return void
130
+ */
131
+ function wprss_generate_sysinfo_download() {
132
+ nocache_headers();
133
+
134
+ header( "Content-type: text/plain" );
135
+ header( 'Content-Disposition: attachment; filename="wprss-system-info.txt"' );
136
+
137
+ echo wp_strip_all_tags( $_POST['wprss-sysinfo'] );
138
+ exit;
139
+ }
140
+ add_action( 'wprss_download_sysinfo', 'wprss_generate_sysinfo_download' );
includes/update.php ADDED
@@ -0,0 +1,211 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Contains all the functions related to updating the plugin from
4
+ * one version to another
5
+ *
6
+ * @package WP RSS Aggregator
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 3.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_insert_all_feed_items();
39
+ }
40
+
41
+ // For version 1.1 to 3.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_insert_all_feed_items();
48
+ }
49
+
50
+ // For version 2+ to 3.0
51
+ // We check if wprss_settings option exists, as this only exists prior to version 3.0
52
+ // Settings field changed, and another added
53
+ elseif ( intval( $old_db_version ) < intval( WPRSS_DB_VERSION ) && ( FALSE != get_option( 'wprss_settings' ) ) ) {
54
+ wprss_upgrade_30();
55
+ wprss_update();
56
+ wprss_fetch_insert_all_feed_items();
57
+ }
58
+
59
+ // For any future versions where DB changes
60
+ // If the old version is less than the new version, run the update.
61
+ elseif ( intval( $old_db_version ) < intval( WPRSS_DB_VERSION ) ) {
62
+ wprss_update();
63
+ wprss_fetch_insert_all_feed_items();
64
+ }
65
+
66
+ }
67
+
68
+
69
+ /**
70
+ * Adds the plugin settings on install.
71
+ *
72
+ * @since 2.0
73
+ */
74
+ function wprss_install() {
75
+
76
+ // Add the database version setting.
77
+ add_option( 'wprss_db_version', WPRSS_DB_VERSION );
78
+
79
+ // Add the default plugin settings.
80
+ add_option( 'wprss_settings_general', wprss_get_default_settings_general() );
81
+ }
82
+
83
+
84
+ /**
85
+ * Update settings of plugin to reflect new version
86
+ *
87
+ * @since 2.0
88
+ */
89
+ function wprss_update() {
90
+
91
+ // Update the database version setting.
92
+ update_option( 'wprss_db_version', WPRSS_DB_VERSION );
93
+ // Initialize settings
94
+ wprss_settings_initialize();
95
+ }
96
+
97
+
98
+ /**
99
+ * Initialize settings to default ones if they are not yet set
100
+ *
101
+ * @since 3.0
102
+ */
103
+ function wprss_settings_initialize() {
104
+ // Get the settings from the new field in the database
105
+ $settings = get_option( 'wprss_settings_general' );
106
+
107
+ // Get the default plugin settings.
108
+ $default_settings = wprss_get_default_settings_general();
109
+
110
+ // Loop through each of the default plugin settings.
111
+ foreach ( $default_settings as $setting_key => $setting_value ) {
112
+
113
+ // If the setting didn't previously exist, add the default value to the $settings array.
114
+ if ( ! isset( $settings[ $setting_key ] ) )
115
+ $settings[ $setting_key ] = $setting_value;
116
+ }
117
+
118
+ // Update the plugin settings.
119
+ update_option( 'wprss_settings_general', $settings );
120
+ }
121
+
122
+
123
+ /**
124
+ * Takes care of cron and DB changes between versions 2+ and 3
125
+ *
126
+ * @since 3.0
127
+ */
128
+ function wprss_upgrade_30() {
129
+ wp_clear_scheduled_hook( 'wprss_fetch_feeds_hook' );
130
+
131
+ // Get the settings from the database.
132
+ $settings = get_option( 'wprss_settings' );
133
+
134
+ // Put them into our new field
135
+ update_option( 'wprss_settings_general', $settings );
136
+
137
+ // Remove old options field, we are now using wprss_settings_general
138
+ delete_option( 'wprss_settings' );
139
+ }
140
+
141
+
142
+ /**
143
+ * Migrates the feed sources from the wprss_options field to the wp_posts table (for older versions)
144
+ *
145
+ * @since 2.0
146
+ */
147
+ function wprss_migrate() {
148
+
149
+ // Get the plugin options
150
+ $options = get_option( 'wprss_options' );
151
+
152
+ $feed_sources = array_chunk( $options, 2 );
153
+
154
+ foreach ( $feed_sources as $feed_source ) {
155
+ $feed_title = $feed_source[0];
156
+ $feed_url = $feed_source[1];
157
+
158
+ // Create post object
159
+ $feed_item = array(
160
+ 'post_title' => $feed_title,
161
+ 'post_content' => '',
162
+ 'post_status' => 'publish',
163
+ 'post_type' => 'wprss_feed'
164
+ );
165
+
166
+ $inserted_ID = wp_insert_post( $feed_item, $wp_error );
167
+ // insert post meta
168
+ update_post_meta( $inserted_ID, 'wprss_url', $feed_url );
169
+ }
170
+ // delete unneeded option
171
+ delete_option( 'wprss_options' );
172
+ }
173
+
174
+
175
+ /**
176
+ * Returns an array of the default plugin settings. These are only used on initial setup.
177
+ *
178
+ * @since 2.0
179
+ */
180
+ function wprss_get_default_settings_general() {
181
+
182
+ // Set up the default plugin settings
183
+ $settings = apply_filters(
184
+ 'wprss_default_settings_general',
185
+ array(
186
+ // from version 1.1
187
+ 'open_dd' => __( 'New window' ),
188
+ 'follow_dd' => __( 'No follow' ),
189
+
190
+ // from version 2.0
191
+ 'feed_limit' => 15,
192
+
193
+ // from version 3.0
194
+ 'date_format' => 'Y-m-d',
195
+ 'limit_feed_items_db' => 200,
196
+ 'cron_interval' => 'hourly',
197
+ 'styles_disable' => 0,
198
+ 'title_link' => 1,
199
+ 'source_enable' => 1,
200
+ 'text_preceding_source' => 'Source:',
201
+ 'date_enable' => 1,
202
+ 'text_preceding_date' => 'Published on',
203
+
204
+ // from version 3.1
205
+ 'limit_feed_items_imported' => 200,
206
+ )
207
+ );
208
+
209
+ // Return the default settings
210
+ return $settings;
211
+ }
js/admin-custom.js ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery( document ).ready( function() {
2
+
3
+ // On TAB pressed when on title input field, go to URL input field
4
+ jQuery('input#title').on( 'keydown', function( event ) {
5
+
6
+ if ( event.which == 9 ) {
7
+ event.preventDefault();
8
+ jQuery('input#wprss_url').focus();
9
+ }
10
+ }
11
+ );
12
+
13
+ // On TAB pressed when on description textarea field, go to Publish submit button
14
+ jQuery('textarea#wprss_description').on( 'keydown', function( event ) {
15
+
16
+ if ( event.which == 9 ) {
17
+ event.preventDefault();
18
+ jQuery('input#publish').focus();
19
+ }
20
+ }
21
+ );
22
+ });
23
+
24
+
25
+ /* JS for admin notice - Leave a review */
26
+
27
+ (function ($) {
28
+ "use strict";
29
+ $(function () {
30
+
31
+ // Check to see if the Ajax Notification is visible
32
+ if ($('#dismiss-ajax-notification').length > 0) {
33
+
34
+ // If so, we need to setup an event handler to trigger it's dismissal
35
+ $('#dismiss-ajax-notification').click(function (evt) {
36
+
37
+ evt.preventDefault();
38
+
39
+ // Initiate a request to the server-side
40
+ $.post(ajaxurl, {
41
+
42
+ // The name of the function to fire on the server
43
+ action: 'wprss_hide_admin_notification',
44
+
45
+ // The nonce value to send for the security check
46
+ nonce: $.trim($('#ajax-notification-nonce').text())
47
+
48
+ }, function (response) {
49
+
50
+ // If the response was successful (that is, 1 was returned), hide the notification;
51
+ // Otherwise, we'll change the class name of the notification
52
+ if ('1' === response) {
53
+ $('#ajax-notification').fadeOut('slow');
54
+ } else {
55
+
56
+ $('#ajax-notification')
57
+ .removeClass('updated')
58
+ .addClass('error');
59
+
60
+ } // end if
61
+
62
+ });
63
+
64
+ });
65
+
66
+ } // end if
67
+
68
+ });
69
+ }(jQuery));
js/custom.js ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ jQuery( document ).ready( function() {
2
+ if(jQuery.fn.colorbox) {
3
+ jQuery( 'a.colorbox' ).colorbox(
4
+ {iframe:true, width:'80%', height:'80%'}
5
+ );
6
+ }
7
+ });
js/jquery.colorbox-min.js ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ /*!
2
+ jQuery ColorBox v1.4.1 - 2013-02-14
3
+ (c) 2013 Jack Moore - jacklmoore.com/colorbox
4
+ license: http://www.opensource.org/licenses/mit-license.php
5
+ */
6
+ (function(e,t,i){function o(i,o,n){var r=t.createElement(i);return o&&(r.id=Y+o),n&&(r.style.cssText=n),e(r)}function n(e){var t=T.length,i=(A+e)%t;return 0>i?t+i:i}function r(e,t){return Math.round((/%/.test(e)?("x"===t?k.width():k.height())/100:1)*parseInt(e,10))}function h(e){return K.photo||K.photoRegex.test(e)}function l(e){return K.retinaUrl&&i.devicePixelRatio>1?e.replace(K.photoRegex,K.retinaSuffix):e}function s(t){e.contains(w[0],t.target)||w[0]===t.target||(t.stopPropagation(),w.focus())}function a(){var t,i=e.data(N,V);null==i?(K=e.extend({},J),console&&console.log&&console.log("Error: cboxElement missing settings object")):K=e.extend({},i);for(t in K)e.isFunction(K[t])&&"on"!==t.slice(0,2)&&(K[t]=K[t].call(N));K.rel=K.rel||N.rel||e(N).data("rel")||"nofollow",K.href=K.href||e(N).attr("href"),K.title=K.title||N.title,"string"==typeof K.href&&(K.href=e.trim(K.href))}function d(i,o){e(t).trigger(i),at.trigger(i),e.isFunction(o)&&o.call(N)}function c(){var e,t,i,o,n,r=Y+"Slideshow_",h="click."+Y;K.slideshow&&T[1]?(t=function(){clearTimeout(e)},i=function(){(K.loop||T[A+1])&&(e=setTimeout(G.next,K.slideshowSpeed))},o=function(){M.html(K.slideshowStop).unbind(h).one(h,n),at.bind(it,i).bind(tt,t).bind(ot,n),w.removeClass(r+"off").addClass(r+"on")},n=function(){t(),at.unbind(it,i).unbind(tt,t).unbind(ot,n),M.html(K.slideshowStart).unbind(h).one(h,function(){G.next(),o()}),w.removeClass(r+"on").addClass(r+"off")},K.slideshowAuto?o():n()):w.removeClass(r+"off "+r+"on")}function u(i){U||(N=i,a(),T=e(N),A=0,"nofollow"!==K.rel&&(T=e("."+Z).filter(function(){var t,i=e.data(this,V);return i&&(t=e(this).data("rel")||i.rel||this.rel),t===K.rel}),A=T.index(N),-1===A&&(T=T.add(N),A=T.length-1)),m.css({opacity:parseFloat(K.opacity),cursor:K.overlayClose?"pointer":"auto",visibility:"visible"}).show(),j||(j=q=!0,w.css({visibility:"hidden",display:"block"}),E=o(dt,"LoadedContent","width:0; height:0; overflow:hidden").appendTo(v),_=x.height()+C.height()+v.outerHeight(!0)-v.height(),z=y.width()+b.width()+v.outerWidth(!0)-v.width(),D=E.outerHeight(!0),B=E.outerWidth(!0),K.w=r(K.initialWidth,"x"),K.h=r(K.initialHeight,"y"),G.position(),lt&&k.bind("resize."+st+" scroll."+st,function(){m.css({width:k.width(),height:k.height(),top:k.scrollTop(),left:k.scrollLeft()})}).trigger("resize."+st),c(),d(et,K.onOpen),P.add(W).hide(),R.html(K.close).show(),w.focus(),t.addEventListener&&(t.addEventListener("focus",s,!0),at.one(nt,function(){t.removeEventListener("focus",s,!0)})),K.returnFocus&&at.one(nt,function(){e(N).focus()})),G.load(!0))}function f(){!w&&t.body&&(X=!1,k=e(i),w=o(dt).attr({id:V,"class":ht?Y+(lt?"IE6":"IE"):"",role:"dialog",tabindex:"-1"}).hide(),m=o(dt,"Overlay",lt?"position:absolute":"").hide(),L=o(dt,"LoadingOverlay").add(o(dt,"LoadingGraphic")),g=o(dt,"Wrapper"),v=o(dt,"Content").append(W=o(dt,"Title"),H=o(dt,"Current"),F=o("button","Previous"),S=o("button","Next"),M=o("button","Slideshow"),L,R=o("button","Close")),g.append(o(dt).append(o(dt,"TopLeft"),x=o(dt,"TopCenter"),o(dt,"TopRight")),o(dt,!1,"clear:left").append(y=o(dt,"MiddleLeft"),v,b=o(dt,"MiddleRight")),o(dt,!1,"clear:left").append(o(dt,"BottomLeft"),C=o(dt,"BottomCenter"),o(dt,"BottomRight"))).find("div div").css({"float":"left"}),I=o(dt,!1,"position:absolute; width:9999px; visibility:hidden; display:none"),P=S.add(F).add(H).add(M),e(t.body).append(m,w.append(g,I)))}function p(){function i(e){e.which>1||e.shiftKey||e.altKey||e.metaKey||(e.preventDefault(),u(this))}return w?(X||(X=!0,S.click(function(){G.next()}),F.click(function(){G.prev()}),R.click(function(){G.close()}),m.click(function(){K.overlayClose&&G.close()}),e(t).bind("keydown."+Y,function(e){var t=e.keyCode;j&&K.escKey&&27===t&&(e.preventDefault(),G.close()),j&&K.arrowKey&&T[1]&&!e.altKey&&(37===t?(e.preventDefault(),F.click()):39===t&&(e.preventDefault(),S.click()))}),e.isFunction(e.fn.on)?e(t).on("click."+Y,"."+Z,i):e("."+Z).live("click."+Y,i)),!0):!1}var m,w,g,v,x,y,b,C,T,k,E,I,L,W,H,M,S,F,R,P,K,_,z,D,B,N,A,O,j,q,U,$,G,Q,X,J={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,className:!1,retinaImage:!1,retinaUrl:!1,retinaSuffix:"@2x.$1",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",photoRegex:/\.(gif|png|jp(e|g|eg)|bmp|ico)((#|\?).*)?$/i,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:void 0},V="colorbox",Y="cbox",Z=Y+"Element",et=Y+"_open",tt=Y+"_load",it=Y+"_complete",ot=Y+"_cleanup",nt=Y+"_closed",rt=Y+"_purge",ht=!e.support.leadingWhitespace,lt=ht&&!i.XMLHttpRequest,st=Y+"_IE6",at=e({}),dt="div";e.colorbox||(e(f),G=e.fn[V]=e[V]=function(t,i){var o=this;if(t=t||{},f(),p()){if(e.isFunction(o))o=e("<a/>"),t.open=!0;else if(!o[0])return o;i&&(t.onComplete=i),o.each(function(){e.data(this,V,e.extend({},e.data(this,V)||J,t))}).addClass(Z),(e.isFunction(t.open)&&t.open.call(o)||t.open)&&u(o[0])}return o},G.position=function(e,t){function i(e){x[0].style.width=C[0].style.width=v[0].style.width=parseInt(e.style.width,10)-z+"px",v[0].style.height=y[0].style.height=b[0].style.height=parseInt(e.style.height,10)-_+"px"}var o,n,h,l=0,s=0,a=w.offset();k.unbind("resize."+Y),w.css({top:-9e4,left:-9e4}),n=k.scrollTop(),h=k.scrollLeft(),K.fixed&&!lt?(a.top-=n,a.left-=h,w.css({position:"fixed"})):(l=n,s=h,w.css({position:"absolute"})),s+=K.right!==!1?Math.max(k.width()-K.w-B-z-r(K.right,"x"),0):K.left!==!1?r(K.left,"x"):Math.round(Math.max(k.width()-K.w-B-z,0)/2),l+=K.bottom!==!1?Math.max(k.height()-K.h-D-_-r(K.bottom,"y"),0):K.top!==!1?r(K.top,"y"):Math.round(Math.max(k.height()-K.h-D-_,0)/2),w.css({top:a.top,left:a.left,visibility:"visible"}),e=w.width()===K.w+B&&w.height()===K.h+D?0:e||0,g[0].style.width=g[0].style.height="9999px",o={width:K.w+B+z,height:K.h+D+_,top:l,left:s},0===e&&w.css(o),w.dequeue().animate(o,{duration:e,complete:function(){i(this),q=!1,g[0].style.width=K.w+B+z+"px",g[0].style.height=K.h+D+_+"px",K.reposition&&setTimeout(function(){k.bind("resize."+Y,G.position)},1),t&&t()},step:function(){i(this)}})},G.resize=function(e){j&&(e=e||{},e.width&&(K.w=r(e.width,"x")-B-z),e.innerWidth&&(K.w=r(e.innerWidth,"x")),E.css({width:K.w}),e.height&&(K.h=r(e.height,"y")-D-_),e.innerHeight&&(K.h=r(e.innerHeight,"y")),e.innerHeight||e.height||(E.css({height:"auto"}),K.h=E.height()),E.css({height:K.h}),G.position("none"===K.transition?0:K.speed))},G.prep=function(t){function i(){return K.w=K.w||E.width(),K.w=K.mw&&K.mw<K.w?K.mw:K.w,K.w}function r(){return K.h=K.h||E.height(),K.h=K.mh&&K.mh<K.h?K.mh:K.h,K.h}if(j){var l,s="none"===K.transition?0:K.speed;E.empty().remove(),E=o(dt,"LoadedContent").append(t),E.hide().appendTo(I.show()).css({width:i(),overflow:K.scrolling?"auto":"hidden"}).css({height:r()}).prependTo(v),I.hide(),e(O).css({"float":"none"}),l=function(){function t(){ht&&w[0].style.removeAttribute("filter")}var i,r,l=T.length,a="frameBorder",c="allowTransparency";j&&(r=function(){clearTimeout($),L.hide(),d(it,K.onComplete)},ht&&O&&E.fadeIn(100),W.html(K.title).add(E).show(),l>1?("string"==typeof K.current&&H.html(K.current.replace("{current}",A+1).replace("{total}",l)).show(),S[K.loop||l-1>A?"show":"hide"]().html(K.next),F[K.loop||A?"show":"hide"]().html(K.previous),K.slideshow&&M.show(),K.preloading&&e.each([n(-1),n(1)],function(){var t,i,o=T[this],n=e.data(o,V);n&&n.href?(t=n.href,e.isFunction(t)&&(t=t.call(o))):t=e(o).attr("href"),t&&(h(t)||n.photo)&&(i=new Image,i.src=t)})):P.hide(),K.iframe?(i=o("iframe")[0],a in i&&(i[a]=0),c in i&&(i[c]="true"),K.scrolling||(i.scrolling="no"),e(i).attr({src:K.href,name:(new Date).getTime(),"class":Y+"Iframe",allowFullScreen:!0,webkitAllowFullScreen:!0,mozallowfullscreen:!0}).one("load",r).appendTo(E),at.one(rt,function(){i.src="//about:blank"}),K.fastIframe&&e(i).trigger("load")):r(),"fade"===K.transition?w.fadeTo(s,1,t):t())},"fade"===K.transition?w.fadeTo(s,0,function(){G.position(0,l)}):G.position(s,l)}},G.load=function(t){var n,s,c,u=G.prep;q=!0,O=!1,N=T[A],t||a(),Q&&w.add(m).removeClass(Q),K.className&&w.add(m).addClass(K.className),Q=K.className,d(rt),d(tt,K.onLoad),K.h=K.height?r(K.height,"y")-D-_:K.innerHeight&&r(K.innerHeight,"y"),K.w=K.width?r(K.width,"x")-B-z:K.innerWidth&&r(K.innerWidth,"x"),K.mw=K.w,K.mh=K.h,K.maxWidth&&(K.mw=r(K.maxWidth,"x")-B-z,K.mw=K.w&&K.w<K.mw?K.w:K.mw),K.maxHeight&&(K.mh=r(K.maxHeight,"y")-D-_,K.mh=K.h&&K.h<K.mh?K.h:K.mh),n=K.href,$=setTimeout(function(){L.show()},100),K.inline?(c=o(dt).hide().insertBefore(e(n)[0]),at.one(rt,function(){c.replaceWith(E.children())}),u(e(n))):K.iframe?u(" "):K.html?u(K.html):h(n)?(n=l(n),e(O=new Image).addClass(Y+"Photo").bind("error",function(){K.title=!1,u(o(dt,"Error").html(K.imgError))}).one("load",function(){var e;K.retinaImage&&i.devicePixelRatio>1&&(O.height=O.height/i.devicePixelRatio,O.width=O.width/i.devicePixelRatio),K.scalePhotos&&(s=function(){O.height-=O.height*e,O.width-=O.width*e},K.mw&&O.width>K.mw&&(e=(O.width-K.mw)/O.width,s()),K.mh&&O.height>K.mh&&(e=(O.height-K.mh)/O.height,s())),K.h&&(O.style.marginTop=Math.max(K.mh-O.height,0)/2+"px"),T[1]&&(K.loop||T[A+1])&&(O.style.cursor="pointer",O.onclick=function(){G.next()}),ht&&(O.style.msInterpolationMode="bicubic"),setTimeout(function(){u(O)},1)}),setTimeout(function(){O.src=n},1)):n&&I.load(n,K.data,function(t,i){u("error"===i?o(dt,"Error").html(K.xhrError):e(this).contents())})},G.next=function(){!q&&T[1]&&(K.loop||T[A+1])&&(A=n(1),G.load())},G.prev=function(){!q&&T[1]&&(K.loop||A)&&(A=n(-1),G.load())},G.close=function(){j&&!U&&(U=!0,j=!1,d(ot,K.onCleanup),k.unbind("."+Y+" ."+st),m.fadeTo(200,0),w.stop().fadeTo(300,0,function(){w.add(m).css({opacity:1,cursor:"auto"}).hide(),d(rt),E.empty().remove(),setTimeout(function(){U=!1,d(nt,K.onClosed)},1)}))},G.remove=function(){e([]).add(w).add(m).remove(),w=null,e("."+Z).removeData(V).removeClass(Z),e(t).unbind("click."+Y)},G.element=function(){return e(N)},G.settings=J)})(jQuery,document,window);
languages/default.mo ADDED
Binary file
languages/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 ""
languages/it.mo ADDED
Binary file
languages/it.po ADDED
@@ -0,0 +1,274 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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-30 11:18+0100\n"
6
+ "Last-Translator: Davide De Maestri <davide.demaestri@gmail.com>\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 "Inserisci il nome del feed qui (es: WP Mayor)"
19
+
20
+ #: wp-rss-aggregator.php:394
21
+ msgid "No feed items found"
22
+ msgstr "Nessun feed trovato"
23
+
24
+ #: inc/activation.php:11
25
+ msgid "This plugin requires WordPress version 3.2 or higher."
26
+ msgstr "Questo plugin richiede la versione di WordPress 3.2 o superiore"
27
+
28
+ #: inc/admin-options.php:45 inc/admin-options.php:88
29
+ msgid "WP RSS Aggregator Settings"
30
+ msgstr "Impostazioni WP RSS Aggregator"
31
+
32
+ #: inc/admin-options.php:45
33
+ msgid "Settings"
34
+ msgstr "Impostazioni"
35
+
36
+ #: inc/admin-options.php:67
37
+ msgid "Open links behaviour"
38
+ msgstr "Comportamento di apertura dei links"
39
+
40
+ #: inc/admin-options.php:70
41
+ msgid "Set links as"
42
+ msgstr "Imposta links come"
43
+
44
+ #: inc/admin-options.php:73
45
+ msgid "Feed limit"
46
+ msgstr "Limite Feed"
47
+
48
+ #: inc/admin-options.php:93
49
+ msgid "Save Settings"
50
+ msgstr "Salva impostazioni"
51
+
52
+ #: inc/admin-options.php:113
53
+ msgid "No follow"
54
+ msgstr "No follow"
55
+
56
+ #: inc/admin-options.php:114
57
+ msgid "Follow"
58
+ msgstr "Follow"
59
+
60
+ #: inc/admin-options.php:132
61
+ msgid "Lightbox"
62
+ msgstr "Lightbox"
63
+
64
+ #: inc/admin-options.php:133
65
+ msgid "New window"
66
+ msgstr "Nuova finestra"
67
+
68
+ #: inc/admin-options.php:134
69
+ msgid "None"
70
+ msgstr "Nessuno"
71
+
72
+ #: inc/cron-jobs.php:53
73
+ msgid "Once Weekly"
74
+ msgstr "Una volta alla settimana"
75
+
76
+ #: inc/custom-post-types.php:30
77
+ msgid "Feed Sources"
78
+ msgstr "Sorgenti Feed"
79
+
80
+ #: inc/custom-post-types.php:31
81
+ msgid "Feed"
82
+ msgstr "Feed"
83
+
84
+ #: inc/custom-post-types.php:32 inc/custom-post-types.php:34
85
+ msgid "Add New Feed Source"
86
+ msgstr "Aggiungi nuova sorgente Feed"
87
+
88
+ #: inc/custom-post-types.php:33
89
+ msgid "All Feed Sources"
90
+ msgstr "Tutte le sorgenti feed"
91
+
92
+ #: inc/custom-post-types.php:35
93
+ msgid "Edit Feed Source"
94
+ msgstr "Modifica sorgente feed"
95
+
96
+ #: inc/custom-post-types.php:36
97
+ msgid "New Feed Source"
98
+ msgstr "Nuova sorgente feed"
99
+
100
+ #: inc/custom-post-types.php:37
101
+ msgid "View Feed Source"
102
+ msgstr "Visualizza sorgente feed"
103
+
104
+ #: inc/custom-post-types.php:38
105
+ msgid "Search Feeds"
106
+ msgstr "Cerca feeds"
107
+
108
+ #: inc/custom-post-types.php:39
109
+ msgid "No Feed Sources Found"
110
+ msgstr "Nessuna sorgente di feed trovata"
111
+
112
+ #: inc/custom-post-types.php:40
113
+ msgid "No Feed Sources Found In Trash"
114
+ msgstr "Nessuna sorgente di feed trovata nel cestino"
115
+
116
+ #: inc/custom-post-types.php:41
117
+ msgid "RSS Aggregator"
118
+ msgstr "Aggregatore RSS"
119
+
120
+ #: inc/custom-post-types.php:58 inc/custom-post-types.php:60
121
+ msgid "Imported Feeds"
122
+ msgstr "Feeds importati"
123
+
124
+ #: inc/custom-post-types.php:59
125
+ msgid "Imported Feed"
126
+ msgstr "Feed importato"
127
+
128
+ #: inc/custom-post-types.php:61
129
+ msgid "View Imported Feed"
130
+ msgstr "Visualizza feed importato"
131
+
132
+ #: inc/custom-post-types.php:62
133
+ msgid "Search Imported Feeds"
134
+ msgstr "Cerca feeds importati"
135
+
136
+ #: inc/custom-post-types.php:63
137
+ msgid "No Imported Feeds Found"
138
+ msgstr "Nessun feed importato trovato"
139
+
140
+ #: inc/custom-post-types.php:64
141
+ msgid "No Imported Feeds Found In Trash"
142
+ msgstr "Nessun feed importato trovato nel cestino"
143
+
144
+ #: inc/custom-post-types.php:83 inc/custom-post-types.php:135
145
+ msgid "Name"
146
+ msgstr "Nome"
147
+
148
+ #: inc/custom-post-types.php:84 inc/custom-post-types.php:306
149
+ msgid "URL"
150
+ msgstr "URL"
151
+
152
+ #: inc/custom-post-types.php:85 inc/custom-post-types.php:313
153
+ msgid "Description"
154
+ msgstr "Descrizione"
155
+
156
+ #: inc/custom-post-types.php:136
157
+ msgid "Permalink"
158
+ msgstr "Permalink"
159
+
160
+ #: inc/custom-post-types.php:137
161
+ msgid "Date published"
162
+ msgstr "Data di pubblicazione"
163
+
164
+ #: inc/custom-post-types.php:138
165
+ msgid "Source"
166
+ msgstr "Sorgente"
167
+
168
+ #: inc/custom-post-types.php:226
169
+ msgid "Save Feed Source"
170
+ msgstr "Salva sorgente feed"
171
+
172
+ #: inc/custom-post-types.php:252
173
+ msgid "WP RSS Aggregator Help"
174
+ msgstr "Aiuto WP RSS Aggregator"
175
+
176
+ #: inc/custom-post-types.php:261
177
+ msgid "Like this plugin?"
178
+ msgstr "Ti piace questo plugin?"
179
+
180
+ #: inc/custom-post-types.php:270
181
+ msgid "Follow us"
182
+ msgstr "Seguici"
183
+
184
+ #: inc/custom-post-types.php:279
185
+ msgid "Feed Source Details"
186
+ msgstr "Dettagli sorgente feed"
187
+
188
+ #: inc/custom-post-types.php:288
189
+ msgid "Feed Preview"
190
+ msgstr "Anteprima Feed"
191
+
192
+ #: inc/custom-post-types.php:307
193
+ msgid "Enter feed URL (including http://)"
194
+ msgstr "Inserisci l'URL del feed (includi http://)"
195
+
196
+ #: inc/custom-post-types.php:314
197
+ msgid "A short description about this feed source (optional)"
198
+ msgstr "Una breve descrizione di questa sorgente feed (opzionale)"
199
+
200
+ #: inc/custom-post-types.php:438
201
+ msgid "Delete Permanently"
202
+ msgstr "Elimina permanentemente"
203
+
204
+ #: inc/custom-post-types.php:440
205
+ msgid "Move to Trash"
206
+ msgstr "Sposta nel cestino"
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
+ "<strong>URL del feed non valido</strong> - Ricontrolla l'URL della sorgente "
214
+ "del feed nelle impostazioni sopra."
215
+
216
+ #: inc/custom-post-types.php:474
217
+ msgid "No feed URL defined yet"
218
+ msgstr "Nessun URL del feed ancora definito"
219
+
220
+ #: inc/custom-post-types.php:486
221
+ msgid "Need help?"
222
+ msgstr "Hai bisogno di aiuto?"
223
+
224
+ #: inc/custom-post-types.php:488
225
+ msgid "Check out the support forum"
226
+ msgstr "Controlla il forum di supporto"
227
+
228
+ #: inc/custom-post-types.php:499
229
+ msgid "Why not do any or all of the following"
230
+ msgstr "Perchè non fare alcuna o tutte delle seguenti cose"
231
+
232
+ #: inc/custom-post-types.php:501
233
+ msgid "Give it a 5 star rating on WordPress.org."
234
+ msgstr "Dare 5 stelle su WordPress.org"
235
+
236
+ #: inc/custom-post-types.php:502
237
+ msgid "Donate a token of your appreciation."
238
+ msgstr "Donare una moneta come ringraziamento."
239
+
240
+ #: inc/custom-post-types.php:517
241
+ msgid "Follow WP Mayor on Twitter."
242
+ msgstr "Segui WP Mayor su Twitter"
243
+
244
+ #: inc/custom-post-types.php:518
245
+ msgid "Like WP Mayor on Facebook."
246
+ msgstr "Segui WP Mayor su Facebook"
247
+
248
+ #: inc/custom-post-types.php:535
249
+ msgid "Feed source updated. "
250
+ msgstr "Sorgente feed aggiornata."
251
+
252
+ #: inc/custom-post-types.php:536
253
+ msgid "Custom field updated."
254
+ msgstr "Campo personalizzato aggiornato."
255
+
256
+ #: inc/custom-post-types.php:537
257
+ msgid "Custom field deleted."
258
+ msgstr "Campo personalizzato cancellato."
259
+
260
+ #: inc/custom-post-types.php:538 inc/custom-post-types.php:544
261
+ msgid "Feed source updated."
262
+ msgstr "Sorgente feed aggiornata."
263
+
264
+ #: inc/custom-post-types.php:540 inc/custom-post-types.php:541
265
+ msgid "Feed source saved."
266
+ msgstr "Sorgente feed salvata."
267
+
268
+ #: inc/custom-post-types.php:542
269
+ msgid "Feed source submitted."
270
+ msgstr "Sorgente feed inviata."
271
+
272
+ #: inc/custom-post-types.php:628
273
+ msgid "Publish Feed"
274
+ msgstr "Pubblica Feed"
readme.txt ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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://www.wprssaggregator.com
5
+ Tags: rss, feeds, aggregation, aggregator, import, feed aggregator, rss aggregator, multiple rss feeds, multi rss feeds, multi rss, rss import, feed import, feed import, multiple feed import, feed aggregation, multiple feeds, multi feed importer, multi feed import, multi import, autoblog, autoblogging, autoblogger
6
+ Requires at least: 3.3
7
+ Tested up to: 3.5.1
8
+ Stable tag: 3.1
9
+ Imports and aggregates 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/aggregator on your WordPress site. It works in a similar fashion to RSS readers like for example Google Reader.
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.
17
+ You can call the function from within the theme or even use a shortcode with parameters.
18
+
19
+ Since the plugin uses Custom Post Types to store the imported feeds, you are also free to display them in any way you want, in a similar fashion as you
20
+ would with other post types such as Posts or Pages.
21
+
22
+ = Demo =
23
+ The plugin can be seen in use on the [WPMayor.com WordPress News page](http://www.wpmayor.com/wordpress-news/)
24
+
25
+ = Credit =
26
+ Created by Jean Galea from [WP Mayor](http://www.wpmayor.com)
27
+
28
+ = Translations =
29
+ Italian - Davide De Maestri
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
+ * links_before
41
+ * links_after
42
+ * link_before
43
+ * link_after
44
+
45
+ An example of a shortcode with parameters:
46
+ `[wp_rss_aggregator link_before='<li class="feed-link">' link_after='</li>']`
47
+ It is advisable to use the 'HTML' view of the editor when inserting the shortcode with paramters.
48
+
49
+ An example of a function call from within the template files:
50
+ `
51
+ <?php
52
+ wprss_display_feed_items( $args = array(
53
+ 'links_before' => '<ul>',
54
+ 'links_after' => '</ul>',
55
+ 'link_before' => '<li>',
56
+ 'link_after' => '</li>'
57
+ ));
58
+ ?>
59
+ `
60
+
61
+ OR
62
+
63
+ `<?php do_shortcode('[wp-rss-aggregator]'); ?>`
64
+
65
+ You can also set whether the feed links should open in a new window, current window or even a lightbox, via the settings panel.
66
+
67
+ The settings panel also has an option to set links as nofollow for SEO purposes.
68
+
69
+ Since version 2.0 you can also specify the number of feed items shown on the frontend.
70
+
71
+ == Frequently Asked Questions ==
72
+ = How can I output the feeds in my theme? =
73
+
74
+ You can either call the function directly within the theme:
75
+ `<?php wprss_display_feed_items(); ?>`
76
+
77
+ Or use the shortcode in your posts and pages:
78
+ [wp_rss_aggregator]
79
+
80
+ == Screenshots ==
81
+
82
+ 1. The output of this plugin on the frontend, as seen on www.wpmayor.com.
83
+
84
+ 2. Feed sources list.
85
+
86
+ 3. Adding a new feed source.
87
+
88
+ 4. Imported feeds.
89
+
90
+ 5. Plugin settings page.
91
+
92
+ == Changelog ==
93
+
94
+ = Version 3.1.1 (2013-06-06) =
95
+ * Fixed bug: Incompatibility with some other plugins due to function missing namespace
96
+
97
+ = Version 3.1 (2013-06-06) =
98
+ * New feature: Option to set the number of feed items imported from every feed (default 5)
99
+ * New feature: Import and Export aggregator settings and feed sources
100
+ * New feature: Debugging page allowing manual feed refresh and feed reset
101
+ * Enhanced: Faster handling of restoring sources from trash when feed limit is 0
102
+ * Fixed bug: Limiter on number of overall feeds stored not working
103
+ * Fixed bug: Incompatibility issue with Foobox plugin fixed
104
+ * Fixed bug: Duplicate feeds sometimes imported
105
+
106
+ = Version 3.0 (2013-03-16) =
107
+ * New feature: Option to select cron frequency
108
+ * New feature: Code extensibility added to be compatible with add-ons
109
+ * New feature: Option to set a limit to the number of feeds stored (previously 50, hard coded)
110
+ * New feature: Option to define the format of the date shown below each feed item
111
+ * New feature: Option to show or hide source of feed item
112
+ * New feature: Option to show or hide publish date of feed item
113
+ * New feature: Option to set text preceding publish date
114
+ * New feature: Option to set text preceding source of feed item
115
+ * New feature: Option to link title or not
116
+ * New feature: Limit of 5 items imported for each source instead of 10
117
+ * Enhanced: Performance improvement when publishing * New feeds in admin
118
+ * Enhanced: Query tuning for better performance
119
+ * Enhanced: Major code rewrite, refactoring and inclusion of hooks
120
+ * Enhanced: Updated Colorbox to v1.4.1
121
+ * Enhanced: Better security implementations
122
+ * Enhanced: Better feed preview display
123
+ * Fixed bug: Deletion of items upon source deletion not working properly
124
+ * Requires: WordPress 3.3
125
+
126
+ = Version 2.2.3 (2012-11-01) =
127
+ * Fixed bug: Tab navigation preventing typing in input boxes
128
+ * Removed: Feeds showing up in internal linking pop up
129
+
130
+ = Version 2.2.2 (2012-10-30) =
131
+ * Removed: Feeds showing up in site search results
132
+ * Enhanced: Better tab button navigation when adding a new feed
133
+ * Enhanced: Better guidance when a feed URL is invalid
134
+
135
+ = Version 2.2.1 (2012-10-17) =
136
+ * Fixed bug: wprss_feed_source_order assumes everyone is an admin
137
+
138
+ = Version 2.2 (2012-10-01) =
139
+ * Italian translation added
140
+ * Feed source order changed to alphabetical
141
+ * Fixed bug - repeated entries when having a non-valid feed source
142
+ * Fixed bug - all imported feeds deleted upon trashing a single feed source
143
+
144
+ = Version 2.1 (2012-09-27) =
145
+ * Now localised for translations
146
+ * Fixed bug with date string
147
+ * Fixed $link_before and $link_after, now working
148
+ * Added backwards compatibility for wp_rss_aggregator() function
149
+
150
+ = Version 2.0 (2012-09-21) =
151
+ * Bulk of code rewritten and refactored
152
+ * Added install and upgrade functions
153
+ * Added DB version setting
154
+ * Feed sources now stored as Custom Post Types
155
+ * Feed source list sortable ascending or descending by name
156
+ * Removed days subsections in feed display
157
+ * Ability to limit total number of feeds displayed
158
+ * Feeds now fetched via Cron
159
+ * Cron job to delete old feed items, keeps max of 50 items in DB
160
+ * Now requires WordPress 3.2
161
+ * Updated colorbox to v1.3.20.1
162
+ * Limit of 15 items max imported for each source
163
+ * Fixed issue of page content displaying incorrectly after feeds
164
+
165
+
166
+ = Version 1.1 (2012-08-13) =
167
+ * Now requires WordPress 3.0
168
+ * More flexible fetching of images directory
169
+ * Has its own top level menu item
170
+ * Added settings section
171
+ * Ability to open in lightbox, new window or default browser behaviour
172
+ * Ability to set links as follow or no follow
173
+ * Using constants for oftenly used locations
174
+ * Code refactoring
175
+ * Changes in file and folder structure
176
+
177
+
178
+ = Version 1.0 (2012-01-06) =
179
+ * Initial release.
templates/wprss.css ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * WP RSS Aggregator Styles
3
+ *
4
+ * @package WP RSS Aggregator
5
+ * @subpackage CSS
6
+ * @copyright Copyright (c) 2013, Jean Galea
7
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
8
+ */
9
+
uninstall.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
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_settings_general' );
10
+ delete_option( 'wprss_db_version' );
11
+ delete_option( 'wprss_settings_notices' );
wp-rss-aggregator.php ADDED
@@ -0,0 +1,195 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: WP RSS Aggregator
4
+ Plugin URI: http://www.wpmayor.com
5
+ Description: Imports and aggregates multiple RSS Feeds using SimplePie
6
+ Version: 3.1.1
7
+ Author: Jean Galea
8
+ Author URI: http://www.wpmayor.com
9
+ License: GPLv3
10
+ */
11
+
12
+ /*
13
+ Copyright 2012-2013 Jean Galea (email : info@jeangalea.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
+ * @package WPRSSAggregator
31
+ * @version 3.1.1
32
+ * @since 1.0
33
+ * @author Jean Galea <info@jeangalea.com>
34
+ * @copyright Copyright (c) 2012-2013, Jean Galea
35
+ * @link http://www.wpmayor.com/
36
+ * @license http://www.gnu.org/licenses/gpl.html
37
+ */
38
+
39
+ /**
40
+ * Define constants used by the plugin.
41
+ */
42
+
43
+ // Set the version number of the plugin.
44
+ if( !defined( 'WPRSS_VERSION' ) )
45
+ define( 'WPRSS_VERSION', '3.1.1', true );
46
+
47
+ // Set the database version number of the plugin.
48
+ if( !defined( 'WPRSS_DB_VERSION' ) )
49
+ define( 'WPRSS_DB_VERSION', 4 );
50
+
51
+ // Set the plugin prefix
52
+ if( !defined( 'WPRSS_PREFIX' ) )
53
+ define( 'WPRSS_PREFIX', 'wprss', true );
54
+
55
+ // Set constant path to the plugin directory.
56
+ if( !defined( 'WPRSS_DIR' ) )
57
+ define( 'WPRSS_DIR', plugin_dir_path( __FILE__ ) );
58
+
59
+ // Set constant URI to the plugin URL.
60
+ if( !defined( 'WPRSS_URI' ) )
61
+ define( 'WPRSS_URI', plugin_dir_url( __FILE__ ) );
62
+
63
+ // Set the constant path to the plugin's javascript directory.
64
+ if( !defined( 'WPRSS_JS' ) )
65
+ define( 'WPRSS_JS', WPRSS_URI . trailingslashit( 'js' ), true );
66
+
67
+ // Set the constant path to the plugin's CSS directory.
68
+ if( !defined( 'WPRSS_CSS' ) )
69
+ define( 'WPRSS_CSS', WPRSS_URI . trailingslashit( 'css' ), true );
70
+
71
+ // Set the constant path to the plugin's images directory.
72
+ if( !defined( 'WPRSS_IMG' ) )
73
+ define( 'WPRSS_IMG', WPRSS_URI . trailingslashit( 'images' ), true );
74
+
75
+ // Set the constant path to the plugin's includes directory.
76
+ if( !defined( 'WPRSS_INC' ) )
77
+ define( 'WPRSS_INC', WPRSS_DIR . trailingslashit( 'includes' ), true );
78
+
79
+
80
+ /**
81
+ * Load required files.
82
+ */
83
+
84
+ /* Load install, upgrade and migration code. */
85
+ require_once ( WPRSS_INC . 'update.php' );
86
+
87
+ /* Load the shortcodes functions file. */
88
+ require_once ( WPRSS_INC . 'shortcodes.php' );
89
+
90
+ /* Load the custom post types and taxonomies. */
91
+ require_once ( WPRSS_INC . 'custom-post-types.php' );
92
+
93
+ /* Load the feed processing functions file */
94
+ require_once ( WPRSS_INC . 'feed-processing.php' );
95
+
96
+ /* Load the feed display functions file */
97
+ require_once ( WPRSS_INC . 'feed-display.php' );
98
+
99
+ /* Load the cron job scheduling functions. */
100
+ require_once ( WPRSS_INC . 'cron-jobs.php' );
101
+
102
+ /* Load the admin functions file. */
103
+ require_once ( WPRSS_INC . 'admin.php' );
104
+
105
+ /* Load the admin options functions file. */
106
+ require_once ( WPRSS_INC . 'admin-options.php' );
107
+
108
+ /* Load the settings import/export file */
109
+ require_once ( WPRSS_INC . 'admin-import-export.php' );
110
+
111
+ /* Load the debugging file */
112
+ require_once ( WPRSS_INC . 'system-info.php' );
113
+
114
+ /* Load the miscellaneous functions file */
115
+ require_once ( WPRSS_INC . 'misc-functions.php' );
116
+
117
+ /* Load the OPMLL importer file */
118
+ require_once ( WPRSS_INC . 'OPML.php' );
119
+
120
+ /* Load the system info file */
121
+ require_once ( WPRSS_INC . 'admin-debugging.php' );
122
+
123
+ /* Load the admin display-related functions */
124
+ require_once ( WPRSS_INC . 'admin-display.php' );
125
+
126
+ /* Load the admin metaboxes functions */
127
+ require_once ( WPRSS_INC . 'admin-metaboxes.php' );
128
+
129
+ /* Load the scripts loading functions file */
130
+ require_once ( WPRSS_INC . 'scripts.php' );
131
+
132
+ /* Load the Ajax notification file */
133
+ require_once ( WPRSS_INC . 'admin-ajax-notice.php' );
134
+
135
+ /* Load the logging class */
136
+ require_once ( WPRSS_INC . 'libraries/WP_Logging.php' );
137
+
138
+ register_activation_hook( __FILE__ , 'wprss_activate' );
139
+ register_deactivation_hook( __FILE__ , 'wprss_deactivate' );
140
+
141
+
142
+ add_action( 'init', 'wprss_init' );
143
+ /**
144
+ * Initialise the plugin
145
+ *
146
+ * @since 1.0
147
+ * @return void
148
+ */
149
+ function wprss_init() {
150
+ do_action( 'wprss_init' );
151
+ }
152
+
153
+
154
+ /**
155
+ * Plugin activation procedure
156
+ *
157
+ * @since 1.0
158
+ * @return void
159
+ */
160
+ function wprss_activate() {
161
+ /* Prevents activation of plugin if compatible version of WordPress not found */
162
+ if ( version_compare( get_bloginfo( 'version' ), '3.3', '<' ) ) {
163
+ deactivate_plugins ( basename( __FILE__ )); // Deactivate plugin
164
+ wp_die( __( 'This plugin requires WordPress version 3.3 or higher.' ), 'WP RSS Aggregator', array( 'back_link' => true ) );
165
+ }
166
+ wprss_settings_initialize();
167
+ flush_rewrite_rules();
168
+ wprss_schedule_fetch_all_feeds_cron();
169
+ }
170
+
171
+
172
+ /**
173
+ * Plugin deactivation procedure
174
+ *
175
+ * @since 1.0
176
+ */
177
+ function wprss_deactivate() {
178
+ // on deactivation remove the cron job
179
+ if ( wp_next_scheduled( 'wprss_fetch_all_feeds_hook' ) ) {
180
+ wp_clear_scheduled_hook( 'wprss_fetch_all_feeds_hook' );
181
+ }
182
+ flush_rewrite_rules();
183
+ }
184
+
185
+
186
+ add_action( 'plugins_loaded', 'wprss_load_textdomain' );
187
+ /**
188
+ * Loads the plugin's translated strings.
189
+ *
190
+ * @since 2.1
191
+ * @return void
192
+ */
193
+ function wprss_load_textdomain() {
194
+ load_plugin_textdomain( 'wprss', false, plugin_dir_path( __FILE__ ) . '/languages/' );
195
+ }