Version Description
Download this release
Release Info
Developer | feedsapi |
Plugin | RSS Post Importer |
Version | 2.4.0 |
Comparing to | |
See all releases |
Code changes from version 2.3.0 to 2.4.0
- app/assets/js/main.js +142 -68
- app/class-rss-post-importer.php +250 -249
- app/classes/admin/class-rss-pi-admin-processor.php +421 -400
- app/classes/admin/class-rss-pi-admin.php +56 -37
- app/classes/front/class-rss-pi-front.php +265 -259
- app/classes/import/class-rss-pi-engine.php +707 -741
- app/templates/feed-table-row.php +46 -21
- app/templates/feed-table.php +13 -7
- app/templates/settings-table.php +72 -44
- index.php +2 -2
- readme.txt +6 -3
app/assets/js/main.js
CHANGED
@@ -1,49 +1,119 @@
|
|
1 |
-
(function($){
|
2 |
|
3 |
$('document').ready(function(){
|
4 |
// Edit-buttons
|
5 |
$('body').on('click', 'a.toggle-edit', function () {
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
return false;
|
9 |
});
|
10 |
|
11 |
// Delete-buttons
|
12 |
$('body').on('click', 'a.delete-row', function () {
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
return false;
|
17 |
-
|
18 |
-
|
19 |
});
|
20 |
-
|
21 |
-
|
22 |
// status-buttons
|
23 |
$('body').on('click', 'a.status-row', function () {
|
24 |
var action = $(this).attr('data-action');
|
25 |
var target = $(this).attr('data-target');
|
26 |
-
|
27 |
-
{
|
28 |
-
$(this).attr('data-action','
|
29 |
-
$(this).html('Enable Feed');
|
30 |
-
}else
|
31 |
-
|
32 |
-
$(this).
|
33 |
-
$(this).html('Pause');
|
34 |
}
|
35 |
-
|
36 |
-
var
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
$(
|
45 |
-
|
46 |
-
|
47 |
return false;
|
48 |
});
|
49 |
|
@@ -80,29 +150,34 @@ $('document').ready(function(){
|
|
80 |
|
81 |
$('a.add-row').on('click', function (e) {
|
82 |
e.preventDefault();
|
83 |
-
var
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
$tr_edit.find("[name^=0-]").each(function(){
|
97 |
-
$(this).attr("name",$(this).attr("name").replace("0-",id+"-"));
|
98 |
});
|
99 |
-
|
100 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
});
|
102 |
|
103 |
$('#save_and_import').on('click', function () {
|
104 |
-
|
105 |
-
|
106 |
$('#save_to_db').val('true');
|
107 |
});
|
108 |
|
@@ -197,7 +272,7 @@ $('document').ready(function(){
|
|
197 |
|
198 |
if ( $("#rss_pi_progressbar").length && feeds !== undefined && feeds.count ) {
|
199 |
var import_feed = function(id) {
|
200 |
-
|
201 |
$.ajax({
|
202 |
type: 'POST',
|
203 |
url: rss_pi.ajaxurl,
|
@@ -228,28 +303,28 @@ $('document').ready(function(){
|
|
228 |
$("#rss_pi_progressbar_label").html("Import in progres. Processed feeds: <span class='processed'>0</span> of <span class='max'>"+feeds.total()+"</span>. Imported posts so far: <span class='count'>0</span>");
|
229 |
import_feed(feeds.get());
|
230 |
}
|
231 |
-
|
232 |
-
|
233 |
/*This is for custom frequency*/
|
234 |
$("#frequency").change(function(){
|
235 |
-
|
236 |
if($(this).val()=="custom_frequency")
|
237 |
{
|
238 |
$("#rss_custom_frequency").show();
|
239 |
$("#rss_custom_frequency").focus();
|
240 |
}else{
|
241 |
-
$("#rss_custom_frequency").val('');
|
242 |
-
$("#rss_custom_frequency").hide();
|
243 |
}
|
244 |
-
|
245 |
-
|
246 |
})
|
247 |
|
248 |
var url = location.href;
|
249 |
-
|
250 |
var myParam1 = location.search.split('version=')[1];
|
251 |
-
|
252 |
-
|
253 |
if (typeof(myParam1) == 'undefined')
|
254 |
{
|
255 |
if(new_js_url=='')
|
@@ -258,29 +333,28 @@ $('document').ready(function(){
|
|
258 |
}
|
259 |
else
|
260 |
{
|
261 |
-
var api_add = "premium";
|
262 |
}
|
263 |
window.location.assign(window.location.href+='&version='+new_js_version+'&type='+api_add);
|
264 |
}
|
265 |
-
|
266 |
else{}
|
267 |
-
|
268 |
//alert(myParam);
|
269 |
-
|
270 |
|
271 |
});
|
272 |
|
273 |
})(jQuery);
|
274 |
|
275 |
function update_ids() {
|
276 |
-
|
277 |
-
ids = jQuery("#rss_pi-feed-table > tbody input[name='id']").map(function () {
|
278 |
return jQuery(this).val();
|
279 |
}).get().join();
|
280 |
|
281 |
-
jQuery('#
|
282 |
-
|
283 |
}
|
|
|
284 |
var feeds = {
|
285 |
ids: feeds || [],
|
286 |
count: feeds && feeds.length ? feeds.length : 0,
|
1 |
+
(function($) {
|
2 |
|
3 |
$('document').ready(function(){
|
4 |
// Edit-buttons
|
5 |
$('body').on('click', 'a.toggle-edit', function () {
|
6 |
+
var target = $(this).attr('data-target');
|
7 |
+
|
8 |
+
var modified = $('#modified_feeds').val();
|
9 |
+
|
10 |
+
if (modified) {
|
11 |
+
modified = modified.split(',');
|
12 |
+
} else {
|
13 |
+
modified = [target];
|
14 |
+
}
|
15 |
+
|
16 |
+
var index = modified.indexOf(target);
|
17 |
+
if ($('#display_' + target).hasClass('show')) {
|
18 |
+
$('#edit_' + target).remove();
|
19 |
+
$('#display_' + target).toggleClass('show');
|
20 |
+
|
21 |
+
if (index > -1) {
|
22 |
+
modified.splice(index, 1);
|
23 |
+
}
|
24 |
+
|
25 |
+
return false;
|
26 |
+
} else {
|
27 |
+
if (index == -1) {
|
28 |
+
modified.push(target);
|
29 |
+
}
|
30 |
+
}
|
31 |
+
|
32 |
+
$('#modified_feeds').val(modified.join(','));
|
33 |
+
|
34 |
+
$.ajax({
|
35 |
+
type: 'POST',
|
36 |
+
url: rss_pi.ajaxurl,
|
37 |
+
data: ({
|
38 |
+
action: 'rss_pi_edit_row',
|
39 |
+
feed_id: $(this).attr('data-target')
|
40 |
+
}),
|
41 |
+
success: function (data) {
|
42 |
+
$(data).insertAfter($('#display_' + target));
|
43 |
+
$('#edit_' + target).toggleClass('show');
|
44 |
+
$('#display_' + target).toggleClass('show');
|
45 |
+
}
|
46 |
+
});
|
47 |
+
|
48 |
return false;
|
49 |
});
|
50 |
|
51 |
// Delete-buttons
|
52 |
$('body').on('click', 'a.delete-row', function () {
|
53 |
+
var target = $(this).attr('data-target');
|
54 |
+
|
55 |
+
var deleted = $('#deleted_feeds').val();
|
56 |
+
var modified = $('#modified_feeds').val();
|
57 |
+
var new_feeds = $('#new_feeds').val();
|
58 |
+
|
59 |
+
if (deleted) {
|
60 |
+
deleted = deleted.split(',');
|
61 |
+
deleted.push(target);
|
62 |
+
} else {
|
63 |
+
deleted = [target];
|
64 |
+
}
|
65 |
+
|
66 |
+
if (modified) {
|
67 |
+
modified = modified.split(',');
|
68 |
+
var index = modified.indexOf(target);
|
69 |
+
if (index > -1) {
|
70 |
+
modified.splice(index, 1);
|
71 |
+
}
|
72 |
+
$('#modified_feeds').val(modified.join(','));
|
73 |
+
}
|
74 |
+
|
75 |
+
if (new_feeds) {
|
76 |
+
new_feeds = new_feeds.split(',');
|
77 |
+
var index = new_feeds.indexOf(target);
|
78 |
+
if (index > -1) {
|
79 |
+
new_feeds.splice(index, 1);
|
80 |
+
}
|
81 |
+
$('#new_feeds').val(new_feeds.join(','));
|
82 |
+
}
|
83 |
+
|
84 |
+
|
85 |
+
$('#deleted_feeds').val(deleted.join(','));
|
86 |
+
|
87 |
+
$('#edit_' + target).remove();
|
88 |
+
$('#display_' + target).remove();
|
89 |
+
|
90 |
return false;
|
|
|
|
|
91 |
});
|
92 |
+
|
93 |
+
|
94 |
// status-buttons
|
95 |
$('body').on('click', 'a.status-row', function () {
|
96 |
var action = $(this).attr('data-action');
|
97 |
var target = $(this).attr('data-target');
|
98 |
+
|
99 |
+
if (action == 'pause') {
|
100 |
+
$(this).attr('data-action', 'enable');
|
101 |
+
$(this).html('Enable Feed');
|
102 |
+
} else {
|
103 |
+
$(this).attr('data-action', 'pause');
|
104 |
+
$(this).html('Pause');
|
|
|
105 |
}
|
106 |
+
|
107 |
+
var paused_feeds = $('#paused_feeds').val();
|
108 |
+
if (paused_feeds) {
|
109 |
+
paused_feeds = paused_feeds.split(',');
|
110 |
+
paused_feeds.push(target);
|
111 |
+
} else {
|
112 |
+
paused_feeds = [target];
|
113 |
+
}
|
114 |
+
|
115 |
+
$('#paused_feeds').val(paused_feeds.join(','));
|
116 |
+
|
|
|
117 |
return false;
|
118 |
});
|
119 |
|
150 |
|
151 |
$('a.add-row').on('click', function (e) {
|
152 |
e.preventDefault();
|
153 |
+
var target = uniqid();
|
154 |
+
|
155 |
+
$.ajax({
|
156 |
+
type: 'POST',
|
157 |
+
url: rss_pi.ajaxurl,
|
158 |
+
data: ({
|
159 |
+
action: 'rss_pi_add_row',
|
160 |
+
feed_id: target
|
161 |
+
}),
|
162 |
+
success: function (data) {
|
163 |
+
$('.rss-rows').append(data);
|
164 |
+
$("#" + target + "-name").focus().select();
|
165 |
+
}
|
|
|
|
|
166 |
});
|
167 |
+
|
168 |
+
var new_feeds = $('#new_feeds').val();
|
169 |
+
|
170 |
+
if (new_feeds) {
|
171 |
+
new_feeds = new_feeds.split(',');
|
172 |
+
new_feeds.push(target);
|
173 |
+
} else {
|
174 |
+
new_feeds = [target];
|
175 |
+
}
|
176 |
+
|
177 |
+
$('#new_feeds').val(new_feeds.join(','));
|
178 |
});
|
179 |
|
180 |
$('#save_and_import').on('click', function () {
|
|
|
|
|
181 |
$('#save_to_db').val('true');
|
182 |
});
|
183 |
|
272 |
|
273 |
if ( $("#rss_pi_progressbar").length && feeds !== undefined && feeds.count ) {
|
274 |
var import_feed = function(id) {
|
275 |
+
|
276 |
$.ajax({
|
277 |
type: 'POST',
|
278 |
url: rss_pi.ajaxurl,
|
303 |
$("#rss_pi_progressbar_label").html("Import in progres. Processed feeds: <span class='processed'>0</span> of <span class='max'>"+feeds.total()+"</span>. Imported posts so far: <span class='count'>0</span>");
|
304 |
import_feed(feeds.get());
|
305 |
}
|
306 |
+
|
307 |
+
|
308 |
/*This is for custom frequency*/
|
309 |
$("#frequency").change(function(){
|
310 |
+
|
311 |
if($(this).val()=="custom_frequency")
|
312 |
{
|
313 |
$("#rss_custom_frequency").show();
|
314 |
$("#rss_custom_frequency").focus();
|
315 |
}else{
|
316 |
+
$("#rss_custom_frequency").val('');
|
317 |
+
$("#rss_custom_frequency").hide();
|
318 |
}
|
319 |
+
|
320 |
+
|
321 |
})
|
322 |
|
323 |
var url = location.href;
|
324 |
+
|
325 |
var myParam1 = location.search.split('version=')[1];
|
326 |
+
|
327 |
+
|
328 |
if (typeof(myParam1) == 'undefined')
|
329 |
{
|
330 |
if(new_js_url=='')
|
333 |
}
|
334 |
else
|
335 |
{
|
336 |
+
var api_add = "premium";
|
337 |
}
|
338 |
window.location.assign(window.location.href+='&version='+new_js_version+'&type='+api_add);
|
339 |
}
|
340 |
+
|
341 |
else{}
|
342 |
+
|
343 |
//alert(myParam);
|
344 |
+
|
345 |
|
346 |
});
|
347 |
|
348 |
})(jQuery);
|
349 |
|
350 |
function update_ids() {
|
351 |
+
var feed_ids = jQuery("#rss_pi-feed-table > tbody input[name='id']").map(function () {
|
|
|
352 |
return jQuery(this).val();
|
353 |
}).get().join();
|
354 |
|
355 |
+
jQuery('#feed_ids').val(feed_ids);
|
|
|
356 |
}
|
357 |
+
|
358 |
var feeds = {
|
359 |
ids: feeds || [],
|
360 |
count: feeds && feeds.length ? feeds.length : 0,
|
app/class-rss-post-importer.php
CHANGED
@@ -2,258 +2,259 @@
|
|
2 |
|
3 |
/**
|
4 |
* One class to rule them all
|
5 |
-
*
|
6 |
* @author mobilova UG (haftungsbeschränkt) <rsspostimporter@feedsapi.com>
|
7 |
*/
|
8 |
-
|
9 |
class rssPostImporter {
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
|
|
258 |
|
259 |
}
|
2 |
|
3 |
/**
|
4 |
* One class to rule them all
|
5 |
+
*
|
6 |
* @author mobilova UG (haftungsbeschränkt) <rsspostimporter@feedsapi.com>
|
7 |
*/
|
8 |
+
|
9 |
class rssPostImporter {
|
10 |
|
11 |
+
/**
|
12 |
+
* A var to store the options in
|
13 |
+
* @var array
|
14 |
+
*/
|
15 |
+
public $options = array();
|
16 |
+
|
17 |
+
/**
|
18 |
+
* A var to store the link to the plugin page
|
19 |
+
* @var array
|
20 |
+
*/
|
21 |
+
public $page_link = '';
|
22 |
+
|
23 |
+
/**
|
24 |
+
* To initialise the admin and cron classes
|
25 |
+
*
|
26 |
+
* @var object
|
27 |
+
*/
|
28 |
+
private $admin, $cron;
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Start
|
32 |
+
*/
|
33 |
+
|
34 |
+
function __construct() {
|
35 |
+
// populate the options first
|
36 |
+
$this->load_options();
|
37 |
+
|
38 |
+
// do any upgrade if needed
|
39 |
+
$this->upgrade();
|
40 |
+
|
41 |
+
$settings = array();
|
42 |
+
$valid_api_key = '';
|
43 |
+
if (isset($_POST['feeds_api_key'])) {
|
44 |
+
$settings = array(
|
45 |
+
'feeds_api_key' => sanitize_key($_POST['feeds_api_key'])
|
46 |
+
);
|
47 |
+
|
48 |
+
// check if submitted api key is valid
|
49 |
+
$valid_api_key = $this->is_valid_key($settings['feeds_api_key']);
|
50 |
+
}
|
51 |
+
|
52 |
+
// determine the API type
|
53 |
+
$api_type = $valid_api_key == '' ? 'normal' : 'premium';
|
54 |
+
|
55 |
+
// setup this plugin options page link
|
56 |
+
$this->page_link = admin_url(
|
57 |
+
'options-general.php?page=rss_pi&version=' . RSS_PI_VERSION .
|
58 |
+
'&type=' . $api_type
|
59 |
+
);
|
60 |
+
|
61 |
+
// hook translations
|
62 |
+
add_action('plugins_loaded', array($this, 'localize'));
|
63 |
+
|
64 |
+
add_filter(
|
65 |
+
'plugin_action_links_' . RSS_PI_BASENAME,
|
66 |
+
array($this, 'settings_link')
|
67 |
+
);
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Load options from the db
|
72 |
+
*/
|
73 |
+
public function load_options() {
|
74 |
+
|
75 |
+
$default_settings = array(
|
76 |
+
'enable_logging' => false,
|
77 |
+
'feeds_api_key' => false,
|
78 |
+
'frequency' => 0,
|
79 |
+
'post_template' => "{\$content}\nSource: {\$feed_title}",
|
80 |
+
'post_status' => 'publish',
|
81 |
+
'author_id' => 1,
|
82 |
+
'allow_comments' => 'open',
|
83 |
+
'block_indexing' => false,
|
84 |
+
'nofollow_outbound' => true,
|
85 |
+
'keywords' => array(),
|
86 |
+
'import_images_locally' => false,
|
87 |
+
'disable_thumbnail' => false,
|
88 |
+
'cache_deleted' => true,
|
89 |
+
);
|
90 |
+
|
91 |
+
$options = get_option('rss_pi_feeds', array());
|
92 |
+
|
93 |
+
// prepare default options when there is no record in the database
|
94 |
+
if (!isset($options['feeds'])) {
|
95 |
+
$options['feeds'] = array();
|
96 |
+
}
|
97 |
+
if (!isset($options['settings'])) {
|
98 |
+
$options['settings'] = array();
|
99 |
+
}
|
100 |
+
if (!isset($options['latest_import'])) {
|
101 |
+
$options['latest_import'] = '';
|
102 |
+
}
|
103 |
+
if (!isset($options['imports'])) {
|
104 |
+
$options['imports'] = 0;
|
105 |
+
}
|
106 |
+
if (!isset($options['upgraded'])) {
|
107 |
+
$options['upgraded'] = array();
|
108 |
+
}
|
109 |
+
|
110 |
+
$options['settings'] = wp_parse_args($options['settings'], $default_settings);
|
111 |
+
|
112 |
+
if (!array_key_exists('imports', $options)) {
|
113 |
+
$options['imports'] = 0;
|
114 |
+
}
|
115 |
+
|
116 |
+
$this->options = $options;
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* Upgrade plugin settings
|
121 |
+
*/
|
122 |
+
public function upgrade() {
|
123 |
+
|
124 |
+
global $wpdb;
|
125 |
+
$upgraded = FALSE;
|
126 |
+
$bail = FALSE;
|
127 |
+
|
128 |
+
// migrate to rss_pi_deleted_posts only items from rss_pi_imported_posts that are actually deleted, discard the others
|
129 |
+
// do this in iterations so not to degrade the UX
|
130 |
+
if ( ! isset($this->options['upgraded']['deleted_posts']) ) {
|
131 |
+
// get meta data for "deleted" and "imported" posts
|
132 |
+
$rss_pi_deleted_posts = get_option( 'rss_pi_deleted_posts', array() );
|
133 |
+
$rss_pi_imported_posts = get_option( 'rss_pi_imported_posts', array() );
|
134 |
+
$rss_pi_imported_posts_migrated = get_option( 'rss_pi_imported_posts_migrated', array() );
|
135 |
+
// limit execution time (in seconds)
|
136 |
+
$_limit = ( ( defined('DOING_CRON') && DOING_CRON ) ? 20 : ( ( defined('DOING_AJAX') && DOING_AJAX ) ? 10 : 3 ) );
|
137 |
+
$_start = microtime(TRUE);
|
138 |
+
// iterate through all imported posts' source URLs
|
139 |
+
foreach ( $rss_pi_imported_posts as $k => $source_url ) {
|
140 |
+
// strip any params from the URL
|
141 |
+
//$_source_url = explode('?', $source_url);
|
142 |
+
//$_source_url = $_source_url[0];
|
143 |
+
// hash the URL for storage
|
144 |
+
$source_md5 = md5($source_url);
|
145 |
+
// properly format the URL for comparison
|
146 |
+
$source_url = esc_url($source_url);
|
147 |
+
// skip if we already have "migrated" this item
|
148 |
+
if ( in_array( $k, $rss_pi_imported_posts_migrated ) ) {
|
149 |
+
continue;
|
150 |
+
}
|
151 |
+
// skip if we already have "deleted" metadata for this item
|
152 |
+
if ( in_array( $source_md5, $rss_pi_deleted_posts ) ) {
|
153 |
+
continue;
|
154 |
+
}
|
155 |
+
$rss_pi_imported_posts_migrated[] = $k;
|
156 |
+
// check if there is a post with this source URL
|
157 |
+
$post_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = 'rss_pi_source_url' and meta_value = %s", $source_url ) );
|
158 |
+
// when there is no such post (it was deleted?)
|
159 |
+
if ( ! $post_id ) {
|
160 |
+
// add this source URL to "deleted" metadata
|
161 |
+
$rss_pi_deleted_posts[] = $source_md5;
|
162 |
+
} else {
|
163 |
+
// otherwise update the post metadata to include hashed URL
|
164 |
+
update_post_meta( $post_id, 'rss_pi_source_md5', $source_md5 );
|
165 |
+
}
|
166 |
+
// remove it from "imported" metadata
|
167 |
+
$_curr = microtime(TRUE);
|
168 |
+
if ( $_curr - $_start > $_limit ) {
|
169 |
+
// bail out when the "max execution time" limit is exhausted
|
170 |
+
$bail = TRUE;
|
171 |
+
break;
|
172 |
+
}
|
173 |
+
}
|
174 |
+
// shed any duplicates
|
175 |
+
$rss_pi_deleted_posts = array_unique($rss_pi_deleted_posts);
|
176 |
+
update_option('rss_pi_deleted_posts', $rss_pi_deleted_posts);
|
177 |
+
// keep record of migrated items
|
178 |
+
update_option('rss_pi_imported_posts_migrated', $rss_pi_imported_posts_migrated);
|
179 |
+
// are there still source URLs in the "imported" metadata?
|
180 |
+
if ( count($rss_pi_imported_posts_migrated) < count($rss_pi_imported_posts) ) {
|
181 |
+
} else {
|
182 |
+
// remove the "imported" metadata from database
|
183 |
+
delete_option('rss_pi_imported_posts_migrated');
|
184 |
+
delete_option('rss_pi_imported_posts');
|
185 |
+
// mark this upgrade as completed
|
186 |
+
$this->options['upgraded']['deleted_posts'] = TRUE;
|
187 |
+
$upgraded = TRUE;
|
188 |
+
}
|
189 |
+
}
|
190 |
+
// check after each upgrade routine
|
191 |
+
if ( $bail ) {
|
192 |
+
return;
|
193 |
+
}
|
194 |
+
|
195 |
+
// if there is something to record as an upgrade
|
196 |
+
if ( $upgraded ) {
|
197 |
+
update_option('rss_pi_feeds', $this->options);
|
198 |
+
}
|
199 |
+
}
|
200 |
+
|
201 |
+
/**
|
202 |
+
* Load translations
|
203 |
+
*/
|
204 |
+
public function localize() {
|
205 |
+
|
206 |
+
load_plugin_textdomain('rss-post-importer', false, RSS_PI_PATH . 'app/lang/');
|
207 |
+
}
|
208 |
+
|
209 |
+
/**
|
210 |
+
* Initialise
|
211 |
+
*/
|
212 |
+
public function init() {
|
213 |
+
|
214 |
+
// initialise admin and cron
|
215 |
+
$this->cron = new rssPICron();
|
216 |
+
$this->cron->init();
|
217 |
+
|
218 |
+
$this->admin = new rssPIAdmin();
|
219 |
+
$this->admin->init();
|
220 |
+
|
221 |
+
$this->front = new rssPIFront();
|
222 |
+
$this->front->init();
|
223 |
+
}
|
224 |
+
|
225 |
+
/**
|
226 |
+
* Check if a given API key is valid
|
227 |
+
*
|
228 |
+
* @param string $key
|
229 |
+
* @return boolean
|
230 |
+
*/
|
231 |
+
public function is_valid_key($key) {
|
232 |
+
|
233 |
+
if (empty($key)) {
|
234 |
+
return false;
|
235 |
+
}
|
236 |
+
|
237 |
+
$url = esc_url("http://www.rsspostimporter.com/fetch.php?key=$key&url=http://dummyurl.com");
|
238 |
+
$content = file_get_contents($url);
|
239 |
+
|
240 |
+
if (trim($content) == "A valid key must be supplied") {
|
241 |
+
return false;
|
242 |
+
}
|
243 |
+
|
244 |
+
return true;
|
245 |
+
}
|
246 |
+
|
247 |
+
/**
|
248 |
+
* Adds a settings link
|
249 |
+
*
|
250 |
+
* @param array $links EXisting links
|
251 |
+
* @return type
|
252 |
+
*/
|
253 |
+
public function settings_link($links) {
|
254 |
+
$settings_link = array(
|
255 |
+
'<a href="' . $this->page_link . '">Settings</a>',
|
256 |
+
);
|
257 |
+
return array_merge($settings_link, $links);
|
258 |
+
}
|
259 |
|
260 |
}
|
app/classes/admin/class-rss-pi-admin-processor.php
CHANGED
@@ -7,405 +7,426 @@
|
|
7 |
*/
|
8 |
class rssPIAdminProcessor {
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
410 |
|
411 |
}
|
7 |
*/
|
8 |
class rssPIAdminProcessor {
|
9 |
|
10 |
+
/**
|
11 |
+
* If we have a valid api key
|
12 |
+
*
|
13 |
+
* @var boolean
|
14 |
+
*/
|
15 |
+
var $is_key_valid;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Process the form result
|
19 |
+
*
|
20 |
+
* @global object $rss_post_importer
|
21 |
+
* @return null
|
22 |
+
*/
|
23 |
+
function process() {
|
24 |
+
global $rss_post_importer;
|
25 |
+
|
26 |
+
// bail if there's nothing to process or the data is invalid
|
27 |
+
if (! isset($_POST['info_update']) ||
|
28 |
+
! wp_verify_nonce($_POST['rss_pi_nonce'], 'settings_page')) {
|
29 |
+
return;
|
30 |
+
}
|
31 |
+
|
32 |
+
// formulate the settings array
|
33 |
+
$settings = $this->process_settings();
|
34 |
+
|
35 |
+
// check result for "invalid_key" flag
|
36 |
+
$invalid_api_key = isset($settings['invalid_api_key']);
|
37 |
+
unset($settings['invalid_api_key']);
|
38 |
+
|
39 |
+
// update cron settings
|
40 |
+
$this->update_cron($settings['frequency']);
|
41 |
+
|
42 |
+
$feeds = $this->process_feeds($rss_post_importer->options['feeds']);
|
43 |
+
|
44 |
+
// import CSV file
|
45 |
+
if (isset($_FILES['import_csv']) && $settings['is_key_valid']) {
|
46 |
+
$feeds = $this->import_csv($feeds);
|
47 |
+
}
|
48 |
+
|
49 |
+
// import OPML file
|
50 |
+
// @since v2.1.3
|
51 |
+
if (isset($_FILES['import_opml']) && is_uploaded_file($_FILES['import_opml']['tmp_name'])) {
|
52 |
+
$opml = new Rss_pi_opml();
|
53 |
+
$feeds = $opml->import($feeds);
|
54 |
+
$opml_errors = $opml->errors;
|
55 |
+
} else {
|
56 |
+
$opml_errors = array();
|
57 |
+
}
|
58 |
+
|
59 |
+
// save and reload the options
|
60 |
+
$this->save_reload_options($settings, $feeds);
|
61 |
+
|
62 |
+
wp_redirect(add_query_arg(
|
63 |
+
array(
|
64 |
+
'settings-updated' => 'true',
|
65 |
+
// yield the routine for import feeds via AJAX when needed
|
66 |
+
'import' => ( $_POST['save_to_db'] == 'true' ),
|
67 |
+
'message' => $invalid_api_key ? 2 : 1,
|
68 |
+
//'opml_errors' => $opml_errors ? urlencode(implode('<br/>', $opml_errors)) : '',
|
69 |
+
),
|
70 |
+
$rss_post_importer->page_link
|
71 |
+
));
|
72 |
+
|
73 |
+
exit;
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Purge "deleted_posts" cache from wp_options
|
78 |
+
* @return void
|
79 |
+
*/
|
80 |
+
function purge_deleted_posts_cache() {
|
81 |
+
if (! isset($_POST['purge_deleted_cache'])) return;
|
82 |
+
|
83 |
+
delete_option('rss_pi_deleted_posts');
|
84 |
+
delete_option('rss_pi_imported_posts');
|
85 |
+
|
86 |
+
global $rss_post_importer;
|
87 |
+
|
88 |
+
wp_redirect(add_query_arg(
|
89 |
+
array(
|
90 |
+
'deleted_cache_purged' => 'true',
|
91 |
+
),
|
92 |
+
$rss_post_importer->page_link
|
93 |
+
));
|
94 |
+
|
95 |
+
exit;
|
96 |
+
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* Import CSV function to import CSV file data into database
|
101 |
+
|
102 |
+
* @return array
|
103 |
+
*/
|
104 |
+
private function import_csv($feeds) {
|
105 |
+
|
106 |
+
if (is_uploaded_file($_FILES['import_csv']['tmp_name'])) {
|
107 |
+
$file = $_FILES['import_csv']['tmp_name'];
|
108 |
+
$fcount = file($file);
|
109 |
+
$linescount = count($fcount) - 1;
|
110 |
+
$file_handle = fopen($file, "r");
|
111 |
+
$t = 0;
|
112 |
+
$titlearray = array();
|
113 |
+
while ($csv_line = fgetcsv($file_handle, 1024)) {
|
114 |
+
|
115 |
+
if ($t <> 0) {
|
116 |
+
|
117 |
+
for ($i = 0, $j = count($csv_line); $i < $j; $i++) {
|
118 |
+
if ($i == 0)
|
119 |
+
$importdata['feeds'][$t - 1]['id'] = uniqid("54d4c" . $t);
|
120 |
+
|
121 |
+
$importdata['feeds'][$t - 1][$titlearray[$i]] = $csv_line[$i];
|
122 |
+
}
|
123 |
+
}
|
124 |
+
else {
|
125 |
+
for ($i = 0, $j = count($csv_line); $i < $j; $i++) {
|
126 |
+
$titlearray[] = $csv_line[$i];
|
127 |
+
}
|
128 |
+
}
|
129 |
+
$t++;
|
130 |
+
}
|
131 |
+
fclose($file_handle) or die("can't close file");
|
132 |
+
|
133 |
+
if (!empty($importdata['feeds'])) {
|
134 |
+
for ($r = 0; $r < count($importdata['feeds']); $r++) {
|
135 |
+
if ( isset($importdata['feeds'][$r]['category_id']) ) {
|
136 |
+
$importdata['feeds'][$r]['category_id'] = explode(',',$importdata['feeds'][$r]['category_id']);
|
137 |
+
$importdata['feeds'][$r]['tags_id'] = explode(',',$importdata['feeds'][$r]['tags_id']);
|
138 |
+
$importdata['feeds'][$r]['keywords'] = explode(',',$importdata['feeds'][$r]['keywords']);
|
139 |
+
$importdata['feeds'][$r]['strip_html'] = $importdata['feeds'][$r]['strip_html']; // this is a STRING, not a BOOLEAN
|
140 |
+
} else {
|
141 |
+
$importdata['feeds'][$r]['category_id'] = array(1);
|
142 |
+
$importdata['feeds'][$r]['tags_id'] = "";
|
143 |
+
$importdata['feeds'][$r]['keywords'] = "";
|
144 |
+
$importdata['feeds'][$r]['strip_html'] = "false";
|
145 |
+
}
|
146 |
+
|
147 |
+
$check_result = $this->check_feed_exist($feeds, $importdata['feeds'][$r]);
|
148 |
+
|
149 |
+
if ($check_result) {
|
150 |
+
unset($importdata['feeds'][$r]);
|
151 |
+
} else {
|
152 |
+
array_push($feeds, $importdata['feeds'][$r]);
|
153 |
+
}
|
154 |
+
}
|
155 |
+
}
|
156 |
+
}
|
157 |
+
|
158 |
+
return $feeds;
|
159 |
+
}
|
160 |
+
|
161 |
+
function check_feed_exist($feeds, $csvlink) {
|
162 |
+
if (!empty($feeds) && !empty($csvlink)) {
|
163 |
+
|
164 |
+
for ($i = 0; $i < count($feeds); $i++) {
|
165 |
+
if ($feeds[$i]['url'] == $csvlink['url']) {
|
166 |
+
return true;
|
167 |
+
}
|
168 |
+
}
|
169 |
+
|
170 |
+
return false;
|
171 |
+
}
|
172 |
+
}
|
173 |
+
|
174 |
+
/**
|
175 |
+
* Process submitted data to formulate settings array
|
176 |
+
*
|
177 |
+
* @global object $rss_post_importer
|
178 |
+
* @return array
|
179 |
+
*/
|
180 |
+
private function process_settings() {
|
181 |
+
|
182 |
+
// Get selected settings for all imported posts
|
183 |
+
|
184 |
+
// Code added for custom frequency
|
185 |
+
$frequency_check = isset($_POST['frequency']) ? sanitize_text_field($_POST['frequency']) : '';
|
186 |
+
|
187 |
+
if ($frequency_check == "custom_frequency") {
|
188 |
+
$rss_custom_frequency = intval($_POST['rss_custom_frequency']);
|
189 |
+
$frequency = "minutes_" . $rss_custom_frequency;
|
190 |
+
$custom_frequency = 'true';
|
191 |
+
// Adding option for custom cron
|
192 |
+
$rss_custom_cron_frequency = serialize(
|
193 |
+
array(
|
194 |
+
'time' => $rss_custom_frequency,
|
195 |
+
'frequency' => $frequency
|
196 |
+
)
|
197 |
+
);
|
198 |
+
|
199 |
+
delete_option( 'rss_custom_cron_frequency' );
|
200 |
+
add_option( 'rss_custom_cron_frequency',$rss_custom_cron_frequency);
|
201 |
+
} else {
|
202 |
+
$frequency = isset($_POST['frequency']) ? sanitize_text_field($_POST['frequency']) : '';
|
203 |
+
$custom_frequency = 'false';
|
204 |
+
|
205 |
+
// Delete custom cron if not exixts
|
206 |
+
delete_option( 'rss_custom_cron_frequency' );
|
207 |
+
}
|
208 |
+
|
209 |
+
|
210 |
+
$settings = array(
|
211 |
+
'frequency' => $frequency,
|
212 |
+
'feeds_api_key' => htmlentities($_POST['feeds_api_key']),
|
213 |
+
'post_template' => stripslashes_deep($_POST['post_template']),
|
214 |
+
'post_status' => sanitize_text_field($_POST['post_status']),
|
215 |
+
'author_id' => intval($_POST['author_id']),
|
216 |
+
'allow_comments' => isset($_POST['allow_comments']) ? sanitize_text_field($_POST['allow_comments']) : '',
|
217 |
+
'block_indexing' => sanitize_text_field($_POST['block_indexing']),
|
218 |
+
'nofollow_outbound' =>sanitize_text_field($_POST['nofollow_outbound']),
|
219 |
+
'enable_logging' => sanitize_text_field($_POST['enable_logging']),
|
220 |
+
'tw_show' => isset($_POST['tw_show']) ? sanitize_text_field($_POST['tw_show']) : '',
|
221 |
+
'gg_show' => isset($_POST['gg_show']) ? sanitize_text_field($_POST['gg_show']) : '',
|
222 |
+
'og_show' => isset($_POST['og_show']) ? sanitize_text_field($_POST['og_show']) : '',
|
223 |
+
'import_images_locally' => sanitize_text_field($_POST['import_images_locally']),
|
224 |
+
'disable_thumbnail' => sanitize_text_field($_POST['disable_thumbnail']),
|
225 |
+
// these values are setup after key_validity check via filter()
|
226 |
+
'keywords' => array(),
|
227 |
+
'cache_deleted' => 'true',
|
228 |
+
'custom_frequency' => $custom_frequency
|
229 |
+
);
|
230 |
+
|
231 |
+
global $rss_post_importer;
|
232 |
+
|
233 |
+
// check if submitted api key is valid
|
234 |
+
$this->is_key_valid = $rss_post_importer->is_valid_key($settings['feeds_api_key']);
|
235 |
+
// save key validity state
|
236 |
+
$settings['is_key_valid'] = $this->is_key_valid;
|
237 |
+
|
238 |
+
// filter the settings and then send them back for saving
|
239 |
+
return $this->filter($settings);
|
240 |
+
}
|
241 |
+
|
242 |
+
/**
|
243 |
+
* Update the frequency of the import cron job
|
244 |
+
*
|
245 |
+
* @param string $frequency
|
246 |
+
*/
|
247 |
+
private function update_cron($frequency) {
|
248 |
+
|
249 |
+
// If cron settings have changed
|
250 |
+
if (wp_get_schedule('rss_pi_cron') != $frequency) {
|
251 |
+
|
252 |
+
// Reset cron
|
253 |
+
wp_clear_scheduled_hook('rss_pi_cron');
|
254 |
+
wp_schedule_event(time(), $frequency, 'rss_pi_cron');
|
255 |
+
}
|
256 |
+
}
|
257 |
+
|
258 |
+
/**
|
259 |
+
* Creates the feeds array from the submitted data
|
260 |
+
*
|
261 |
+
* @return array
|
262 |
+
*/
|
263 |
+
private function process_feeds($feeds) {
|
264 |
+
$paused_feeds = array();
|
265 |
+
if (isset($_POST['paused_feeds'])) {
|
266 |
+
$paused_feeds = explode(',', $_POST['paused_feeds']);
|
267 |
+
}
|
268 |
+
|
269 |
+
$deleted_feeds = array();
|
270 |
+
if (isset($_POST['deleted_feeds'])) {
|
271 |
+
$deleted_feeds = explode(',', $_POST['deleted_feeds']);
|
272 |
+
}
|
273 |
+
|
274 |
+
$modified_feeds = array();
|
275 |
+
if (isset($_POST['modified_feeds'])) {
|
276 |
+
$modified_feeds = explode(',', $_POST['modified_feeds']);
|
277 |
+
}
|
278 |
+
|
279 |
+
$new_feeds = array();
|
280 |
+
if (isset($_POST['new_feeds'])) {
|
281 |
+
$new_feeds = explode(',', $_POST['new_feeds']);
|
282 |
+
}
|
283 |
+
|
284 |
+
foreach ($feeds as $key => $feed) {
|
285 |
+
if (in_array($feed['id'], $paused_feeds)) {
|
286 |
+
$feeds[$key]['feed_status'] = 'pause';
|
287 |
+
} else {
|
288 |
+
$feeds[$key]['feed_status'] = 'active';
|
289 |
+
}
|
290 |
+
|
291 |
+
if (in_array($feed['id'], $deleted_feeds)) {
|
292 |
+
unset($feeds[$key]);
|
293 |
+
}
|
294 |
+
|
295 |
+
if (in_array($feed['id'], $modified_feeds)) {
|
296 |
+
$keywords = array();
|
297 |
+
if ($this->is_key_valid) {
|
298 |
+
// if the key is valid set up keywords (otherwise don't)
|
299 |
+
if (isset($_POST[$feed['id'] . '-keywords'])) {
|
300 |
+
$keyword_str = $_POST[$feed['id'] . '-keywords'];
|
301 |
+
}
|
302 |
+
if (! empty($keyword_str)) {
|
303 |
+
$keywords = explode(',', $keyword_str);
|
304 |
+
}
|
305 |
+
}
|
306 |
+
|
307 |
+
$feed['url'] = $_POST[$feed['id'] . '-url'];
|
308 |
+
$feed['name'] = $_POST[$feed['id'] . '-name'];
|
309 |
+
$feed['max_posts'] = intval($_POST[$feed['id'] . '-max_posts']);
|
310 |
+
$feed['author_id'] = ($this->is_key_valid && isset($_POST[$feed['id'] . '-author_id'])) ? intval($_POST[$feed['id'] . '-author_id']) : intval($_POST['author_id']);
|
311 |
+
$feed['category_id'] = (isset($_POST[$feed['id'] . '-category_id'])) ? $_POST[$feed['id'] . '-category_id'] : '';
|
312 |
+
$feed['tags_id'] = (isset($_POST[$feed['id'] . '-tags_id'])) ? $_POST[$feed['id'] . '-tags_id'] : '';
|
313 |
+
$feed['keywords'] = array_map('trim', $keywords);
|
314 |
+
$feed['strip_html'] = (isset($_POST[$feed['id'] . '-strip_html'])) ? $_POST[$feed['id'] . '-strip_html'] : '';
|
315 |
+
$feed['nofollow_outbound'] = (isset($_POST[$feed['id'] . '-nofollow_outbound'])) ? $_POST[$feed['id'] . '-nofollow_outbound'] : '';
|
316 |
+
$feed['automatic_import_categories'] = (isset($_POST[$feed['id'] . '-automatic_import_categories'])) ? $_POST[$feed['id'] . '-automatic_import_categories'] : '';
|
317 |
+
$feed['automatic_import_author'] = (isset($_POST[$feed['id'] . '-automatic_import_author'])) ? $_POST[$feed['id'] . '-automatic_import_author'] : '';
|
318 |
+
$feed['canonical_urls'] = (isset($_POST[$feed['id'] . '-canonical_urls'])) ? $_POST[$feed['id'] . '-canonical_urls'] : '';
|
319 |
+
|
320 |
+
$feeds[$key] = $feed;
|
321 |
+
}
|
322 |
+
}
|
323 |
+
|
324 |
+
foreach ($new_feeds as $id) {
|
325 |
+
if (! $id) continue;
|
326 |
+
|
327 |
+
$keywords = array();
|
328 |
+
if ($this->is_key_valid) {
|
329 |
+
// if the key is valid set up keywords (otherwise don't)
|
330 |
+
if (isset($_POST[$id . '-keywords'])) {
|
331 |
+
$keyword_str = $_POST[$id . '-keywords'];
|
332 |
+
}
|
333 |
+
if (! empty($keyword_str)) {
|
334 |
+
$keywords = explode(',', $keyword_str);
|
335 |
+
}
|
336 |
+
}
|
337 |
+
|
338 |
+
$feed_status = in_array($id, $paused_feeds) ? 'pause' : 'active';
|
339 |
+
|
340 |
+
array_push($feeds, array(
|
341 |
+
'id' => $id,
|
342 |
+
'url' => $_POST[$id . '-url'],
|
343 |
+
'name' => $_POST[$id . '-name'],
|
344 |
+
'max_posts' => intval($_POST[$id . '-max_posts']),
|
345 |
+
// different author ids depending on valid API keys
|
346 |
+
'author_id' => ($this->is_key_valid && isset($_POST[$id . '-author_id'])) ? intval($_POST[$id . '-author_id']) : intval($_POST['author_id']),
|
347 |
+
'category_id' => (isset($_POST[$id . '-category_id'])) ? $_POST[$id . '-category_id'] : '',
|
348 |
+
'tags_id' => (isset($_POST[$id . '-tags_id'])) ? $_POST[$id . '-tags_id'] : '',
|
349 |
+
'keywords' => array_map('trim',$keywords),
|
350 |
+
'strip_html' => (isset($_POST[$id . '-strip_html'])) ? $_POST[$id . '-strip_html'] : '',
|
351 |
+
'nofollow_outbound' => (isset($_POST[$id . '-nofollow_outbound'])) ? $_POST[$id . '-nofollow_outbound'] : '',
|
352 |
+
'automatic_import_categories' => (isset($_POST[$id . '-automatic_import_categories'])) ? $_POST[$id . '-automatic_import_categories'] : '',
|
353 |
+
'automatic_import_author' => (isset($_POST[$id . '-automatic_import_author'])) ? $_POST[$id . '-automatic_import_author'] : '',
|
354 |
+
'canonical_urls' => (isset($_POST[$id . '-canonical_urls'])) ? $_POST[$id . '-canonical_urls'] : '',
|
355 |
+
'feed_status' => $feed_status
|
356 |
+
));
|
357 |
+
}
|
358 |
+
|
359 |
+
return $feeds;
|
360 |
+
}
|
361 |
+
|
362 |
+
/**
|
363 |
+
* Update options and reload global options
|
364 |
+
*
|
365 |
+
* @global type $rss_post_importer
|
366 |
+
* @param array $settings
|
367 |
+
* @param array $feeds
|
368 |
+
*/
|
369 |
+
private function save_reload_options($settings, $feeds) {
|
370 |
+
global $rss_post_importer;
|
371 |
+
|
372 |
+
// existing options
|
373 |
+
$options = $rss_post_importer->options;
|
374 |
+
|
375 |
+
// new data
|
376 |
+
$new_options = array(
|
377 |
+
'feeds' => $feeds,
|
378 |
+
'settings' => $settings,
|
379 |
+
'latest_import' => $options['latest_import'],
|
380 |
+
'imports' => $options['imports'],
|
381 |
+
'upgraded' => $options['upgraded']
|
382 |
+
);
|
383 |
+
|
384 |
+
// update in db
|
385 |
+
update_option('rss_pi_feeds', $new_options);
|
386 |
+
|
387 |
+
// reload so that the new options are used henceforth
|
388 |
+
$rss_post_importer->load_options();
|
389 |
+
}
|
390 |
+
|
391 |
+
/**
|
392 |
+
* Filter settings for API key vs non-API key installs
|
393 |
+
*
|
394 |
+
* @param array $settings
|
395 |
+
* @return array
|
396 |
+
*/
|
397 |
+
private function filter($settings) {
|
398 |
+
|
399 |
+
// if the key is not fine
|
400 |
+
if (!empty($settings['feeds_api_key']) && !$this->is_key_valid) {
|
401 |
+
|
402 |
+
// unset from settings
|
403 |
+
unset($settings['feeds_api_key']);
|
404 |
+
$settings['invalid_api_key'] = true;
|
405 |
+
}
|
406 |
+
|
407 |
+
// if the key is valid
|
408 |
+
if ($this->is_key_valid) {
|
409 |
+
|
410 |
+
// set up keywords (otherwise don't)
|
411 |
+
if (isset($_POST['keyword_filter']))
|
412 |
+
|
413 |
+
// Strip Slases for RegEx
|
414 |
+
$keyword_str = stripslashes($_POST['keyword_filter']);
|
415 |
+
|
416 |
+
$keywords = array();
|
417 |
+
|
418 |
+
if (!empty($keyword_str)) {
|
419 |
+
$keywords = explode(',', $keyword_str);
|
420 |
+
}
|
421 |
+
|
422 |
+
$settings['keywords'] = array_map('trim',$keywords);
|
423 |
+
|
424 |
+
// set up "import deleted posts" (otherwise don't)
|
425 |
+
$settings['cache_deleted'] = isset($_POST['cache_deleted']) ? $_POST['cache_deleted'] : 'true';
|
426 |
+
|
427 |
+
}
|
428 |
+
|
429 |
+
return $settings;
|
430 |
+
}
|
431 |
|
432 |
}
|
app/classes/admin/class-rss-pi-admin.php
CHANGED
@@ -9,15 +9,15 @@ class rssPIAdmin {
|
|
9 |
|
10 |
/**
|
11 |
* Whether the API key is valid
|
12 |
-
*
|
13 |
* @var boolean
|
14 |
*/
|
15 |
var $is_key_valid;
|
16 |
|
17 |
/**
|
18 |
* The options
|
19 |
-
*
|
20 |
-
* @var array
|
21 |
*/
|
22 |
var $options;
|
23 |
|
@@ -29,7 +29,7 @@ class rssPIAdmin {
|
|
29 |
|
30 |
/**
|
31 |
* Start
|
32 |
-
*
|
33 |
* @global object $rss_post_importer
|
34 |
*/
|
35 |
public function __construct() {
|
@@ -101,6 +101,9 @@ class rssPIAdmin {
|
|
101 |
// the ajax for adding new feeds (table rows)
|
102 |
add_action('wp_ajax_rss_pi_add_row', array($this, 'add_row'));
|
103 |
|
|
|
|
|
|
|
104 |
// the ajax for stats chart
|
105 |
add_action('wp_ajax_rss_pi_stats', array($this, 'ajax_stats'));
|
106 |
|
@@ -112,7 +115,7 @@ class rssPIAdmin {
|
|
112 |
|
113 |
// Add 10 minutes in frequency.
|
114 |
add_filter('cron_schedules', array($this, 'rss_pi_cron_add'));
|
115 |
-
|
116 |
add_filter('cron_schedules', array($this, 'rss_pi_cron_add_custom'));
|
117 |
|
118 |
// trigger on Export
|
@@ -127,16 +130,12 @@ class rssPIAdmin {
|
|
127 |
* Add to admin menu
|
128 |
*/
|
129 |
function admin_menu() {
|
130 |
-
|
131 |
-
|
132 |
-
add_options_page('Rss Post Importer', 'Rss Post Importer', 'manage_options','rss_pi', array($this, 'screen'));
|
133 |
-
|
134 |
-
|
135 |
-
}
|
136 |
|
137 |
/**
|
138 |
* Enqueue our admin css and js
|
139 |
-
*
|
140 |
* @param string $hook The current screens hook
|
141 |
* @return null
|
142 |
*/
|
@@ -159,7 +158,7 @@ class rssPIAdmin {
|
|
159 |
wp_enqueue_script('modernizr', RSS_PI_URL . 'app/assets/js/modernizr.custom.32882.js', array(), RSS_PI_VERSION, true);
|
160 |
wp_enqueue_script('phpjs-uniqid', RSS_PI_URL . 'app/assets/js/uniqid.js', array(), RSS_PI_VERSION, true);
|
161 |
wp_enqueue_script('rss-pi', RSS_PI_URL . 'app/assets/js/main.js', array('jquery'), RSS_PI_VERSION, true);
|
162 |
-
|
163 |
|
164 |
// localise ajaxuel for use
|
165 |
$localise_args = array(
|
@@ -200,13 +199,13 @@ class rssPIAdmin {
|
|
200 |
'interval' => 600,
|
201 |
'display' => '10 minutes'
|
202 |
);
|
203 |
-
|
204 |
return $schedules;
|
205 |
}
|
206 |
-
|
207 |
// this will fetch custom frequency
|
208 |
function rss_pi_cron_add_custom($schedules) {
|
209 |
-
|
210 |
// min in sec
|
211 |
$rss_min = 60;
|
212 |
$custom_cron_options = get_option( 'rss_custom_cron_frequency',array());
|
@@ -214,13 +213,13 @@ class rssPIAdmin {
|
|
214 |
$rss_custom_cron = unserialize($custom_cron_options);
|
215 |
$rss_frequency_cron = $rss_custom_cron['frequency'];
|
216 |
$rss_frequency_time = $rss_custom_cron['time'];
|
217 |
-
// Adding custom cron
|
218 |
$schedules[$rss_frequency_cron] = array(
|
219 |
'interval' => $rss_min*$rss_frequency_time,
|
220 |
'display' => $rss_frequency_time.' minutes'
|
221 |
);
|
222 |
}
|
223 |
-
return $schedules;
|
224 |
}
|
225 |
|
226 |
/**
|
@@ -241,7 +240,7 @@ class rssPIAdmin {
|
|
241 |
* Display the screen/ui
|
242 |
*/
|
243 |
function screen() {
|
244 |
-
|
245 |
// it'll process any submitted form data
|
246 |
// reload the options just in case
|
247 |
$this->load_options();
|
@@ -275,20 +274,22 @@ class rssPIAdmin {
|
|
275 |
if( isset($_GET['import']) && isset($_GET['settings-updated']) && $_GET['settings-updated'] ) {
|
276 |
?>
|
277 |
<script type="text/javascript">
|
|
|
278 |
<?php
|
279 |
-
|
280 |
-
$
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
endif;
|
286 |
?>
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
|
|
|
|
292 |
</script>
|
293 |
<?php
|
294 |
}
|
@@ -321,7 +322,7 @@ if ( feeds !== undefined ) {
|
|
321 |
|
322 |
/**
|
323 |
* Display errors
|
324 |
-
*
|
325 |
* @param string $error The error message
|
326 |
* @param boolean $inline Whether the error is inline or shown like regular wp errors
|
327 |
*/
|
@@ -336,16 +337,34 @@ if ( feeds !== undefined ) {
|
|
336 |
* Add a new row for a new feed
|
337 |
*/
|
338 |
function add_row() {
|
|
|
|
|
|
|
339 |
|
|
|
|
|
340 |
include( RSS_PI_PATH . 'app/templates/feed-table-row.php');
|
341 |
die();
|
342 |
}
|
343 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
344 |
/**
|
345 |
* Generate stats data and return
|
346 |
*/
|
347 |
function ajax_stats() {
|
348 |
-
|
349 |
include( RSS_PI_PATH . 'app/templates/stats.php');
|
350 |
die();
|
351 |
}
|
@@ -444,7 +463,7 @@ if ( feeds !== undefined ) {
|
|
444 |
|
445 |
/**
|
446 |
* Disable the user dropdwon for each feed
|
447 |
-
*
|
448 |
* @param string $output The html of the select dropdown
|
449 |
* @return string
|
450 |
*/
|
@@ -469,9 +488,9 @@ if ( feeds !== undefined ) {
|
|
469 |
|
470 |
/**
|
471 |
* Walker class function for category multiple checkbox
|
472 |
-
*
|
473 |
-
*
|
474 |
-
*
|
475 |
*/
|
476 |
function wp_category_checklist_rss_pi($post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $walker = null, $checked_ontop = true) {
|
477 |
|
9 |
|
10 |
/**
|
11 |
* Whether the API key is valid
|
12 |
+
*
|
13 |
* @var boolean
|
14 |
*/
|
15 |
var $is_key_valid;
|
16 |
|
17 |
/**
|
18 |
* The options
|
19 |
+
*
|
20 |
+
* @var array
|
21 |
*/
|
22 |
var $options;
|
23 |
|
29 |
|
30 |
/**
|
31 |
* Start
|
32 |
+
*
|
33 |
* @global object $rss_post_importer
|
34 |
*/
|
35 |
public function __construct() {
|
101 |
// the ajax for adding new feeds (table rows)
|
102 |
add_action('wp_ajax_rss_pi_add_row', array($this, 'add_row'));
|
103 |
|
104 |
+
// the ajax for editing a feed row
|
105 |
+
add_action('wp_ajax_rss_pi_edit_row', array($this, 'edit_row'));
|
106 |
+
|
107 |
// the ajax for stats chart
|
108 |
add_action('wp_ajax_rss_pi_stats', array($this, 'ajax_stats'));
|
109 |
|
115 |
|
116 |
// Add 10 minutes in frequency.
|
117 |
add_filter('cron_schedules', array($this, 'rss_pi_cron_add'));
|
118 |
+
|
119 |
add_filter('cron_schedules', array($this, 'rss_pi_cron_add_custom'));
|
120 |
|
121 |
// trigger on Export
|
130 |
* Add to admin menu
|
131 |
*/
|
132 |
function admin_menu() {
|
133 |
+
add_options_page('Rss Post Importer', 'Rss Post Importer', 'manage_options','rss_pi', array($this, 'screen'));
|
134 |
+
}
|
|
|
|
|
|
|
|
|
135 |
|
136 |
/**
|
137 |
* Enqueue our admin css and js
|
138 |
+
*
|
139 |
* @param string $hook The current screens hook
|
140 |
* @return null
|
141 |
*/
|
158 |
wp_enqueue_script('modernizr', RSS_PI_URL . 'app/assets/js/modernizr.custom.32882.js', array(), RSS_PI_VERSION, true);
|
159 |
wp_enqueue_script('phpjs-uniqid', RSS_PI_URL . 'app/assets/js/uniqid.js', array(), RSS_PI_VERSION, true);
|
160 |
wp_enqueue_script('rss-pi', RSS_PI_URL . 'app/assets/js/main.js', array('jquery'), RSS_PI_VERSION, true);
|
161 |
+
|
162 |
|
163 |
// localise ajaxuel for use
|
164 |
$localise_args = array(
|
199 |
'interval' => 600,
|
200 |
'display' => '10 minutes'
|
201 |
);
|
202 |
+
|
203 |
return $schedules;
|
204 |
}
|
205 |
+
|
206 |
// this will fetch custom frequency
|
207 |
function rss_pi_cron_add_custom($schedules) {
|
208 |
+
|
209 |
// min in sec
|
210 |
$rss_min = 60;
|
211 |
$custom_cron_options = get_option( 'rss_custom_cron_frequency',array());
|
213 |
$rss_custom_cron = unserialize($custom_cron_options);
|
214 |
$rss_frequency_cron = $rss_custom_cron['frequency'];
|
215 |
$rss_frequency_time = $rss_custom_cron['time'];
|
216 |
+
// Adding custom cron
|
217 |
$schedules[$rss_frequency_cron] = array(
|
218 |
'interval' => $rss_min*$rss_frequency_time,
|
219 |
'display' => $rss_frequency_time.' minutes'
|
220 |
);
|
221 |
}
|
222 |
+
return $schedules;
|
223 |
}
|
224 |
|
225 |
/**
|
240 |
* Display the screen/ui
|
241 |
*/
|
242 |
function screen() {
|
243 |
+
|
244 |
// it'll process any submitted form data
|
245 |
// reload the options just in case
|
246 |
$this->load_options();
|
274 |
if( isset($_GET['import']) && isset($_GET['settings-updated']) && $_GET['settings-updated'] ) {
|
275 |
?>
|
276 |
<script type="text/javascript">
|
277 |
+
// determine the feed ids within wordpress
|
278 |
<?php
|
279 |
+
$feed_ids = array();
|
280 |
+
if (is_array($this->options['feeds']) ) {
|
281 |
+
foreach ($this->options['feeds'] as $f) {
|
282 |
+
$feed_ids[] = $f['id'];
|
283 |
+
}
|
284 |
+
}
|
|
|
285 |
?>
|
286 |
+
// and set them as a global JS variable
|
287 |
+
if ( feeds !== undefined ) {
|
288 |
+
feeds.set(<?php echo json_encode($feed_ids); ?>);
|
289 |
+
} else {
|
290 |
+
var feeds = <?php echo json_encode($feed_ids); ?>;
|
291 |
+
}
|
292 |
+
console.log('what is this');
|
293 |
</script>
|
294 |
<?php
|
295 |
}
|
322 |
|
323 |
/**
|
324 |
* Display errors
|
325 |
+
*
|
326 |
* @param string $error The error message
|
327 |
* @param boolean $inline Whether the error is inline or shown like regular wp errors
|
328 |
*/
|
337 |
* Add a new row for a new feed
|
338 |
*/
|
339 |
function add_row() {
|
340 |
+
if (! isset($_POST['feed_id'])) {
|
341 |
+
die();
|
342 |
+
}
|
343 |
|
344 |
+
$ajax_add = true;
|
345 |
+
$ajax_feed_id = $_POST['feed_id'];
|
346 |
include( RSS_PI_PATH . 'app/templates/feed-table-row.php');
|
347 |
die();
|
348 |
}
|
349 |
|
350 |
+
function edit_row() {
|
351 |
+
if (! isset($_POST['feed_id'])) {
|
352 |
+
die();
|
353 |
+
}
|
354 |
+
|
355 |
+
foreach ($this->options['feeds'] as $f) {
|
356 |
+
if ($f['id'] == $_POST['feed_id']) {
|
357 |
+
$ajax_edit = true;
|
358 |
+
include( RSS_PI_PATH . 'app/templates/feed-table-row.php');
|
359 |
+
die();
|
360 |
+
}
|
361 |
+
}
|
362 |
+
}
|
363 |
+
|
364 |
/**
|
365 |
* Generate stats data and return
|
366 |
*/
|
367 |
function ajax_stats() {
|
|
|
368 |
include( RSS_PI_PATH . 'app/templates/stats.php');
|
369 |
die();
|
370 |
}
|
463 |
|
464 |
/**
|
465 |
* Disable the user dropdwon for each feed
|
466 |
+
*
|
467 |
* @param string $output The html of the select dropdown
|
468 |
* @return string
|
469 |
*/
|
488 |
|
489 |
/**
|
490 |
* Walker class function for category multiple checkbox
|
491 |
+
*
|
492 |
+
*
|
493 |
+
*
|
494 |
*/
|
495 |
function wp_category_checklist_rss_pi($post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $walker = null, $checked_ontop = true) {
|
496 |
|
app/classes/front/class-rss-pi-front.php
CHANGED
@@ -7,268 +7,274 @@
|
|
7 |
*/
|
8 |
class rssPIFront {
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
238 |
echo '<meta property="og:image" content="'.$tc_image_thumb.'"/>';
|
239 |
-
|
240 |
-
|
241 |
echo '<meta property="og:site_name" content="'.get_bloginfo().'"/>';
|
242 |
echo '<meta property="og:description" content="'.$rest.'"/>';
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
|
273 |
|
274 |
}
|
7 |
*/
|
8 |
class rssPIFront {
|
9 |
|
10 |
+
/**
|
11 |
+
* Whether the API key is valid
|
12 |
+
*
|
13 |
+
* @var boolean
|
14 |
+
*/
|
15 |
+
var $is_key_valid;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* The options
|
19 |
+
*
|
20 |
+
* @var array
|
21 |
+
*/
|
22 |
+
var $options;
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Aprompt for invalid/absent API keys
|
26 |
+
* @var string
|
27 |
+
*/
|
28 |
+
var $key_prompt;
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Initialise and hook all actions
|
32 |
+
*/
|
33 |
+
public function init() {
|
34 |
+
global $post, $rss_post_importer;
|
35 |
+
|
36 |
+
// add noidex to front
|
37 |
+
add_action('wp_head', array($this, 'rss_pi_noindex_meta_tag'));
|
38 |
+
// add canonical urls
|
39 |
+
|
40 |
+
remove_action( 'wp_head', 'rel_canonical' );
|
41 |
+
add_action('wp_head', array($this, 'rss_pi_canonical_urls_meta_tag'));
|
42 |
+
|
43 |
+
// add options
|
44 |
+
$this->options = $rss_post_importer->options;
|
45 |
+
|
46 |
+
// Check for block indexing
|
47 |
+
if ($this->options['settings']['nofollow_outbound'] == 'true') {
|
48 |
+
add_filter('the_content', array($this, 'rss_pi_url_parse'));
|
49 |
+
}
|
50 |
+
|
51 |
+
$social = array(
|
52 |
+
'tw_show' => 'add_twitter_cards',
|
53 |
+
'gg_show' => 'add_google_item',
|
54 |
+
'og_show' => 'fb_opengraph',
|
55 |
+
);
|
56 |
+
|
57 |
+
foreach($social as $key => $value) {
|
58 |
+
if (isset($this->options['settings'][$key]) &&
|
59 |
+
$this->options['settings'][$key] == 1) {
|
60 |
+
|
61 |
+
add_action('wp_head', array($this, $value));
|
62 |
+
|
63 |
+
}
|
64 |
+
}
|
65 |
+
|
66 |
+
}
|
67 |
+
|
68 |
+
function rss_pi_noindex_meta_tag() {
|
69 |
+
global $post, $rss_post_importer;
|
70 |
+
|
71 |
+
//Add meta tag for UTF-8 character encoding.
|
72 |
+
echo '<meta http-equiv="Content-type" content="text/html; charset=utf-8" />';
|
73 |
+
|
74 |
+
// Check if single post
|
75 |
+
if (is_single()) {
|
76 |
+
|
77 |
+
// Get current post id
|
78 |
+
$current_post_id = $post->ID;
|
79 |
+
|
80 |
+
// add options
|
81 |
+
$this->options = $rss_post_importer->options;
|
82 |
+
|
83 |
+
// get value of block indexing
|
84 |
+
$block_indexing = $this->options['settings']['block_indexing'];
|
85 |
+
|
86 |
+
// Check for block indexing
|
87 |
+
if ($this->options['settings']['block_indexing'] == 'true') {
|
88 |
+
$meta_values = get_post_meta($current_post_id, 'rss_pi_source_url', false);
|
89 |
+
// if meta value array is empty it means post is not imported by this plugin.
|
90 |
+
if (!empty($meta_values)) {
|
91 |
+
echo '<meta name="robots" content="noindex">';
|
92 |
+
}
|
93 |
+
}
|
94 |
+
}
|
95 |
+
}
|
96 |
+
|
97 |
+
|
98 |
+
function rss_pi_canonical_urls_meta_tag() {
|
99 |
+
global $post, $rss_post_importer;
|
100 |
+
|
101 |
+
// Check if single post
|
102 |
+
if (is_single()) {
|
103 |
+
|
104 |
+
// Get current post id
|
105 |
+
$current_post_id = $post->ID;
|
106 |
+
// add options
|
107 |
+
$this->options = $rss_post_importer->options;
|
108 |
+
|
109 |
+
// Check for block indexing
|
110 |
+
|
111 |
+
$meta_rss_pi_canonical_url = get_post_meta($current_post_id, 'rss_pi_canonical_url', false);
|
112 |
+
if(!empty($meta_rss_pi_canonical_url) && $meta_rss_pi_canonical_url[0]=="source_blog"){
|
113 |
+
$meta_values_source = get_post_meta($current_post_id, 'rss_pi_source_url', false);
|
114 |
+
if (!empty($meta_values_source)) {
|
115 |
+
$pieces = parse_url($meta_values_source[0]);
|
116 |
+
$domain = isset($pieces['host']) ? $pieces['host'] : '';
|
117 |
+
if (preg_match('/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i', $domain, $regs)) {
|
118 |
+
$domain= $regs['domain'];
|
119 |
+
}
|
120 |
+
$domain= $regs['domain'];
|
121 |
+
$check_domain = explode('.',$domain);
|
122 |
+
//Check URL for Google Only
|
123 |
+
if(isset($check_domain[0]) && $check_domain[0]=="google"){
|
124 |
+
$google_url = $pieces['fragment'];
|
125 |
+
$google_explode = explode("url=",$google_url);
|
126 |
+
if(isset($google_explode[1]) && $google_explode[1]!='')
|
127 |
+
{
|
128 |
+
$canonical_urls = $google_explode[1];
|
129 |
+
}
|
130 |
+
}else{
|
131 |
+
$canonical_urls = $meta_values_source[0];
|
132 |
+
}
|
133 |
+
|
134 |
+
// if meta value array is empty it means post is not imported by this plugin.
|
135 |
+
if (!empty($meta_values_source)) {
|
136 |
+
|
137 |
+
echo "<link rel='canonical' href='".$canonical_urls."' />";
|
138 |
+
}
|
139 |
+
|
140 |
+
}
|
141 |
+
}else
|
142 |
+
{
|
143 |
+
// original code
|
144 |
+
$link = get_permalink( $current_post_id );
|
145 |
+
echo "<link rel='canonical' href='$link' />\n";
|
146 |
+
|
147 |
+
}
|
148 |
+
|
149 |
+
|
150 |
+
}
|
151 |
+
}
|
152 |
+
|
153 |
+
|
154 |
+
function rss_pi_url_parse($content) {
|
155 |
+
|
156 |
+
$regexp = "<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>";
|
157 |
+
if (preg_match_all("/$regexp/siU", $content, $matches, PREG_SET_ORDER)) {
|
158 |
+
if (!empty($matches)) {
|
159 |
+
|
160 |
+
$srcUrl = get_option('home');
|
161 |
+
for ($i = 0; $i < count($matches); $i++) {
|
162 |
+
|
163 |
+
$tag = $matches[$i][0];
|
164 |
+
$tag2 = $matches[$i][0];
|
165 |
+
$url = $matches[$i][0];
|
166 |
+
|
167 |
+
$noFollow = '';
|
168 |
+
|
169 |
+
$pattern = '/target\s*=\s*"\s*_blank\s*"/';
|
170 |
+
preg_match($pattern, $tag2, $match, PREG_OFFSET_CAPTURE);
|
171 |
+
if (count($match) < 1)
|
172 |
+
$noFollow .= ' target="_blank" ';
|
173 |
+
|
174 |
+
$pattern = '/rel\s*=\s*"\s*[n|d]ofollow\s*"/';
|
175 |
+
preg_match($pattern, $tag2, $match, PREG_OFFSET_CAPTURE);
|
176 |
+
if (count($match) < 1)
|
177 |
+
$noFollow .= ' rel="nofollow" ';
|
178 |
+
|
179 |
+
$pos = strpos($url, $srcUrl);
|
180 |
+
if ($pos === false) {
|
181 |
+
$tag = rtrim($tag, '>');
|
182 |
+
$tag .= $noFollow . '>';
|
183 |
+
$content = str_replace($tag2, $tag, $content);
|
184 |
+
}
|
185 |
+
}
|
186 |
+
}
|
187 |
+
}
|
188 |
+
|
189 |
+
$content = str_replace(']]>', ']]>', $content);
|
190 |
+
return $content;
|
191 |
+
}
|
192 |
+
|
193 |
+
function add_twitter_cards() {
|
194 |
+
global $post;
|
195 |
+
if($this->options['settings']['tw_show']==1){
|
196 |
+
if(is_single()) {
|
197 |
+
$tc_url = get_permalink();
|
198 |
+
$tc_title = get_the_title();
|
199 |
+
if($excerpt = $post->post_content) {
|
200 |
+
$excerpt = strip_tags($post->post_content);
|
201 |
+
$excerpt = str_replace("", "'", $excerpt);
|
202 |
+
}
|
203 |
+
$tc_description = trim(substr($excerpt, 0,150));
|
204 |
+
if(has_post_thumbnail($post->ID)) {
|
205 |
+
$img_src = wp_get_attachment_image_src(get_post_thumbnail_id( $post->ID ), full );
|
206 |
+
$tc_image_thumb = $img_src[0];
|
207 |
+
} else {
|
208 |
+
//$tc_image_thumb = site_url() . '/wp-content/plugins/rss-post-importer/app/assets/img/03-04-feedsapi-api.jpg';
|
209 |
+
//plugins_url( 'images/wordpress.png', __FILE__ )
|
210 |
+
$tc_image_thumb = plugins_url( 'app/assets/img/03-04-feedsapi-api.jpg', __FILE__ );
|
211 |
+
}
|
212 |
+
echo '<meta name="twitter:card" value="summary" />';
|
213 |
+
echo '<meta name="twitter:site" value="@feedsapi" />';
|
214 |
+
echo '<meta name="twitter:title" value="'.$tc_title.'" />';
|
215 |
+
echo '<meta name="twitter:description" value="'.$tc_description.'" />';
|
216 |
+
echo '<meta name="twitter:url" value="'.$tc_url.'" />';
|
217 |
+
echo '<meta name="twitter:image" value="'.$tc_image_thumb.'" />';
|
218 |
+
echo '<meta name="twitter:creator" value="@feedsapi" />';
|
219 |
+
}
|
220 |
+
}
|
221 |
+
}
|
222 |
+
|
223 |
+
function fb_opengraph() {
|
224 |
+
global $post;
|
225 |
+
if($this->options['settings']['og_show']==1){
|
226 |
+
if(is_single()) {
|
227 |
+
if(has_post_thumbnail($post->ID)) {
|
228 |
+
$img_src = wp_get_attachment_image_src(get_post_thumbnail_id( $post->ID ), 'medium');
|
229 |
+
$tc_image_thumb = $img_src[0];
|
230 |
+
} else {
|
231 |
+
//$tc_image_thumb = site_url() . '/wp-content/plugins/rss-post-importer/app/assets/img/03-04-feedsapi-api.jpg';
|
232 |
+
$tc_image_thumb = plugins_url( 'app/assets/img/03-04-feedsapi-api.jpg', __FILE__ );
|
233 |
+
}
|
234 |
+
|
235 |
+
if($excerpt = $post->post_content) {
|
236 |
+
$excerpt = strip_tags($post->post_content);
|
237 |
+
$excerpt = str_replace("", "'", $excerpt);
|
238 |
+
}
|
239 |
+
$rest = trim(substr($excerpt, 0,150));
|
240 |
+
$post_date = $post->post_date;
|
241 |
+
$og_title = get_the_title();
|
242 |
+
$og_url = get_permalink();
|
243 |
+
echo '<meta property="og:title" content="'.$og_title.'"/>';
|
244 |
echo '<meta property="og:image" content="'.$tc_image_thumb.'"/>';
|
245 |
+
echo '<meta property="og:image:width" content="681" />';
|
246 |
+
echo '<meta property="og:image:height" content="358" />';
|
247 |
echo '<meta property="og:site_name" content="'.get_bloginfo().'"/>';
|
248 |
echo '<meta property="og:description" content="'.$rest.'"/>';
|
249 |
+
}
|
250 |
+
}
|
251 |
+
}
|
252 |
+
|
253 |
+
function add_google_item() {
|
254 |
+
global $post;
|
255 |
+
if($this->options['settings']['gg_show']==1){
|
256 |
+
if(is_single()) {
|
257 |
+
if(has_post_thumbnail($post->ID)) {
|
258 |
+
$img_src = wp_get_attachment_image_src(get_post_thumbnail_id( $post->ID ), full );
|
259 |
+
$tc_image_thumb = $img_src[0];
|
260 |
+
} else {
|
261 |
+
//$tc_image_thumb = site_url() . '/wp-content/plugins/rss-post-importer/app/assets/img/03-04-feedsapi-api.jpg';
|
262 |
+
$tc_image_thumb = plugins_url( 'app/assets/img/03-04-feedsapi-api.jpg', __FILE__ );
|
263 |
+
}
|
264 |
+
|
265 |
+
if($excerpt = $post->post_content) {
|
266 |
+
$excerpt = strip_tags($post->post_content);
|
267 |
+
$excerpt = str_replace("", "'", $excerpt);
|
268 |
+
}
|
269 |
+
$rest = trim(substr($excerpt, 0,150));
|
270 |
+
$gg_url = get_permalink();
|
271 |
+
$gg_title = get_the_title();
|
272 |
+
echo '<meta itemprop="name" content="'.$gg_title.'">';
|
273 |
+
echo '<meta itemprop="description" content="'.$rest.'">';
|
274 |
+
echo '<meta itemprop="image" content="'.$tc_image_thumb.'">';
|
275 |
+
}
|
276 |
+
}
|
277 |
+
}
|
278 |
|
279 |
|
280 |
}
|
app/classes/import/class-rss-pi-engine.php
CHANGED
@@ -7,747 +7,713 @@
|
|
7 |
*/
|
8 |
class rssPIEngine {
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
$domain_old = $this->get_domain($permalink);
|
563 |
-
|
564 |
-
//checking if post title already exists
|
565 |
-
if ($posts = $wpdb->get_results("SELECT ID FROM " . $wpdb->prefix . "posts WHERE post_title = '" . $title . "' and post_status = 'publish' ", 'ARRAY_A')) {
|
566 |
-
//checking if post source is also same
|
567 |
-
foreach ($posts as $post) {
|
568 |
-
$post_id = $post['ID'];
|
569 |
-
$source_url = get_post_meta($post_id, 'rss_pi_source_url', true);
|
570 |
-
$domain_new = $this->get_domain($source_url);
|
571 |
-
|
572 |
-
if ($domain_new == $domain_old) {
|
573 |
-
$post_exists = TRUE;
|
574 |
-
}
|
575 |
-
}
|
576 |
-
}
|
577 |
-
}
|
578 |
-
|
579 |
-
if ( ! $post_exists && $this->options['settings']['cache_deleted'] == 'true' ) {
|
580 |
-
|
581 |
-
// check if the post has been imported and then deleted
|
582 |
-
if ( $this->options['upgraded']['deleted_posts'] ) { // database migrated
|
583 |
-
$rss_pi_deleted_posts = get_option( 'rss_pi_deleted_posts', array() );
|
584 |
-
if ( in_array( $permalink_md5, $rss_pi_deleted_posts )) {
|
585 |
-
$post_exists = TRUE;
|
586 |
-
}
|
587 |
-
} else {
|
588 |
-
//do it the old fashion way
|
589 |
-
$rss_pi_imported_posts = get_option( 'rss_pi_imported_posts', array() );
|
590 |
-
if ( in_array( $permalink, $rss_pi_imported_posts ) ) {
|
591 |
-
$post_exists = TRUE;
|
592 |
-
}
|
593 |
-
}
|
594 |
-
}
|
595 |
/* if($post_exists==true){
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
}
|
752 |
|
753 |
}
|
7 |
*/
|
8 |
class rssPIEngine {
|
9 |
|
10 |
+
/**
|
11 |
+
* Whether the API key is valid
|
12 |
+
*
|
13 |
+
* @var boolean
|
14 |
+
*/
|
15 |
+
var $is_key_valid;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* The options
|
19 |
+
*
|
20 |
+
* @var array
|
21 |
+
*/
|
22 |
+
var $options = array();
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Start the engine
|
26 |
+
*
|
27 |
+
* @global type $rss_post_importer
|
28 |
+
*/
|
29 |
+
public function __construct() {
|
30 |
+
|
31 |
+
global $rss_post_importer;
|
32 |
+
|
33 |
+
$this->load_options();
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Start the engine
|
38 |
+
*
|
39 |
+
* @global type $rss_post_importer
|
40 |
+
*/
|
41 |
+
public function load_options() {
|
42 |
+
|
43 |
+
global $rss_post_importer;
|
44 |
+
$this->options = $rss_post_importer->options;
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Import feeds
|
49 |
+
*
|
50 |
+
* @return int
|
51 |
+
*/
|
52 |
+
public function import_feed() {
|
53 |
+
global $rss_post_importer;
|
54 |
+
$this->load_options();
|
55 |
+
$post_count = 0;
|
56 |
+
// filter cache lifetime
|
57 |
+
add_filter('wp_feed_cache_transient_lifetime', array($this, 'frequency'));
|
58 |
+
|
59 |
+
foreach ($this->options['feeds'] as $i => $f) {
|
60 |
+
|
61 |
+
// before the first feed, we check for key validity
|
62 |
+
if ( $i == 0 ) {
|
63 |
+
$this->is_key_valid = $rss_post_importer->is_valid_key($this->options['settings']['feeds_api_key']);
|
64 |
+
$this->options['settings']['is_key_valid'] = $this->is_key_valid;
|
65 |
+
// if the key is not fine
|
66 |
+
if (!empty($this->options['settings']['feeds_api_key']) && !$this->is_key_valid) {
|
67 |
+
// unset from settings
|
68 |
+
unset($this->options['settings']['feeds_api_key']);
|
69 |
+
}
|
70 |
+
// update options
|
71 |
+
$new_options = array(
|
72 |
+
'feeds' => $this->options['feeds'],
|
73 |
+
'settings' => $this->options['settings'],
|
74 |
+
'latest_import' => $this->options['latest_import'],
|
75 |
+
'imports' => $this->options['imports'],
|
76 |
+
'upgraded' => $this->options['upgraded']
|
77 |
+
);
|
78 |
+
// update in db
|
79 |
+
update_option('rss_pi_feeds', $new_options);
|
80 |
+
}
|
81 |
+
|
82 |
+
// prepare, import feed and count imported posts
|
83 |
+
if ( $items = $this->do_import($f) ) {
|
84 |
+
$post_count += count($items);
|
85 |
+
}
|
86 |
+
}
|
87 |
+
|
88 |
+
// reformulate import count
|
89 |
+
$imports = intval($this->options['imports']) + $post_count;
|
90 |
+
|
91 |
+
// update options
|
92 |
+
update_option('rss_pi_feeds', array(
|
93 |
+
'feeds' => $this->options['feeds'],
|
94 |
+
'settings' => $this->options['settings'],
|
95 |
+
'latest_import' => date("Y-m-d H:i:s"),
|
96 |
+
'imports' => $imports
|
97 |
+
));
|
98 |
+
|
99 |
+
global $rss_post_importer;
|
100 |
+
// reload options
|
101 |
+
$rss_post_importer->load_options();
|
102 |
+
|
103 |
+
remove_filter('wp_feed_cache_transient_lifetime', array($this, 'frequency'));
|
104 |
+
|
105 |
+
// log this
|
106 |
+
rssPILog::log($post_count);
|
107 |
+
|
108 |
+
return $post_count;
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* Dummy function for filtering because we can't use anon ones yet
|
113 |
+
* @return string
|
114 |
+
*/
|
115 |
+
public function frequency() {
|
116 |
+
|
117 |
+
return $this->options['settings']['frequency'];
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Prepares arguments and imports
|
122 |
+
*
|
123 |
+
* @param array $f feed array
|
124 |
+
* @return array
|
125 |
+
*/
|
126 |
+
public function do_import($f) {
|
127 |
+
$args = array(
|
128 |
+
'feed_title' => $f['name'],
|
129 |
+
'max_posts' => $f['max_posts'],
|
130 |
+
'author_id' => $f['author_id'],
|
131 |
+
'category_id' => $f['category_id'],
|
132 |
+
'tags_id' => $f['tags_id'],
|
133 |
+
'keywords' => isset($f['keywords']) && is_array($f['keywords']) ? $f['keywords'] : array(),
|
134 |
+
'strip_html' => $f['strip_html'],
|
135 |
+
'nofollow_outbound' => $f['nofollow_outbound'],
|
136 |
+
'automatic_import_categories' => $f['automatic_import_categories'],
|
137 |
+
'automatic_import_author' => $f['automatic_import_author'],
|
138 |
+
'feed_status' => $f['feed_status'],
|
139 |
+
'canonical_urls' => $f['canonical_urls'],
|
140 |
+
'save_to_db' => true
|
141 |
+
);
|
142 |
+
|
143 |
+
return $this->_import($f['url'], $args);
|
144 |
+
}
|
145 |
+
|
146 |
+
/**
|
147 |
+
* Import feeds from url
|
148 |
+
*
|
149 |
+
* @param string $url The remote feed url
|
150 |
+
* @param array $args Arguments for the import
|
151 |
+
* @return null|array
|
152 |
+
*/
|
153 |
+
private function _import($url='', $args=array()) {
|
154 |
+
|
155 |
+
if (empty($url)) return;
|
156 |
+
|
157 |
+
if($args['feed_status'] == 'pause') return;
|
158 |
+
|
159 |
+
$defaults = array(
|
160 |
+
'feed_title' => '',
|
161 |
+
'max_posts' => 5,
|
162 |
+
'author_id' => 1,
|
163 |
+
'category_id' => 0,
|
164 |
+
'tags_id' => array(),
|
165 |
+
'keywords' => array(),
|
166 |
+
'strip_html' => true,
|
167 |
+
'save_to_db' => true,
|
168 |
+
'nofollow_outbound' => true,
|
169 |
+
'automatic_import_categories' => true,
|
170 |
+
'automatic_import_author' => true,
|
171 |
+
'feed_status' => 'active',
|
172 |
+
'canonical_urls' => 'my_blog'
|
173 |
+
);
|
174 |
+
|
175 |
+
$args = wp_parse_args($args, $defaults);
|
176 |
+
|
177 |
+
// include the default WP feed processing functions
|
178 |
+
include_once( ABSPATH . WPINC . '/feed.php' );
|
179 |
+
|
180 |
+
// get the right url for fetching (premium vs free)
|
181 |
+
$url = $this->url($url);
|
182 |
+
|
183 |
+
// fetch the feed
|
184 |
+
$feed = fetch_feed($url);
|
185 |
+
|
186 |
+
|
187 |
+
if (is_wp_error($feed)) {
|
188 |
+
return false;
|
189 |
+
}
|
190 |
+
|
191 |
+
// save as posts
|
192 |
+
$posts = $this->save($feed, $args);
|
193 |
+
|
194 |
+
return $posts;
|
195 |
+
}
|
196 |
+
|
197 |
+
/**
|
198 |
+
* Formulate the right url
|
199 |
+
*
|
200 |
+
* @param string $url
|
201 |
+
* @return string
|
202 |
+
*/
|
203 |
+
private function url($url) {
|
204 |
+
|
205 |
+
$key = $this->options['settings']['feeds_api_key'];
|
206 |
+
|
207 |
+
//if api key has been saved by user and is not empty
|
208 |
+
if (isset($key) && !empty($key)) {
|
209 |
+
//$api_url = 'http://176.58.108.28/fetch.php?key=' . $key . '&url=' . $url;
|
210 |
+
$api_url = 'http://176.58.108.28/fetch.php?key=' . $key . '&url=' . urlencode($url);
|
211 |
+
|
212 |
+
return $api_url;
|
213 |
+
}
|
214 |
+
|
215 |
+
return $url;
|
216 |
+
}
|
217 |
+
|
218 |
+
/**
|
219 |
+
* Save the feed
|
220 |
+
*
|
221 |
+
* @param object $feed The feed object
|
222 |
+
* @param array $args The arguments
|
223 |
+
* @return boolean
|
224 |
+
*/
|
225 |
+
private function save($feed, $args=array()) {
|
226 |
+
|
227 |
+
// filter the feed and get feed items
|
228 |
+
$feed_items = $this->filter($feed, $args);
|
229 |
+
|
230 |
+
// if we are saving
|
231 |
+
if ($args['save_to_db']) {
|
232 |
+
// insert and return
|
233 |
+
$saved_posts = $this->insert($feed_items, $args);
|
234 |
+
|
235 |
+
return $saved_posts;
|
236 |
+
}
|
237 |
+
|
238 |
+
// otherwsie return the feed items
|
239 |
+
return $feed_items;
|
240 |
+
}
|
241 |
+
|
242 |
+
/**
|
243 |
+
* Filter the feed based on keywords
|
244 |
+
*
|
245 |
+
* @param object $feed The feed object
|
246 |
+
* @param array $args Arguments
|
247 |
+
* @return array
|
248 |
+
*/
|
249 |
+
private function filter($feed, $args) {
|
250 |
+
// the count of keyword matched items
|
251 |
+
$got = 0;
|
252 |
+
|
253 |
+
// the current index of the items aray
|
254 |
+
$index = 0;
|
255 |
+
|
256 |
+
$filtered = array();
|
257 |
+
|
258 |
+
// till we have as many as the posts needed
|
259 |
+
while ($got < $args['max_posts']) {
|
260 |
+
// get only one item at the current index
|
261 |
+
$feed_item = $feed->get_items($index, 1);
|
262 |
+
|
263 |
+
// if this is empty, get out of the while
|
264 |
+
if (empty($feed_item)) {
|
265 |
+
break;
|
266 |
+
}
|
267 |
+
// else be in a forever loop
|
268 |
+
// get the content
|
269 |
+
$content = $feed_item[0]->get_content();
|
270 |
+
|
271 |
+
// test it against the keywords
|
272 |
+
$tested = $this->test($content,$args['keywords']);
|
273 |
+
|
274 |
+
// if this is good for us
|
275 |
+
if ($tested) {
|
276 |
+
$got++;
|
277 |
+
|
278 |
+
array_push($filtered, $feed_item[0]);
|
279 |
+
}
|
280 |
+
// shift the index
|
281 |
+
$index++;
|
282 |
+
}
|
283 |
+
|
284 |
+
return $filtered;
|
285 |
+
}
|
286 |
+
|
287 |
+
/**
|
288 |
+
* Test a piece of content against keywords
|
289 |
+
*
|
290 |
+
* @param string $content
|
291 |
+
* @return boolean
|
292 |
+
*/
|
293 |
+
function test($content,$keywords=null) {
|
294 |
+
if ( ! $keywords ) {
|
295 |
+
$keywords = $this->options['settings']['keywords'];
|
296 |
+
}
|
297 |
+
|
298 |
+
if ( empty($keywords) || ! is_array($keywords) ) {
|
299 |
+
return true;
|
300 |
+
}
|
301 |
+
|
302 |
+
$match = false;
|
303 |
+
|
304 |
+
// loop through keywords
|
305 |
+
foreach ( $keywords as $keyword ) {
|
306 |
+
// if the keyword is not a regex, make it one
|
307 |
+
if ( ! $this->is_regex($keyword) ) {
|
308 |
+
$keyword = '/' . $keyword . '/i';
|
309 |
+
}
|
310 |
+
|
311 |
+
// look for keyword in content
|
312 |
+
preg_match($keyword, $content, $tested);
|
313 |
+
|
314 |
+
// if it's there, we are good
|
315 |
+
if ( ! empty($tested) ) {
|
316 |
+
$match = true;
|
317 |
+
// no need to test anymore
|
318 |
+
break;
|
319 |
+
}
|
320 |
+
}
|
321 |
+
|
322 |
+
return $match;
|
323 |
+
}
|
324 |
+
|
325 |
+
/**
|
326 |
+
* Check if a string is regex
|
327 |
+
*
|
328 |
+
* @param string $str The string to check
|
329 |
+
* @return boolean
|
330 |
+
*/
|
331 |
+
private function is_regex($str) {
|
332 |
+
|
333 |
+
// check regex with a regex!
|
334 |
+
$regex = '/^\/[\s\S]+\/$/';
|
335 |
+
preg_match($regex, $str, $matched);
|
336 |
+
return !empty($matched);
|
337 |
+
}
|
338 |
+
|
339 |
+
/**
|
340 |
+
* Insert feed items as posts
|
341 |
+
*
|
342 |
+
* @param array $items Fetched feed items
|
343 |
+
* @param array $args arguments
|
344 |
+
* @return array
|
345 |
+
*/
|
346 |
+
private function insert($items, $args = array()) {
|
347 |
+
$saved_posts = array();
|
348 |
+
|
349 |
+
// Initialise the content parser
|
350 |
+
$parser = new rssPIParser($this->options);
|
351 |
+
|
352 |
+
// Featured Image setter
|
353 |
+
$thumbnail = new rssPIFeaturedImage();
|
354 |
+
|
355 |
+
// If Item is active then Import
|
356 |
+
if($args['feed_status'] == "active") {
|
357 |
+
|
358 |
+
foreach ( $items as $item ) {
|
359 |
+
|
360 |
+
if ( ! $this->post_exists($item) ) {
|
361 |
+
|
362 |
+
/* Code to convert tags id array to tag name array * */
|
363 |
+
if ( ! empty($args['tags_id']) ) {
|
364 |
+
foreach ( $args['tags_id'] as $tagid ) {
|
365 |
+
$tag_name = get_tag($tagid); // <-- your tag ID
|
366 |
+
$tags_name[] = $tag_name->name;
|
367 |
+
}
|
368 |
+
} else {
|
369 |
+
$tags_name = array();
|
370 |
+
}
|
371 |
+
|
372 |
+
// parse the content
|
373 |
+
$content = $parser->_parse($item, $args['feed_title'], $args['strip_html']);
|
374 |
+
|
375 |
+
//Filter content for /* Add rel="nofollow" to all outbounded links. */
|
376 |
+
if($args['nofollow_outbound']=='true') {
|
377 |
+
$content=$this->rss_pi_url_parse_content($content);
|
378 |
+
}
|
379 |
+
|
380 |
+
// Get auto categories from Feeds
|
381 |
+
$post_category = array();
|
382 |
+
if($args['automatic_import_categories']=='true') {
|
383 |
+
$category_array = array();
|
384 |
+
foreach ($item->get_categories() as $category) {
|
385 |
+
$cat_id = wp_create_category($category->get_label());
|
386 |
+
if ($cat_id > 0) {
|
387 |
+
$category_array[] = $cat_id;
|
388 |
+
} else {
|
389 |
+
$category = get_term_by('name', $category->get_label(), 'category');
|
390 |
+
if ($category) {
|
391 |
+
$category_array[] = $category->term_id;
|
392 |
+
}
|
393 |
+
}
|
394 |
+
}
|
395 |
+
$post_category = $category_array;
|
396 |
+
} else {
|
397 |
+
$post_category = array($args['category_id']);
|
398 |
+
}
|
399 |
+
|
400 |
+
// Get Author From Feed URl
|
401 |
+
if($args['automatic_import_author']=='true') {
|
402 |
+
if ($author = $item->get_author()) {
|
403 |
+
$array_author = explode(",",$author->get_name());
|
404 |
+
$user_name = preg_replace('/[^A-Za-z0-9\-]/', ' ', $array_author[0]);
|
405 |
+
$user_id = username_exists( $user_name );
|
406 |
+
if (! $user_id) {
|
407 |
+
$random_password = wp_generate_password( $length=12, $include_standard_special_chars=false );
|
408 |
+
$user_id = wp_create_user( $user_name, $random_password,'');
|
409 |
+
}
|
410 |
+
$post_author = $user_id;
|
411 |
+
|
412 |
+
} else {
|
413 |
+
$post_author = $args['author_id'];
|
414 |
+
}
|
415 |
+
} else {
|
416 |
+
$post_author = $args['author_id'];
|
417 |
+
}
|
418 |
+
|
419 |
+
$post = array(
|
420 |
+
'post_title' => $item->get_title(),
|
421 |
+
'post_content' => $content,
|
422 |
+
'post_status' => $this->options['settings']['post_status'],
|
423 |
+
'post_author' => $post_author,
|
424 |
+
'post_category' => $post_category,
|
425 |
+
'tags_input' => $tags_name,
|
426 |
+
'comment_status' => $this->options['settings']['allow_comments'],
|
427 |
+
'post_date' => get_date_from_gmt($item->get_date('Y-m-d H:i:s'))
|
428 |
+
);
|
429 |
+
|
430 |
+
// catch base url and replace any img src with it
|
431 |
+
if (preg_match('/src="\//ui', $content)) {
|
432 |
+
preg_match('/href="(.+?)"/ui', $content, $matches);
|
433 |
+
$baseref = (is_array($matches) && !empty($matches)) ? $matches[1] : '';
|
434 |
+
if (!empty($baseref)) {
|
435 |
+
$bc = parse_url($baseref);
|
436 |
+
$scheme = (!isset($bc['scheme']) || empty($bc['scheme'])) ? 'http' : $bc['scheme'];
|
437 |
+
$port = isset($bc['port']) ? $bc['port'] : '';
|
438 |
+
$host = isset($bc['host']) ? $bc['host'] : '';
|
439 |
+
if (!empty($host)) {
|
440 |
+
$preurl = $scheme . ( $port ? ':' . $port : '' ) . '//' . $host;
|
441 |
+
$post['post_content'] = preg_replace('/(src="\/)/i', 'src="' . $preurl . '/', $content);
|
442 |
+
}
|
443 |
+
}
|
444 |
+
}
|
445 |
+
|
446 |
+
//download images and save them locally if setting suggests so
|
447 |
+
if ($this->options['settings']['import_images_locally'] == 'true') {
|
448 |
+
$post = $this->download_images_locally($post);
|
449 |
+
}
|
450 |
+
|
451 |
+
// insert as post
|
452 |
+
$post_id = $this->_insert($post, $item->get_permalink());
|
453 |
+
|
454 |
+
// set thumbnail
|
455 |
+
if ( $this->options['settings']['disable_thumbnail'] == 'false' ) {
|
456 |
+
// assign a thumbnail (featured image) to the post
|
457 |
+
$thumbnail->_set($item, $post_id);
|
458 |
+
$attachment_id = get_post_thumbnail_id($post_id);
|
459 |
+
} else {
|
460 |
+
// just download the image to the media library
|
461 |
+
$attachment_id = $thumbnail->_prepare($item, $post_id);
|
462 |
+
}
|
463 |
+
|
464 |
+
/* Parse {$inline_image} template tag
|
465 |
+
* @since 2.1.3
|
466 |
+
*/
|
467 |
+
if ( preg_match('/\{\$inline_image\}/i', $post['post_content']) ) {
|
468 |
+
$_post_content = $post['post_content'];
|
469 |
+
if ( $attachment_id ) {
|
470 |
+
//$featured_image = wp_get_attachment_image($attachment_id);
|
471 |
+
$featured_image = wp_get_attachment_image_src($attachment_id, 'full');
|
472 |
+
$featured_image = '<img src="' . $featured_image[0] . '" width="' . $featured_image[1] . '" height="' . $featured_image[2] . '">';
|
473 |
+
} else {
|
474 |
+
$featured_image = '';
|
475 |
+
}
|
476 |
+
$_post_content = preg_replace('/\{\$inline_image\}/i', $featured_image, $_post_content);
|
477 |
+
$_post = array(
|
478 |
+
'ID' => $post_id,
|
479 |
+
'post_content' => $_post_content
|
480 |
+
);
|
481 |
+
|
482 |
+
wp_update_post($_post);
|
483 |
+
|
484 |
+
$post['post_content'] = $_post_content;
|
485 |
+
}
|
486 |
+
// canonical_urls
|
487 |
+
update_post_meta($post_id, 'rss_pi_canonical_url',$args['canonical_urls']);
|
488 |
+
array_push($saved_posts, $post);
|
489 |
+
}
|
490 |
+
}
|
491 |
+
}
|
492 |
+
|
493 |
+
return $saved_posts;
|
494 |
+
}
|
495 |
+
|
496 |
+
/**
|
497 |
+
* Check if a feed item is alreday imported
|
498 |
+
*
|
499 |
+
* @param string $permalink
|
500 |
+
* @return boolean
|
501 |
+
*/
|
502 |
+
private function post_exists($item) {
|
503 |
+
global $wpdb;
|
504 |
+
|
505 |
+
$permalink = $item->get_permalink();
|
506 |
+
// calculate md5 hash
|
507 |
+
$permalink_md5 = md5($permalink);
|
508 |
+
// strip any params from the URL
|
509 |
+
$permalink_new = $permalink;
|
510 |
+
$permalink_new = explode('?', $permalink_new);
|
511 |
+
|
512 |
+
$permalink_new = $permalink_new[0];
|
513 |
+
// calculate new md5 hash
|
514 |
+
$permalink_md5_new = md5($permalink_new);
|
515 |
+
$post_exists = FALSE;
|
516 |
+
|
517 |
+
if ( isset($this->options['upgraded']['deleted_posts']) ) { // database migrated
|
518 |
+
// check if there is post with this source URL that is not trashed
|
519 |
+
//$posts = $wpdb->get_results( $wpdb->prepare( "SELECT meta_id FROM {$wpdb->postmeta} WHERE meta_key = 'rss_pi_source_md5' and meta_value = %s", $permalink_md5 ), 'ARRAY_A');
|
520 |
+
$posts = $wpdb->get_results( $wpdb->prepare( "SELECT meta_id FROM {$wpdb->postmeta} pm, {$wpdb->posts} p WHERE pm.meta_key = 'rss_pi_source_md5' AND ( pm.meta_value = %s) AND pm.post_id = p.ID AND p.post_status <> 'trash'", $permalink_md5), 'ARRAY_A');
|
521 |
+
//echo $wpdb->last_query;
|
522 |
+
if ( count($posts) ) {
|
523 |
+
$post_exists = TRUE;
|
524 |
+
}
|
525 |
+
}
|
526 |
+
// } else {
|
527 |
+
if ( ! $post_exists ) {
|
528 |
+
// do it the old fashion way -> check for post title and source domain
|
529 |
+
$title = $item->get_title();
|
530 |
+
$domain_old = $this->get_domain($permalink);
|
531 |
+
|
532 |
+
//checking if post title already exists
|
533 |
+
if ($posts = $wpdb->get_results("SELECT ID FROM " . $wpdb->prefix . "posts WHERE post_title = '" . $title . "' and post_status = 'publish' ", 'ARRAY_A')) {
|
534 |
+
//checking if post source is also same
|
535 |
+
foreach ($posts as $post) {
|
536 |
+
$post_id = $post['ID'];
|
537 |
+
$source_url = get_post_meta($post_id, 'rss_pi_source_url', true);
|
538 |
+
$domain_new = $this->get_domain($source_url);
|
539 |
+
|
540 |
+
if ($domain_new == $domain_old) {
|
541 |
+
$post_exists = TRUE;
|
542 |
+
}
|
543 |
+
}
|
544 |
+
}
|
545 |
+
}
|
546 |
+
|
547 |
+
if ( ! $post_exists && $this->options['settings']['cache_deleted'] == 'true' ) {
|
548 |
+
// check if the post has been imported and then deleted
|
549 |
+
if ( $this->options['upgraded']['deleted_posts'] ) { // database migrated
|
550 |
+
$rss_pi_deleted_posts = get_option( 'rss_pi_deleted_posts', array() );
|
551 |
+
if ( in_array( $permalink_md5, $rss_pi_deleted_posts )) {
|
552 |
+
$post_exists = TRUE;
|
553 |
+
}
|
554 |
+
} else {
|
555 |
+
//do it the old fashion way
|
556 |
+
$rss_pi_imported_posts = get_option( 'rss_pi_imported_posts', array() );
|
557 |
+
if ( in_array( $permalink, $rss_pi_imported_posts ) ) {
|
558 |
+
$post_exists = TRUE;
|
559 |
+
}
|
560 |
+
}
|
561 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
562 |
/* if($post_exists==true){
|
563 |
+
|
564 |
+
echo "1";
|
565 |
+
}else{
|
566 |
+
echo "0";
|
567 |
+
}*/
|
568 |
+
return $post_exists;
|
569 |
+
}
|
570 |
+
|
571 |
+
// deprecated as of 2.1.2
|
572 |
+
// TODO: Remove
|
573 |
+
private function get_domain($url) {
|
574 |
+
$pieces = parse_url($url);
|
575 |
+
$domain = isset($pieces['host']) ? $pieces['host'] : '';
|
576 |
+
if (preg_match('/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i', $domain, $regs)) {
|
577 |
+
return $regs['domain'];
|
578 |
+
}
|
579 |
+
return false;
|
580 |
+
}
|
581 |
+
|
582 |
+
/**
|
583 |
+
* Insert feed item as post
|
584 |
+
*
|
585 |
+
* @param array $post Post array
|
586 |
+
* @param string $url source url meta
|
587 |
+
* @return int
|
588 |
+
*/
|
589 |
+
private function _insert($post, $url) {
|
590 |
+
|
591 |
+
if ($post['post_category'][0] == "") {
|
592 |
+
$post['post_category'] = array(1);
|
593 |
+
} else {
|
594 |
+
if (is_array($post['post_category'][0])) {
|
595 |
+
$post['post_category'] = array_values($post['post_category'][0]);
|
596 |
+
} else {
|
597 |
+
$post['post_category'] = array_values($post['post_category']);
|
598 |
+
}
|
599 |
+
}
|
600 |
+
|
601 |
+
$_post = apply_filters('pre_rss_pi_insert_post', $post);
|
602 |
+
|
603 |
+
$post_id = wp_insert_post($_post);
|
604 |
+
|
605 |
+
add_action('save_rss_pi_post', $post_id);
|
606 |
+
|
607 |
+
//$url_md5 = md5($url);
|
608 |
+
// strip any params from the URL
|
609 |
+
//$url_new = $url;
|
610 |
+
//$url_new = explode('?', $url_new);
|
611 |
+
//$url_new = $post_id . $url_new[0] . $post_id;
|
612 |
+
// calculate new md5 hash
|
613 |
+
$url_md5 = md5($url);
|
614 |
+
update_post_meta($post_id, 'rss_pi_source_url', esc_url($url));
|
615 |
+
update_post_meta($post_id, 'rss_pi_source_md5', $url_md5);
|
616 |
+
|
617 |
+
return $post_id;
|
618 |
+
}
|
619 |
+
|
620 |
+
public function pre($arr) {
|
621 |
+
|
622 |
+
echo '<pre>';
|
623 |
+
print_r($arr);
|
624 |
+
echo '</pre>';
|
625 |
+
}
|
626 |
+
|
627 |
+
function download_images_locally($post) {
|
628 |
+
$post_content = $post['post_content'];
|
629 |
+
// initializing DOMDocument to modify the img source
|
630 |
+
$dom = new DOMDocument;
|
631 |
+
libxml_use_internal_errors(true);
|
632 |
+
$dom->loadHTML('<?xml encoding="utf-8" ?>' . $post_content);
|
633 |
+
$xpath = new DOMXPath($dom);
|
634 |
+
libxml_clear_errors();
|
635 |
+
//get all the src attribs and their values
|
636 |
+
$doc = $dom->getElementsByTagName('html')->item(0);
|
637 |
+
$src = $xpath->query('.//@src');
|
638 |
+
$count = 1;
|
639 |
+
foreach ($src as $s) {
|
640 |
+
$url = trim($s->nodeValue);
|
641 |
+
$attachment_id = $this->add_to_media($url, 0, $post['post_title'] . '-media-' . $count);
|
642 |
+
$src = wp_get_attachment_url($attachment_id);
|
643 |
+
$s->nodeValue = $src;
|
644 |
+
$count++;
|
645 |
+
}
|
646 |
+
$post['post_content'] = $dom->saveXML($doc);
|
647 |
+
return $post;
|
648 |
+
}
|
649 |
+
|
650 |
+
function add_to_media($url, $associated_with_post, $desc) {
|
651 |
+
$tmp = @download_url($url);
|
652 |
+
if (is_wp_error($tmp)) {
|
653 |
+
return false;
|
654 |
+
}
|
655 |
+
$post_id = $associated_with_post;
|
656 |
+
$desc = $desc;
|
657 |
+
$file_array = array();
|
658 |
+
// Set variables for storage
|
659 |
+
// fix file filename for query strings
|
660 |
+
if ( ! preg_match('/[^\?]+\.(jpg|jpe|jpeg|gif|png)/i', $url, $matches) ) {
|
661 |
+
return false;
|
662 |
+
}
|
663 |
+
$file_array['name'] = basename($matches[0]);
|
664 |
+
$file_array['tmp_name'] = $tmp;
|
665 |
+
// If error storing temporarily, unlink
|
666 |
+
if (is_wp_error($tmp)) {
|
667 |
+
@unlink($file_array['tmp_name']);
|
668 |
+
return false;
|
669 |
+
}
|
670 |
+
// do the validation and storage stuff
|
671 |
+
$id = media_handle_sideload($file_array, $post_id, $desc);
|
672 |
+
// If error storing permanently, unlink
|
673 |
+
if (is_wp_error($id)) {
|
674 |
+
@unlink($file_array['tmp_name']);
|
675 |
+
return false;
|
676 |
+
}
|
677 |
+
|
678 |
+
return $id;
|
679 |
+
}
|
680 |
+
|
681 |
+
function rss_pi_url_parse_content($content) {
|
682 |
+
$regexp = "<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>";
|
683 |
+
if (preg_match_all("/$regexp/siU", $content, $matches, PREG_SET_ORDER)) {
|
684 |
+
if (!empty($matches)) {
|
685 |
+
|
686 |
+
$srcUrl = get_option('home');
|
687 |
+
for ($i = 0; $i < count($matches); $i++) {
|
688 |
+
|
689 |
+
$tag = $matches[$i][0];
|
690 |
+
$tag2 = $matches[$i][0];
|
691 |
+
$url = $matches[$i][0];
|
692 |
+
|
693 |
+
$noFollow = '';
|
694 |
+
|
695 |
+
$pattern = '/target\s*=\s*"\s*_blank\s*"/';
|
696 |
+
preg_match($pattern, $tag2, $match, PREG_OFFSET_CAPTURE);
|
697 |
+
if (count($match) < 1)
|
698 |
+
$noFollow .= ' target="_blank" ';
|
699 |
+
|
700 |
+
$pattern = '/rel\s*=\s*"\s*[n|d]ofollow\s*"/';
|
701 |
+
preg_match($pattern, $tag2, $match, PREG_OFFSET_CAPTURE);
|
702 |
+
if (count($match) < 1)
|
703 |
+
$noFollow .= ' rel="nofollow" ';
|
704 |
+
|
705 |
+
$pos = strpos($url, $srcUrl);
|
706 |
+
if ($pos === false) {
|
707 |
+
$tag = rtrim($tag, '>');
|
708 |
+
$tag .= $noFollow . '>';
|
709 |
+
$content = str_replace($tag2, $tag, $content);
|
710 |
+
}
|
711 |
+
}
|
712 |
+
}
|
713 |
+
}
|
714 |
+
|
715 |
+
$content = str_replace(']]>', ']]>', $content);
|
716 |
+
return $content;
|
717 |
+
}
|
|
|
718 |
|
719 |
}
|
app/templates/feed-table-row.php
CHANGED
@@ -1,9 +1,16 @@
|
|
1 |
<?php
|
2 |
-
$show = '';
|
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
if (!isset($f)) {
|
5 |
$f = array(
|
6 |
-
'id' => 0,
|
7 |
'name' => 'New feed',
|
8 |
'url' => '',
|
9 |
'max_posts' => 5,
|
@@ -57,25 +64,40 @@ if (is_array($f['category_id'])) {
|
|
57 |
|
58 |
?>
|
59 |
|
|
|
|
|
|
|
60 |
<tr id="display_<?php echo ($f['id']); ?>" class="data-row<?php echo $show; ?>" data-fields="name,url,max_posts">
|
61 |
<td class="rss_pi-feed_name">
|
62 |
<strong><a href="#" class="toggle-edit" data-target="<?php echo ($f['id']); ?>"><span class="field-name"><?php echo esc_html(stripslashes($f['name'])); ?></span></a></strong>
|
63 |
<div class="row-options">
|
64 |
-
|
|
|
|
|
|
|
|
|
|
|
65 |
<a href="#" class="delete-row" data-target="<?php echo ($f['id']); ?>"><?php _e('Delete', 'rss-post-importer'); ?></a>
|
66 |
-
<?php
|
67 |
-
if($f['feed_status']=="active"){ ?>
|
68 |
| <a href="#" class="status-row" data-action="pause" data-target="<?php echo ($f['id']); ?>"><?php _e('Pause', 'rss-post-importer'); ?></a>
|
69 |
-
<?php }elseif($f['feed_status']=="pause"){ ?>
|
70 |
-
| <a href="#" class="status-row" data-action="
|
71 |
<?php } ?>
|
72 |
-
|
73 |
</div>
|
74 |
</td>
|
75 |
<td class="rss_pi-feed_url"><span class="field-url"><?php echo esc_url(stripslashes($f['url'])); ?></span></td>
|
76 |
<td class="rss_pi_feed_max_posts"><span class="field-max_posts"><?php echo $f['max_posts']; ?></span></td>
|
77 |
<!-- <td width="20%"><?php //echo $category; ?></td>-->
|
78 |
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
<tr id="edit_<?php echo ($f['id']); ?>" class="edit-row<?php echo $show; ?>">
|
80 |
<td colspan="4">
|
81 |
<table class="widefat edit-table">
|
@@ -111,8 +133,8 @@ if (is_array($f['category_id'])) {
|
|
111 |
</li>
|
112 |
</ul>
|
113 |
</td>
|
114 |
-
</tr>
|
115 |
-
|
116 |
<tr>
|
117 |
<td>
|
118 |
<label for="<?php echo ($f['id']); ?>-canonical_urls"><?php _e('SEO canonical URLs ?', "rss-post-importer"); ?></label>
|
@@ -128,12 +150,12 @@ if (is_array($f['category_id'])) {
|
|
128 |
</li>
|
129 |
</ul>
|
130 |
</td>
|
131 |
-
</tr>
|
132 |
-
|
133 |
<tr>
|
134 |
<td>
|
135 |
<label for="<?php echo ($f['id']); ?>-automatic_import_author"><?php _e('Automatic import of Authors ?', "rss-post-importer"); ?></label>
|
136 |
-
|
137 |
</td>
|
138 |
<td>
|
139 |
<ul class="radiolist">
|
@@ -145,8 +167,8 @@ if (is_array($f['category_id'])) {
|
|
145 |
</li>
|
146 |
</ul>
|
147 |
</td>
|
148 |
-
</tr>
|
149 |
-
|
150 |
<tr>
|
151 |
<td><label for="<?php echo ($f['id']); ?>-author_id"><?php _e("Feed Author", 'rss-post-importer'); ?></label></td>
|
152 |
<td>
|
@@ -164,11 +186,11 @@ wp_dropdown_users($args);
|
|
164 |
?>
|
165 |
</td>
|
166 |
</tr>
|
167 |
-
|
168 |
<tr>
|
169 |
<td>
|
170 |
<label for="<?php echo ($f['id']); ?>-automatic_import_categories"><?php _e('Automatic import of Categories ?', "rss-post-importer"); ?></label>
|
171 |
-
|
172 |
</td>
|
173 |
<td>
|
174 |
<ul class="radiolist">
|
@@ -181,8 +203,8 @@ wp_dropdown_users($args);
|
|
181 |
</ul>
|
182 |
</td>
|
183 |
</tr>
|
184 |
-
|
185 |
-
|
186 |
<tr>
|
187 |
<td><label for=""><?php _e("Category", 'rss-post-importer'); ?></label></td>
|
188 |
<td>
|
@@ -208,7 +230,7 @@ wp_dropdown_users($args);
|
|
208 |
?>
|
209 |
</td>
|
210 |
</tr>
|
211 |
-
|
212 |
<tr>
|
213 |
<td><label for=""><?php _e("Tags", 'rss-post-importer'); ?></label></td>
|
214 |
<td>
|
@@ -249,7 +271,7 @@ wp_dropdown_users($args);
|
|
249 |
?></textarea>
|
250 |
</td>
|
251 |
</tr>
|
252 |
-
|
253 |
<tr>
|
254 |
<td><label for=""><?php _e("Strip html tags", 'rss-post-importer'); ?></label></td>
|
255 |
<td>
|
@@ -271,3 +293,6 @@ wp_dropdown_users($args);
|
|
271 |
|
272 |
</td>
|
273 |
</tr>
|
|
|
|
|
|
1 |
<?php
|
|
|
2 |
|
3 |
+
if (! isset($ajax_add)) {
|
4 |
+
$ajax_add = false;
|
5 |
+
}
|
6 |
+
if (! isset($ajax_edit)) {
|
7 |
+
$ajax_edit = false;
|
8 |
+
}
|
9 |
+
|
10 |
+
$show = '';
|
11 |
if (!isset($f)) {
|
12 |
$f = array(
|
13 |
+
'id' => isset($ajax_feed_id) ? $ajax_feed_id : 0,
|
14 |
'name' => 'New feed',
|
15 |
'url' => '',
|
16 |
'max_posts' => 5,
|
64 |
|
65 |
?>
|
66 |
|
67 |
+
<?php
|
68 |
+
if ($ajax_add || ! $ajax_edit):
|
69 |
+
?>
|
70 |
<tr id="display_<?php echo ($f['id']); ?>" class="data-row<?php echo $show; ?>" data-fields="name,url,max_posts">
|
71 |
<td class="rss_pi-feed_name">
|
72 |
<strong><a href="#" class="toggle-edit" data-target="<?php echo ($f['id']); ?>"><span class="field-name"><?php echo esc_html(stripslashes($f['name'])); ?></span></a></strong>
|
73 |
<div class="row-options">
|
74 |
+
<?php
|
75 |
+
if (isset($f['feed_status'])): ?>
|
76 |
+
<a href="#" class="toggle-edit" data-target="<?php echo ($f['id']); ?>"><?php _e('Edit', 'rss-post-importer'); ?></a> |
|
77 |
+
<?php
|
78 |
+
endif;
|
79 |
+
?>
|
80 |
<a href="#" class="delete-row" data-target="<?php echo ($f['id']); ?>"><?php _e('Delete', 'rss-post-importer'); ?></a>
|
81 |
+
<?php
|
82 |
+
if(isset($f['feed_status']) && $f['feed_status'] == "active") { ?>
|
83 |
| <a href="#" class="status-row" data-action="pause" data-target="<?php echo ($f['id']); ?>"><?php _e('Pause', 'rss-post-importer'); ?></a>
|
84 |
+
<?php } elseif (isset($f['feed_status']) && $f['feed_status'] == "pause"){ ?>
|
85 |
+
| <a href="#" class="status-row" data-action="enable" data-target="<?php echo ($f['id']); ?>"><?php _e('Enable Feed', 'rss-post-importer'); ?></a>
|
86 |
<?php } ?>
|
87 |
+
|
88 |
</div>
|
89 |
</td>
|
90 |
<td class="rss_pi-feed_url"><span class="field-url"><?php echo esc_url(stripslashes($f['url'])); ?></span></td>
|
91 |
<td class="rss_pi_feed_max_posts"><span class="field-max_posts"><?php echo $f['max_posts']; ?></span></td>
|
92 |
<!-- <td width="20%"><?php //echo $category; ?></td>-->
|
93 |
</tr>
|
94 |
+
<?php
|
95 |
+
endif;
|
96 |
+
?>
|
97 |
+
|
98 |
+
<?php
|
99 |
+
if ($ajax_add || $ajax_edit):
|
100 |
+
?>
|
101 |
<tr id="edit_<?php echo ($f['id']); ?>" class="edit-row<?php echo $show; ?>">
|
102 |
<td colspan="4">
|
103 |
<table class="widefat edit-table">
|
133 |
</li>
|
134 |
</ul>
|
135 |
</td>
|
136 |
+
</tr>
|
137 |
+
|
138 |
<tr>
|
139 |
<td>
|
140 |
<label for="<?php echo ($f['id']); ?>-canonical_urls"><?php _e('SEO canonical URLs ?', "rss-post-importer"); ?></label>
|
150 |
</li>
|
151 |
</ul>
|
152 |
</td>
|
153 |
+
</tr>
|
154 |
+
|
155 |
<tr>
|
156 |
<td>
|
157 |
<label for="<?php echo ($f['id']); ?>-automatic_import_author"><?php _e('Automatic import of Authors ?', "rss-post-importer"); ?></label>
|
158 |
+
|
159 |
</td>
|
160 |
<td>
|
161 |
<ul class="radiolist">
|
167 |
</li>
|
168 |
</ul>
|
169 |
</td>
|
170 |
+
</tr>
|
171 |
+
|
172 |
<tr>
|
173 |
<td><label for="<?php echo ($f['id']); ?>-author_id"><?php _e("Feed Author", 'rss-post-importer'); ?></label></td>
|
174 |
<td>
|
186 |
?>
|
187 |
</td>
|
188 |
</tr>
|
189 |
+
|
190 |
<tr>
|
191 |
<td>
|
192 |
<label for="<?php echo ($f['id']); ?>-automatic_import_categories"><?php _e('Automatic import of Categories ?', "rss-post-importer"); ?></label>
|
193 |
+
|
194 |
</td>
|
195 |
<td>
|
196 |
<ul class="radiolist">
|
203 |
</ul>
|
204 |
</td>
|
205 |
</tr>
|
206 |
+
|
207 |
+
|
208 |
<tr>
|
209 |
<td><label for=""><?php _e("Category", 'rss-post-importer'); ?></label></td>
|
210 |
<td>
|
230 |
?>
|
231 |
</td>
|
232 |
</tr>
|
233 |
+
|
234 |
<tr>
|
235 |
<td><label for=""><?php _e("Tags", 'rss-post-importer'); ?></label></td>
|
236 |
<td>
|
271 |
?></textarea>
|
272 |
</td>
|
273 |
</tr>
|
274 |
+
|
275 |
<tr>
|
276 |
<td><label for=""><?php _e("Strip html tags", 'rss-post-importer'); ?></label></td>
|
277 |
<td>
|
293 |
|
294 |
</td>
|
295 |
</tr>
|
296 |
+
<?php
|
297 |
+
endif;
|
298 |
+
?>
|
app/templates/feed-table.php
CHANGED
@@ -9,13 +9,16 @@
|
|
9 |
</thead>
|
10 |
<tbody class="rss-rows">
|
11 |
<?php
|
12 |
-
|
|
|
13 |
|
14 |
if (is_array($this->options['feeds']) && count($this->options['feeds']) > 0) :
|
15 |
foreach ($this->options['feeds'] as $f) :
|
|
|
|
|
16 |
$category = get_the_category($f['category_id']);
|
17 |
-
array_push($
|
18 |
-
include(
|
19 |
endforeach;
|
20 |
else :
|
21 |
?>
|
@@ -34,17 +37,20 @@
|
|
34 |
<a href="#" class="button button-large button-primary add-row">
|
35 |
<?php _e('Add new feed', "rss-post-importer"); ?>
|
36 |
</a>
|
37 |
-
|
38 |
-
|
|
|
|
|
|
|
39 |
</td>
|
40 |
</tr>
|
41 |
<?php
|
42 |
// preload an empty (and hidden by css) "new feed" row
|
43 |
unset($f);
|
44 |
-
include(
|
45 |
?>
|
46 |
</tfoot>
|
47 |
</table>
|
48 |
<style>
|
49 |
.rss_pi-table tfoot tr.data-row,.rss_pi-table tfoot tr.edit-row{display:none;}
|
50 |
-
</style>
|
9 |
</thead>
|
10 |
<tbody class="rss-rows">
|
11 |
<?php
|
12 |
+
$feed_ids = array();
|
13 |
+
$paused_feeds = array();
|
14 |
|
15 |
if (is_array($this->options['feeds']) && count($this->options['feeds']) > 0) :
|
16 |
foreach ($this->options['feeds'] as $f) :
|
17 |
+
if ($f['feed_status'] == 'pause') array_push($paused_feeds, $f['id']);
|
18 |
+
|
19 |
$category = get_the_category($f['category_id']);
|
20 |
+
//array_push($feed_ids, $f['id']);
|
21 |
+
include(RSS_PI_PATH . 'app/templates/feed-table-row.php');
|
22 |
endforeach;
|
23 |
else :
|
24 |
?>
|
37 |
<a href="#" class="button button-large button-primary add-row">
|
38 |
<?php _e('Add new feed', "rss-post-importer"); ?>
|
39 |
</a>
|
40 |
+
<!--<input type="hidden" name="feed_ids" id="feed_ids" value="<?php echo(join($feed_ids, ',')); ?>" />-->
|
41 |
+
<input type="hidden" name="deleted_feeds" id="deleted_feeds" value="" />
|
42 |
+
<input type="hidden" name="modified_feeds" id="modified_feeds" value="" />
|
43 |
+
<input type="hidden" name="new_feeds" id="new_feeds" value="" />
|
44 |
+
<input type="hidden" id="paused_feeds" name="paused_feeds" value="<?php echo(join($paused_feeds, ',')); ?>" />
|
45 |
</td>
|
46 |
</tr>
|
47 |
<?php
|
48 |
// preload an empty (and hidden by css) "new feed" row
|
49 |
unset($f);
|
50 |
+
include(RSS_PI_PATH . 'app/templates/feed-table-row.php');
|
51 |
?>
|
52 |
</tfoot>
|
53 |
</table>
|
54 |
<style>
|
55 |
.rss_pi-table tfoot tr.data-row,.rss_pi-table tfoot tr.edit-row{display:none;}
|
56 |
+
</style>
|
app/templates/settings-table.php
CHANGED
@@ -15,32 +15,45 @@
|
|
15 |
<p class="description"><?php _e('Custom Frequency in minutes only.', "rss-post-importer"); ?></p>
|
16 |
</td>
|
17 |
<td>
|
18 |
-
<?php
|
19 |
-
$
|
20 |
-
$custom_cron_options = get_option( 'rss_custom_cron_frequency',array());
|
21 |
-
if(!empty($custom_cron_options))
|
22 |
-
|
23 |
-
|
|
|
|
|
24 |
?>
|
25 |
<select name="frequency" id="frequency">
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
|
|
|
|
|
|
38 |
</select>
|
39 |
|
40 |
-
|
41 |
-
<input type="text" id="rss_custom_frequency"
|
42 |
-
|
43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
</td>
|
45 |
</tr>
|
46 |
<tr>
|
@@ -48,8 +61,8 @@
|
|
48 |
<label for="feeds_api_key"><?php _e('Full Text RSS Feed API Key', "rss-post-importer"); ?></label>
|
49 |
<?php if ( ! $this->is_key_valid ) : ?>
|
50 |
<p class="description">
|
51 |
-
<?php _e('Boost Your traffic with Full RSS Content - ', "rss-post-importer"); ?>
|
52 |
-
Request a Free 14 Days <a href="http://www.feedsapi.com/?utm_source=rsspi-full-rss-key-here" target="_blank"> Full RSS Key Here !</a>
|
53 |
</p>
|
54 |
<?php endif; ?>
|
55 |
</td>
|
@@ -138,7 +151,7 @@
|
|
138 |
'selected' => $this->options['settings']['author_id']
|
139 |
);
|
140 |
wp_dropdown_users($args);
|
141 |
-
?>
|
142 |
</td>
|
143 |
</tr>
|
144 |
<tr>
|
@@ -200,7 +213,7 @@
|
|
200 |
<label><input type="radio" id="enable_logging_false" name="enable_logging" value="false" <?php echo($this->options['settings']['enable_logging'] == 'false' || $this->options['settings']['enable_logging'] == '' ? 'checked="checked"' : ''); ?> /> <?php _e('No', 'rss-post-importer'); ?></label>
|
201 |
</li>
|
202 |
</ul>
|
203 |
-
</td>
|
204 |
</tr>
|
205 |
<tr>
|
206 |
<td>
|
@@ -216,7 +229,7 @@
|
|
216 |
<label><input type="radio" id="import_images_locally_false" name="import_images_locally" value="false" <?php echo($this->options['settings']['import_images_locally'] == 'false' || $this->options['settings']['enable_logging'] == '' ? 'checked="checked"' : ''); ?> /> <?php _e('No', 'rss-post-importer'); ?></label>
|
217 |
</li>
|
218 |
</ul>
|
219 |
-
</td>
|
220 |
</tr>
|
221 |
<tr>
|
222 |
<td>
|
@@ -232,7 +245,7 @@
|
|
232 |
<label><input type="radio" id="disable_thumbnail_false" name="disable_thumbnail" value="false" <?php echo($this->options['settings']['disable_thumbnail'] == 'false' || $this->options['settings']['disable_thumbnail'] == '' ? 'checked="checked"' : ''); ?> /> <?php _e('No', 'rss-post-importer'); ?></label>
|
233 |
</li>
|
234 |
</ul>
|
235 |
-
</td>
|
236 |
</tr>
|
237 |
<tr>
|
238 |
<td>
|
@@ -255,7 +268,7 @@
|
|
255 |
<label><input type="radio" id="cache_deleted_false" name="cache_deleted" value="true" <?php echo($this->options['settings']['cache_deleted'] == 'true' || $this->options['settings']['cache_deleted'] == '' ? 'checked="checked"' : ''); ?><?php echo $disabled; ?> /> <?php _e('No', 'rss-post-importer'); ?></label>
|
256 |
</li>
|
257 |
</ul>
|
258 |
-
</td>
|
259 |
</tr>
|
260 |
<?php if ( isset($this->options['upgraded']['deleted_posts']) ) { ?>
|
261 |
<tr>
|
@@ -273,8 +286,8 @@
|
|
273 |
?>
|
274 |
<?php $rss_pi_deleted_posts = count( get_option( 'rss_pi_deleted_posts', array() ) ); ?>
|
275 |
<p><?php printf( _n('Cached: <strong>%d</strong> deleted post', 'Cached: <strong>%d</strong> deleted posts', $rss_pi_deleted_posts, 'rss-post-importer'), $rss_pi_deleted_posts ); ?></p>
|
276 |
-
<input type="submit" value="Purge Cache" name="purge_deleted_cache" class="button button-primary button-large"<?php echo $disabled; ?> />
|
277 |
-
</td>
|
278 |
</tr>
|
279 |
<?php } ?>
|
280 |
<tr>
|
@@ -290,8 +303,8 @@
|
|
290 |
$this->key_error( sprintf( $this->key_prompt, '', 'http://www.feedsapi.com/?utm_source=rsspostimporter&utm_medium=upgrade&utm_term=export-feeds&utm_content=rsspi-full-rss-key-here&utm_campaign=wordpress' ), true );
|
291 |
}
|
292 |
?>
|
293 |
-
<input type="submit" value="Export your Feeds and Setting as CSV File" name="csv_download" class="button button-primary button-large"<?php echo $disabled; ?> />
|
294 |
-
</td>
|
295 |
</tr>
|
296 |
<tr>
|
297 |
<td>
|
@@ -318,7 +331,7 @@ strip_html = strip html tags - "true" or "false"', "rss-post-importer"); ?></p>
|
|
318 |
}
|
319 |
?>
|
320 |
<input type="file" name="import_csv"<?php echo $disabled; ?> />
|
321 |
-
</td>
|
322 |
</tr>
|
323 |
<tr>
|
324 |
<td>
|
@@ -333,8 +346,8 @@ strip_html = strip html tags - "true" or "false"', "rss-post-importer"); ?></p>
|
|
333 |
$this->key_error( sprintf( $this->key_prompt, '', 'http://www.feedsapi.com/?utm_source=rsspostimporter&utm_medium=upgrade&utm_term=export-opml&utm_content=rsspi-full-rss-key-here&utm_campaign=wordpress' ), true );
|
334 |
}
|
335 |
?>
|
336 |
-
<input type="submit" value="Export your Feeds as OPML File" name="export_opml" class="button button-primary button-large"<?php echo $disabled; ?> />
|
337 |
-
</td>
|
338 |
</tr>
|
339 |
<tr>
|
340 |
<td>
|
@@ -350,9 +363,9 @@ strip_html = strip html tags - "true" or "false"', "rss-post-importer"); ?></p>
|
|
350 |
}
|
351 |
?>
|
352 |
<input type="file" name="import_opml"<?php echo $disabled; ?> />
|
353 |
-
</td>
|
354 |
</tr>
|
355 |
-
|
356 |
<tr>
|
357 |
<td>
|
358 |
<?php _e('Social Media Optimization and Open Graph', "rss-post-importer"); ?>
|
@@ -361,19 +374,34 @@ strip_html = strip html tags - "true" or "false"', "rss-post-importer"); ?></p>
|
|
361 |
<td>
|
362 |
<ul class="radiolist">
|
363 |
<li>
|
364 |
-
|
|
|
|
|
|
|
|
|
|
|
365 |
</li>
|
366 |
<li>
|
367 |
-
|
|
|
|
|
|
|
|
|
|
|
368 |
</li>
|
369 |
<li>
|
370 |
-
|
|
|
|
|
|
|
|
|
|
|
371 |
</li>
|
372 |
</ul>
|
373 |
-
</td>
|
374 |
</tr>
|
375 |
-
|
376 |
-
|
377 |
</table>
|
378 |
</td>
|
379 |
</tr>
|
15 |
<p class="description"><?php _e('Custom Frequency in minutes only.', "rss-post-importer"); ?></p>
|
16 |
</td>
|
17 |
<td>
|
18 |
+
<?php
|
19 |
+
$schedules = wp_get_schedules();
|
20 |
+
$custom_cron_options = get_option( 'rss_custom_cron_frequency', array());
|
21 |
+
if (! empty($custom_cron_options)) {
|
22 |
+
$rss_custom_cron = unserialize($custom_cron_options);
|
23 |
+
} else {
|
24 |
+
$rss_custom_cron = array();
|
25 |
+
}
|
26 |
?>
|
27 |
<select name="frequency" id="frequency">
|
28 |
+
<?php
|
29 |
+
foreach (array_keys($schedules) as $interval) :
|
30 |
+
if (empty($rss_custom_cron) || $rss_custom_cron['frequency'] != $interval) :
|
31 |
+
?>
|
32 |
+
<option value="<?php echo $interval; ?>"
|
33 |
+
<?php if ($this->options['settings']['frequency'] == $interval) echo('selected="selected"'); ?>
|
34 |
+
><?php echo $schedules[$interval]['display']; ?></option>
|
35 |
+
<?php
|
36 |
+
endif;
|
37 |
+
endforeach;
|
38 |
+
?>
|
39 |
+
|
40 |
+
<option value="custom_frequency"
|
41 |
+
<?php if (isset($this->options['settings']['custom_frequency']) && $this->options['settings']['custom_frequency'] == "true") echo('selected="selected"'); ?>
|
42 |
+
><?php _e('Custom frequency', "rss-post-importer"); ?></option>
|
43 |
</select>
|
44 |
|
45 |
+
|
46 |
+
<input type="text" id="rss_custom_frequency" name="rss_custom_frequency" value="<?php echo(isset($rss_custom_cron['time']) ? $rss_custom_cron['time'] : ''); ?>" placeholder="Minutes"
|
47 |
+
<?php
|
48 |
+
if (isset($this->options['settings']['custom_frequency']) && $this->options['settings']['custom_frequency'] == 'true') {
|
49 |
+
echo('style="display:inline"');
|
50 |
+
} else {
|
51 |
+
echo('style="display:none"');
|
52 |
+
}
|
53 |
+
?>
|
54 |
+
/>
|
55 |
+
|
56 |
+
|
57 |
</td>
|
58 |
</tr>
|
59 |
<tr>
|
61 |
<label for="feeds_api_key"><?php _e('Full Text RSS Feed API Key', "rss-post-importer"); ?></label>
|
62 |
<?php if ( ! $this->is_key_valid ) : ?>
|
63 |
<p class="description">
|
64 |
+
<?php _e('Boost Your traffic with Full RSS Content - ', "rss-post-importer"); ?>
|
65 |
+
Request a Free 14 Days <a href="http://www.feedsapi.com/?utm_source=rsspi-full-rss-key-here" target="_blank"> Full RSS Key Here !</a>
|
66 |
</p>
|
67 |
<?php endif; ?>
|
68 |
</td>
|
151 |
'selected' => $this->options['settings']['author_id']
|
152 |
);
|
153 |
wp_dropdown_users($args);
|
154 |
+
?>
|
155 |
</td>
|
156 |
</tr>
|
157 |
<tr>
|
213 |
<label><input type="radio" id="enable_logging_false" name="enable_logging" value="false" <?php echo($this->options['settings']['enable_logging'] == 'false' || $this->options['settings']['enable_logging'] == '' ? 'checked="checked"' : ''); ?> /> <?php _e('No', 'rss-post-importer'); ?></label>
|
214 |
</li>
|
215 |
</ul>
|
216 |
+
</td>
|
217 |
</tr>
|
218 |
<tr>
|
219 |
<td>
|
229 |
<label><input type="radio" id="import_images_locally_false" name="import_images_locally" value="false" <?php echo($this->options['settings']['import_images_locally'] == 'false' || $this->options['settings']['enable_logging'] == '' ? 'checked="checked"' : ''); ?> /> <?php _e('No', 'rss-post-importer'); ?></label>
|
230 |
</li>
|
231 |
</ul>
|
232 |
+
</td>
|
233 |
</tr>
|
234 |
<tr>
|
235 |
<td>
|
245 |
<label><input type="radio" id="disable_thumbnail_false" name="disable_thumbnail" value="false" <?php echo($this->options['settings']['disable_thumbnail'] == 'false' || $this->options['settings']['disable_thumbnail'] == '' ? 'checked="checked"' : ''); ?> /> <?php _e('No', 'rss-post-importer'); ?></label>
|
246 |
</li>
|
247 |
</ul>
|
248 |
+
</td>
|
249 |
</tr>
|
250 |
<tr>
|
251 |
<td>
|
268 |
<label><input type="radio" id="cache_deleted_false" name="cache_deleted" value="true" <?php echo($this->options['settings']['cache_deleted'] == 'true' || $this->options['settings']['cache_deleted'] == '' ? 'checked="checked"' : ''); ?><?php echo $disabled; ?> /> <?php _e('No', 'rss-post-importer'); ?></label>
|
269 |
</li>
|
270 |
</ul>
|
271 |
+
</td>
|
272 |
</tr>
|
273 |
<?php if ( isset($this->options['upgraded']['deleted_posts']) ) { ?>
|
274 |
<tr>
|
286 |
?>
|
287 |
<?php $rss_pi_deleted_posts = count( get_option( 'rss_pi_deleted_posts', array() ) ); ?>
|
288 |
<p><?php printf( _n('Cached: <strong>%d</strong> deleted post', 'Cached: <strong>%d</strong> deleted posts', $rss_pi_deleted_posts, 'rss-post-importer'), $rss_pi_deleted_posts ); ?></p>
|
289 |
+
<input type="submit" value="Purge Cache" name="purge_deleted_cache" class="button button-primary button-large"<?php echo $disabled; ?> />
|
290 |
+
</td>
|
291 |
</tr>
|
292 |
<?php } ?>
|
293 |
<tr>
|
303 |
$this->key_error( sprintf( $this->key_prompt, '', 'http://www.feedsapi.com/?utm_source=rsspostimporter&utm_medium=upgrade&utm_term=export-feeds&utm_content=rsspi-full-rss-key-here&utm_campaign=wordpress' ), true );
|
304 |
}
|
305 |
?>
|
306 |
+
<input type="submit" value="Export your Feeds and Setting as CSV File" name="csv_download" class="button button-primary button-large"<?php echo $disabled; ?> />
|
307 |
+
</td>
|
308 |
</tr>
|
309 |
<tr>
|
310 |
<td>
|
331 |
}
|
332 |
?>
|
333 |
<input type="file" name="import_csv"<?php echo $disabled; ?> />
|
334 |
+
</td>
|
335 |
</tr>
|
336 |
<tr>
|
337 |
<td>
|
346 |
$this->key_error( sprintf( $this->key_prompt, '', 'http://www.feedsapi.com/?utm_source=rsspostimporter&utm_medium=upgrade&utm_term=export-opml&utm_content=rsspi-full-rss-key-here&utm_campaign=wordpress' ), true );
|
347 |
}
|
348 |
?>
|
349 |
+
<input type="submit" value="Export your Feeds as OPML File" name="export_opml" class="button button-primary button-large"<?php echo $disabled; ?> />
|
350 |
+
</td>
|
351 |
</tr>
|
352 |
<tr>
|
353 |
<td>
|
363 |
}
|
364 |
?>
|
365 |
<input type="file" name="import_opml"<?php echo $disabled; ?> />
|
366 |
+
</td>
|
367 |
</tr>
|
368 |
+
|
369 |
<tr>
|
370 |
<td>
|
371 |
<?php _e('Social Media Optimization and Open Graph', "rss-post-importer"); ?>
|
374 |
<td>
|
375 |
<ul class="radiolist">
|
376 |
<li>
|
377 |
+
<label>
|
378 |
+
<input type="checkbox" name="tw_show" id="tw_show" value="1"
|
379 |
+
<?php echo(isset($this->options['settings']['tw_show']) && $this->options['settings']['tw_show'] == '1' ? 'checked="checked"' : ''); ?>
|
380 |
+
/>
|
381 |
+
<?php _e('Twitter', 'rss-post-importer'); ?>
|
382 |
+
</label>
|
383 |
</li>
|
384 |
<li>
|
385 |
+
<label>
|
386 |
+
<input type="checkbox" name="gg_show" id="gg_show" value="1"
|
387 |
+
<?php echo(isset($this->options['settings']['gg_show']) && $this->options['settings']['gg_show'] == '1' ? 'checked="checked"' : ''); ?>
|
388 |
+
/>
|
389 |
+
<?php _e('Google+', 'rss-post-importer'); ?>
|
390 |
+
</label>
|
391 |
</li>
|
392 |
<li>
|
393 |
+
<label>
|
394 |
+
<input type="checkbox" name="og_show" id="og_show" value="1"
|
395 |
+
<?php echo(isset($this->options['settings']['og_show']) && $this->options['settings']['og_show'] == '1' ? 'checked="checked"' : ''); ?>
|
396 |
+
/>
|
397 |
+
<?php _e('Facebook Opengraph', 'rss-post-importer'); ?>
|
398 |
+
</label>
|
399 |
</li>
|
400 |
</ul>
|
401 |
+
</td>
|
402 |
</tr>
|
403 |
+
|
404 |
+
|
405 |
</table>
|
406 |
</td>
|
407 |
</tr>
|
index.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
Plugin URI: https://wordpress.org/plugins/rss-post-importer/
|
6 |
Description: This plugin lets you set up an import posts from one or several rss-feeds and save them as posts on your site, simple and flexible.
|
7 |
Author: feedsapi
|
8 |
-
Version: 2.
|
9 |
Author URI: https://www.feedsapi.org/
|
10 |
License: GPLv2 or later
|
11 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
@@ -32,7 +32,7 @@ if (!defined('RSS_PI_BASENAME')) {
|
|
32 |
}
|
33 |
|
34 |
if (!defined('RSS_PI_VERSION')) {
|
35 |
-
define('RSS_PI_VERSION', '2.
|
36 |
}
|
37 |
|
38 |
if (!defined('RSS_PI_LOG_PATH')) {
|
5 |
Plugin URI: https://wordpress.org/plugins/rss-post-importer/
|
6 |
Description: This plugin lets you set up an import posts from one or several rss-feeds and save them as posts on your site, simple and flexible.
|
7 |
Author: feedsapi
|
8 |
+
Version: 2.4.0
|
9 |
Author URI: https://www.feedsapi.org/
|
10 |
License: GPLv2 or later
|
11 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
32 |
}
|
33 |
|
34 |
if (!defined('RSS_PI_VERSION')) {
|
35 |
+
define('RSS_PI_VERSION', '2.4.0');
|
36 |
}
|
37 |
|
38 |
if (!defined('RSS_PI_LOG_PATH')) {
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: feedsapi
|
|
3 |
Donate link: https://www.feedsapi.org/
|
4 |
Tags: rss aggregation, wordpress autoblog aggregator, Autoblogger, rss autopost and syndicator, blog content curation, feedsyndicate, feedwordpress, multiple rss feed importer, rss feeds to post, content syndication, blog migration, yahoo pipes
|
5 |
Requires at least: 3.5
|
6 |
-
Tested up to: 4.
|
7 |
-
Stable tag: 2.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -128,6 +128,9 @@ Learn more (and get detailed instructions) in our [contribute guide](http://jetp
|
|
128 |
|
129 |
== Change Log ==
|
130 |
|
|
|
|
|
|
|
131 |
= Version 2.3.0 =
|
132 |
* Featured Image Fix
|
133 |
* Logs Fix
|
@@ -297,4 +300,4 @@ Learn more (and get detailed instructions) in our [contribute guide](http://jetp
|
|
297 |
* Added possibility to log each time imports are made in a textfile (for debugging purposes).
|
298 |
|
299 |
= Version 1.0.1 =
|
300 |
-
* Fixed some localization issues.
|
3 |
Donate link: https://www.feedsapi.org/
|
4 |
Tags: rss aggregation, wordpress autoblog aggregator, Autoblogger, rss autopost and syndicator, blog content curation, feedsyndicate, feedwordpress, multiple rss feed importer, rss feeds to post, content syndication, blog migration, yahoo pipes
|
5 |
Requires at least: 3.5
|
6 |
+
Tested up to: 4.7.4
|
7 |
+
Stable tag: 2.4.0
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
128 |
|
129 |
== Change Log ==
|
130 |
|
131 |
+
= Version 2.4.0 =
|
132 |
+
* Several bugs fixing and stability improvement
|
133 |
+
|
134 |
= Version 2.3.0 =
|
135 |
* Featured Image Fix
|
136 |
* Logs Fix
|
300 |
* Added possibility to log each time imports are made in a textfile (for debugging purposes).
|
301 |
|
302 |
= Version 1.0.1 =
|
303 |
+
* Fixed some localization issues.
|