Version Description
Download this release
Release Info
Developer | jeangalea |
Plugin | WP RSS Aggregator |
Version | 3.3.1 |
Comparing to | |
See all releases |
Version 3.3.1
- changelog.txt +106 -0
- css/admin-styles.css +213 -0
- css/colorbox.css +93 -0
- css/styles.css +14 -0
- images/colorbox/border.png +0 -0
- images/colorbox/controls.png +0 -0
- images/colorbox/ie6/borderBottomCenter.png +0 -0
- images/colorbox/ie6/borderBottomLeft.png +0 -0
- images/colorbox/ie6/borderBottomRight.png +0 -0
- images/colorbox/ie6/borderMiddleLeft.png +0 -0
- images/colorbox/ie6/borderMiddleRight.png +0 -0
- images/colorbox/ie6/borderTopCenter.png +0 -0
- images/colorbox/ie6/borderTopLeft.png +0 -0
- images/colorbox/ie6/borderTopRight.png +0 -0
- images/colorbox/loading.gif +0 -0
- images/colorbox/loading_background.png +0 -0
- images/colorbox/overlay.png +0 -0
- images/facebook.png +0 -0
- images/icon-adminmenu16-sprite.png +0 -0
- images/icon-adminpage32.png +0 -0
- images/twitter.png +0 -0
- includes/admin-ajax-notice.php +78 -0
- includes/admin-dashboard.php +98 -0
- includes/admin-debugging.php +111 -0
- includes/admin-display.php +284 -0
- includes/admin-import-export.php +162 -0
- includes/admin-metaboxes.php +337 -0
- includes/admin-options.php +611 -0
- includes/admin-welcome.php +127 -0
- includes/admin.php +110 -0
- includes/cron-jobs.php +80 -0
- includes/custom-feed.php +99 -0
- includes/custom-post-types.php +100 -0
- includes/deprecated-functions.php +83 -0
- includes/feed-display.php +263 -0
- includes/feed-processing.php +450 -0
- includes/libraries/WP_Logging.php +360 -0
- includes/libraries/browser.php +1082 -0
- includes/misc-functions.php +30 -0
- includes/opml-importer.php +231 -0
- includes/opml.php +126 -0
- includes/roles-capabilities.php +107 -0
- includes/scripts.php +119 -0
- includes/shortcodes.php +20 -0
- includes/system-info.php +140 -0
- includes/update.php +215 -0
- js/admin-custom.js +95 -0
- js/custom.js +7 -0
- js/jquery.colorbox-min.js +6 -0
- languages/default.mo +0 -0
- languages/default.po +272 -0
- languages/it.mo +0 -0
- languages/it.po +274 -0
- readme.txt +211 -0
- templates/wprss.css +9 -0
- uninstall.php +12 -0
- wp-rss-aggregator.php +213 -0
changelog.txt
ADDED
@@ -0,0 +1,106 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
3.3.1 (2013-08-09)
|
2 |
+
Fixed Bug: Roles and Capabilities file had not been included
|
3 |
+
Fixed Bug: Error on install, function not found
|
4 |
+
|
5 |
+
3.3 (2013-08-08)
|
6 |
+
New feature: OPML importer
|
7 |
+
New feature: Feed item limits for individual Feed Sources
|
8 |
+
New feature: Custom feed URL
|
9 |
+
New feature: Feed limit on custom feed
|
10 |
+
New feature: New 'Fetch feed items' action for each Feed Source in listing display
|
11 |
+
New feature: Option to enable link to source
|
12 |
+
Enhanced: Date strings now change according to locale being used (i.e. compatible with WPML)
|
13 |
+
Enhanced: Capabilities implemented
|
14 |
+
Enhanced: Feed Sources row action 'View' removed
|
15 |
+
Fixed Bug: Proxy feed URLs resulting in the permalink: example.com/url
|
16 |
+
|
17 |
+
3.2 (2013-07-06)
|
18 |
+
New feature: Parameter to limit number of feeds displayed
|
19 |
+
New feature: Paramter to limit feeds displayed to particular sources (via ID)
|
20 |
+
New feature: Now handles licensing for add-ons
|
21 |
+
Enhanced: Better feed import handling to handle large number of feed sources
|
22 |
+
|
23 |
+
3.1.1 (2013-06-06)
|
24 |
+
Fixed bug: Incompatibility with some other plugins due to function missing namespace
|
25 |
+
|
26 |
+
3.1 (2013-06-06)
|
27 |
+
New feature: Option to set the number of feed items imported from every feed (default 5)
|
28 |
+
New feature: Import and Export aggregator settings and feed sources
|
29 |
+
New feature: Debugging page allowing manual feed refresh and feed reset
|
30 |
+
Enhanced: Faster handling of restoring sources from trash when feed limit is 0
|
31 |
+
Fixed bug: Limiter on number of overall feeds stored not working
|
32 |
+
Fixed bug: Incompatibility issue with Foobox plugin fixed
|
33 |
+
Fixed bug: Duplicate feeds sometimes imported
|
34 |
+
|
35 |
+
3.0 (2013-03-16)
|
36 |
+
New feature: Option to select cron frequency
|
37 |
+
New feature: Code extensibility added to be compatible with add-ons
|
38 |
+
New feature: Option to set a limit to the number of feeds stored (previously 50, hard coded)
|
39 |
+
New feature: Option to define the format of the date shown below each feed item
|
40 |
+
New feature: Option to show or hide source of feed item
|
41 |
+
New feature: Option to show or hide publish date of feed item
|
42 |
+
New feature: Option to set text preceding publish date
|
43 |
+
New feature: Option to set text preceding source of feed item
|
44 |
+
New feature: Option to link title or not
|
45 |
+
New feature: Limit of 5 items imported for each source instead of 10
|
46 |
+
Enhanced: Performance improvement when publishing new feeds in admin
|
47 |
+
Enhanced: Query tuning for better performance
|
48 |
+
Enhanced: Major code rewrite, refactoring and inclusion of hooks
|
49 |
+
Enhanced: Updated Colorbox to v1.4.1
|
50 |
+
Enhanced: Better security implementations
|
51 |
+
Enhanced: Better feed preview display
|
52 |
+
Fixed bug: Deletion of items upon source deletion not working properly
|
53 |
+
Requires: WordPress 3.3
|
54 |
+
|
55 |
+
2.2.3 (2012-11-01)
|
56 |
+
Fixed bug: Tab navigation preventing typing in input boxes
|
57 |
+
Removed: Feeds showing up in internal linking pop up
|
58 |
+
|
59 |
+
2.2.2 (2012-10-30)
|
60 |
+
Removed: Feeds showing up in site search results
|
61 |
+
Enhanced: Better tab button navigation when adding a new feed
|
62 |
+
Enhanced: Better guidance when a feed URL is invalid
|
63 |
+
|
64 |
+
2.2.1 (2012-10-17)
|
65 |
+
Fixed bug: wprss_feed_source_order assumes everyone is an admin
|
66 |
+
|
67 |
+
2.2 (2012-10-01)
|
68 |
+
New feature: Italian translation added
|
69 |
+
Enhanced: Feed source order changed to alphabetical
|
70 |
+
Fixed bug: repeated entries when having a non-valid feed source
|
71 |
+
Fixed bug: all imported feeds deleted upon trashing a single feed source
|
72 |
+
|
73 |
+
2.1 (2012-09-27)
|
74 |
+
New feature: Now localised for translations
|
75 |
+
Fixed bug: with date string
|
76 |
+
Fixed bug: $link_before and $link_after, now working
|
77 |
+
Enhanced: Added backwards compatibility for wp_rss_aggregator() function
|
78 |
+
|
79 |
+
2.0 (2012-09-21)
|
80 |
+
Bulk of code rewritten and refactored
|
81 |
+
Added install and upgrade functions
|
82 |
+
Added DB version setting
|
83 |
+
Feed sources now stored as Custom Post Types
|
84 |
+
Feed source list sortable ascending or descending by name
|
85 |
+
Removed days subsections in feed display
|
86 |
+
Ability to limit total number of feeds displayed
|
87 |
+
Feeds now fetched via Cron
|
88 |
+
Cron job to delete old feed items, keeps max of 50 items in DB
|
89 |
+
Now requires WordPress 3.2
|
90 |
+
updated colorbox to v1.3.20.1
|
91 |
+
Limit of 15 items max imported for each source
|
92 |
+
Fixed issue of page content displaying incorrectly after feeds
|
93 |
+
|
94 |
+
1.1 (2012-08-13)
|
95 |
+
Now requires WordPress 3.0
|
96 |
+
More flexible fetching of images directory
|
97 |
+
Has its own top level menu item
|
98 |
+
Added settings section
|
99 |
+
Ability to open in lightbox, new window or default browser behaviour
|
100 |
+
Ability to set links as follow or no follow
|
101 |
+
Using constants for oftenly used locations
|
102 |
+
Code refactoring
|
103 |
+
Changes in file and folder structure
|
104 |
+
|
105 |
+
1.0 (2012-01-06)
|
106 |
+
First release
|
css/admin-styles.css
ADDED
@@ -0,0 +1,213 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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,
|
90 |
+
input#wprss-et-license-key,
|
91 |
+
input#wprss-c-license-key,
|
92 |
+
input#wprss-kf-license-key {
|
93 |
+
width: 300px;
|
94 |
+
}
|
95 |
+
|
96 |
+
input#thumbnails-height,
|
97 |
+
input#thumbnails-width {
|
98 |
+
/*width: 29px;*/
|
99 |
+
}
|
100 |
+
|
101 |
+
|
102 |
+
/* Red Button */
|
103 |
+
|
104 |
+
.wp-core-ui .button-red {
|
105 |
+
background-color: #9B2124;
|
106 |
+
background-image: -webkit-gradient(linear, left top, left bottom, from(#C5292E), to(#9B2124));
|
107 |
+
background-image: -webkit-linear-gradient(top, #C5292E, #9B2124);
|
108 |
+
background-image: -moz-linear-gradient(top, #C5292E, #9B2124);
|
109 |
+
background-image: -ms-linear-gradient(top, #C5292E, #9B2124);
|
110 |
+
background-image: -o-linear-gradient(top, #C5292E, #9B2124);
|
111 |
+
background-image: linear-gradient(to bottom, #C5292E, #9B2124);
|
112 |
+
border-color: #9B2124;
|
113 |
+
border-bottom-color: #8D1F21;
|
114 |
+
-webkit-box-shadow: inset 0 1px 0 rgba(120,200,230,0.5);
|
115 |
+
box-shadow: inset 0 1px 0 rgba(120,200,230,0.5);
|
116 |
+
color: #fff;
|
117 |
+
text-decoration: none;
|
118 |
+
text-shadow: 0 1px 0 rgba(0,0,0,0.1);
|
119 |
+
/*float: right;*/
|
120 |
+
}
|
121 |
+
|
122 |
+
.wp-core-ui .button-red.hover,
|
123 |
+
.wp-core-ui .button-red:hover,
|
124 |
+
.wp-core-ui .button-red.focus,
|
125 |
+
.wp-core-ui .button-red:focus {
|
126 |
+
background-color: #B72629;
|
127 |
+
background-image: -webkit-gradient(linear, left top, left bottom, from(#D22E30), to(#9B2124));
|
128 |
+
background-image: -webkit-linear-gradient(top, #D22E30, #9B2124);
|
129 |
+
background-image: -moz-linear-gradient(top, #D22E30, #9B2124);
|
130 |
+
background-image: -ms-linear-gradient(top, #D22E30, #9B2124);
|
131 |
+
background-image: -o-linear-gradient(top, #D22E30, #9B2124);
|
132 |
+
background-image: linear-gradient(to bottom, #D22E30, #9B2124);
|
133 |
+
border-color: #7F1C1F;
|
134 |
+
-webkit-box-shadow: inset 0 1px 0 rgba(120,200,230,0.6);
|
135 |
+
box-shadow: inset 0 1px 0 rgba(120,200,230,0.6);
|
136 |
+
color: #fff;
|
137 |
+
text-shadow: 0 -1px 0 rgba(0,0,0,0.3);
|
138 |
+
}
|
139 |
+
|
140 |
+
.wp-core-ui .button-red.focus,
|
141 |
+
.wp-core-ui .button-red:focus {
|
142 |
+
border-color: #500F0E;
|
143 |
+
-webkit-box-shadow: inset 0 1px 0 rgba(120,200,230,0.6), 1px 1px 2px rgba(0,0,0,0.4);
|
144 |
+
box-shadow: inset 0 1px 0 rgba(120,200,230,0.6), 1px 1px 2px rgba(0,0,0,0.4);
|
145 |
+
}
|
146 |
+
|
147 |
+
.wp-core-ui .button-red.active,
|
148 |
+
.wp-core-ui .button-red.active:hover,
|
149 |
+
.wp-core-ui .button-red.active:focus,
|
150 |
+
.wp-core-ui .button-red:active {
|
151 |
+
background: #7F1C1F;
|
152 |
+
background-image: -webkit-gradient(linear, left top, left bottom, from(#9B2124), to(#B72629));
|
153 |
+
background-image: -webkit-linear-gradient(top, #9B2124, #B72629);
|
154 |
+
background-image: -moz-linear-gradient(top, #9B2124, #B72629);
|
155 |
+
background-image: -ms-linear-gradient(top, #9B2124, #B72629);
|
156 |
+
background-image: -o-linear-gradient(top, #9B2124, #B72629);
|
157 |
+
background-image: linear-gradient(to bottom, #9B2124, #B72629);
|
158 |
+
border-color: #601312 #AE2426 #AE2426 #AE2426;
|
159 |
+
color: rgba(255,255,255,0.95);
|
160 |
+
-webkit-box-shadow: inset 0 1px 0 rgba(0,0,0,0.1);
|
161 |
+
box-shadow: inset 0 1px 0 rgba(0,0,0,0.1);
|
162 |
+
text-shadow: 0 1px 0 rgba(0,0,0,0.1);
|
163 |
+
}
|
164 |
+
|
165 |
+
.wp-core-ui .button-red[disabled],
|
166 |
+
.wp-core-ui .button-red:disabled,
|
167 |
+
.wp-core-ui .button-red-disabled {
|
168 |
+
color: #E79496 !important;
|
169 |
+
background: #BA292B !important;
|
170 |
+
border-color: #7F1C1F !important;
|
171 |
+
-webkit-box-shadow: none !important;
|
172 |
+
box-shadow: none !important;
|
173 |
+
text-shadow: 0 -1px 0 rgba(0,0,0,0.1) !important;
|
174 |
+
cursor: default;
|
175 |
+
}
|
176 |
+
|
177 |
+
#system-info-textarea {
|
178 |
+
width: 800px;
|
179 |
+
height: 400px;
|
180 |
+
font-family: Menlo, Monaco, monospace;
|
181 |
+
background: none;
|
182 |
+
white-space: pre;
|
183 |
+
overflow: auto;
|
184 |
+
display: block;
|
185 |
+
}
|
186 |
+
|
187 |
+
|
188 |
+
/* Number Roller for Feed Source Limit */
|
189 |
+
.wprss-number-roller {
|
190 |
+
width: 75px;
|
191 |
+
}
|
192 |
+
|
193 |
+
/* Welcome Screen */
|
194 |
+
.about-wrap ul {
|
195 |
+
list-style: disc;
|
196 |
+
padding-left: 30px;
|
197 |
+
}
|
198 |
+
|
199 |
+
/* Excerpts and Thumbnails */
|
200 |
+
|
201 |
+
input#thumbnails-height,
|
202 |
+
input#thumbnails-width {
|
203 |
+
margin-right: 2px;
|
204 |
+
}
|
205 |
+
|
206 |
+
label[for=thumbnails-height],
|
207 |
+
label[for=thumbnails-width] {
|
208 |
+
margin-left: 8px;
|
209 |
+
}
|
210 |
+
|
211 |
+
.wp-list-table > thead > tr > th#thumbnail[scope="col"] {
|
212 |
+
width: 95px;
|
213 |
+
}
|
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/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-dashboard.php
ADDED
@@ -0,0 +1,98 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Adds a dashboard page for the admin
|
4 |
+
* It is triggered on plugin activation and upon
|
5 |
+
* update.
|
6 |
+
*
|
7 |
+
* @since 3.3
|
8 |
+
*/
|
9 |
+
|
10 |
+
|
11 |
+
// Exit if the page is accessed directly
|
12 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
13 |
+
|
14 |
+
|
15 |
+
add_action( 'admin_menu', 'wprss_admin_menu' );
|
16 |
+
/**
|
17 |
+
* Adds a dashboard page.
|
18 |
+
* Usde to add the Welcome Page to the dashboard.
|
19 |
+
*
|
20 |
+
* @since 3.3
|
21 |
+
*/
|
22 |
+
function wprss_admin_menu() {
|
23 |
+
// Welcome Page
|
24 |
+
add_dashboard_page(
|
25 |
+
__( 'Welcome to WP RSS Aggregator', 'wprss' ),
|
26 |
+
__( 'Welcome to WP RSS Aggregator', 'wprss' ),
|
27 |
+
'manage_options',
|
28 |
+
'wprss-welcome',
|
29 |
+
'wprss_show_welcome_screen'
|
30 |
+
);
|
31 |
+
}
|
32 |
+
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Callback for the Welcome Dashboard page.
|
36 |
+
* It merely includes the contents of the admin-welcome.php file,
|
37 |
+
* which contains the markup for the welcome screen.
|
38 |
+
*
|
39 |
+
* @since 3.3
|
40 |
+
*/
|
41 |
+
function wprss_show_welcome_screen() {
|
42 |
+
include_once( 'admin-welcome.php' );
|
43 |
+
}
|
44 |
+
|
45 |
+
|
46 |
+
add_action( 'admin_init', 'wprss_welcome' );
|
47 |
+
/**
|
48 |
+
* Detects an activation and redirects the user to
|
49 |
+
* the welcome page.
|
50 |
+
*
|
51 |
+
* @since 3.3
|
52 |
+
*/
|
53 |
+
function wprss_welcome() {
|
54 |
+
// Bail if no activation redirect
|
55 |
+
if ( ! get_transient( '_wprss_activation_redirect' ) )
|
56 |
+
return;
|
57 |
+
|
58 |
+
// Delete the redirect transient
|
59 |
+
delete_transient( '_wprss_activation_redirect' );
|
60 |
+
|
61 |
+
// Bail if activating from network, or bulk
|
62 |
+
if ( is_network_admin() || isset( $_GET['activate-multi'] ) )
|
63 |
+
return;
|
64 |
+
|
65 |
+
wp_safe_redirect( admin_url( 'index.php?page=wprss-welcome' ) );
|
66 |
+
exit;
|
67 |
+
}
|
68 |
+
|
69 |
+
|
70 |
+
add_action( 'admin_head', 'wprss_admin_head' );
|
71 |
+
/**
|
72 |
+
* Removes the dashboard welcome page from the dashboard
|
73 |
+
* menu, and adds some styles for the welcome page.
|
74 |
+
*
|
75 |
+
* @since 3.3
|
76 |
+
*/
|
77 |
+
function wprss_admin_head() {
|
78 |
+
remove_submenu_page( 'index.php', 'wprss-welcome' );
|
79 |
+
?>
|
80 |
+
<style type="text/css" media="screen">
|
81 |
+
/*<![CDATA[*/
|
82 |
+
|
83 |
+
/*.wprss-welcome-table > tbody > tr > td {
|
84 |
+
line-height: 30px;
|
85 |
+
}
|
86 |
+
.wprss-welcome-table > tbody > tr {
|
87 |
+
font-size: 1.3em;
|
88 |
+
font-weight: normal;
|
89 |
+
}
|
90 |
+
.wprss-welcome-table > thead > tr > th{
|
91 |
+
font-size: 2em;
|
92 |
+
border-bottom: 8px solid #999;
|
93 |
+
}*/
|
94 |
+
|
95 |
+
/*]]>*/
|
96 |
+
</style>
|
97 |
+
<?php
|
98 |
+
}
|
includes/admin-debugging.php
ADDED
@@ -0,0 +1,111 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
/*
|
15 |
+
//allow redirection, even if my theme starts to send output to the browser
|
16 |
+
add_action( 'admin_init', 'wprss_do_output_buffer' );
|
17 |
+
function wprss_do_output_buffer() {
|
18 |
+
//ob_start();
|
19 |
+
}*/
|
20 |
+
|
21 |
+
|
22 |
+
add_action( 'init', 'wprss_debug_operations' );
|
23 |
+
/**
|
24 |
+
* Performs debug operations, depending on the POST request.
|
25 |
+
*
|
26 |
+
* @since 3.3
|
27 |
+
*/
|
28 |
+
function wprss_debug_operations(){
|
29 |
+
// If page loading after having clicked 'Update all fields'
|
30 |
+
if ( isset( $_POST['update-feeds'] ) && check_admin_referer( 'wprss-update-feed-items' ) ) {
|
31 |
+
wprss_fetch_insert_all_feed_items();
|
32 |
+
wp_redirect( "edit.php?post_type=wprss_feed&page=wprss-debugging&debug_message=1" );
|
33 |
+
}
|
34 |
+
|
35 |
+
// If page loading after having clicked 'Delete and re-import all fields'
|
36 |
+
else if ( isset( $_POST['reimport-feeds'] ) && check_admin_referer( 'wprss-delete-import-feed-items' ) ) {
|
37 |
+
wprss_feed_reset();
|
38 |
+
wp_redirect( "edit.php?post_type=wprss_feed&page=wprss-debugging&debug_message=2" );
|
39 |
+
}
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Build the debugging page
|
44 |
+
*
|
45 |
+
* @since 3.0
|
46 |
+
*/
|
47 |
+
function wprss_debugging_page_display() {
|
48 |
+
?>
|
49 |
+
|
50 |
+
<div class="wrap">
|
51 |
+
<?php screen_icon( 'wprss-aggregator' ); ?>
|
52 |
+
|
53 |
+
<h2><?php _e( 'Debugging', 'wprss' ); ?></h2>
|
54 |
+
<?php
|
55 |
+
if ( isset( $_GET['debug_message'] )) {//&& ( check_admin_referer( 'wprss-delete-import-feed-items' ) || check_admin_referer( 'wprss-update-feed-items' ) ) ) {
|
56 |
+
$message = $_GET['debug_message'];
|
57 |
+
|
58 |
+
switch ( $message ) {
|
59 |
+
case 1 :
|
60 |
+
wprss_debugging_admin_notice_update_feeds();
|
61 |
+
break;
|
62 |
+
case 2 :
|
63 |
+
wprss_debugging_admin_notice_reimport_feeds();
|
64 |
+
break;
|
65 |
+
}
|
66 |
+
} ?>
|
67 |
+
<h3><?php _e( 'Update All Feeds Now', 'wprss' ); ?></h3>
|
68 |
+
<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' ); ?>
|
69 |
+
<br><?php _e( 'Existing feed items will not be modified.', 'wprss' ); ?>
|
70 |
+
</p>
|
71 |
+
<p><?php _e( '<strong>Note:</strong> This might take more than a few seconds if you have many feed sources.', 'wprss' ); ?></p>
|
72 |
+
|
73 |
+
<form action="edit.php?post_type=wprss_feed&page=wprss-debugging" method="post">
|
74 |
+
|
75 |
+
<?php wp_nonce_field( 'wprss-update-feed-items' );
|
76 |
+
submit_button( __( 'Update all feeds', 'wprss' ), 'primary', 'update-feeds', true ); ?>
|
77 |
+
|
78 |
+
</form>
|
79 |
+
|
80 |
+
<h3><?php _e( 'Delete and Re-import Feeds', 'wprss' ); ?></h3>
|
81 |
+
<p><?php _e( 'Click the red button to delete all imported feed items and re-import them.', 'wprss' ); ?></p>
|
82 |
+
<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>
|
83 |
+
|
84 |
+
<form action="edit.php?post_type=wprss_feed&page=wprss-debugging" method="post">
|
85 |
+
|
86 |
+
<?php wp_nonce_field( 'wprss-delete-import-feed-items' );
|
87 |
+
submit_button( __( 'Delete and Re-import all feeds', 'wprss' ), 'button-red', 'reimport-feeds', true ); ?>
|
88 |
+
|
89 |
+
</form>
|
90 |
+
<?php wprss_system_info(); ?>
|
91 |
+
</div>
|
92 |
+
<?php
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* Output admin notice that feeds have been updated successfully
|
97 |
+
*
|
98 |
+
* @since 3.0
|
99 |
+
*/
|
100 |
+
function wprss_debugging_admin_notice_update_feeds() {
|
101 |
+
echo '<div class="updated"><p>Feeds are being updated in the background.</p></div>';
|
102 |
+
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* Output admin notice that feeds have been deleted and re-imported successfully
|
106 |
+
*
|
107 |
+
* @since 3.0
|
108 |
+
*/
|
109 |
+
function wprss_debugging_admin_notice_reimport_feeds() {
|
110 |
+
echo '<div class="updated"><p>Feeds deleted and are being re-imported in the background.</p></div>';
|
111 |
+
}
|
includes/admin-display.php
ADDED
@@ -0,0 +1,284 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
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|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
$columns = apply_filters( 'wprss_set_feed_custom_columns', $columns );
|
18 |
+
$columns['id'] = __( 'ID', 'wprss' );
|
19 |
+
return $columns;
|
20 |
+
}
|
21 |
+
|
22 |
+
|
23 |
+
add_action( "manage_wprss_feed_posts_custom_column", "wprss_show_custom_columns", 10, 2 );
|
24 |
+
/**
|
25 |
+
* Show up the custom columns for the wprss_feed list
|
26 |
+
*
|
27 |
+
* @since 2.0
|
28 |
+
*/
|
29 |
+
function wprss_show_custom_columns( $column, $post_id ) {
|
30 |
+
|
31 |
+
switch ( $column ) {
|
32 |
+
case 'url':
|
33 |
+
$url = get_post_meta( $post_id, 'wprss_url', true);
|
34 |
+
echo '<a href="' . esc_url($url) . '">' . esc_url($url) . '</a>';
|
35 |
+
break;
|
36 |
+
case 'description':
|
37 |
+
$description = get_post_meta( $post_id, 'wprss_description', true);
|
38 |
+
echo esc_html( $description );
|
39 |
+
break;
|
40 |
+
case 'id':
|
41 |
+
echo esc_html( $post_id );
|
42 |
+
break;
|
43 |
+
}
|
44 |
+
}
|
45 |
+
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Make the custom columns sortable for wprss_feed post type
|
49 |
+
*
|
50 |
+
* @since 2.0
|
51 |
+
*/
|
52 |
+
function wprss_feed_sortable_columns() {
|
53 |
+
$sortable_columns = array(
|
54 |
+
// meta column id => sortby value used in query
|
55 |
+
'title' => 'title',
|
56 |
+
);
|
57 |
+
return apply_filters( 'wprss_feed_sortable_columns', $sortable_columns );
|
58 |
+
}
|
59 |
+
|
60 |
+
|
61 |
+
add_action( 'pre_get_posts', 'wprss_feed_source_order' );
|
62 |
+
/**
|
63 |
+
* Change order of feed sources to alphabetical ascending according to feed name
|
64 |
+
*
|
65 |
+
* @since 2.2
|
66 |
+
*/
|
67 |
+
function wprss_feed_source_order( $query ) {
|
68 |
+
if ( ! is_admin() ) {
|
69 |
+
return;
|
70 |
+
}
|
71 |
+
|
72 |
+
$post_type = $query->get('post_type');
|
73 |
+
|
74 |
+
if ( $post_type == 'wprss_feed' ) {
|
75 |
+
/* Post Column: e.g. title */
|
76 |
+
if ( $query->get( 'orderby' ) == '' ) {
|
77 |
+
$query->set( 'orderby', 'title' );
|
78 |
+
}
|
79 |
+
/* Post Order: ASC / DESC */
|
80 |
+
if( $query->get( 'order' ) == '' ){
|
81 |
+
$query->set( 'order', 'ASC' );
|
82 |
+
}
|
83 |
+
}
|
84 |
+
}
|
85 |
+
|
86 |
+
|
87 |
+
add_filter( 'manage_edit-wprss_feed_item_columns', 'wprss_set_feed_item_custom_columns');
|
88 |
+
/**
|
89 |
+
* Set up the custom columns for the wprss_feed source list
|
90 |
+
*
|
91 |
+
* @since 2.0
|
92 |
+
*/
|
93 |
+
function wprss_set_feed_item_custom_columns( $columns ) {
|
94 |
+
|
95 |
+
$columns = array (
|
96 |
+
'cb' => '<input type="checkbox" />',
|
97 |
+
'title' => __( 'Name', 'wprss' ),
|
98 |
+
'permalink' => __( 'Permalink', 'wprss' ),
|
99 |
+
'publishdate' => __( 'Date published', 'wprss' ),
|
100 |
+
'source' => __( 'Source', 'wprss' )
|
101 |
+
);
|
102 |
+
return apply_filters( 'wprss_set_feed_item_custom_columns', $columns );
|
103 |
+
}
|
104 |
+
|
105 |
+
|
106 |
+
add_action( "manage_wprss_feed_item_posts_custom_column", "wprss_show_feed_item_custom_columns", 10, 2 );
|
107 |
+
/**
|
108 |
+
* Show up the custom columns for the wprss_feed list
|
109 |
+
*
|
110 |
+
* @since 2.0
|
111 |
+
*/
|
112 |
+
function wprss_show_feed_item_custom_columns( $column, $post_id ) {
|
113 |
+
|
114 |
+
switch ( $column ) {
|
115 |
+
case "permalink":
|
116 |
+
$url = get_post_meta( $post_id, 'wprss_item_permalink', true);
|
117 |
+
echo '<a href="' . $url . '">' . $url. '</a>';
|
118 |
+
break;
|
119 |
+
|
120 |
+
case "publishdate":
|
121 |
+
$publishdate = date( 'Y-m-d H:i:s', get_post_meta( get_the_ID(), 'wprss_item_date', true ) ) ;
|
122 |
+
echo $publishdate;
|
123 |
+
break;
|
124 |
+
|
125 |
+
case "source":
|
126 |
+
$query = new WP_Query();
|
127 |
+
$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>';
|
128 |
+
echo $source;
|
129 |
+
break;
|
130 |
+
}
|
131 |
+
}
|
132 |
+
|
133 |
+
|
134 |
+
add_filter( "manage_edit-wprss_feed_item_sortable_columns", "wprss_feed_item_sortable_columns" );
|
135 |
+
/**
|
136 |
+
* Make the custom columns sortable
|
137 |
+
*
|
138 |
+
* @since 2.0
|
139 |
+
*/
|
140 |
+
function wprss_feed_item_sortable_columns() {
|
141 |
+
$sortable_columns = array(
|
142 |
+
// meta column id => sortby value used in query
|
143 |
+
'publishdate' => 'publishdate',
|
144 |
+
'source' => 'source'
|
145 |
+
);
|
146 |
+
return apply_filters( 'wprss_feed_item_sortable_columns', $sortable_columns );
|
147 |
+
}
|
148 |
+
|
149 |
+
|
150 |
+
add_action( 'pre_get_posts', 'wprss_feed_item_orderby' );
|
151 |
+
/**
|
152 |
+
* Change ordering of posts on wprss_feed_item screen
|
153 |
+
*
|
154 |
+
* @since 2.0
|
155 |
+
*/
|
156 |
+
function wprss_feed_item_orderby( $query ) {
|
157 |
+
if( ! is_admin() )
|
158 |
+
return;
|
159 |
+
|
160 |
+
$post_type = $query->get('post_type');
|
161 |
+
|
162 |
+
// If we're on the feed listing admin page
|
163 |
+
if ( $post_type == 'wprss_feed_item') {
|
164 |
+
// Set general orderby to date the feed item was published
|
165 |
+
$query->set('orderby','publishdate');
|
166 |
+
// If user clicks on the reorder link, implement reordering
|
167 |
+
$orderby = $query->get( 'orderby');
|
168 |
+
if( 'publishdate' == $orderby ) {
|
169 |
+
$query->set( 'meta_key', 'wprss_item_date' );
|
170 |
+
$query->set( 'orderby', 'meta_value_num' );
|
171 |
+
}
|
172 |
+
}
|
173 |
+
}
|
174 |
+
|
175 |
+
|
176 |
+
add_filter( 'post_updated_messages', 'wprss_feed_updated_messages' );
|
177 |
+
/**
|
178 |
+
* Change default notification message when new feed is added or updated
|
179 |
+
*
|
180 |
+
* @since 2.0
|
181 |
+
*/
|
182 |
+
function wprss_feed_updated_messages( $messages ) {
|
183 |
+
global $post, $post_ID;
|
184 |
+
|
185 |
+
$messages[ 'wprss_feed' ] = array(
|
186 |
+
0 => '', // Unused. Messages start at index 1.
|
187 |
+
1 => __( 'Feed source updated. ', 'wprss' ),
|
188 |
+
2 => __( 'Custom field updated.', 'wprss' ),
|
189 |
+
3 => __( 'Custom field deleted.', 'wprss' ),
|
190 |
+
4 => __( 'Feed source updated.', 'wprss' ),
|
191 |
+
5 => '',
|
192 |
+
6 => __( 'Feed source saved.', 'wprss' ),
|
193 |
+
7 => __( 'Feed source saved.', 'wprss' ),
|
194 |
+
8 => __( 'Feed source submitted.', 'wprss' ),
|
195 |
+
9 => '',
|
196 |
+
10 => __( 'Feed source updated.', 'wprss' )
|
197 |
+
);
|
198 |
+
|
199 |
+
return apply_filters( 'wprss_feed_updated_messages', $messages );
|
200 |
+
}
|
201 |
+
|
202 |
+
|
203 |
+
add_filter( 'post_row_actions', 'wprss_remove_row_actions', 10, 1 );
|
204 |
+
/**
|
205 |
+
* Remove actions row for imported feed items, we don't want them to be editable or viewable
|
206 |
+
*
|
207 |
+
* @since 2.0
|
208 |
+
*/
|
209 |
+
function wprss_remove_row_actions( $actions )
|
210 |
+
{
|
211 |
+
if ( get_post_type() === 'wprss_feed_item' ) {
|
212 |
+
unset( $actions[ 'edit' ] );
|
213 |
+
unset( $actions[ 'view' ] );
|
214 |
+
//unset( $actions[ 'trash' ] );
|
215 |
+
unset( $actions[ 'inline hide-if-no-js' ] );
|
216 |
+
}
|
217 |
+
elseif ( get_post_type() === 'wprss_feed' ) {
|
218 |
+
unset( $actions[ 'view'] );
|
219 |
+
if ( get_post_status( get_the_ID() ) !== 'trash' ) {
|
220 |
+
$actions[ 'fetch' ] = '<a href="javascript:;" class="wprss_ajax_action" pid="'. get_the_ID() .'" purl="'.home_url().'/wp-admin/admin-ajax.php" title="'. esc_attr( __( 'Fetch Latest Feed Items', 'wprss' ) ) .'" >' . __( 'Fetch Latest Feed Items', 'wprss' ) . '</a>';
|
221 |
+
}
|
222 |
+
}
|
223 |
+
return apply_filters( 'wprss_remove_row_actions', $actions );
|
224 |
+
}
|
225 |
+
|
226 |
+
|
227 |
+
add_action( 'wp_ajax_wprss_fetch_feeds_action', 'wprss_fetch_feeds_action_hook' );
|
228 |
+
/**
|
229 |
+
* The AJAX function for the 'Fetch Feed Items' row action on the
|
230 |
+
* 'All Feed Sources' page.
|
231 |
+
*
|
232 |
+
* @since 3.3
|
233 |
+
*/
|
234 |
+
function wprss_fetch_feeds_action_hook() {
|
235 |
+
if ( isset( $_POST['id'] ) && !empty( $_POST['id'] ) ) {
|
236 |
+
wprss_fetch_insert_single_feed_items( $_POST['id'] );
|
237 |
+
die();
|
238 |
+
}
|
239 |
+
}
|
240 |
+
|
241 |
+
|
242 |
+
add_filter( 'bulk_actions-edit-wprss_feed_item', 'wprss_custom_feed_item_bulk_actions' );
|
243 |
+
/**
|
244 |
+
* Remove bulk action link to edit imported feed items
|
245 |
+
*
|
246 |
+
* @since 2.0
|
247 |
+
*/
|
248 |
+
function wprss_custom_feed_item_bulk_actions( $actions ){
|
249 |
+
unset( $actions[ 'edit' ] );
|
250 |
+
return apply_filters( 'wprss_custom_feed_item_bulk_actions', $actions );
|
251 |
+
}
|
252 |
+
|
253 |
+
|
254 |
+
add_action( 'admin_footer-edit.php', 'wprss_remove_a_from_feed_title' );
|
255 |
+
/**
|
256 |
+
* Remove hyperlink from imported feed titles in list posts screen
|
257 |
+
*
|
258 |
+
* @since 2.0
|
259 |
+
*/
|
260 |
+
function wprss_remove_a_from_feed_title() {
|
261 |
+
if ( 'edit-wprss_feed_item' !== get_current_screen()->id )
|
262 |
+
return;
|
263 |
+
?>
|
264 |
+
|
265 |
+
<script type="text/javascript">
|
266 |
+
jQuery('table.wp-list-table a.row-title').contents().unwrap();
|
267 |
+
</script>
|
268 |
+
<?php
|
269 |
+
}
|
270 |
+
|
271 |
+
|
272 |
+
add_filter( 'gettext', 'wprss_change_publish_button_text', 10, 2 );
|
273 |
+
/**
|
274 |
+
* Modify 'Publish' button text when adding a new feed source
|
275 |
+
*
|
276 |
+
* @since 2.0
|
277 |
+
*/
|
278 |
+
function wprss_change_publish_button_text( $translation, $text ) {
|
279 |
+
if ( 'wprss_feed' == get_post_type()) {
|
280 |
+
if ( $text == 'Publish' )
|
281 |
+
return __( 'Publish Feed', 'wprss' );
|
282 |
+
}
|
283 |
+
return apply_filters( 'wprss_change_publish_button_text', $translation );
|
284 |
+
}
|
includes/admin-import-export.php
ADDED
@@ -0,0 +1,162 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
/**
|
13 |
+
* Handles exporting of aggregator settings
|
14 |
+
*
|
15 |
+
* @since 3.1
|
16 |
+
*/
|
17 |
+
function wp_rss_aggregator_export() {
|
18 |
+
if ( isset( $_POST['export'] ) && check_admin_referer( 'wprss-settings-export' ) ) {
|
19 |
+
$blogname = str_replace( " ", "", get_option( 'blogname' ) );
|
20 |
+
$date = date( "m-d-Y" );
|
21 |
+
$json_name = $blogname . "-" . $date; // Naming the filename that will be generated.
|
22 |
+
|
23 |
+
header( 'Content-Description: File Transfer' );
|
24 |
+
header( "Content-Type: text/json; charset=" . get_option( 'blog_charset' ) );
|
25 |
+
header( "Content-Disposition: attachment; filename=$json_name.json" );
|
26 |
+
wp_rss_set_export_data();
|
27 |
+
die();
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Gathers relevant options, encodes them in Json and echoes the file
|
34 |
+
*
|
35 |
+
* @since 3.1
|
36 |
+
*/
|
37 |
+
function wp_rss_set_export_data() {
|
38 |
+
$options = apply_filters(
|
39 |
+
'wprss_fields_export',
|
40 |
+
array( 'wprss_settings_general' => get_option( 'wprss_settings_general' ) )
|
41 |
+
);
|
42 |
+
$json_file = json_encode( $options );
|
43 |
+
|
44 |
+
foreach ( $options as $key => $value ) {
|
45 |
+
$value = maybe_unserialize( $value );
|
46 |
+
$need_options[ $key ] = $value;
|
47 |
+
}
|
48 |
+
$json_file = json_encode( $need_options ); // Encode data into json data
|
49 |
+
echo $json_file;
|
50 |
+
die();
|
51 |
+
}
|
52 |
+
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Notice for a successful export
|
56 |
+
*
|
57 |
+
* @since 3.1
|
58 |
+
*/
|
59 |
+
function wp_rss_aggregator_export_notice() {
|
60 |
+
echo '<div class="updated"><p>All options are export successfully.</p></div>';
|
61 |
+
|
62 |
+
}
|
63 |
+
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Notice for a successful import
|
67 |
+
*
|
68 |
+
* @since 3.1
|
69 |
+
*/
|
70 |
+
function wp_rss_aggregator_import_notice1() {
|
71 |
+
echo '<div class="updated"><p>' . __( 'All options are restored successfully.', 'wprss' ) . '</p></div>';
|
72 |
+
|
73 |
+
}
|
74 |
+
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Notice for an unsuccessful import
|
78 |
+
*
|
79 |
+
* @since 3.1
|
80 |
+
*/
|
81 |
+
function wp_rss_aggregator_import_notice2() {
|
82 |
+
echo '<div class="error"><p>' . __( 'Invalid file or file size too big.', 'wprss' ) . '</p></div>';
|
83 |
+
|
84 |
+
}
|
85 |
+
|
86 |
+
|
87 |
+
add_action( 'admin_init', 'wp_rss_aggregator_import' );
|
88 |
+
/**
|
89 |
+
* Handles the importing of settings
|
90 |
+
*
|
91 |
+
* @since 3.1
|
92 |
+
*/
|
93 |
+
function wp_rss_aggregator_import(){
|
94 |
+
global $pagenow;
|
95 |
+
if( $pagenow == 'admin.php' ) {
|
96 |
+
//Hope this plugin don't use admin.php for anything
|
97 |
+
return;
|
98 |
+
}
|
99 |
+
if ( isset( $_FILES['import'] ) && check_admin_referer( 'wprss-settings-import' ) ) {
|
100 |
+
if ( $_FILES['import']['error'] > 0) {
|
101 |
+
wp_die( "Error during import" );
|
102 |
+
} else {
|
103 |
+
$file_name = $_FILES['import']['name'];
|
104 |
+
$file_ext = strtolower( end( explode( ".", $file_name ) ) );
|
105 |
+
$file_size = $_FILES['import']['size'];
|
106 |
+
if ( ( $file_ext == "json" ) && ( $file_size < 500000 ) ) {
|
107 |
+
$encode_options = file_get_contents( $_FILES['import']['tmp_name'] );
|
108 |
+
$options = json_decode( $encode_options, true );
|
109 |
+
foreach ( $options as $key => $value ) {
|
110 |
+
update_option( $key, $value );
|
111 |
+
}
|
112 |
+
add_action( 'admin_notices', 'wp_rss_aggregator_import_notice1' );
|
113 |
+
}
|
114 |
+
else {
|
115 |
+
add_action( 'admin_notices', 'wp_rss_aggregator_import_notice2' );
|
116 |
+
}
|
117 |
+
}
|
118 |
+
}
|
119 |
+
}
|
120 |
+
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Handles the import/export page display
|
124 |
+
*
|
125 |
+
* @since 3.1
|
126 |
+
*/
|
127 |
+
function wprss_import_export_settings_page_display() {
|
128 |
+
if ( !isset( $_POST['export'] ) ) { ?>
|
129 |
+
<div class="wrap">
|
130 |
+
<?php screen_icon( 'wprss-aggregator' ); ?>
|
131 |
+
<h2><?php _e( 'Import & Export Settings', 'wprss' ); ?></h2>
|
132 |
+
|
133 |
+
<h3><?php _e( 'Export Settings', 'wprss' ); ?></h3>
|
134 |
+
<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>
|
135 |
+
<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>
|
136 |
+
<form method="post">
|
137 |
+
<p class="submit">
|
138 |
+
<?php wp_nonce_field( 'wprss-settings-export' ); ?>
|
139 |
+
<input type="submit" name="export" value="<?php _e( 'Export Settings', 'wprss' ); ?>" class="button" />
|
140 |
+
</p>
|
141 |
+
</form>
|
142 |
+
|
143 |
+
<h3><?php _e( 'Import Settings', 'wprss' ); ?></h3>
|
144 |
+
<p><?php _e( 'Click the <strong>Choose file</strong> button and choose a backup file.', 'wprss' ); ?></p>
|
145 |
+
<p><?php _e( 'Press the <strong>Import Settings</strong> button, and WordPress will do the rest for you.', 'wprss' ); ?></p>
|
146 |
+
<form method='post' enctype='multipart/form-data'>
|
147 |
+
<p class="submit">
|
148 |
+
<?php wp_nonce_field( 'wprss-settings-import' ); ?>
|
149 |
+
<input type='file' name='import' />
|
150 |
+
<input type='submit' name='import' value="<?php _e( 'Import Settings', 'wprss' ); ?>" class="button" />
|
151 |
+
</p>
|
152 |
+
</form>
|
153 |
+
|
154 |
+
<h3><?php _e( 'Importing/Exporting Feed Sources', 'wprss' ); ?></h3>
|
155 |
+
<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>
|
156 |
+
<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>
|
157 |
+
<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>
|
158 |
+
|
159 |
+
</div>
|
160 |
+
<?php
|
161 |
+
}
|
162 |
+
}
|
includes/admin-metaboxes.php
ADDED
@@ -0,0 +1,337 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|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â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
'high' // $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 |
+
$wprss_meta_fields[ 'limit' ] = array(
|
95 |
+
'label' => __( 'Limit', 'wprss' ),
|
96 |
+
'desc' => __( 'Enter a field limit. Leave blank to use the default setting.', 'wprss' ),
|
97 |
+
'id' => $prefix . 'limit',
|
98 |
+
'type' => 'number'
|
99 |
+
);
|
100 |
+
|
101 |
+
// for extensibility, allows more meta fields to be added
|
102 |
+
return apply_filters( 'wprss_fields', $wprss_meta_fields );
|
103 |
+
}
|
104 |
+
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Set up the meta box for the wprss_feed post type
|
108 |
+
*
|
109 |
+
* @since 2.0
|
110 |
+
*/
|
111 |
+
function wprss_show_meta_box_callback() {
|
112 |
+
global $post;
|
113 |
+
$meta_fields = wprss_get_custom_fields();
|
114 |
+
|
115 |
+
// Use nonce for verification
|
116 |
+
wp_nonce_field( basename( __FILE__ ), 'wprss_meta_box_nonce' );
|
117 |
+
|
118 |
+
// Begin the field table and loop
|
119 |
+
echo '<table class="form-table">';
|
120 |
+
|
121 |
+
foreach ( $meta_fields as $field ) {
|
122 |
+
|
123 |
+
// get value of this field if it exists for this post
|
124 |
+
$meta = get_post_meta( $post->ID, $field['id'], true );
|
125 |
+
// begin a table row with
|
126 |
+
echo '<tr>
|
127 |
+
<th><label for="' . $field['id'] . '">' . $field['label'] . '</label></th>
|
128 |
+
<td>';
|
129 |
+
|
130 |
+
switch( $field['type'] ) {
|
131 |
+
|
132 |
+
// text
|
133 |
+
case 'text':
|
134 |
+
echo '<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'. esc_attr( $meta ) .'" size="55" />
|
135 |
+
<br><span class="description">'.$field['desc'].'</span>';
|
136 |
+
break;
|
137 |
+
|
138 |
+
// textarea
|
139 |
+
case 'textarea':
|
140 |
+
echo '<textarea name="'.$field['id'].'" id="'.$field['id'].'" cols="60" rows="4">'. esc_attr( $meta ) .'</textarea>
|
141 |
+
<br><span class="description">'.$field['desc'].'</span>';
|
142 |
+
break;
|
143 |
+
|
144 |
+
// checkbox
|
145 |
+
case 'checkbox':
|
146 |
+
echo '<input type="checkbox" name="'.$field['id'].'" id="'.$field['id'].'" ', esc_attr( $meta ) ? ' checked="checked"' : '','/>
|
147 |
+
<label for="'.$field['id'].'">'.$field['desc'].'</label>';
|
148 |
+
break;
|
149 |
+
|
150 |
+
// select
|
151 |
+
case 'select':
|
152 |
+
echo '<select name="'.$field['id'].'" id="'.$field['id'].'">';
|
153 |
+
foreach ($field['options'] as $option) {
|
154 |
+
echo '<option', $meta == $option['value'] ? ' selected="selected"' : '', ' value="'.$option['value'].'">'.$option['label'].'</option>';
|
155 |
+
}
|
156 |
+
echo '</select><br><span class="description">'.$field['desc'].'</span>';
|
157 |
+
break;
|
158 |
+
|
159 |
+
// number
|
160 |
+
case 'number':
|
161 |
+
echo '<input class="wprss-number-roller" type="number" placeholder="Default" min="0" name="'.$field['id'].'" id="'.$field['id'].'" value="'.esc_attr( $meta ).'" />
|
162 |
+
<label for="'.$field['id'].'"><span class="description">'.$field['desc'].'</span></label>';
|
163 |
+
|
164 |
+
break;
|
165 |
+
|
166 |
+
} //end switch
|
167 |
+
echo '</td></tr>';
|
168 |
+
} // end foreach
|
169 |
+
echo '</table>'; // end table
|
170 |
+
}
|
171 |
+
|
172 |
+
|
173 |
+
add_action( 'save_post', 'wprss_save_custom_fields', 10, 2 );
|
174 |
+
/**
|
175 |
+
* Save the custom fields
|
176 |
+
*
|
177 |
+
* @since 2.0
|
178 |
+
*/
|
179 |
+
function wprss_save_custom_fields( $post_id, $post ) {
|
180 |
+
$meta_fields = wprss_get_custom_fields();
|
181 |
+
|
182 |
+
/* Verify the nonce before proceeding. */
|
183 |
+
if ( !isset( $_POST['wprss_meta_box_nonce'] ) || !wp_verify_nonce( $_POST['wprss_meta_box_nonce'], basename( __FILE__ ) ) )
|
184 |
+
return $post_id;
|
185 |
+
|
186 |
+
/* Get the post type object. */
|
187 |
+
$post_type = get_post_type_object( $post->post_type );
|
188 |
+
|
189 |
+
/* Check if the current user has permission to edit the post. */
|
190 |
+
if ( !current_user_can( $post_type->cap->edit_post, $post_id ) )
|
191 |
+
return $post_id;
|
192 |
+
|
193 |
+
/* // Stop WP from clearing custom fields on autosave - maybe not needed
|
194 |
+
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
|
195 |
+
return;
|
196 |
+
|
197 |
+
// Prevent quick edit from clearing custom fields - maybe not needed
|
198 |
+
if (defined('DOING_AJAX') && DOING_AJAX)
|
199 |
+
return; */
|
200 |
+
|
201 |
+
/** Bail out if running an autosave, ajax or a cron */
|
202 |
+
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
|
203 |
+
return;
|
204 |
+
if ( defined( 'DOING_AJAX' ) && DOING_AJAX )
|
205 |
+
return;
|
206 |
+
if ( defined( 'DOING_CRON' ) && DOING_CRON )
|
207 |
+
return;
|
208 |
+
|
209 |
+
// loop through fields and save the data
|
210 |
+
foreach ( $meta_fields as $field ) {
|
211 |
+
$old = get_post_meta( $post_id, $field[ 'id' ], true );
|
212 |
+
$new = $_POST[ $field[ 'id' ] ];
|
213 |
+
if ( $new && $new != $old ) {
|
214 |
+
update_post_meta( $post_id, $field[ 'id' ], $new );
|
215 |
+
} elseif ( '' == $new && $old ) {
|
216 |
+
delete_post_meta( $post_id, $field[ 'id' ], $old );
|
217 |
+
}
|
218 |
+
} // end foreach
|
219 |
+
}
|
220 |
+
|
221 |
+
|
222 |
+
/**
|
223 |
+
* Generate a preview of the latest 5 posts from the feed source being added/edited
|
224 |
+
*
|
225 |
+
* @since 2.0
|
226 |
+
*/
|
227 |
+
function wprss_preview_meta_box_callback() {
|
228 |
+
global $post;
|
229 |
+
$feed_url = get_post_meta( $post->ID, 'wprss_url', true );
|
230 |
+
|
231 |
+
if( ! empty( $feed_url ) ) {
|
232 |
+
$feed = fetch_feed( $feed_url );
|
233 |
+
if ( ! is_wp_error( $feed ) ) {
|
234 |
+
$items = $feed->get_items();
|
235 |
+
// Figure out how many total items there are, but limit it to 5.
|
236 |
+
$maxitems = $feed->get_item_quantity(5);
|
237 |
+
|
238 |
+
// Build an array of all the items, starting with element 0 (first element).
|
239 |
+
$items = $feed->get_items( 0, $maxitems );
|
240 |
+
echo '<h4>Latest 5 feeds available from ' . get_the_title() . '</h4>';
|
241 |
+
echo '<ul>';
|
242 |
+
foreach ( $items as $item ) {
|
243 |
+
// Get human date (comment if you want to use non human date)
|
244 |
+
$item_date = human_time_diff( $item->get_date('U'), current_time('timestamp')).' '.__( 'ago', 'rc_mdm' );
|
245 |
+
// Start displaying item content within a <li> tag
|
246 |
+
echo '<li>';
|
247 |
+
// create item link
|
248 |
+
//echo '<a href="'.esc_url( $item->get_permalink() ).'" title="'.$item_date.'">';
|
249 |
+
// Get item title
|
250 |
+
echo esc_html( $item->get_title() );
|
251 |
+
//echo '</a>';
|
252 |
+
// Display date
|
253 |
+
echo ' <div class="rss-date"><small>'.$item_date.'</small></div>';
|
254 |
+
// End <li> tag
|
255 |
+
echo '</li>';
|
256 |
+
}
|
257 |
+
echo '</ul>';
|
258 |
+
}
|
259 |
+
else _e( '<span class="invalid-feed-url"><strong>Invalid feed URL</strong> - Double check the feed source URL setting above.</span>
|
260 |
+
<p>Not sure where to find the RSS feed on a website?
|
261 |
+
<a target="_blank" href="http://webtrends.about.com/od/webfeedsyndicationrss/ss/rss_howto.htm">Click here</a> for a visual guide' , 'wprss' );
|
262 |
+
}
|
263 |
+
|
264 |
+
else _e( 'No feed URL defined yet', 'wprss' );
|
265 |
+
}
|
266 |
+
|
267 |
+
|
268 |
+
/**
|
269 |
+
* Generate Help meta box
|
270 |
+
*
|
271 |
+
* @since 2.0
|
272 |
+
*
|
273 |
+
*/
|
274 |
+
function wprss_help_meta_box_callback() {
|
275 |
+
echo '<p><strong>';
|
276 |
+
_e( 'Need help?', 'wprss' );
|
277 |
+
echo '</strong> <a target="_blank" href="http://wordpress.org/support/plugin/wp-rss-aggregator">';
|
278 |
+
_e( 'Check out the support forum', 'wprss' );
|
279 |
+
echo '</a></p>';
|
280 |
+
}
|
281 |
+
|
282 |
+
/**
|
283 |
+
* Generate Like this plugin meta box
|
284 |
+
*
|
285 |
+
* @since 2.0
|
286 |
+
*
|
287 |
+
*/
|
288 |
+
function wprss_like_meta_box_callback() { ?>
|
289 |
+
<p><?php _e( 'Why not do any or all of the following', 'wprss' ) ?>:</p>
|
290 |
+
<ul>
|
291 |
+
<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>
|
292 |
+
<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>
|
293 |
+
</ul>
|
294 |
+
</p>
|
295 |
+
<?php }
|
296 |
+
|
297 |
+
|
298 |
+
/**
|
299 |
+
* Generate Like this plugin meta box
|
300 |
+
*
|
301 |
+
* @since 2.0
|
302 |
+
*
|
303 |
+
*/
|
304 |
+
function wprss_follow_meta_box_callback() {
|
305 |
+
?>
|
306 |
+
<ul>
|
307 |
+
<li class="twitter"><a href="http://twitter.com/wpmayor"><?php _e( 'Follow WP Mayor on Twitter.', 'wprss' ) ?></a></li>
|
308 |
+
<li class="facebook"><a href="https://www.facebook.com/wpmayor"><?php _e( 'Like WP Mayor on Facebook.', 'wprss' ) ?></a></li>
|
309 |
+
</ul>
|
310 |
+
<?php }
|
311 |
+
|
312 |
+
|
313 |
+
add_action( 'add_meta_boxes', 'wprss_remove_meta_boxes', 100 );
|
314 |
+
/**
|
315 |
+
* Remove unneeded meta boxes from add feed source screen
|
316 |
+
*
|
317 |
+
* @since 2.0
|
318 |
+
*/
|
319 |
+
function wprss_remove_meta_boxes() {
|
320 |
+
if ( 'wprss_feed' !== get_current_screen()->id ) return;
|
321 |
+
// Remove meta boxes of other plugins that tend to appear on all posts
|
322 |
+
remove_meta_box( 'wpseo_meta', 'wprss_feed' ,'normal' );
|
323 |
+
remove_meta_box( 'postpsp', 'wprss_feed' ,'normal' );
|
324 |
+
remove_meta_box( 'su_postmeta', 'wprss_feed' ,'normal' );
|
325 |
+
remove_meta_box( 'woothemes-settings', 'wprss_feed' ,'normal' );
|
326 |
+
remove_meta_box( 'wpcf-post-relationship', 'wprss_feed' ,'normal' );
|
327 |
+
remove_meta_box( 'wpar_plugin_meta_box ', 'wprss_feed' ,'normal' );
|
328 |
+
remove_meta_box( 'sharing_meta', 'wprss_feed' ,'advanced' );
|
329 |
+
remove_meta_box( 'content-permissions-meta-box', 'wprss_feed' ,'advanced' );
|
330 |
+
remove_meta_box( 'theme-layouts-post-meta-box', 'wprss_feed' ,'side' );
|
331 |
+
remove_meta_box( 'post-stylesheets', 'wprss_feed' ,'side' );
|
332 |
+
remove_meta_box( 'hybrid-core-post-template', 'wprss_feed' ,'side' );
|
333 |
+
remove_meta_box( 'wpcf-marketing', 'wprss_feed' ,'side' );
|
334 |
+
remove_meta_box( 'trackbacksdiv22', 'wprss_feed' ,'advanced' );
|
335 |
+
remove_meta_box( 'aiosp', 'wprss_feed' ,'advanced' );
|
336 |
+
remove_action( 'post_submitbox_start', 'fpp_post_submitbox_start_action' );
|
337 |
+
}
|
includes/admin-options.php
ADDED
@@ -0,0 +1,611 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
// Licensing of add-ons
|
30 |
+
register_setting(
|
31 |
+
'wprss_settings_license_keys',
|
32 |
+
'wprss_settings_license_keys',
|
33 |
+
''
|
34 |
+
);
|
35 |
+
|
36 |
+
add_settings_section(
|
37 |
+
'wprss_settings_general_section', // ID used to identify this section and with which to register options
|
38 |
+
__( 'General plugin settings', 'wprss' ), // Section title that shows within <H3> tags
|
39 |
+
'wprss_settings_general_callback', // Callback function that echoes some explanations
|
40 |
+
'wprss_settings_general' // Settings page on which to show this section
|
41 |
+
);
|
42 |
+
|
43 |
+
add_settings_section(
|
44 |
+
'wprss_settings_styles_section',
|
45 |
+
__( 'Styles', 'wprss' ),
|
46 |
+
'wprss_settings_styles_callback',
|
47 |
+
'wprss_settings_general'
|
48 |
+
);
|
49 |
+
|
50 |
+
add_settings_field(
|
51 |
+
'wprss-settings-open-dd', // ID used to identify the field
|
52 |
+
__( 'Open links behaviour', 'wprss' ), // Text printed next to the field
|
53 |
+
'wprss_setting_open_dd_callback', // Callback function that echoes the field
|
54 |
+
'wprss_settings_general', // Settings page on which to show this field
|
55 |
+
'wprss_settings_general_section' // Section of the settings page on which to show this field
|
56 |
+
);
|
57 |
+
|
58 |
+
add_settings_field(
|
59 |
+
'wprss-settings-follow-dd',
|
60 |
+
__( 'Set links as', 'wprss' ),
|
61 |
+
'wprss_setting_follow_dd_callback',
|
62 |
+
'wprss_settings_general',
|
63 |
+
'wprss_settings_general_section'
|
64 |
+
);
|
65 |
+
|
66 |
+
add_settings_field(
|
67 |
+
'wprss-settings-feed-limit',
|
68 |
+
__( 'Feed display limit', 'wprss' ),
|
69 |
+
'wprss_setting_feed_limit_callback',
|
70 |
+
'wprss_settings_general',
|
71 |
+
'wprss_settings_general_section'
|
72 |
+
);
|
73 |
+
|
74 |
+
add_settings_field(
|
75 |
+
'wprss-settings-date-format',
|
76 |
+
__( 'Date format', 'wprss' ),
|
77 |
+
'wprss_setting_date_format_callback',
|
78 |
+
'wprss_settings_general',
|
79 |
+
'wprss_settings_general_section'
|
80 |
+
);
|
81 |
+
|
82 |
+
add_settings_field(
|
83 |
+
'wprss-settings-limit-feed-items-db',
|
84 |
+
__( 'Limit feed items stored', 'wprss' ),
|
85 |
+
'wprss_setting_limit_feed_items_callback',
|
86 |
+
'wprss_settings_general',
|
87 |
+
'wprss_settings_general_section'
|
88 |
+
);
|
89 |
+
|
90 |
+
add_settings_field(
|
91 |
+
'wprss-settings-limit-feed-items-imported',
|
92 |
+
__( 'Limit feed items per feed', 'wprss' ),
|
93 |
+
'wprss_setting_limit_feed_items_imported_callback',
|
94 |
+
'wprss_settings_general',
|
95 |
+
'wprss_settings_general_section'
|
96 |
+
);
|
97 |
+
|
98 |
+
add_settings_field(
|
99 |
+
'wprss-settings-cron-interval',
|
100 |
+
__( 'Cron interval', 'wprss' ),
|
101 |
+
'wprss_setting_cron_interval_callback',
|
102 |
+
'wprss_settings_general',
|
103 |
+
'wprss_settings_general_section'
|
104 |
+
);
|
105 |
+
|
106 |
+
add_settings_field(
|
107 |
+
'wprss-settings-title-link-enable',
|
108 |
+
__( 'Link title', 'wprss' ),
|
109 |
+
'wprss_setting_title_link_callback',
|
110 |
+
'wprss_settings_general',
|
111 |
+
'wprss_settings_general_section'
|
112 |
+
);
|
113 |
+
|
114 |
+
add_settings_field(
|
115 |
+
'wprss-settings-source-enable',
|
116 |
+
__( 'Show source', 'wprss' ),
|
117 |
+
'wprss_setting_source_enable_callback',
|
118 |
+
'wprss_settings_general',
|
119 |
+
'wprss_settings_general_section'
|
120 |
+
);
|
121 |
+
|
122 |
+
add_settings_field(
|
123 |
+
'wprss-settings-source-link',
|
124 |
+
__( 'Link source', 'wprss' ),
|
125 |
+
'wprss_setting_source_link_callback',
|
126 |
+
'wprss_settings_general',
|
127 |
+
'wprss_settings_general_section'
|
128 |
+
);
|
129 |
+
|
130 |
+
add_settings_field(
|
131 |
+
'wprss-settings-text-preceding-source',
|
132 |
+
__( 'Text preceding source', 'wprss' ),
|
133 |
+
'wprss_setting_text_preceding_source_callback',
|
134 |
+
'wprss_settings_general',
|
135 |
+
'wprss_settings_general_section'
|
136 |
+
);
|
137 |
+
|
138 |
+
add_settings_field(
|
139 |
+
'wprss-settings-date-enable',
|
140 |
+
__( 'Show date', 'wprss' ),
|
141 |
+
'wprss_setting_date_enable_callback',
|
142 |
+
'wprss_settings_general',
|
143 |
+
'wprss_settings_general_section'
|
144 |
+
);
|
145 |
+
|
146 |
+
add_settings_field(
|
147 |
+
'wprss-settings-text-preceding-date',
|
148 |
+
__( 'Text preceding date', 'wprss' ),
|
149 |
+
'wprss_setting_text_preceding_date_callback',
|
150 |
+
'wprss_settings_general',
|
151 |
+
'wprss_settings_general_section'
|
152 |
+
);
|
153 |
+
|
154 |
+
add_settings_field(
|
155 |
+
'wprss-settings-custom-feed-url',
|
156 |
+
__( 'Custom Feed URL', 'wprss' ),
|
157 |
+
'wprss_setings_custom_feed_url_callback',
|
158 |
+
'wprss_settings_general',
|
159 |
+
'wprss_settings_general_section'
|
160 |
+
);
|
161 |
+
|
162 |
+
add_settings_field(
|
163 |
+
'wprss-settings-styles-disable',
|
164 |
+
__( 'Disable Styles', 'wprss' ),
|
165 |
+
'wprss_setting_styles_disable_callback',
|
166 |
+
'wprss_settings_general',
|
167 |
+
'wprss_settings_styles_section'
|
168 |
+
);
|
169 |
+
|
170 |
+
add_settings_field(
|
171 |
+
'wprss-settings-custom-feed-limit',
|
172 |
+
__( 'Custom feed limit', 'wprss' ),
|
173 |
+
'wprss_setings_custom_feed_limit_callback',
|
174 |
+
'wprss_settings_general',
|
175 |
+
'wprss_settings_general_section'
|
176 |
+
);
|
177 |
+
|
178 |
+
do_action( 'wprss_admin_init' );
|
179 |
+
}
|
180 |
+
|
181 |
+
|
182 |
+
/**
|
183 |
+
* Build the plugin settings page, used to save general settings like whether a link should be follow or no follow
|
184 |
+
* @since 1.1
|
185 |
+
*/
|
186 |
+
function wprss_settings_page_display() {
|
187 |
+
?>
|
188 |
+
<div class="wrap">
|
189 |
+
<?php screen_icon( 'wprss-aggregator' ); ?>
|
190 |
+
|
191 |
+
<h2><?php _e( 'WP RSS Aggregator Settings', 'wprss' ); ?></h2>
|
192 |
+
|
193 |
+
<?php settings_errors(); ?>
|
194 |
+
|
195 |
+
<?php $active_tab = isset( $_GET['tab'] ) ? $_GET['tab'] : 'general_settings'; ?>
|
196 |
+
|
197 |
+
<?php
|
198 |
+
|
199 |
+
$default_tabs = array(
|
200 |
+
'general' => array(
|
201 |
+
'label' => __( 'General', 'wprss' ),
|
202 |
+
'slug' => 'general_settings',
|
203 |
+
),
|
204 |
+
'licenses' => array(
|
205 |
+
'label' => __( 'Licenses', 'wprss' ),
|
206 |
+
'slug' => 'licenses_settings'
|
207 |
+
)
|
208 |
+
);
|
209 |
+
|
210 |
+
$addon_tabs = apply_filters( 'wprss_options_tabs', array() );
|
211 |
+
|
212 |
+
$tabs = array_merge( array( $default_tabs['general'] ), $addon_tabs , array( $default_tabs['licenses'] ) );
|
213 |
+
|
214 |
+
$show_tabs = ( count( $addon_tabs ) > 0 ) || apply_filters( 'wprss_show_settings_tabs_condition', FALSE );
|
215 |
+
|
216 |
+
if ( $show_tabs ) { ?>
|
217 |
+
<h2 class="nav-tab-wrapper">
|
218 |
+
<?php
|
219 |
+
foreach ( $tabs as $tab => $tab_property ) { ?>
|
220 |
+
<a href="?post_type=wprss_feed&page=wprss-aggregator-settings&tab=<?php echo esc_attr( $tab_property['slug'] ); ?>"
|
221 |
+
class="nav-tab <?php echo $active_tab == $tab_property['slug'] ? 'nav-tab-active' : ''; ?>"><?php echo esc_html( $tab_property['label'] ); ?></a>
|
222 |
+
<?php } ?>
|
223 |
+
<?php } ?>
|
224 |
+
</h2>
|
225 |
+
|
226 |
+
<form action="options.php" method="post">
|
227 |
+
|
228 |
+
<?php
|
229 |
+
|
230 |
+
if ( $active_tab === 'general_settings' ) {
|
231 |
+
settings_fields( 'wprss_settings_general' );
|
232 |
+
do_settings_sections( 'wprss_settings_general' );
|
233 |
+
}
|
234 |
+
elseif ( $show_tabs ) {
|
235 |
+
|
236 |
+
if ( $active_tab === 'licenses_settings' ) {
|
237 |
+
settings_fields( 'wprss_settings_license_keys' );
|
238 |
+
do_settings_sections( 'wprss_settings_license_keys' );
|
239 |
+
}
|
240 |
+
|
241 |
+
do_action( 'wprss_add_settings_fields_sections', $active_tab );
|
242 |
+
}
|
243 |
+
|
244 |
+
submit_button( __( 'Save Settings', 'wprss' ) );
|
245 |
+
|
246 |
+
?>
|
247 |
+
</form>
|
248 |
+
</div>
|
249 |
+
<?php
|
250 |
+
}
|
251 |
+
|
252 |
+
|
253 |
+
/**
|
254 |
+
* General settings section header
|
255 |
+
* @since 3.0
|
256 |
+
*/
|
257 |
+
function wprss_settings_general_callback() {
|
258 |
+
echo '<p>' . __( 'These are the general settings for WP RSS Aggregator.', 'wprss' ) . '</p>';
|
259 |
+
}
|
260 |
+
|
261 |
+
|
262 |
+
/**
|
263 |
+
* General settings section header
|
264 |
+
* @since 3.0
|
265 |
+
*/
|
266 |
+
function wprss_settings_styles_callback() {
|
267 |
+
echo '<p>' . __( 'If you would like to disable all styles used in this plugin, tick the checkbox.', 'wprss' ) . '</p>';
|
268 |
+
}
|
269 |
+
|
270 |
+
|
271 |
+
/**
|
272 |
+
* Follow or No Follow dropdown
|
273 |
+
* @since 1.1
|
274 |
+
*/
|
275 |
+
function wprss_setting_follow_dd_callback() {
|
276 |
+
$options = get_option( 'wprss_settings_general' );
|
277 |
+
$items = array(
|
278 |
+
__( 'No follow', 'wprss' ),
|
279 |
+
__( 'Follow', 'wprss' )
|
280 |
+
);
|
281 |
+
echo "<select id='follow-dd' name='wprss_settings_general[follow_dd]'>";
|
282 |
+
foreach( $items as $item ) {
|
283 |
+
$selected = ( $options['follow_dd'] == $item) ? 'selected="selected"' : '';
|
284 |
+
echo "<option value='$item' $selected>$item</option>";
|
285 |
+
}
|
286 |
+
echo "</select>";
|
287 |
+
}
|
288 |
+
|
289 |
+
|
290 |
+
/**
|
291 |
+
* Link open setting dropdown
|
292 |
+
* @since 1.1
|
293 |
+
*/
|
294 |
+
function wprss_setting_open_dd_callback() {
|
295 |
+
$options = get_option( 'wprss_settings_general' );
|
296 |
+
$items = array(
|
297 |
+
__( 'Lightbox', 'wprss' ),
|
298 |
+
__( 'New window', 'wprss' ),
|
299 |
+
__( 'None', 'wprss' )
|
300 |
+
);
|
301 |
+
echo "<select id='open-dd' name='wprss_settings_general[open_dd]'>";
|
302 |
+
foreach( $items as $item ) {
|
303 |
+
$selected = ( $options['open_dd'] == $item ) ? 'selected="selected"' : '';
|
304 |
+
echo "<option value='$item' $selected>$item</option>";
|
305 |
+
}
|
306 |
+
echo "</select>";
|
307 |
+
}
|
308 |
+
|
309 |
+
|
310 |
+
/**
|
311 |
+
* Set limit for feeds on frontend
|
312 |
+
* @since 2.0
|
313 |
+
*/
|
314 |
+
function wprss_setting_feed_limit_callback() {
|
315 |
+
$options = get_option( 'wprss_settings_general' );
|
316 |
+
echo "<input id='feed-limit' name='wprss_settings_general[feed_limit]' type='text' value='{$options['feed_limit']}' />";
|
317 |
+
echo "<label class='description' for='feed-limit'>Enter the number of feeds to display on the front end</label>";
|
318 |
+
}
|
319 |
+
|
320 |
+
|
321 |
+
/**
|
322 |
+
* Set date format
|
323 |
+
* @since 3.0
|
324 |
+
*/
|
325 |
+
function wprss_setting_date_format_callback() {
|
326 |
+
$options = get_option( 'wprss_settings_general' );
|
327 |
+
echo "<input id='date-format' name='wprss_settings_general[date_format]' type='text' value='{$options['date_format']}' />";
|
328 |
+
echo "<label class='description' for='date-format'>Date formatting, using the <a href='http://codex.wordpress.org/Formatting_Date_and_Time'>PHP date formats</a></label>";
|
329 |
+
}
|
330 |
+
|
331 |
+
|
332 |
+
/**
|
333 |
+
* Limit number of feed items stored
|
334 |
+
* @since 3.0
|
335 |
+
*/
|
336 |
+
function wprss_setting_limit_feed_items_callback() {
|
337 |
+
$options = get_option( 'wprss_settings_general' );
|
338 |
+
echo "<input id='limit-feed-items-db' name='wprss_settings_general[limit_feed_items_db]' type='text' value='{$options['limit_feed_items_db']}' />";
|
339 |
+
echo "<label class='description' for='limit-feed-items-db'>Enter the maximum number of feeds to store in the database; enter 0 for unlimited feed items</label>";
|
340 |
+
}
|
341 |
+
|
342 |
+
|
343 |
+
/**
|
344 |
+
* Limit number of feed items imported per feed
|
345 |
+
* @since 3.1
|
346 |
+
*/
|
347 |
+
function wprss_setting_limit_feed_items_imported_callback() {
|
348 |
+
$options = get_option( 'wprss_settings_general' );
|
349 |
+
echo "<input id='limit-feed-items-imported' name='wprss_settings_general[limit_feed_items_imported]' type='text' value='{$options['limit_feed_items_imported']}' />";
|
350 |
+
echo "<label class='description' for='limit-feed-items-imported'>Enter the maximum number of feeds to import per feed</label>";
|
351 |
+
}
|
352 |
+
|
353 |
+
|
354 |
+
/**
|
355 |
+
* Gets a sorted (according to interval) list of the cron schedules
|
356 |
+
* @since 3.0
|
357 |
+
*/
|
358 |
+
function wprss_get_schedules() {
|
359 |
+
$schedules = wp_get_schedules();
|
360 |
+
uasort( $schedules, create_function( '$a,$b', 'return $a["interval"]-$b["interval"];' ) );
|
361 |
+
return $schedules;
|
362 |
+
}
|
363 |
+
|
364 |
+
|
365 |
+
/**
|
366 |
+
* Cron interval dropdown callback
|
367 |
+
* @since 3.0
|
368 |
+
*/
|
369 |
+
function wprss_setting_cron_interval_callback() {
|
370 |
+
$options = get_option( 'wprss_settings_general' );
|
371 |
+
$current = $options['cron_interval'];
|
372 |
+
|
373 |
+
$schedules = wprss_get_schedules();
|
374 |
+
// Set the allowed Cron schedules, we don't want any intervals that can lead to issues with server load
|
375 |
+
$wprss_schedules = apply_filters(
|
376 |
+
'wprss_schedules',
|
377 |
+
array( 'fifteen_min', 'thirty_min', 'hourly', 'two_hours', 'twicedaily', 'daily' )
|
378 |
+
);
|
379 |
+
echo "<select id='cron-interval' name='wprss_settings_general[cron_interval]'>";
|
380 |
+
foreach( $schedules as $schedule_name => $schedule_data ) {
|
381 |
+
if ( in_array( $schedule_name, $wprss_schedules ) ) { ?>
|
382 |
+
<option value="<?php echo $schedule_name; ?>" <?php selected( $current, $schedule_name ); ?> >
|
383 |
+
<?php echo $schedule_data['display']; ?> (<?php echo wprss_interval( $schedule_data['interval'] ); ?>)
|
384 |
+
</option>
|
385 |
+
<?php } ?>
|
386 |
+
<?php } ?>
|
387 |
+
</select><?php
|
388 |
+
}
|
389 |
+
|
390 |
+
|
391 |
+
/**
|
392 |
+
* Enable linked title
|
393 |
+
* @since 3.0
|
394 |
+
*/
|
395 |
+
function wprss_setting_title_link_callback( $args ) {
|
396 |
+
$options = get_option( 'wprss_settings_general' );
|
397 |
+
echo "<input id='title-link' name='wprss_settings_general[title_link]' type='checkbox' value='1' " . checked( 1, $options['title_link'], false ) . " />";
|
398 |
+
echo "<label class='description' for='title-link'>Check this box to enable linked titles</label>";
|
399 |
+
}
|
400 |
+
|
401 |
+
|
402 |
+
/**
|
403 |
+
* Enable source
|
404 |
+
* @since 3.0
|
405 |
+
*/
|
406 |
+
function wprss_setting_source_enable_callback( $args ) {
|
407 |
+
$options = get_option( 'wprss_settings_general' );
|
408 |
+
echo "<input id='source-enable' name='wprss_settings_general[source_enable]' type='checkbox' value='1' " . checked( 1, $options['source_enable'], false ) . " />";
|
409 |
+
echo "<label class='description' for='source-enable'>Check this box to enable feed source display</label>";
|
410 |
+
}
|
411 |
+
|
412 |
+
/**
|
413 |
+
* Enable linked title
|
414 |
+
* @since 3.0
|
415 |
+
*/
|
416 |
+
function wprss_setting_source_link_callback( $args ) {
|
417 |
+
$options = get_option( 'wprss_settings_general' );
|
418 |
+
echo "<input id='source-link' name='wprss_settings_general[source_link]' type='checkbox' value='1' " . checked( 1, $options['source_link'], false ) . " />";
|
419 |
+
echo "<label class='description' for='source-link'>Check this box to enable linked sources</label>";
|
420 |
+
}
|
421 |
+
|
422 |
+
|
423 |
+
/**
|
424 |
+
* Set text preceding source
|
425 |
+
* @since 3.0
|
426 |
+
*/
|
427 |
+
function wprss_setting_text_preceding_source_callback() {
|
428 |
+
$options = get_option( 'wprss_settings_general' );
|
429 |
+
echo "<input id='text-preceding-source' name='wprss_settings_general[text_preceding_source]' type='text' value='{$options['text_preceding_source']}' />";
|
430 |
+
echo "<label class='description' for='text-preceding-source'>Enter the text you want shown before the feed item's source</label>";
|
431 |
+
}
|
432 |
+
/**
|
433 |
+
* Enable date
|
434 |
+
* @since 3.0
|
435 |
+
*/
|
436 |
+
function wprss_setting_date_enable_callback( $args ) {
|
437 |
+
$options = get_option( 'wprss_settings_general' );
|
438 |
+
echo "<input id='date-enable' name='wprss_settings_general[date_enable]' type='checkbox' value='1' " . checked( 1, $options['date_enable'], false ) . " />";
|
439 |
+
echo "<label class='description' for='date-enable'>Check this box to enable display of date published</label>";
|
440 |
+
}
|
441 |
+
|
442 |
+
/**
|
443 |
+
* Set text preceding date
|
444 |
+
* @since 3.0
|
445 |
+
*/
|
446 |
+
function wprss_setting_text_preceding_date_callback() {
|
447 |
+
$options = get_option( 'wprss_settings_general' );
|
448 |
+
echo "<input id='text-preceding-date' name='wprss_settings_general[text_preceding_date]' type='text' value='{$options['text_preceding_date']}' />";
|
449 |
+
echo "<label class='description' for='text-preceding-date'>Enter the text you want shown before the feed item's publish date</label>";
|
450 |
+
}
|
451 |
+
|
452 |
+
/**
|
453 |
+
* Sets the custom feed URL
|
454 |
+
* @since 3.3
|
455 |
+
*/
|
456 |
+
function wprss_setings_custom_feed_url_callback() {
|
457 |
+
$options = get_option( 'wprss_settings_general' );
|
458 |
+
echo "<input id='custom_feed_url' name='wprss_settings_general[custom_feed_url]' type='text' value='{$options['custom_feed_url']}' />";
|
459 |
+
echo "<label class='description' for='custom_feed_url'>" . __( 'Custom Feed URL', 'wprss' ) . "</label>";
|
460 |
+
}
|
461 |
+
|
462 |
+
/**
|
463 |
+
* Sets the custom feed limit
|
464 |
+
* @since 3.3
|
465 |
+
*/
|
466 |
+
function wprss_setings_custom_feed_limit_callback() {
|
467 |
+
$options = get_option( 'wprss_settings_general' );
|
468 |
+
echo "<input id='custom_feed_limit' name='wprss_settings_general[custom_feed_limit]' placeholder='Default' min='0' class='wprss-number-roller' type='number' value='{$options['custom_feed_limit']}' />";
|
469 |
+
echo "<label class='description' for='custom_feed_limit'>" . __( 'Custom feed limit', 'wprss' ) . "</label>";
|
470 |
+
}
|
471 |
+
|
472 |
+
/**
|
473 |
+
* Disable styles
|
474 |
+
* @since 3.0
|
475 |
+
*/
|
476 |
+
function wprss_setting_styles_disable_callback( $args ) {
|
477 |
+
$options = get_option( 'wprss_settings_general' );
|
478 |
+
echo "<input id='styles-disable' name='wprss_settings_general[styles_disable]' type='checkbox' value='1' " . checked( 1, $options['styles_disable'], false ) . " />";
|
479 |
+
echo "<label class='description' for='styles-disable'>Check this box to disable all plugin styles</label>";
|
480 |
+
echo "<p class='description'>You will then be responsible for providing your own CSS styles.</p>";
|
481 |
+
}
|
482 |
+
|
483 |
+
|
484 |
+
/**
|
485 |
+
* Pretty-prints the difference in two times.
|
486 |
+
*
|
487 |
+
* @since 3.0
|
488 |
+
* @param time $older_date
|
489 |
+
* @param time $newer_date
|
490 |
+
* @return string The pretty time_since value
|
491 |
+
* @link http://wordpress.org/extend/plugins/wp-crontrol/
|
492 |
+
*/
|
493 |
+
function wprss_time_since( $older_date, $newer_date ) {
|
494 |
+
return wprss_interval( $newer_date - $older_date );
|
495 |
+
}
|
496 |
+
|
497 |
+
/**
|
498 |
+
* Calculates difference between times
|
499 |
+
*
|
500 |
+
* Taken from the WP-Crontrol plugin
|
501 |
+
* @link http://wordpress.org/extend/plugins/wp-crontrol/
|
502 |
+
* @since 3.0
|
503 |
+
*
|
504 |
+
*/
|
505 |
+
function wprss_interval( $since ) {
|
506 |
+
// array of time period chunks
|
507 |
+
$chunks = array(
|
508 |
+
array(60 * 60 * 24 * 365 , _n_noop('%s year', '%s years', 'crontrol')),
|
509 |
+
array(60 * 60 * 24 * 30 , _n_noop('%s month', '%s months', 'crontrol')),
|
510 |
+
array(60 * 60 * 24 * 7, _n_noop('%s week', '%s weeks', 'crontrol')),
|
511 |
+
array(60 * 60 * 24 , _n_noop('%s day', '%s days', 'crontrol')),
|
512 |
+
array(60 * 60 , _n_noop('%s hour', '%s hours', 'crontrol')),
|
513 |
+
array(60 , _n_noop('%s minute', '%s minutes', 'crontrol')),
|
514 |
+
array( 1 , _n_noop('%s second', '%s seconds', 'crontrol')),
|
515 |
+
);
|
516 |
+
|
517 |
+
|
518 |
+
if( $since <= 0 ) {
|
519 |
+
return __( 'now', 'wprss' );
|
520 |
+
}
|
521 |
+
|
522 |
+
// we only want to output two chunks of time here, eg:
|
523 |
+
// x years, xx months
|
524 |
+
// x days, xx hours
|
525 |
+
// so there's only two bits of calculation below:
|
526 |
+
|
527 |
+
// step one: the first chunk
|
528 |
+
for ($i = 0, $j = count($chunks); $i < $j; $i++)
|
529 |
+
{
|
530 |
+
$seconds = $chunks[$i][0];
|
531 |
+
$name = $chunks[$i][1];
|
532 |
+
|
533 |
+
// finding the biggest chunk (if the chunk fits, break)
|
534 |
+
if (($count = floor($since / $seconds)) != 0)
|
535 |
+
{
|
536 |
+
break;
|
537 |
+
}
|
538 |
+
}
|
539 |
+
|
540 |
+
// set output var
|
541 |
+
$output = sprintf(_n($name[0], $name[1], $count, 'wprss'), $count);
|
542 |
+
|
543 |
+
// step two: the second chunk
|
544 |
+
if ($i + 1 < $j)
|
545 |
+
{
|
546 |
+
$seconds2 = $chunks[$i + 1][0];
|
547 |
+
$name2 = $chunks[$i + 1][1];
|
548 |
+
|
549 |
+
if (($count2 = floor(($since - ($seconds * $count)) / $seconds2)) != 0)
|
550 |
+
{
|
551 |
+
// add to output var
|
552 |
+
$output .= ' '.sprintf(_n($name2[0], $name2[1], $count2, 'wprss'), $count2);
|
553 |
+
}
|
554 |
+
}
|
555 |
+
|
556 |
+
return $output;
|
557 |
+
}
|
558 |
+
|
559 |
+
|
560 |
+
/**
|
561 |
+
* Validate inputs from the general settings page
|
562 |
+
* @since 3.0
|
563 |
+
*/
|
564 |
+
function wprss_settings_general_validate( $input ) {
|
565 |
+
$options = get_option( 'wprss_settings_general' );
|
566 |
+
$current_cron_interval = $options['cron_interval'];
|
567 |
+
|
568 |
+
// Create our array for storing the validated options
|
569 |
+
$output = array();
|
570 |
+
|
571 |
+
// Loop through each of the incoming options
|
572 |
+
foreach( $input as $key => $value ) {
|
573 |
+
|
574 |
+
// Check to see if the current option has a value. If so, process it.
|
575 |
+
if( isset( $input[ $key ] ) ) {
|
576 |
+
|
577 |
+
// Strip all HTML and PHP tags and properly handle quoted strings
|
578 |
+
$output[ $key ] = strip_tags( stripslashes( $input[ $key ] ) );
|
579 |
+
|
580 |
+
} // end if
|
581 |
+
|
582 |
+
} // end foreach
|
583 |
+
|
584 |
+
if ( ! isset( $input['title_link'] ) || $input['title_link'] != '1' )
|
585 |
+
$output['title_link'] = 0;
|
586 |
+
else
|
587 |
+
$output['title_link'] = 1;
|
588 |
+
|
589 |
+
if ( ! isset( $input['source_enable'] ) || $input['source_enable'] != '1' )
|
590 |
+
$output['source_enable'] = 0;
|
591 |
+
else
|
592 |
+
$output['source_enable'] = 1;
|
593 |
+
|
594 |
+
if ( ! isset( $input['date_enable'] ) || $input['date_enable'] != '1' )
|
595 |
+
$output['date_enable'] = 0;
|
596 |
+
else
|
597 |
+
$output['date_enable'] = 1;
|
598 |
+
|
599 |
+
if ( ! isset( $input['styles_disable'] ) || $input['styles_disable'] != '1' )
|
600 |
+
$output['styles_disable'] = 0;
|
601 |
+
else
|
602 |
+
$output['styles_disable'] = 1;
|
603 |
+
|
604 |
+
if ( $input['cron_interval'] != $current_cron_interval ) {
|
605 |
+
wp_clear_scheduled_hook( 'wprss_fetch_all_feeds_hook' );
|
606 |
+
wp_schedule_event( time(), $input['cron_interval'], 'wprss_fetch_all_feeds_hook' );
|
607 |
+
}
|
608 |
+
|
609 |
+
// Return the array processing any additional functions filtered by this action
|
610 |
+
return apply_filters( 'wprss_settings_general_validate', $output, $input );
|
611 |
+
}
|
includes/admin-welcome.php
ADDED
@@ -0,0 +1,127 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @todo Localize
|
5 |
+
*/
|
6 |
+
|
7 |
+
// Exit if the page is accessed directly
|
8 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
9 |
+
|
10 |
+
|
11 |
+
// The tabs to be shown
|
12 |
+
$tabs = array(
|
13 |
+
/* 'cat' => 'Categories',
|
14 |
+
'et' => 'Excerpts & Thumbnails',
|
15 |
+
'kf' => 'Keyword Filtering'*/
|
16 |
+
);
|
17 |
+
|
18 |
+
// Determine the tab currently being shown
|
19 |
+
$tab = null;
|
20 |
+
if ( isset( $_GET['tab'] ) && !empty( $_GET['tab'] ) ) {
|
21 |
+
$tab = $_GET['tab'];
|
22 |
+
}
|
23 |
+
|
24 |
+
?>
|
25 |
+
|
26 |
+
<div class="wrap about-wrap">
|
27 |
+
<h1><?php printf( __( 'Welcome to WP RSS Aggregator %s !', 'wprss' ), WPRSS_VERSION ); ?></h1>
|
28 |
+
<div class="about-text">
|
29 |
+
Thank you for upgrading to the latest version!
|
30 |
+
WP RSS Aggregator 3.3 is more powerful than ever before, and you can now check out the new add-ons!<br>
|
31 |
+
</div>
|
32 |
+
<!-- <div class="wprss-badge">Version</div>-->
|
33 |
+
|
34 |
+
<!-- TAB WRAPPER -->
|
35 |
+
<h2 class="nav-tab-wrapper">
|
36 |
+
<a class="nav-tab <?php if ( $tab === null ) echo 'nav-tab-active'; ?>"
|
37 |
+
href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'wprss-welcome' ), 'index.php' ) ) ); ?>">
|
38 |
+
Overview
|
39 |
+
</a>
|
40 |
+
|
41 |
+
<!-- SHOW ALL TABS -->
|
42 |
+
<?php foreach ($tabs as $slug => $title) : ?>
|
43 |
+
|
44 |
+
<a class="nav-tab <?php if ( $tab === $slug ) echo 'nav-tab-active'; ?>"
|
45 |
+
href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'wprss-welcome', 'tab' => $slug ), 'index.php' ) ) ); ?>">
|
46 |
+
<?php echo $title; ?>
|
47 |
+
</a>
|
48 |
+
|
49 |
+
<?php endforeach; ?>
|
50 |
+
|
51 |
+
</h2>
|
52 |
+
|
53 |
+
<!-- TAB CONTENT -->
|
54 |
+
<?php
|
55 |
+
/* Show content depending on the current tab */
|
56 |
+
switch( $tab ) {
|
57 |
+
|
58 |
+
// Default tab. ( when tab = null )
|
59 |
+
default: ?>
|
60 |
+
|
61 |
+
<p class="about-description">
|
62 |
+
We have released three brand new add-ons to go along with v3.3:</p>
|
63 |
+
|
64 |
+
<ul>
|
65 |
+
<li><strong><a href="http://www.wprssaggregator.com/extension/excerpts-thumbnails/">Excerpts & Thumbnails</a></strong></li>
|
66 |
+
<li><strong><a href="http://www.wprssaggregator.com/extension/categories/">Categories</a></strong></li>
|
67 |
+
<li><strong><a href="http://www.wprssaggregator.com/extension/keyword-filtering/">Keyword Filtering</a></strong></li>
|
68 |
+
</ul>
|
69 |
+
</p>
|
70 |
+
<p>Plus we've got some other add-ons already being developed!</p>
|
71 |
+
<p>More information about add-ons can be found on our new website <a href="http://www.wprssaggregator.com">www.wprssaggregator.com</a></p>
|
72 |
+
|
73 |
+
<h3>Change log v3.3</h3>
|
74 |
+
<ul>
|
75 |
+
<li>New feature: OPML importer</li>
|
76 |
+
<li>New feature: Feed item limits for individual Feed Sources</li>
|
77 |
+
<li>New feature: Custom feed URL</li>
|
78 |
+
<li>New feature: Feed limit on custom feed</li>
|
79 |
+
<li>New feature: New 'Fetch feed items' action for each Feed Source in listing display</li>
|
80 |
+
<li>New feature: Option to enable link to source</li>
|
81 |
+
<li>Enhanced: Date strings now change according to locale being used (i.e. compatible with WPML)</li>
|
82 |
+
<li>Enhanced: Capabilities implemented</li>
|
83 |
+
<li>Enhanced: Feed Sources row action 'View' removed</li>
|
84 |
+
<li>Fixed Bug: Proxy feed URLs resulting in the permalink: example.com/url</li>
|
85 |
+
</ul>
|
86 |
+
</p>
|
87 |
+
|
88 |
+
<?php
|
89 |
+
break;
|
90 |
+
|
91 |
+
// Excerpts and Thumbnails tab
|
92 |
+
case 'et': ?>
|
93 |
+
|
94 |
+
<p class="about-description">
|
95 |
+
Fetch RSS feed excerpts to your blog and add thumbnails! Perfect for adding some life and color to your feeds.
|
96 |
+
</p>
|
97 |
+
|
98 |
+
<?php
|
99 |
+
break;
|
100 |
+
|
101 |
+
// Categories Tab
|
102 |
+
case 'cat': ?>
|
103 |
+
|
104 |
+
<p class="about-description">
|
105 |
+
Organize your feeds into custom categories. Filter feed items by category and make custom WordPress feeds for specific categories.
|
106 |
+
</p>
|
107 |
+
|
108 |
+
<?php
|
109 |
+
break;
|
110 |
+
|
111 |
+
// Keyword Filtering tab
|
112 |
+
case 'kf': ?>
|
113 |
+
|
114 |
+
<p class="about-description">
|
115 |
+
Import and store feeds that contain specific keywords in either the title or their content. Control what gets imported to your blog.
|
116 |
+
</p>
|
117 |
+
|
118 |
+
<?php
|
119 |
+
break;
|
120 |
+
}
|
121 |
+
?>
|
122 |
+
|
123 |
+
<hr/>
|
124 |
+
|
125 |
+
<p><a href="<?php echo admin_url( 'edit.php?post_type=wprss_feed&page=wprss-aggregator-settings'); ?>">Go to WP RSS Aggregator settings</a></p>
|
126 |
+
|
127 |
+
</div>
|
includes/admin.php
ADDED
@@ -0,0 +1,110 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Plugin administration related functions
|
4 |
+
*
|
5 |
+
* @package WPRSSAggregator
|
6 |
+
*/
|
7 |
+
|
8 |
+
add_action( 'admin_head', 'wprss_custom_post_type_icon' );
|
9 |
+
/**
|
10 |
+
* Custom Post Type Icon for Admin Menu & Post Screen
|
11 |
+
* @since 2.0
|
12 |
+
*/
|
13 |
+
function wprss_custom_post_type_icon() {
|
14 |
+
?>
|
15 |
+
<style>
|
16 |
+
/* Post Screen - 32px */
|
17 |
+
.icon32-posts-wprss_feed {
|
18 |
+
background: transparent url( <?php echo WPRSS_IMG . 'icon-adminpage32.png'; ?> ) no-repeat left top !important;
|
19 |
+
}
|
20 |
+
/* Post Screen - 32px */
|
21 |
+
.icon32-posts-wprss_feed_item {
|
22 |
+
background: transparent url( <?php echo WPRSS_IMG . 'icon-adminpage32.png'; ?> ) no-repeat left top !important;
|
23 |
+
}
|
24 |
+
</style>
|
25 |
+
<?php }
|
26 |
+
|
27 |
+
|
28 |
+
add_action( 'admin_menu', 'wprss_register_menu_pages' );
|
29 |
+
/**
|
30 |
+
* Register menu and submenus
|
31 |
+
* @since 2.0
|
32 |
+
*/
|
33 |
+
|
34 |
+
// Add the admin options pages as submenus to the Feed CPT
|
35 |
+
function wprss_register_menu_pages() {
|
36 |
+
|
37 |
+
//create submenu items
|
38 |
+
add_submenu_page( 'edit.php?post_type=wprss_feed', __( 'WP RSS Aggregator Settings', 'wprss' ), __( 'Settings', 'wprss' ), apply_filters( 'wprss_capability', 'manage_feed_settings' ), 'wprss-aggregator-settings', 'wprss_settings_page_display' );
|
39 |
+
add_submenu_page( 'edit.php?post_type=wprss_feed', __( 'Export & Import Settings', 'wprss' ), __( 'Import & Export', 'wprss' ), apply_filters( 'wprss_capability', 'manage_feed_settings' ), 'wprss-import-export-settings', 'wprss_import_export_settings_page_display' );
|
40 |
+
add_submenu_page( 'edit.php?post_type=wprss_feed', __( 'Debugging', 'wprss' ), __( 'Debugging', 'wprss' ), apply_filters( 'wprss_capability', 'manage_feed_settings'), 'wprss-debugging', 'wprss_debugging_page_display' );
|
41 |
+
}
|
42 |
+
|
43 |
+
|
44 |
+
add_filter('admin_body_class', 'wprss_base_admin_body_class');
|
45 |
+
/**
|
46 |
+
* Set body class for admin screens
|
47 |
+
* http://www.kevinleary.net/customizing-wordpress-admin-css-javascript/
|
48 |
+
* @since 2.0
|
49 |
+
*/
|
50 |
+
function wprss_base_admin_body_class( $classes )
|
51 |
+
{
|
52 |
+
// Current action
|
53 |
+
if ( is_admin() && isset($_GET['action']) ) {
|
54 |
+
$classes .= 'action-'.$_GET['action'];
|
55 |
+
}
|
56 |
+
// Current post ID
|
57 |
+
if ( is_admin() && isset($_GET['post']) ) {
|
58 |
+
$classes .= ' ';
|
59 |
+
$classes .= 'post-'.$_GET['post'];
|
60 |
+
}
|
61 |
+
// New post type & listing page
|
62 |
+
if ( isset($_GET['post_type']) ) $post_type = $_GET['post_type'];
|
63 |
+
if ( isset($post_type) ) {
|
64 |
+
$classes .= ' ';
|
65 |
+
$classes .= 'post-type-'.$post_type;
|
66 |
+
}
|
67 |
+
// Editting a post type
|
68 |
+
if ( isset( $_GET['post'] ) ) {
|
69 |
+
$post_query = $_GET['post'];
|
70 |
+
}
|
71 |
+
if ( isset($post_query) ) {
|
72 |
+
$current_post_edit = get_post($post_query);
|
73 |
+
$current_post_type = $current_post_edit->post_type;
|
74 |
+
if ( !empty($current_post_type) ) {
|
75 |
+
$classes .= ' ';
|
76 |
+
$classes .= 'post-type-'.$current_post_type;
|
77 |
+
}
|
78 |
+
}
|
79 |
+
// Return the $classes array
|
80 |
+
return $classes;
|
81 |
+
}
|
82 |
+
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Change title on wprss_feed post type screen
|
86 |
+
*
|
87 |
+
* @since 2.0
|
88 |
+
* @return void
|
89 |
+
*/
|
90 |
+
function wprss_change_title_text() {
|
91 |
+
return __( 'Enter feed name here (e.g. WP Mayor)', 'wprss' );
|
92 |
+
}
|
93 |
+
|
94 |
+
|
95 |
+
add_filter( 'plugin_action_links', 'wprss_plugin_action_links', 10, 2 );
|
96 |
+
/**
|
97 |
+
* Add Settings action link in plugin listing
|
98 |
+
*
|
99 |
+
* @since 3.0
|
100 |
+
* @param array $action_links
|
101 |
+
* @param string $plugin_file
|
102 |
+
* @return array
|
103 |
+
*/
|
104 |
+
function wprss_plugin_action_links( $action_links, $plugin_file ) {
|
105 |
+
if ( $plugin_file == plugin_basename( __FILE__ ) ) {
|
106 |
+
$settings_link = '<a href="' . get_admin_url() . 'edit.php?post_type=wprss_feed&page=wprss-aggregator-settings">' . __("Settings") . '</a>';
|
107 |
+
array_unshift( $action_links, $settings_link );
|
108 |
+
}
|
109 |
+
return $action_links;
|
110 |
+
}
|
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' => 5 * MINUTE_IN_SECONDS,
|
59 |
+
'display' => __( 'Once every five minutes', 'wprss' )
|
60 |
+
),
|
61 |
+
'ten_min' => array(
|
62 |
+
'interval' => 10 * MINUTE_IN_SECONDS,
|
63 |
+
'display' => __( 'Once every ten minutes', 'wprss' )
|
64 |
+
),
|
65 |
+
'fifteen_min' => array(
|
66 |
+
'interval' => 15 * MINUTE_IN_SECONDS,
|
67 |
+
'display' => __( 'Once every fifteen minutes', 'wprss' )
|
68 |
+
),
|
69 |
+
'thirty_min' => array(
|
70 |
+
'interval' => 30 * MINUTE_IN_SECONDS,
|
71 |
+
'display' => __( 'Once every thirty minutes', 'wprss' )
|
72 |
+
),
|
73 |
+
'two_hours' => array(
|
74 |
+
'interval' => 2 * HOUR_IN_SECONDS,
|
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,99 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Function to create a custom feed with the latest imported feed items
|
4 |
+
*
|
5 |
+
* @package WP RSS Aggregator
|
6 |
+
*/
|
7 |
+
|
8 |
+
|
9 |
+
add_filter( 'init', 'wprss_addfeed_add_feed' );
|
10 |
+
/**
|
11 |
+
* Adds feed named 'wprss'
|
12 |
+
*
|
13 |
+
* @since 3.3
|
14 |
+
*/
|
15 |
+
function wprss_addfeed_add_feed() {
|
16 |
+
$general_settings = get_option( 'wprss_settings_general', 'wprss' );
|
17 |
+
if ( !empty( $general_settings ) && isset( $general_settings['custom_feed_url'] ) ) {
|
18 |
+
$url = $general_settings['custom_feed_url'];
|
19 |
+
}
|
20 |
+
else $url = 'wprss';
|
21 |
+
add_feed( $url, 'wprss_addfeed_do_feed' );
|
22 |
+
flush_rewrite_rules();
|
23 |
+
}
|
24 |
+
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Generate the feed
|
28 |
+
*
|
29 |
+
* @since 3.3
|
30 |
+
*/
|
31 |
+
function wprss_addfeed_do_feed( $in ) {
|
32 |
+
|
33 |
+
// Prepare the post query
|
34 |
+
$wprss_custom_feed_query = apply_filters(
|
35 |
+
'wprss_custom_feed_query',
|
36 |
+
array(
|
37 |
+
'post_type' => 'wprss_feed_item',
|
38 |
+
'post_status' => 'publish',
|
39 |
+
'cache_results' => false, // disable caching
|
40 |
+
)
|
41 |
+
|
42 |
+
);
|
43 |
+
|
44 |
+
// Get options
|
45 |
+
$options = get_option( 'wprss_settings_general' );
|
46 |
+
if ( $options !== FALSE ) {
|
47 |
+
// If options exist, get the limit
|
48 |
+
$limit = $options['custom_feed_limit'];
|
49 |
+
if ( $limit !== FALSE ) {
|
50 |
+
// if limit exists, set the query limit
|
51 |
+
$wprss_custom_feed_query['posts_per_page'] = $limit;
|
52 |
+
}
|
53 |
+
}
|
54 |
+
|
55 |
+
// Submit the query to get latest feed items
|
56 |
+
query_posts( $wprss_custom_feed_query );
|
57 |
+
|
58 |
+
// Send content header and start ATOM output
|
59 |
+
header('Content-Type: application/atom+xml');
|
60 |
+
// Disabling caching
|
61 |
+
header('Cache-Control: no-cache, no-store, must-revalidate'); // HTTP 1.1.
|
62 |
+
header('Pragma: no-cache'); // HTTP 1.0.
|
63 |
+
header('Expires: 0'); // Proxies.
|
64 |
+
echo '<?xml version="1.0" encoding="' . get_option('blog_charset') . '"?' . '>';
|
65 |
+
?>
|
66 |
+
<feed xmlns="http://www.w3.org/2005/Atom">
|
67 |
+
<title type="text">Latest imported feed items on <?php bloginfo_rss('name'); ?></title>
|
68 |
+
<?php
|
69 |
+
// Start the Loop
|
70 |
+
while ( have_posts() ) : the_post();
|
71 |
+
?>
|
72 |
+
<entry>
|
73 |
+
<title><![CDATA[<?php the_title_rss(); ?>]]></title>
|
74 |
+
<link href="<?php the_permalink_rss(); ?>" />
|
75 |
+
<published><?php echo get_post_time( 'Y-m-d\TH:i:s\Z' ); ?></published>
|
76 |
+
<content type="html"><![CDATA[<?php the_content(); ?>]]></content>
|
77 |
+
</entry>
|
78 |
+
<?php
|
79 |
+
// End of the Loop
|
80 |
+
endwhile;
|
81 |
+
?>
|
82 |
+
</feed>
|
83 |
+
<?php
|
84 |
+
}
|
85 |
+
|
86 |
+
|
87 |
+
add_filter( 'post_limits', 'wprss_custom_feed_limits' );
|
88 |
+
/**
|
89 |
+
* Set a different limit to our custom feeds
|
90 |
+
*
|
91 |
+
* @since 3.3
|
92 |
+
*/
|
93 |
+
function wprss_custom_feed_limits( $limit ) {
|
94 |
+
if ( is_feed( ) ) {
|
95 |
+
// return 'LIMIT 0, 3';
|
96 |
+
return $limit;
|
97 |
+
}
|
98 |
+
return $limit;
|
99 |
+
}
|
includes/custom-post-types.php
ADDED
@@ -0,0 +1,100 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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' => true,
|
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 |
+
'capability_type' => 'feed',
|
55 |
+
'supports' => array( 'title' ),
|
56 |
+
'labels' => $labels
|
57 |
+
)
|
58 |
+
);
|
59 |
+
|
60 |
+
// Register the 'wprss_feed' post type
|
61 |
+
register_post_type( 'wprss_feed', $feed_args );
|
62 |
+
|
63 |
+
// Set up labels for the 'wprss_feed_item' post type
|
64 |
+
$labels = apply_filters(
|
65 |
+
'wprss_feed_item_post_type_labels',
|
66 |
+
array(
|
67 |
+
'name' => __( 'Imported Feeds', 'wprss' ),
|
68 |
+
'singular_name' => __( 'Imported Feed', 'wprss' ),
|
69 |
+
'all_items' => __( 'Imported Feeds', 'wprss' ),
|
70 |
+
'view_item' => __( 'View Imported Feed', 'wprss' ),
|
71 |
+
'search_items' => __( 'Search Imported Feeds', 'wprss' ),
|
72 |
+
'not_found' => __( 'No Imported Feeds Found', 'wprss' ),
|
73 |
+
'not_found_in_trash' => __( 'No Imported Feeds Found In Trash', 'wprss' )
|
74 |
+
)
|
75 |
+
);
|
76 |
+
|
77 |
+
// Set up the arguments for the 'wprss_feed_item' post type
|
78 |
+
$feed_item_args = apply_filters(
|
79 |
+
'wprss_feed_item_post_type_args',
|
80 |
+
array(
|
81 |
+
'exclude_from_search' => true,
|
82 |
+
'publicly_querable' => false,
|
83 |
+
'show_in_nav_menus' => false,
|
84 |
+
'show_in_admin_bar' => true,
|
85 |
+
'public' => false,
|
86 |
+
'show_ui' => true,
|
87 |
+
'query_var' => 'feed_item',
|
88 |
+
'show_in_menu' => 'edit.php?post_type=wprss_feed',
|
89 |
+
'rewrite' => array(
|
90 |
+
'slug' => 'feeds/items',
|
91 |
+
'with_front' => false,
|
92 |
+
),
|
93 |
+
'capability_type' => 'feed_source',
|
94 |
+
'labels' => $labels
|
95 |
+
)
|
96 |
+
);
|
97 |
+
|
98 |
+
// Register the 'feed_item' post type
|
99 |
+
register_post_type( 'wprss_feed_item', $feed_item_args );
|
100 |
+
}
|
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 |
+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
|
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_shortcode_default_args( $args ) {
|
46 |
+
// Default shortcode/function arguments for displaying feed items
|
47 |
+
$shortcode_args = apply_filters(
|
48 |
+
'wprss_shortcode_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 $shortcode_args
|
58 |
+
$args = wp_parse_args( $args, $shortcode_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 |
+
$feed_items_args = array(
|
71 |
+
'post_type' => 'wprss_feed_item',
|
72 |
+
'posts_per_page' => $settings['feed_limit'],
|
73 |
+
'orderby' => 'meta_value',
|
74 |
+
'meta_key' => 'wprss_item_date',
|
75 |
+
'order' => 'DESC'
|
76 |
+
);
|
77 |
+
|
78 |
+
if ( isset( $settings['source'] ) ) {
|
79 |
+
$feeds = array_filter( array_map( 'intval', explode( ',', $settings['source'] ) ) );
|
80 |
+
foreach ( $feeds as $feed )
|
81 |
+
trim( $feed );
|
82 |
+
if ( !empty( $feeds ) ) {
|
83 |
+
$feed_items_args['meta_query'] = array(
|
84 |
+
array(
|
85 |
+
'key' => 'wprss_feed_id',
|
86 |
+
'value' => $feeds,
|
87 |
+
'type' => 'numeric',
|
88 |
+
'compare' => 'IN',
|
89 |
+
),
|
90 |
+
);
|
91 |
+
}
|
92 |
+
}
|
93 |
+
|
94 |
+
// Arguments for the next query to fetch all feed items
|
95 |
+
$feed_items_args = apply_filters( 'wprss_display_feed_items_query', $feed_items_args, $settings );
|
96 |
+
|
97 |
+
// Query to get all feed items for display
|
98 |
+
$feed_items = new WP_Query( $feed_items_args );
|
99 |
+
|
100 |
+
return $feed_items;
|
101 |
+
}
|
102 |
+
|
103 |
+
|
104 |
+
add_action( 'wprss_display_template', 'wprss_default_display_template', 10, 3 );
|
105 |
+
/**
|
106 |
+
* Default template for feed items display
|
107 |
+
*
|
108 |
+
* @since 3.0
|
109 |
+
*/
|
110 |
+
function wprss_default_display_template( $display_settings, $args, $feed_items ) {
|
111 |
+
|
112 |
+
$general_settings = get_option( 'wprss_settings_general' );
|
113 |
+
$excerpts_settings = get_option( 'wprss_settings_excerpts' );
|
114 |
+
$thumbnails_settings = get_option( 'wprss_settings_thumbnails' );
|
115 |
+
|
116 |
+
$source_link = $general_settings['source_link'];
|
117 |
+
// Declare each item in $args as its own variable
|
118 |
+
extract( $args, EXTR_SKIP );
|
119 |
+
|
120 |
+
$output = '';
|
121 |
+
|
122 |
+
if( $feed_items->have_posts() ) {
|
123 |
+
|
124 |
+
$output .= "$links_before";
|
125 |
+
|
126 |
+
while ( $feed_items->have_posts() ) {
|
127 |
+
$feed_items->the_post();
|
128 |
+
$permalink = get_post_meta( get_the_ID(), 'wprss_item_permalink', true );
|
129 |
+
$feed_source_id = get_post_meta( get_the_ID(), 'wprss_feed_id', true );
|
130 |
+
$source_name = get_the_title( $feed_source_id );
|
131 |
+
$source_url = get_post_meta( $feed_source_id, 'wprss_url', true );
|
132 |
+
|
133 |
+
do_action( 'wprss_get_post_data' );
|
134 |
+
|
135 |
+
// convert from Unix timestamp
|
136 |
+
$date = date_i18n( $general_settings['date_format'], intval( get_post_meta( get_the_ID(), 'wprss_item_date', true ) ) );
|
137 |
+
|
138 |
+
if ( $general_settings['title_link'] == 1 ) {
|
139 |
+
$output .= "$link_before" . '<a ' . $display_settings['open'] . ' ' . $display_settings['follow'] . ' href="'. $permalink . '">'. get_the_title(). '</a>';
|
140 |
+
}
|
141 |
+
else {
|
142 |
+
$output .= get_the_title();
|
143 |
+
}
|
144 |
+
|
145 |
+
if ( ( $general_settings['source_enable'] == 1 ) && ( $general_settings['date_enable'] == 1 ) ) {
|
146 |
+
$output .= '<div class="source-date"><span class="feed-source">' .
|
147 |
+
( !empty( $general_settings['text_preceding_source'] ) ? $general_settings['text_preceding_source'] . ' ' : '' );
|
148 |
+
|
149 |
+
if ( $source_link == 1 ) {
|
150 |
+
$output .= '<a href="' . $source_url . '">' . $source_name . "</a>";
|
151 |
+
}
|
152 |
+
else $output .= $source_name;
|
153 |
+
|
154 |
+
$output .= ' | ' .
|
155 |
+
( !empty( $general_settings['text_preceding_date'] ) ? $general_settings['text_preceding_date'] . ' ' : '' ) . $date .
|
156 |
+
'</span></div>' . "$link_after";
|
157 |
+
}
|
158 |
+
|
159 |
+
else if ( ( $general_settings['source_enable'] == 1 ) && ( $general_settings['date_enable'] == 0 ) ) {
|
160 |
+
$output .= '<div class="source-date"><span class="feed-source">' .
|
161 |
+
( !empty( $general_settings['text_preceding_source'] ) ? $general_settings['text_preceding_source'] . ' ' : '' );
|
162 |
+
|
163 |
+
if ( $source_link == 1 ) {
|
164 |
+
$output .= '<a href="' . $source_url . '">' . $source_name . "</a>";
|
165 |
+
}
|
166 |
+
else $output .= $source_name;
|
167 |
+
|
168 |
+
$output .= '</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_shortcode_default_args( $args );
|
205 |
+
|
206 |
+
$args = apply_filters( 'wprss_shortcode_args', $args );
|
207 |
+
|
208 |
+
$query_args = $settings;
|
209 |
+
if ( isset( $args['limit'] ) ) {
|
210 |
+
$query_args['feed_limit'] = filter_var( $args['limit'], FILTER_VALIDATE_INT, array(
|
211 |
+
'options' => array(
|
212 |
+
'min_range' => 1,
|
213 |
+
'default' => $query_args['feed_limit'],
|
214 |
+
),
|
215 |
+
) );
|
216 |
+
}
|
217 |
+
|
218 |
+
if ( isset( $args['source'] ) ) {
|
219 |
+
$query_args['source'] = $args['source'];
|
220 |
+
}
|
221 |
+
|
222 |
+
$feed_items = wprss_get_feed_items_query( $query_args );
|
223 |
+
|
224 |
+
do_action( 'wprss_display_template', $display_settings, $args, $feed_items );
|
225 |
+
}
|
226 |
+
|
227 |
+
|
228 |
+
/**
|
229 |
+
* Redirects to wprss_display_feed_items
|
230 |
+
* It is used for backwards compatibility to versions < 2.0
|
231 |
+
*
|
232 |
+
* @since 2.1
|
233 |
+
*/
|
234 |
+
function wp_rss_aggregator( $args = array() ) {
|
235 |
+
wprss_display_feed_items( $args );
|
236 |
+
}
|
237 |
+
|
238 |
+
|
239 |
+
/**
|
240 |
+
* Limits a phrase/content to a defined number of words
|
241 |
+
*
|
242 |
+
* NOT BEING USED as we're using the native WP function, although the native one strips tags, so I'll
|
243 |
+
* probably revisit this one again soon.
|
244 |
+
*
|
245 |
+
* @since 3.0
|
246 |
+
* @param string $words
|
247 |
+
* @param integer $limit
|
248 |
+
* @param string $append
|
249 |
+
* @return string
|
250 |
+
*/
|
251 |
+
function wprss_limit_words( $words, $limit, $append = '' ) {
|
252 |
+
/* Add 1 to the specified limit becuase arrays start at 0 */
|
253 |
+
$limit = $limit + 1;
|
254 |
+
/* Store each individual word as an array element
|
255 |
+
up to the limit */
|
256 |
+
$words = explode( ' ', $words, $limit );
|
257 |
+
/* Shorten the array by 1 because that final element will be the sum of all the words after the limit */
|
258 |
+
array_pop( $words );
|
259 |
+
/* Implode the array for output, and append an ellipse */
|
260 |
+
$words = implode( ' ', $words ) . $append;
|
261 |
+
/* Return the result */
|
262 |
+
return rtrim( $words );
|
263 |
+
}
|
includes/feed-processing.php
ADDED
@@ -0,0 +1,450 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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
|
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 |
+
/*
|
148 |
+
$response = wp_remote_head( $permalink );
|
149 |
+
if ( !is_wp_error( $response ) && isset( $response['headers']['location'] ) ) {
|
150 |
+
$permalink = current( explode( '?', $response['headers']['location'] ) );
|
151 |
+
}*/
|
152 |
+
|
153 |
+
// Check if newly fetched item already present in existing feed items,
|
154 |
+
// if not insert it into wp_posts and insert post meta.
|
155 |
+
if ( ! ( in_array( $permalink, $existing_permalinks ) ) ) {
|
156 |
+
|
157 |
+
// Apply filters that determine if the feed item should be inserted into the DB or not.
|
158 |
+
$item = apply_filters( 'wprss_insert_post_item_conditionals', $item, $feed_ID );
|
159 |
+
|
160 |
+
// If the item is not NULL, continue to inserting the feed item post into the DB
|
161 |
+
if ( $item !== NULL ) {
|
162 |
+
|
163 |
+
$feed_item = apply_filters(
|
164 |
+
'wprss_populate_post_data',
|
165 |
+
array(
|
166 |
+
'post_title' => $item->get_title(),
|
167 |
+
'post_content' => '',
|
168 |
+
'post_status' => 'publish',
|
169 |
+
'post_type' => 'wprss_feed_item',
|
170 |
+
),
|
171 |
+
$item
|
172 |
+
);
|
173 |
+
|
174 |
+
// Create and insert post object into the DB
|
175 |
+
$inserted_ID = wp_insert_post( $feed_item );
|
176 |
+
|
177 |
+
// Create and insert post meta into the DB
|
178 |
+
wprss_items_insert_post_meta( $inserted_ID, $item, $feed_ID, $permalink );
|
179 |
+
|
180 |
+
// Remember newly added permalink
|
181 |
+
$existing_permalinks[] = $permalink;
|
182 |
+
}
|
183 |
+
}
|
184 |
+
}
|
185 |
+
}
|
186 |
+
|
187 |
+
|
188 |
+
/**
|
189 |
+
* Creates meta entries for feed items while they are being imported
|
190 |
+
*
|
191 |
+
* @since 2.3
|
192 |
+
*/
|
193 |
+
function wprss_items_insert_post_meta( $inserted_ID, $item, $feed_ID, $feed_url) {
|
194 |
+
update_post_meta( $inserted_ID, 'wprss_item_permalink', $feed_url );
|
195 |
+
update_post_meta( $inserted_ID, 'wprss_item_description', $item->get_description() );
|
196 |
+
update_post_meta( $inserted_ID, 'wprss_item_date', $item->get_date( 'U' ) ); // Save as Unix timestamp format
|
197 |
+
update_post_meta( $inserted_ID, 'wprss_feed_id', $feed_ID);
|
198 |
+
do_action( 'wprss_items_create_post_meta', $inserted_ID, $item, $feed_ID );
|
199 |
+
}
|
200 |
+
|
201 |
+
|
202 |
+
add_action( 'wp_insert_post', 'wprss_fetch_insert_feed_items', 10, 2 );
|
203 |
+
/**
|
204 |
+
* Fetches feed items from source provided and inserts into db
|
205 |
+
*
|
206 |
+
* This function is used when inserting or untrashing a new feed source, it only gets feeds from that particular source
|
207 |
+
*
|
208 |
+
* @since 3.0
|
209 |
+
*/
|
210 |
+
function wprss_fetch_insert_feed_items( $post_id, $post ) {
|
211 |
+
|
212 |
+
// Only run the rest of the function if the post is a feed source and it has just been published
|
213 |
+
if( ( $post->post_type == 'wprss_feed' ) && ( $post->post_status == 'publish' ) ) {
|
214 |
+
wp_schedule_single_event( time(), 'wprss_fetch_single_feed_hook', array( $post_id ) );
|
215 |
+
}
|
216 |
+
}
|
217 |
+
|
218 |
+
|
219 |
+
add_action( 'post_updated', 'wprss_pre_update_feed_source', 10, 3 );
|
220 |
+
/**
|
221 |
+
* This function is triggered just before a post is updated.
|
222 |
+
* It checks if the updated post is a feed source, and carries out any
|
223 |
+
* updating necassary.
|
224 |
+
*
|
225 |
+
* @since 3.3
|
226 |
+
*/
|
227 |
+
function wprss_pre_update_feed_source( $post_ID, $post_after, $post_before ) {
|
228 |
+
// Check if the post is a feed source and is published
|
229 |
+
if ( ( $post_after->post_type == 'wprss_feed' ) && ( $post_after->post_status == 'publish' ) ) {
|
230 |
+
|
231 |
+
// Checking feed limit change
|
232 |
+
// Get the limit currently saved in db, and limit in POST request
|
233 |
+
$limit_before = get_post_meta( $post_ID, 'wprss_limit', true );
|
234 |
+
$limit_after = ( isset( $_POST['wprss_limit'] ) )? $_POST['wprss_limit'] : null;
|
235 |
+
// Calculate the difference
|
236 |
+
$difference = $limit_before - $limit_after;
|
237 |
+
// If the difference is > 0, i.e. user has updated limit with a smaller number
|
238 |
+
if ( $difference > 0 ) {
|
239 |
+
// Delete all feed items for this source
|
240 |
+
wprss_delete_feed_items( $post_ID );
|
241 |
+
}
|
242 |
+
}
|
243 |
+
}
|
244 |
+
|
245 |
+
|
246 |
+
|
247 |
+
add_action( 'wprss_fetch_single_feed_hook', 'wprss_fetch_insert_single_feed_items' );
|
248 |
+
/**
|
249 |
+
* Fetches feed items from source provided and inserts into db
|
250 |
+
*
|
251 |
+
* @since 3.2
|
252 |
+
*/
|
253 |
+
function wprss_fetch_insert_single_feed_items( $feed_ID ) {
|
254 |
+
|
255 |
+
// Get the URL and Feed Limit post meta data
|
256 |
+
$feed_url = get_post_meta( $feed_ID, 'wprss_url', true );
|
257 |
+
$feed_limit = get_post_meta( $feed_ID, 'wprss_limit', true );
|
258 |
+
|
259 |
+
// Use the URL custom field to fetch the feed items for this source
|
260 |
+
if ( filter_var( $feed_url, FILTER_VALIDATE_URL ) ) {
|
261 |
+
$items = wprss_get_feed_items( $feed_url );
|
262 |
+
|
263 |
+
// If the feed has its own meta limit,
|
264 |
+
// slice the items array using the feed meta limit
|
265 |
+
if ( !empty( $feed_limit ) )
|
266 |
+
$items_to_insert = array_slice($items, 0, $feed_limit);
|
267 |
+
else $items_to_insert = $items;
|
268 |
+
|
269 |
+
// Insert the items into the db
|
270 |
+
if ( !empty( $items_to_insert ) ) {
|
271 |
+
wprss_items_insert_post( $items_to_insert, $feed_ID );
|
272 |
+
}
|
273 |
+
}
|
274 |
+
}
|
275 |
+
|
276 |
+
|
277 |
+
/**
|
278 |
+
* Fetches all feed items from sources provided and inserts into db
|
279 |
+
*
|
280 |
+
* This function is used by the cron job or the debugging functions to get all feeds from all feed sources
|
281 |
+
*
|
282 |
+
* @since 3.0
|
283 |
+
*/
|
284 |
+
function wprss_fetch_insert_all_feed_items() {
|
285 |
+
|
286 |
+
// Get all feed sources
|
287 |
+
$feed_sources = wprss_get_all_feed_sources();
|
288 |
+
|
289 |
+
if( $feed_sources->have_posts() ) {
|
290 |
+
// Start by getting one feed source, we will cycle through them one by one,
|
291 |
+
// fetching feed items and adding them to the database in each pass
|
292 |
+
while ( $feed_sources->have_posts() ) {
|
293 |
+
$feed_sources->the_post();
|
294 |
+
wp_schedule_single_event( time(), 'wprss_fetch_single_feed_hook', array( get_the_ID() ) );
|
295 |
+
}
|
296 |
+
wp_reset_postdata(); // Restore the $post global to the current post in the main query
|
297 |
+
}
|
298 |
+
}
|
299 |
+
|
300 |
+
|
301 |
+
add_action( 'trash_wprss_feed', 'wprss_delete_feed_items' ); // maybe use wp_trash_post action? wp_trash_wprss_feed
|
302 |
+
/**
|
303 |
+
* Delete feed items on trashing of corresponding feed source
|
304 |
+
*
|
305 |
+
* @since 2.0
|
306 |
+
*/
|
307 |
+
function wprss_delete_feed_items( $postid ) {
|
308 |
+
|
309 |
+
$args = array(
|
310 |
+
'post_type' => 'wprss_feed_item',
|
311 |
+
// Next 3 parameters for performance, see http://thomasgriffinmedia.com/blog/2012/10/optimize-wordpress-queries
|
312 |
+
'cache_results' => false, // Disable caching, used for one-off queries
|
313 |
+
'no_found_rows' => true, // We don't need pagination, so disable it
|
314 |
+
'fields' => 'ids', // Returns post IDs only
|
315 |
+
'posts_per_page'=> -1,
|
316 |
+
'meta_query' => array(
|
317 |
+
array(
|
318 |
+
'key' => 'wprss_feed_id',
|
319 |
+
'value' => $postid,
|
320 |
+
'compare' => 'LIKE'
|
321 |
+
)
|
322 |
+
)
|
323 |
+
);
|
324 |
+
|
325 |
+
$feed_item_ids = get_posts( $args );
|
326 |
+
foreach( $feed_item_ids as $feed_item_id ) {
|
327 |
+
$purge = wp_delete_post( $feed_item_id, true ); // delete the feed item, skipping trash
|
328 |
+
}
|
329 |
+
wp_reset_postdata();
|
330 |
+
}
|
331 |
+
|
332 |
+
|
333 |
+
/**
|
334 |
+
* Delete all feed items
|
335 |
+
*
|
336 |
+
* @since 3.0
|
337 |
+
*/
|
338 |
+
function wprss_delete_all_feed_items() {
|
339 |
+
$args = array(
|
340 |
+
'post_type' => 'wprss_feed_item',
|
341 |
+
'cache_results' => false, // Disable caching, used for one-off queries
|
342 |
+
'no_found_rows' => true, // We don't need pagination, so disable it
|
343 |
+
'fields' => 'ids', // Returns post IDs only
|
344 |
+
'posts_per_page' => -1,
|
345 |
+
);
|
346 |
+
|
347 |
+
//$feed_items = new WP_Query( $args );
|
348 |
+
|
349 |
+
$feed_item_ids = get_posts( $args );
|
350 |
+
foreach( $feed_item_ids as $feed_item_id ) {
|
351 |
+
$purge = wp_delete_post( $feed_item_id, true ); // delete the feed item, skipping trash
|
352 |
+
}
|
353 |
+
wp_reset_postdata();
|
354 |
+
}
|
355 |
+
|
356 |
+
|
357 |
+
/**
|
358 |
+
* Delete old feed items from the database to avoid bloat
|
359 |
+
*
|
360 |
+
* @since 2.0
|
361 |
+
*/
|
362 |
+
function wprss_truncate_posts() {
|
363 |
+
global $wpdb;
|
364 |
+
$general_settings = get_option( 'wprss_settings_general' );
|
365 |
+
|
366 |
+
if ( $general_settings['limit_feed_items_db'] == 0 ) {
|
367 |
+
return;
|
368 |
+
}
|
369 |
+
|
370 |
+
// Set your threshold of max posts and post_type name
|
371 |
+
$threshold = $general_settings['limit_feed_items_db'];
|
372 |
+
$post_type = 'wprss_feed_item';
|
373 |
+
|
374 |
+
// Query post type
|
375 |
+
// $wpdb query allows me to select specific columns instead of grabbing the entire post object.
|
376 |
+
$query = "
|
377 |
+
SELECT ID, post_title FROM $wpdb->posts
|
378 |
+
WHERE post_type = '$post_type'
|
379 |
+
AND post_status = 'publish'
|
380 |
+
ORDER BY post_modified DESC
|
381 |
+
";
|
382 |
+
$results = $wpdb->get_results( $query );
|
383 |
+
|
384 |
+
// Check if there are any results
|
385 |
+
if ( count( $results ) ){
|
386 |
+
foreach ( $results as $post ) {
|
387 |
+
$i++;
|
388 |
+
|
389 |
+
// Skip any posts within our threshold
|
390 |
+
if ( $i <= $threshold )
|
391 |
+
continue;
|
392 |
+
|
393 |
+
// Let the WordPress API do the heavy lifting for cleaning up entire post trails
|
394 |
+
$purge = wp_delete_post( $post->ID, true );
|
395 |
+
}
|
396 |
+
}
|
397 |
+
}
|
398 |
+
|
399 |
+
|
400 |
+
/**
|
401 |
+
* Custom version of the WP fetch_feed() function, since we want custom sanitization of a feed
|
402 |
+
*
|
403 |
+
* Not being used at the moment, until we decide whether we can still use fetch_feed and modify its handling of sanitization
|
404 |
+
*
|
405 |
+
* @since 3.0
|
406 |
+
*
|
407 |
+
*/
|
408 |
+
/*function wprss_fetch_feed($url) {
|
409 |
+
require_once (ABSPATH . WPINC . '/class-feed.php');
|
410 |
+
|
411 |
+
$feed = new SimplePie();
|
412 |
+
|
413 |
+
// $feed->set_sanitize_class( 'WP_SimplePie_Sanitize_KSES' );
|
414 |
+
// We must manually overwrite $feed->sanitize because SimplePie's
|
415 |
+
// constructor sets it before we have a chance to set the sanitization class
|
416 |
+
// $feed->sanitize = new WP_SimplePie_Sanitize_KSES();
|
417 |
+
|
418 |
+
$feed->set_cache_class( 'WP_Feed_Cache' );
|
419 |
+
$feed->set_file_class( 'WP_SimplePie_File' );
|
420 |
+
|
421 |
+
$feed->set_feed_url($url);
|
422 |
+
$feed->strip_htmltags(array_merge($feed->strip_htmltags, array( 'h1', 'h2', 'h3', 'h4', 'h5', 'a' )));
|
423 |
+
$feed->set_cache_duration( apply_filters( 'wp_feed_cache_transient_lifetime', 12 * HOUR_IN_SECONDS, $url ) );
|
424 |
+
do_action_ref_array( 'wp_feed_options', array( &$feed, $url ) );
|
425 |
+
$feed->init();
|
426 |
+
$feed->handle_content_type();
|
427 |
+
|
428 |
+
if ( $feed->error() )
|
429 |
+
return new WP_Error('simplepie-error', $feed->error());
|
430 |
+
|
431 |
+
return $feed;
|
432 |
+
}*/
|
433 |
+
|
434 |
+
|
435 |
+
/**
|
436 |
+
* Deletes all imported feeds and re-imports everything
|
437 |
+
*
|
438 |
+
* @since 3.0
|
439 |
+
*/
|
440 |
+
function wprss_feed_reset() {
|
441 |
+
wprss_delete_all_feed_items();
|
442 |
+
wprss_fetch_insert_all_feed_items();
|
443 |
+
}
|
444 |
+
|
445 |
+
/* add_action( 'wp_feed_options', 'wprss_feed_options' );
|
446 |
+
function wprss_feed_options( $feed) {
|
447 |
+
$feed->strip_htmltags(array_merge($feed->strip_htmltags, array('h1', 'a', 'img','em')));
|
448 |
+
}
|
449 |
+
|
450 |
+
*/
|
includes/libraries/WP_Logging.php
ADDED
@@ -0,0 +1,360 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
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
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|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
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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/opml-importer.php
ADDED
@@ -0,0 +1,231 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â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
+
* Define the WPRSS OPML Importer to set up the Import OPML Page
|
5 |
+
* and parse uploaded OPML files and import them into WPRSS'
|
6 |
+
* custom post types.
|
7 |
+
*
|
8 |
+
* @since 3.3
|
9 |
+
* @package WPRSSAggregator
|
10 |
+
*/
|
11 |
+
|
12 |
+
|
13 |
+
|
14 |
+
/*
|
15 |
+
* Check if the WP_Importer Class is already loaded.
|
16 |
+
* If not, load it.
|
17 |
+
*/
|
18 |
+
if ( !class_exists( 'WP_Importer' ) ) {
|
19 |
+
$class_wp_importer = ABSPATH . 'wp-admin/includes/class-wp-importer.php';
|
20 |
+
if ( file_exists( $class_wp_importer ) )
|
21 |
+
require $class_wp_importer;
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* WPRSS_OPML_Importer Class handles the OPML Import Page and
|
26 |
+
* OPML file upload. It also constructs a WPRSS_OPML object
|
27 |
+
* for the uploaded file, which parses the file, and then
|
28 |
+
* imports it into WPRSS' custom post types.
|
29 |
+
*
|
30 |
+
* @since 3.3
|
31 |
+
*/
|
32 |
+
class WPRSS_OPML_Importer extends WP_Importer {
|
33 |
+
|
34 |
+
/**
|
35 |
+
* The static Singleton Instance of the importer
|
36 |
+
*/
|
37 |
+
public static $singleton;
|
38 |
+
|
39 |
+
/**
|
40 |
+
* The ID of the uploaded file to import
|
41 |
+
*/
|
42 |
+
private $id;
|
43 |
+
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Constructor: Prepares the Importer
|
47 |
+
*/
|
48 |
+
public function __contruct() {
|
49 |
+
parent::__contruct();
|
50 |
+
}
|
51 |
+
|
52 |
+
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Shows The Import Page and import form for step 1.
|
56 |
+
* Calls the parsing and importing function for step 2.
|
57 |
+
*
|
58 |
+
* @since 3.3
|
59 |
+
* @return void
|
60 |
+
*/
|
61 |
+
public function opml_import() {
|
62 |
+
// Show the Icon and Title
|
63 |
+
echo '<div class="wrap">';
|
64 |
+
screen_icon();
|
65 |
+
echo '<h2>Import OPML</h2>';
|
66 |
+
|
67 |
+
// Get the current step from URL query string
|
68 |
+
$step = empty( $_GET['step'] ) ? 0 : (int) $_GET['step'];
|
69 |
+
|
70 |
+
// Check the current step
|
71 |
+
switch ( $step ) {
|
72 |
+
default :
|
73 |
+
case 0 :
|
74 |
+
// Show the Import Message and the import upload form
|
75 |
+
echo '<p>' . __( 'Howdy! Import your feeds here from an OPML (.xml) export file.', 'wprss' ) . '</p>';
|
76 |
+
echo '<p>' . __( "Click the button below, choose your file, and click 'Upload'.", 'wprss' ) . '</p>';
|
77 |
+
echo '<p>' . __( 'We will take care of the rest.', 'wprss' ) . '</p>';
|
78 |
+
|
79 |
+
// Show an import upload form that submits to the same page, with GET parameter step=1
|
80 |
+
wp_import_upload_form( 'admin.php?import=wprss_opml_importer&step=1' );
|
81 |
+
break;
|
82 |
+
|
83 |
+
case 1:
|
84 |
+
// Check referer
|
85 |
+
check_admin_referer( 'import-upload' );
|
86 |
+
// If the handle_upload function returns true
|
87 |
+
if ( $this->handle_upload() ) {
|
88 |
+
// Get the uploaded file
|
89 |
+
$file = get_attached_file( $this->id );
|
90 |
+
set_time_limit(0);
|
91 |
+
// Parse the File and Import the feeds
|
92 |
+
$this->parse_and_import( $file );
|
93 |
+
}
|
94 |
+
break;
|
95 |
+
}
|
96 |
+
|
97 |
+
echo '</div>';
|
98 |
+
}
|
99 |
+
|
100 |
+
|
101 |
+
|
102 |
+
private function handle_upload() {
|
103 |
+
// Get the upload file
|
104 |
+
$file = wp_import_handle_upload();
|
105 |
+
|
106 |
+
// If the 'error' property is set, show the error message and return FALSE
|
107 |
+
if ( isset( $file['error'] ) ) {
|
108 |
+
echo '<p><strong>' . __( 'Sorry, an error has been encountered.', 'wprss' ) . '</strong><br />';
|
109 |
+
echo esc_html( $file['error'] ) . '</p>';
|
110 |
+
return false;
|
111 |
+
// If the file does not exist, then show the error message and return FALSE
|
112 |
+
} else if ( ! file_exists( $file['file'] ) ) {
|
113 |
+
echo '<p><strong>' . __( 'Sorry, it seems your uploaded file has been misplaced!', 'wprss' ) . '</strong><br />';
|
114 |
+
echo __( 'The uploaded file could not be found at ', 'wprss') . '<code>' . esc_html( $file['file'] ) . '</code>';
|
115 |
+
echo __( 'It is likely that this was caused by a permissions problem.' , 'wprss' );
|
116 |
+
echo '</p>';
|
117 |
+
return false;
|
118 |
+
}
|
119 |
+
|
120 |
+
|
121 |
+
$this->id = (int) $file['id'];
|
122 |
+
return true;
|
123 |
+
}
|
124 |
+
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Imports the give <outline> OPML element as a wprss_feed
|
128 |
+
*
|
129 |
+
* @since 3.3
|
130 |
+
* @param $outline The outline OPML element
|
131 |
+
*/
|
132 |
+
private function import_opml_feed( $outline ) {
|
133 |
+
// Create an associative array, with the feed's properties
|
134 |
+
$feed = array(
|
135 |
+
'post_title' => $outline['title'],
|
136 |
+
'post_content' => '',
|
137 |
+
'post_status' => 'publish',
|
138 |
+
'post_type' => 'wprss_feed'
|
139 |
+
);
|
140 |
+
// Insert the post into the database and store the inserted ID
|
141 |
+
$inserted_id = wp_insert_post( $feed );
|
142 |
+
// Update the post's meta
|
143 |
+
update_post_meta( $inserted_id, 'wprss_url', $outline['xmlUrl'] );
|
144 |
+
// Return inserted ID
|
145 |
+
return $inserted_id;
|
146 |
+
}
|
147 |
+
|
148 |
+
|
149 |
+
/**
|
150 |
+
* Attempts to parse the given file as an OPML construct, and
|
151 |
+
* import each found feed.
|
152 |
+
*
|
153 |
+
* @since 3.3
|
154 |
+
* @param file The OPML file to parse and import
|
155 |
+
* @return void
|
156 |
+
* @todo Use the parsed $opml object to import the feeds AND remove var_dump
|
157 |
+
*/
|
158 |
+
private function parse_and_import( $file ) {
|
159 |
+
try {
|
160 |
+
$opml = new WPRSS_OPML( $file );
|
161 |
+
|
162 |
+
// Show Success Message
|
163 |
+
echo '<h3>Feeds were imported successfully!</h3>';
|
164 |
+
|
165 |
+
// Show imported feeds
|
166 |
+
?>
|
167 |
+
<table class="widefat">
|
168 |
+
<thead>
|
169 |
+
<tr>
|
170 |
+
<th>ID</th>
|
171 |
+
<th>Title</th>
|
172 |
+
<th>URL</th>
|
173 |
+
</tr>
|
174 |
+
</thead>
|
175 |
+
|
176 |
+
<tbody>
|
177 |
+
<?php
|
178 |
+
foreach ( $opml->body as $opml_feed ) :
|
179 |
+
$inserted_id = $this->import_opml_feed( $opml_feed );
|
180 |
+
?>
|
181 |
+
<tr>
|
182 |
+
<td><?php echo $inserted_id; ?></td>
|
183 |
+
<td><?php echo $opml_feed['title']; ?> </td>
|
184 |
+
<td><?php echo $opml_feed['xmlUrl']; ?></td>
|
185 |
+
</tr>
|
186 |
+
<?php endforeach; ?>
|
187 |
+
</tbody>
|
188 |
+
|
189 |
+
<tfoot>
|
190 |
+
<tr>
|
191 |
+
<th>ID</th>
|
192 |
+
<th>Title</th>
|
193 |
+
<th>URL</th>
|
194 |
+
</tr>
|
195 |
+
</tfoot>
|
196 |
+
|
197 |
+
</table>
|
198 |
+
<?php
|
199 |
+
|
200 |
+
} catch (Exception $e) {
|
201 |
+
// Show Error Message
|
202 |
+
echo '<div class="error"><p>' . $e->getMessage() . '</p></div>';
|
203 |
+
}
|
204 |
+
}
|
205 |
+
|
206 |
+
}
|
207 |
+
|
208 |
+
|
209 |
+
/* Initialize the Singleton Instance of the Importer */
|
210 |
+
WPRSS_OPML_Importer::$singleton = new WPRSS_OPML_Importer();
|
211 |
+
|
212 |
+
|
213 |
+
|
214 |
+
add_action( 'admin_init', 'wprss_opml_register_import' );
|
215 |
+
/**
|
216 |
+
* Initializes and registers the OPML Importer
|
217 |
+
* @since 3.3
|
218 |
+
*/
|
219 |
+
function wprss_opml_register_import() {
|
220 |
+
|
221 |
+
register_importer(
|
222 |
+
'wprss_opml_importer',
|
223 |
+
'WP RSS OPML',
|
224 |
+
'Import Feeds from an OPML file into WP RSS Aggregator',
|
225 |
+
array( WPRSS_OPML_Importer::$singleton ,'opml_import' )
|
226 |
+
);
|
227 |
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constructed using a file, which it parses upon creation.
|
6 |
+
*
|
7 |
+
* @since 3.3
|
8 |
+
* @package WPRSSAggregator
|
9 |
+
*/
|
10 |
+
class WPRSS_OPML {
|
11 |
+
|
12 |
+
|
13 |
+
public $file;
|
14 |
+
public $head;
|
15 |
+
public $body;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Constructor: Parses the given XML file as an OPML
|
19 |
+
*
|
20 |
+
* @since 3.3
|
21 |
+
* @param $file The file to be parsed into a WPRSS_OPML object
|
22 |
+
*/
|
23 |
+
public function __construct( $file ) {
|
24 |
+
// Initialize Properties
|
25 |
+
$this->file = $file;
|
26 |
+
$this->head = array();
|
27 |
+
$this->body = array();
|
28 |
+
// Begin Parsing
|
29 |
+
try {
|
30 |
+
// Wrap file data in a SimpleXMLElement
|
31 |
+
$xml = simplexml_load_file( $this->file );
|
32 |
+
|
33 |
+
// Check if the head section exists before parsing it
|
34 |
+
if ( $xml->head )
|
35 |
+
$this->head = WPRSS_OPML::parse_opml_head( $xml->head->children() );
|
36 |
+
// Check if the body section exists before parsing it
|
37 |
+
if ( $xml->body )
|
38 |
+
$this->body = WPRSS_OPML::parse_opml_body_element( $xml->body->outline );
|
39 |
+
|
40 |
+
} catch (Exception $e) {
|
41 |
+
// If an exception is caught. Throw an error message
|
42 |
+
throw new Exception( __( 'An error occured: The file might not be a valid OPML file or is corrrupt. ', 'wprss' ), 1);
|
43 |
+
}
|
44 |
+
}
|
45 |
+
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Parses the given variable as an OPML head section
|
49 |
+
*
|
50 |
+
* @since 3.3
|
51 |
+
* @param $head The head section of an OPML file ( SimpleXMLElement )
|
52 |
+
* @return array An associative array containing SimpleXMLElements for each tag in the given head section.
|
53 |
+
*/
|
54 |
+
private static function parse_opml_head( $head ) {
|
55 |
+
$parsed_data = array();
|
56 |
+
|
57 |
+
foreach ( $head as $property ) {
|
58 |
+
$parsed_data[ $property->getName() ] = $property;
|
59 |
+
}
|
60 |
+
|
61 |
+
return $parsed_data;
|
62 |
+
}
|
63 |
+
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Iterates through the elements given OPML/XML data and parses
|
67 |
+
* each element, and recurses where necessary, into an associative
|
68 |
+
* array that mimics OPML structure.
|
69 |
+
* @since 1.0
|
70 |
+
* @return array The Parsed OPML as an associative array
|
71 |
+
*/
|
72 |
+
private static function parse_opml_body_element( $element ) {
|
73 |
+
$parsed_data = array();
|
74 |
+
|
75 |
+
// Iterates through each child element in the given element
|
76 |
+
foreach ( $element as $child_element ) {
|
77 |
+
|
78 |
+
// If child element has type attribute set to 'rss' or has the 'xmlUrl' attribute
|
79 |
+
if ( $child_element['type'] === 'rss' || isset( $child_element['xmlUrl'] ) ) {
|
80 |
+
// Parse the child element and add it to the parsed data array
|
81 |
+
$parsed_data[] = WPRSS_OPML::SimpleXMLElement_to_OPMLElement( $child_element );
|
82 |
+
}
|
83 |
+
// Otherwise, if the child element has children 'outline' elements
|
84 |
+
elseif ( $child_element->outline ) {
|
85 |
+
// Recurse using this child element as parameter, and add the result to the parsed data array
|
86 |
+
$parsed_data[ (string) $child_element['text'] ] = WPRSS_OPML::parse_opml_body_element( $child_element->outline );
|
87 |
+
}
|
88 |
+
|
89 |
+
}
|
90 |
+
|
91 |
+
return $parsed_data;
|
92 |
+
}
|
93 |
+
|
94 |
+
|
95 |
+
/**
|
96 |
+
* Parses a SimpleXMLElement Object into an OPML element compliant
|
97 |
+
* associative array.
|
98 |
+
* @since 1.0
|
99 |
+
* @return array An array in OPML element format
|
100 |
+
*/
|
101 |
+
private static function SimpleXMLElement_to_OPMLElement( $element ) {
|
102 |
+
// Copy attribute data from $element to a new associative array
|
103 |
+
$result = array(
|
104 |
+
'text' => (string) $element['text'],
|
105 |
+
'title' => (string) $element['title'],
|
106 |
+
'htmlUrl' => (string) $element['htmlUrl'],
|
107 |
+
'xmlUrl' => (string) $element['xmlUrl'],
|
108 |
+
'description' => (string) $element['description']
|
109 |
+
);
|
110 |
+
|
111 |
+
/*
|
112 |
+
* Check for existence of htmlUrl and xmlUrl.
|
113 |
+
* If not found, use lowercased attribute names.
|
114 |
+
*/
|
115 |
+
if ( !isset( $element['htmlUrl'] ) )
|
116 |
+
$result['htmlUrl'] = $element['htmlurl'];
|
117 |
+
if ( !isset( $element['xmlUrl'] ) )
|
118 |
+
$result['xmlUrl'] = $element['xmlurl'];
|
119 |
+
|
120 |
+
// Return the result OPML Element
|
121 |
+
return $result;
|
122 |
+
}
|
123 |
+
|
124 |
+
}
|
125 |
+
|
126 |
+
?>
|
includes/roles-capabilities.php
ADDED
@@ -0,0 +1,107 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Contains all roles and capabilities functions
|
5 |
+
*
|
6 |
+
* @package WPRSSAggregator
|
7 |
+
*/
|
8 |
+
|
9 |
+
|
10 |
+
add_action('init', 'wprss_add_caps');
|
11 |
+
/**
|
12 |
+
* Add feed aggregator-specific capabilities
|
13 |
+
*
|
14 |
+
* @since 3.3
|
15 |
+
*/
|
16 |
+
function wprss_add_caps() {
|
17 |
+
global $wp_roles;
|
18 |
+
|
19 |
+
if ( class_exists('WP_Roles') )
|
20 |
+
if ( ! isset( $wp_roles ) )
|
21 |
+
$wp_roles = new WP_Roles();
|
22 |
+
|
23 |
+
if ( is_object( $wp_roles ) ) {
|
24 |
+
|
25 |
+
$wp_roles->add_cap( 'administrator', 'manage_feed_settings' );
|
26 |
+
$wp_roles->add_cap( 'editor', 'manage_feed_settings' );
|
27 |
+
|
28 |
+
// Add the main post type capabilities
|
29 |
+
$capabilities = wprss_get_core_caps();
|
30 |
+
foreach ( $capabilities as $cap_group ) {
|
31 |
+
foreach ( $cap_group as $cap ) {
|
32 |
+
$wp_roles->add_cap( 'administrator', $cap );
|
33 |
+
$wp_roles->add_cap( 'editor', $cap );
|
34 |
+
}
|
35 |
+
}
|
36 |
+
}
|
37 |
+
}
|
38 |
+
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Gets the core post type capabilties
|
42 |
+
*
|
43 |
+
* @since 3.3
|
44 |
+
*/
|
45 |
+
function wprss_get_core_caps() {
|
46 |
+
$capabilities = array();
|
47 |
+
|
48 |
+
$capability_types = array( 'feed', 'feed_source' );
|
49 |
+
|
50 |
+
foreach ( $capability_types as $capability_type ) {
|
51 |
+
$capabilities[ $capability_type ] = array(
|
52 |
+
// Post type
|
53 |
+
"edit_{$capability_type}",
|
54 |
+
"read_{$capability_type}",
|
55 |
+
"delete_{$capability_type}",
|
56 |
+
"edit_{$capability_type}s",
|
57 |
+
"edit_others_{$capability_type}s",
|
58 |
+
"publish_{$capability_type}s",
|
59 |
+
"read_private_{$capability_type}s",
|
60 |
+
"delete_{$capability_type}s",
|
61 |
+
"delete_private_{$capability_type}s",
|
62 |
+
"delete_published_{$capability_type}s",
|
63 |
+
"delete_others_{$capability_type}s",
|
64 |
+
"edit_private_{$capability_type}s",
|
65 |
+
"edit_published_{$capability_type}s",
|
66 |
+
|
67 |
+
// Terms
|
68 |
+
"manage_{$capability_type}_terms",
|
69 |
+
"edit_{$capability_type}_terms",
|
70 |
+
"delete_{$capability_type}_terms",
|
71 |
+
"assign_{$capability_type}_terms"
|
72 |
+
);
|
73 |
+
}
|
74 |
+
|
75 |
+
return $capabilities;
|
76 |
+
}
|
77 |
+
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Remove core post type capabilities (called on uninstall)
|
81 |
+
*
|
82 |
+
* @since 3.3
|
83 |
+
* @return void
|
84 |
+
*/
|
85 |
+
function wprss_remove_caps() {
|
86 |
+
if ( class_exists( 'WP_Roles' ) )
|
87 |
+
if ( ! isset( $wp_roles ) )
|
88 |
+
$wp_roles = new WP_Roles();
|
89 |
+
|
90 |
+
if ( is_object( $wp_roles ) ) {
|
91 |
+
|
92 |
+
/** Site Administrator Capabilities */
|
93 |
+
$wp_roles->remove_cap( 'administrator', 'manage_feed_settings' );
|
94 |
+
/** Editor Capabilities */
|
95 |
+
$wp_roles->remove_cap( 'editor', 'manage_feed_settings' );
|
96 |
+
|
97 |
+
/** Remove the Main Post Type Capabilities */
|
98 |
+
$capabilities = $this->get_core_caps();
|
99 |
+
|
100 |
+
foreach ( $capabilities as $cap_group ) {
|
101 |
+
foreach ( $cap_group as $cap ) {
|
102 |
+
$wp_roles->remove_cap( 'administrator', $cap );
|
103 |
+
$wp_roles->remove_cap( 'editor', $cap );
|
104 |
+
}
|
105 |
+
}
|
106 |
+
}
|
107 |
+
}
|
includes/scripts.php
ADDED
@@ -0,0 +1,119 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
$screen = get_current_screen();
|
24 |
+
|
25 |
+
if ( ( 'post' === $screen->base || 'edit' === $screen->base || 'wprss-debugging' === $screen->base ) &&
|
26 |
+
( 'wprss_feed' === $screen->post_type || 'wprss_feed_item' === $screen->post_type ) || ( isset( $_GET['page'] ) &&
|
27 |
+
( $_GET['page'] == 'wprss-aggregator-settings' ) ) ) {
|
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 |
+
else if ( 'dashboard_page_wprss-welcome' === $screen->base ) {
|
37 |
+
wp_enqueue_style( 'admin-styles', WPRSS_CSS . 'admin-styles.css' );
|
38 |
+
}
|
39 |
+
|
40 |
+
do_action( 'wprss_admin_scripts_styles' );
|
41 |
+
} // end wprss_admin_scripts_styles
|
42 |
+
|
43 |
+
|
44 |
+
add_action( 'wp_enqueue_scripts', 'wprss_load_scripts' );
|
45 |
+
/**
|
46 |
+
* Enqueues the required scripts.
|
47 |
+
*
|
48 |
+
* @since 3.0
|
49 |
+
*/
|
50 |
+
function wprss_load_scripts() {
|
51 |
+
wp_enqueue_script( 'jquery.colorbox-min', WPRSS_JS . 'jquery.colorbox-min.js', array( 'jquery' ) );
|
52 |
+
wp_enqueue_script( 'custom', WPRSS_JS . 'custom.js', array( 'jquery', 'jquery.colorbox-min' ) );
|
53 |
+
do_action( 'wprss_register_scripts' );
|
54 |
+
} // end wprss_head_scripts_styles
|
55 |
+
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Returns the path to the WPRSS templates directory
|
59 |
+
*
|
60 |
+
* @since 3.0
|
61 |
+
* @return string
|
62 |
+
*/
|
63 |
+
function wprss_get_templates_dir() {
|
64 |
+
return WPRSS_DIR . 'templates';
|
65 |
+
}
|
66 |
+
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Returns the URL to the WPRSS templates directory
|
70 |
+
*
|
71 |
+
* @since 3.0
|
72 |
+
* @return string
|
73 |
+
*/
|
74 |
+
function wprss_get_templates_uri() {
|
75 |
+
return WPRSS_URI . 'templates';
|
76 |
+
}
|
77 |
+
|
78 |
+
|
79 |
+
add_action( 'wp_enqueue_scripts', 'wprss_register_styles' );
|
80 |
+
/**
|
81 |
+
* Register front end CSS styling files
|
82 |
+
* Inspiration from Easy Digital Downloads
|
83 |
+
*
|
84 |
+
* @since 3.0
|
85 |
+
*/
|
86 |
+
function wprss_register_styles() {
|
87 |
+
|
88 |
+
$general_settings = get_option( 'wprss_settings_general' );
|
89 |
+
|
90 |
+
if( $general_settings['styles_disable'] == 1 )
|
91 |
+
return;
|
92 |
+
wp_enqueue_style( 'colorbox', WPRSS_CSS . 'colorbox.css', array(), '1.4.1' );
|
93 |
+
wp_enqueue_style( 'styles', WPRSS_CSS . 'styles.css', array(), '' );
|
94 |
+
|
95 |
+
/* If using DISABLE CSS option:
|
96 |
+
global $edd_options;
|
97 |
+
|
98 |
+
if( isset( $edd_options['disable_styles'] ) )
|
99 |
+
return;
|
100 |
+
|
101 |
+
*/
|
102 |
+
|
103 |
+
/* $file = 'wprss.css';
|
104 |
+
|
105 |
+
// Check child theme first
|
106 |
+
if ( file_exists( trailingslashit( get_stylesheet_directory() ) . 'wprss_templates/' . $file ) ) {
|
107 |
+
$url = trailingslashit( get_stylesheet_directory_uri() ) . 'wprss_templates/' . $file;
|
108 |
+
|
109 |
+
// Check parent theme next
|
110 |
+
} elseif ( file_exists( trailingslashit( get_template_directory() ) . 'wprss_templates/' . $file ) ) {
|
111 |
+
$url = trailingslashit( get_template_directory_uri() ) . 'wprss_templates/' . $file;
|
112 |
+
|
113 |
+
// Check theme compatibility last
|
114 |
+
} elseif ( file_exists( trailingslashit( wprss_get_templates_dir() ) . $file ) ) {
|
115 |
+
$url = trailingslashit( wprss_get_templates_uri() ) . $file;
|
116 |
+
}
|
117 |
+
|
118 |
+
wp_enqueue_style( 'wprss-styles', $url, WPRSS_VERSION );*/
|
119 |
+
}
|
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 @@
|
|
Â
|
|
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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,215 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â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
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
// from version 3.3
|
208 |
+
'custom_feed_url' => 'wprss',
|
209 |
+
'source_link' => 0
|
210 |
+
)
|
211 |
+
);
|
212 |
+
|
213 |
+
// Return the default settings
|
214 |
+
return $settings;
|
215 |
+
}
|
js/admin-custom.js
ADDED
@@ -0,0 +1,95 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
// jQuery for 'Fetch Feed Items' Row Action in 'All Feed Sources' page
|
24 |
+
jQuery('.wprss_ajax_action').click( function(){
|
25 |
+
action_link = jQuery(this);
|
26 |
+
id = action_link.attr('pid');
|
27 |
+
url = action_link.attr('purl');
|
28 |
+
jQuery.post(
|
29 |
+
url,
|
30 |
+
{
|
31 |
+
'action': 'wprss_fetch_feeds_action',
|
32 |
+
'id': id
|
33 |
+
},
|
34 |
+
function(response){
|
35 |
+
action_link.text('Feed items imported!');
|
36 |
+
}
|
37 |
+
);
|
38 |
+
action_link.text('Please wait ...');
|
39 |
+
action_link.unbind('click');
|
40 |
+
});
|
41 |
+
|
42 |
+
// Make the number rollers change their value to empty string when value is 0, making
|
43 |
+
// them use the placeholder.
|
44 |
+
jQuery('.wprss-number-roller').on('change', function(){
|
45 |
+
if ( jQuery(this).val() == 0 )
|
46 |
+
jQuery(this).val('');
|
47 |
+
});
|
48 |
+
});
|
49 |
+
|
50 |
+
|
51 |
+
/* JS for admin notice - Leave a review */
|
52 |
+
|
53 |
+
(function ($) {
|
54 |
+
"use strict";
|
55 |
+
$(function () {
|
56 |
+
|
57 |
+
// Check to see if the Ajax Notification is visible
|
58 |
+
if ($('#dismiss-ajax-notification').length > 0) {
|
59 |
+
|
60 |
+
// If so, we need to setup an event handler to trigger it's dismissal
|
61 |
+
$('#dismiss-ajax-notification').click(function (evt) {
|
62 |
+
|
63 |
+
evt.preventDefault();
|
64 |
+
|
65 |
+
// Initiate a request to the server-side
|
66 |
+
$.post(ajaxurl, {
|
67 |
+
|
68 |
+
// The name of the function to fire on the server
|
69 |
+
action: 'wprss_hide_admin_notification',
|
70 |
+
|
71 |
+
// The nonce value to send for the security check
|
72 |
+
nonce: $.trim($('#ajax-notification-nonce').text())
|
73 |
+
|
74 |
+
}, function (response) {
|
75 |
+
|
76 |
+
// If the response was successful (that is, 1 was returned), hide the notification;
|
77 |
+
// Otherwise, we'll change the class name of the notification
|
78 |
+
if ('1' === response) {
|
79 |
+
$('#ajax-notification').fadeOut('slow');
|
80 |
+
} else {
|
81 |
+
|
82 |
+
$('#ajax-notification')
|
83 |
+
.removeClass('updated')
|
84 |
+
.addClass('error');
|
85 |
+
|
86 |
+
} // end if
|
87 |
+
|
88 |
+
});
|
89 |
+
|
90 |
+
});
|
91 |
+
|
92 |
+
} // end if
|
93 |
+
|
94 |
+
});
|
95 |
+
}(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 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|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
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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,211 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
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
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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.6
|
8 |
+
Stable tag: 3.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 lets you create a feed reader/aggregator on your WordPress site.
|
14 |
+
|
15 |
+
It works in a similar fashion to RSS readers like for example Google Reader. You can add any number of feeds through an administration panel, the plugin will then pull feed items from these sites, merge them and sort them by date.
|
16 |
+
|
17 |
+
The plugin uses SimplePie for the feed operations. You can call the function from within your 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 would with other post types such as Posts or Pages.
|
20 |
+
|
21 |
+
WP RSS Aggregator can also be used to display feed items from a particular feed source anywhere you want on your site.
|
22 |
+
|
23 |
+
= Premium Add-Ons =
|
24 |
+
Add-Ons that add more functionality to the core plugin are now [available for purchase](http://www.wprssaggregator.com/extensions/).
|
25 |
+
|
26 |
+
= Demo =
|
27 |
+
The plugin can be seen in use on the [WPMayor.com WordPress News page](http://www.wpmayor.com/wordpress-news/).
|
28 |
+
|
29 |
+
= Documentation =
|
30 |
+
Instructions for plugin usage are available on the plugin's [documentation page](http://www.wprssaggregator.com/documentation/).
|
31 |
+
|
32 |
+
= Credit =
|
33 |
+
Created by Jean Galea from [WP Mayor](http://www.wpmayor.com)
|
34 |
+
|
35 |
+
= Translations =
|
36 |
+
Italian - Davide De Maestri
|
37 |
+
|
38 |
+
== Installation ==
|
39 |
+
|
40 |
+
1. Upload the `wp-rss-aggregator` folder to the `/wp-content/plugins/` directory
|
41 |
+
2. Activate the WP RSS Aggregator plugin through the 'Plugins' menu in WordPress
|
42 |
+
3. Configure the plugin by going to the `RSS Aggregator` menu item that appears in your dashboard menu.
|
43 |
+
3. Use the shortcode in your posts or pages: `[wp-rss-aggregator]`
|
44 |
+
|
45 |
+
The parameters accepted are:
|
46 |
+
|
47 |
+
* links_before
|
48 |
+
* links_after
|
49 |
+
* link_before
|
50 |
+
* link_after
|
51 |
+
* limit
|
52 |
+
* source
|
53 |
+
|
54 |
+
An example of a shortcode with parameters:
|
55 |
+
`[wp_rss_aggregator link_before='<li class="feed-link">' link_after='</li>']`
|
56 |
+
It is advisable to use the 'HTML' view of the editor when inserting the shortcode with paramters.
|
57 |
+
|
58 |
+
An example of a function call from within the template files:
|
59 |
+
`
|
60 |
+
<?php
|
61 |
+
wprss_display_feed_items( $args = array(
|
62 |
+
'links_before' => '<ul>',
|
63 |
+
'links_after' => '</ul>',
|
64 |
+
'link_before' => '<li>',
|
65 |
+
'link_after' => '</li>',
|
66 |
+
'limit' => '8',
|
67 |
+
'source' => '5,9'
|
68 |
+
));
|
69 |
+
?>
|
70 |
+
`
|
71 |
+
|
72 |
+
OR
|
73 |
+
|
74 |
+
`<?php do_shortcode('[wp-rss-aggregator]'); ?>`
|
75 |
+
|
76 |
+
You can also set whether the feed links should open in a new window, current window or even a lightbox, via the settings panel.
|
77 |
+
|
78 |
+
The settings panel also has an option to set links as nofollow for SEO purposes.
|
79 |
+
|
80 |
+
Since version 2.0 you can also specify the number of feed items shown on the frontend via the settings panel.
|
81 |
+
|
82 |
+
== Frequently Asked Questions ==
|
83 |
+
= How can I output the feeds in my theme? =
|
84 |
+
|
85 |
+
You can either call the function directly within the theme:
|
86 |
+
`<?php wprss_display_feed_items(); ?>`
|
87 |
+
|
88 |
+
Or use the shortcode in your posts and pages:
|
89 |
+
[wp-rss-aggregator]
|
90 |
+
|
91 |
+
== Screenshots ==
|
92 |
+
|
93 |
+
1. The output of this plugin on the frontend, as seen on www.wpmayor.com.
|
94 |
+
|
95 |
+
2. Feed sources list.
|
96 |
+
|
97 |
+
3. Adding a new feed source.
|
98 |
+
|
99 |
+
4. Imported feeds.
|
100 |
+
|
101 |
+
5. Plugin settings page.
|
102 |
+
|
103 |
+
== Changelog ==
|
104 |
+
|
105 |
+
= Version 3.3.1 (2013-08-09) =
|
106 |
+
* Fixed Bug: Roles and Capabilities file had not been included
|
107 |
+
* Fixed Bug: Error on install, function not found
|
108 |
+
|
109 |
+
= Version 3.3 (2013-08-08) =
|
110 |
+
* New feature: OPML importer
|
111 |
+
* New feature: Feed item limits for individual Feed Sources
|
112 |
+
* New feature: Custom feed URL
|
113 |
+
* New feature: Feed limit on custom feed
|
114 |
+
* New feature: New 'Fetch feed items' action for each Feed Source in listing display
|
115 |
+
* New feature: Option to enable link to source
|
116 |
+
* Enhanced: Date strings now change according to locale being used (i.e. compatible with WPML)
|
117 |
+
* Enhanced: Capabilities implemented
|
118 |
+
* Enhanced: Feed Sources row action 'View' removed
|
119 |
+
* Fixed Bug: Proxy feed URLs resulting in the permalink: example.com/url
|
120 |
+
|
121 |
+
= Version 3.2 (2013-07-06) =
|
122 |
+
* New feature: Parameter to limit number of feeds displayed
|
123 |
+
* New feature: Paramter to limit feeds displayed to particular sources (via ID)
|
124 |
+
* Enhanced: Better feed import handling to handle large number of feed sources
|
125 |
+
|
126 |
+
= Version 3.1.1 (2013-06-06) =
|
127 |
+
* Fixed bug: Incompatibility with some other plugins due to function missing namespace
|
128 |
+
|
129 |
+
= Version 3.1 (2013-06-06) =
|
130 |
+
* New feature: Option to set the number of feed items imported from every feed (default 5)
|
131 |
+
* New feature: Import and Export aggregator settings and feed sources
|
132 |
+
* New feature: Debugging page allowing manual feed refresh and feed reset
|
133 |
+
* Enhanced: Faster handling of restoring sources from trash when feed limit is 0
|
134 |
+
* Fixed bug: Limiter on number of overall feeds stored not working
|
135 |
+
* Fixed bug: Incompatibility issue with Foobox plugin fixed
|
136 |
+
* Fixed bug: Duplicate feeds sometimes imported
|
137 |
+
|
138 |
+
= Version 3.0 (2013-03-16) =
|
139 |
+
* New feature: Option to select cron frequency
|
140 |
+
* New feature: Code extensibility added to be compatible with add-ons
|
141 |
+
* New feature: Option to set a limit to the number of feeds stored (previously 50, hard coded)
|
142 |
+
* New feature: Option to define the format of the date shown below each feed item
|
143 |
+
* New feature: Option to show or hide source of feed item
|
144 |
+
* New feature: Option to show or hide publish date of feed item
|
145 |
+
* New feature: Option to set text preceding publish date
|
146 |
+
* New feature: Option to set text preceding source of feed item
|
147 |
+
* New feature: Option to link title or not
|
148 |
+
* New feature: Limit of 5 items imported for each source instead of 10
|
149 |
+
* Enhanced: Performance improvement when publishing * New feeds in admin
|
150 |
+
* Enhanced: Query tuning for better performance
|
151 |
+
* Enhanced: Major code rewrite, refactoring and inclusion of hooks
|
152 |
+
* Enhanced: Updated Colorbox to v1.4.1
|
153 |
+
* Enhanced: Better security implementations
|
154 |
+
* Enhanced: Better feed preview display
|
155 |
+
* Fixed bug: Deletion of items upon source deletion not working properly
|
156 |
+
* Requires: WordPress 3.3
|
157 |
+
|
158 |
+
= Version 2.2.3 (2012-11-01) =
|
159 |
+
* Fixed bug: Tab navigation preventing typing in input boxes
|
160 |
+
* Removed: Feeds showing up in internal linking pop up
|
161 |
+
|
162 |
+
= Version 2.2.2 (2012-10-30) =
|
163 |
+
* Removed: Feeds showing up in site search results
|
164 |
+
* Enhanced: Better tab button navigation when adding a new feed
|
165 |
+
* Enhanced: Better guidance when a feed URL is invalid
|
166 |
+
|
167 |
+
= Version 2.2.1 (2012-10-17) =
|
168 |
+
* Fixed bug: wprss_feed_source_order assumes everyone is an admin
|
169 |
+
|
170 |
+
= Version 2.2 (2012-10-01) =
|
171 |
+
* Italian translation added
|
172 |
+
* Feed source order changed to alphabetical
|
173 |
+
* Fixed bug - repeated entries when having a non-valid feed source
|
174 |
+
* Fixed bug - all imported feeds deleted upon trashing a single feed source
|
175 |
+
|
176 |
+
= Version 2.1 (2012-09-27) =
|
177 |
+
* Now localised for translations
|
178 |
+
* Fixed bug with date string
|
179 |
+
* Fixed $link_before and $link_after, now working
|
180 |
+
* Added backwards compatibility for wp_rss_aggregator() function
|
181 |
+
|
182 |
+
= Version 2.0 (2012-09-21) =
|
183 |
+
* Bulk of code rewritten and refactored
|
184 |
+
* Added install and upgrade functions
|
185 |
+
* Added DB version setting
|
186 |
+
* Feed sources now stored as Custom Post Types
|
187 |
+
* Feed source list sortable ascending or descending by name
|
188 |
+
* Removed days subsections in feed display
|
189 |
+
* Ability to limit total number of feeds displayed
|
190 |
+
* Feeds now fetched via Cron
|
191 |
+
* Cron job to delete old feed items, keeps max of 50 items in DB
|
192 |
+
* Now requires WordPress 3.2
|
193 |
+
* Updated colorbox to v1.3.20.1
|
194 |
+
* Limit of 15 items max imported for each source
|
195 |
+
* Fixed issue of page content displaying incorrectly after feeds
|
196 |
+
|
197 |
+
|
198 |
+
= Version 1.1 (2012-08-13) =
|
199 |
+
* Now requires WordPress 3.0
|
200 |
+
* More flexible fetching of images directory
|
201 |
+
* Has its own top level menu item
|
202 |
+
* Added settings section
|
203 |
+
* Ability to open in lightbox, new window or default browser behaviour
|
204 |
+
* Ability to set links as follow or no follow
|
205 |
+
* Using constants for oftenly used locations
|
206 |
+
* Code refactoring
|
207 |
+
* Changes in file and folder structure
|
208 |
+
|
209 |
+
|
210 |
+
= Version 1.0 (2012-01-06) =
|
211 |
+
* 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,12 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
wprss_remove_caps();
|
8 |
+
delete_option( 'wprss_options' );
|
9 |
+
delete_option( 'wprss_settings' );
|
10 |
+
delete_option( 'wprss_settings_general' );
|
11 |
+
delete_option( 'wprss_db_version' );
|
12 |
+
delete_option( 'wprss_settings_notices' );
|
wp-rss-aggregator.php
ADDED
@@ -0,0 +1,213 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|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â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: WP RSS Aggregator
|
4 |
+
Plugin URI: http://www.wprssaggregator.com
|
5 |
+
Description: Imports and aggregates multiple RSS Feeds using SimplePie
|
6 |
+
Version: 3.3.1
|
7 |
+
Author: Jean Galea
|
8 |
+
Author URI: http://www.wprssaggregator.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.3.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.3.1', true );
|
46 |
+
|
47 |
+
// Set the database version number of the plugin.
|
48 |
+
if( !defined( 'WPRSS_DB_VERSION' ) )
|
49 |
+
define( 'WPRSS_DB_VERSION', 5 );
|
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 file for setting capabilities of our post types */
|
94 |
+
require_once ( WPRSS_INC . 'roles-capabilities.php' );
|
95 |
+
|
96 |
+
/* Load the feed processing functions file */
|
97 |
+
require_once ( WPRSS_INC . 'feed-processing.php' );
|
98 |
+
|
99 |
+
/* Load the feed display functions file */
|
100 |
+
require_once ( WPRSS_INC . 'feed-display.php' );
|
101 |
+
|
102 |
+
/* Load the custom feed file */
|
103 |
+
require_once ( WPRSS_INC . 'custom-feed.php' );
|
104 |
+
|
105 |
+
/* Load the cron job scheduling functions. */
|
106 |
+
require_once ( WPRSS_INC . 'cron-jobs.php' );
|
107 |
+
|
108 |
+
/* Load the admin functions file. */
|
109 |
+
require_once ( WPRSS_INC . 'admin.php' );
|
110 |
+
|
111 |
+
/* Load the admin options functions file. */
|
112 |
+
require_once ( WPRSS_INC . 'admin-options.php' );
|
113 |
+
|
114 |
+
/* Load the settings import/export file */
|
115 |
+
require_once ( WPRSS_INC . 'admin-import-export.php' );
|
116 |
+
|
117 |
+
/* Load the debugging file */
|
118 |
+
require_once ( WPRSS_INC . 'system-info.php' );
|
119 |
+
|
120 |
+
/* Load the miscellaneous functions file */
|
121 |
+
require_once ( WPRSS_INC . 'misc-functions.php' );
|
122 |
+
|
123 |
+
/* Load the OPML Class file */
|
124 |
+
require_once ( WPRSS_INC . 'opml.php' );
|
125 |
+
|
126 |
+
/* Load the OPML Importer file */
|
127 |
+
require_once ( WPRSS_INC . 'opml-importer.php' );
|
128 |
+
|
129 |
+
/* Load the system info file */
|
130 |
+
require_once ( WPRSS_INC . 'admin-debugging.php' );
|
131 |
+
|
132 |
+
/* Load the admin display-related functions */
|
133 |
+
require_once ( WPRSS_INC . 'admin-display.php' );
|
134 |
+
|
135 |
+
/* Load the admin metaboxes functions */
|
136 |
+
require_once ( WPRSS_INC . 'admin-metaboxes.php' );
|
137 |
+
|
138 |
+
/* Load the scripts loading functions file */
|
139 |
+
require_once ( WPRSS_INC . 'scripts.php' );
|
140 |
+
|
141 |
+
/* Load the Ajax notification file */
|
142 |
+
require_once ( WPRSS_INC . 'admin-ajax-notice.php' );
|
143 |
+
|
144 |
+
/* Load the dashboard welcome screen file */
|
145 |
+
require_once ( WPRSS_INC . 'admin-dashboard.php' );
|
146 |
+
|
147 |
+
/* Load the logging class */
|
148 |
+
require_once ( WPRSS_INC . 'roles-capabilities.php' );
|
149 |
+
|
150 |
+
/* Load the logging class */
|
151 |
+
require_once ( WPRSS_INC . 'libraries/WP_Logging.php' );
|
152 |
+
|
153 |
+
|
154 |
+
register_activation_hook( __FILE__ , 'wprss_activate' );
|
155 |
+
register_deactivation_hook( __FILE__ , 'wprss_deactivate' );
|
156 |
+
|
157 |
+
|
158 |
+
add_action( 'init', 'wprss_init' );
|
159 |
+
/**
|
160 |
+
* Initialise the plugin
|
161 |
+
*
|
162 |
+
* @since 1.0
|
163 |
+
* @return void
|
164 |
+
*/
|
165 |
+
function wprss_init() {
|
166 |
+
do_action( 'wprss_init' );
|
167 |
+
}
|
168 |
+
|
169 |
+
|
170 |
+
/**
|
171 |
+
* Plugin activation procedure
|
172 |
+
*
|
173 |
+
* @since 1.0
|
174 |
+
* @return void
|
175 |
+
*/
|
176 |
+
function wprss_activate() {
|
177 |
+
/* Prevents activation of plugin if compatible version of WordPress not found */
|
178 |
+
if ( version_compare( get_bloginfo( 'version' ), '3.3', '<' ) ) {
|
179 |
+
deactivate_plugins ( basename( __FILE__ )); // Deactivate plugin
|
180 |
+
wp_die( __( 'This plugin requires WordPress version 3.3 or higher.' ), 'WP RSS Aggregator', array( 'back_link' => true ) );
|
181 |
+
}
|
182 |
+
wprss_settings_initialize();
|
183 |
+
flush_rewrite_rules();
|
184 |
+
wprss_schedule_fetch_all_feeds_cron();
|
185 |
+
// Sets a transient to trigger a redirect upon completion of activation procedure
|
186 |
+
set_transient( '_wprss_activation_redirect', true, 30 );
|
187 |
+
}
|
188 |
+
|
189 |
+
|
190 |
+
/**
|
191 |
+
* Plugin deactivation procedure
|
192 |
+
*
|
193 |
+
* @since 1.0
|
194 |
+
*/
|
195 |
+
function wprss_deactivate() {
|
196 |
+
// on deactivation remove the cron job
|
197 |
+
if ( wp_next_scheduled( 'wprss_fetch_all_feeds_hook' ) ) {
|
198 |
+
wp_clear_scheduled_hook( 'wprss_fetch_all_feeds_hook' );
|
199 |
+
}
|
200 |
+
flush_rewrite_rules();
|
201 |
+
}
|
202 |
+
|
203 |
+
|
204 |
+
add_action( 'plugins_loaded', 'wprss_load_textdomain' );
|
205 |
+
/**
|
206 |
+
* Loads the plugin's translated strings.
|
207 |
+
*
|
208 |
+
* @since 2.1
|
209 |
+
* @return void
|
210 |
+
*/
|
211 |
+
function wprss_load_textdomain() {
|
212 |
+
load_plugin_textdomain( 'wprss', false, plugin_dir_path( __FILE__ ) . '/languages/' );
|
213 |
+
}
|