RSS Post Importer - Version 2.0.10

Version Description

Download this release

Release Info

Developer promz
Plugin Icon 128x128 RSS Post Importer
Version 2.0.10
Comparing to
See all releases

Code changes from version 2.0.9 to 2.0.10

app/assets/font/fontawesome-webfont.eot CHANGED
File without changes
app/assets/font/fontawesome-webfont.svg CHANGED
File without changes
app/assets/font/fontawesome-webfont.ttf CHANGED
File without changes
app/assets/font/fontawesome-webfont.woff CHANGED
File without changes
app/class-rss-post-importer.php CHANGED
@@ -98,7 +98,9 @@ class rssPostImporter {
98
 
99
  'nofollow_outbound' => true,
100
 
101
- 'keywords' => array()
 
 
102
 
103
  );
104
 
@@ -252,5 +254,6 @@ class rssPostImporter {
252
 
253
 
254
 
 
255
  }
256
 
98
 
99
  'nofollow_outbound' => true,
100
 
101
+ 'keywords' => array(),
102
+
103
+ 'import_images_locally' => false
104
 
105
  );
106
 
254
 
255
 
256
 
257
+
258
  }
259
 
app/classes/admin/class-rss-pi-admin-processor.php CHANGED
@@ -1,216 +1,434 @@
1
- <?php
2
-
3
- /**
4
- * Processes the admin screen form submissions
5
- *
6
- * @author Saurabh Shukla <saurabh@yapapaya.com>
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
- * @return null
21
- */
22
- function process() {
23
-
24
- // if there's nothing for processing or invalid data, bail
25
- if (!isset($_POST['info_update']) || !wp_verify_nonce($_POST['rss_pi_nonce'], 'settings_page')) {
26
- return;
27
- }
28
-
29
- // Get ids of feed-rows
30
- $ids = explode(",", $_POST['ids']);
31
-
32
- // formulate the settings array
33
- $settings = $this->process_settings();
34
-
35
- // update cron settings
36
- $this->update_cron($settings['frequency']);
37
-
38
- // formulate the feeds array
39
- $feeds = $this->process_feeds($ids);
40
-
41
- // save and reload the options
42
- $this->save_reload_options($settings, $feeds);
43
-
44
- // display a success message
45
- ?>
46
- <div id="message" class="updated">
47
- <p><strong><?php _e('Settings saved.', 'rss_pi') ?></strong></p>
48
- </div>
49
- <?php
50
- // check if we need to and import feeds
51
- $this->import();
52
- }
53
-
54
- /**
55
- * Process submitted data to formulate settings array
56
- *
57
- * @global object $rss_post_importer
58
- * @return array
59
- */
60
- private function process_settings() {
61
-
62
- // Get selected settings for all imported posts
63
- $settings = array(
64
- 'frequency' => $_POST['frequency'],
65
- 'feeds_api_key' => $_POST['feeds_api_key'],
66
- 'post_template' => stripslashes_deep($_POST['post_template']),
67
- 'post_status' => $_POST['post_status'],
68
- 'author_id' => $_POST['author_id'],
69
- 'allow_comments' => $_POST['allow_comments'],
70
- 'block_indexing' => $_POST['block_indexing'],
71
- 'nofollow_outbound' => $_POST['nofollow_outbound'],
72
- 'enable_logging' => $_POST['enable_logging'],
73
- 'keywords' => array()
74
- );
75
-
76
- global $rss_post_importer;
77
-
78
- // check if submitted api key is valid
79
- $this->is_key_valid = $rss_post_importer->is_valid_key($settings['feeds_api_key']);
80
-
81
- // filter the settings and then send them back for saving
82
- return $this->filter($settings);
83
- }
84
-
85
- /**
86
- * Update the frequency of the import cron job
87
- *
88
- * @param string $frequency
89
- */
90
- private function update_cron($frequency) {
91
-
92
- // If cron settings have changed
93
- if (wp_get_schedule('rss_pi_cron') != $frequency) {
94
-
95
- // Reset cron
96
- wp_clear_scheduled_hook('rss_pi_cron');
97
- wp_schedule_event(time(), $frequency, 'rss_pi_cron');
98
- }
99
- }
100
-
101
- /**
102
- * Forms the feeds array from submitted data
103
- *
104
- * @param array $ids feeds ids
105
- * @return array
106
- */
107
- private function process_feeds($ids) {
108
-
109
- $feeds = array();
110
-
111
- foreach ($ids as $id) {
112
- if ($id) {
113
- array_push($feeds, array(
114
- 'id' => $id,
115
- 'url' => strtolower($_POST[$id . '-url']),
116
- 'name' => $_POST[$id . '-name'],
117
- 'max_posts' => $_POST[$id . '-max_posts'],
118
- // different author ids depending on valid API keys
119
- 'author_id' => $this->is_key_valid ? $_POST[$id . '-author_id'] : $_POST['author_id'],
120
- 'category_id' => $_POST[$id . '-category_id'],
121
- 'tags_id' => $_POST[$id . '-tags_id'],
122
- 'strip_html' => $_POST[$id . '-strip_html']
123
- ));
124
- }
125
- }
126
-
127
- return $feeds;
128
- }
129
-
130
- /**
131
- * Update options and reload global options
132
- *
133
- * @global type $rss_post_importer
134
- * @param array $settings
135
- * @param array $feeds
136
- */
137
- private function save_reload_options($settings, $feeds) {
138
-
139
- global $rss_post_importer;
140
-
141
- // existing options
142
- $options = $rss_post_importer->options;
143
-
144
- // new data
145
- $new_options = array(
146
- 'feeds' => $feeds,
147
- 'settings' => $settings,
148
- 'latest_import' => $options['latest_import'],
149
- 'imports' => $options['imports']
150
- );
151
-
152
- // update in db
153
- update_option('rss_pi_feeds', $new_options);
154
-
155
- // reload so that the new options are used henceforth
156
- $rss_post_importer->load_options();
157
- }
158
-
159
- /**
160
- * Import feeds
161
- *
162
- * @return null
163
- */
164
- private function import() {
165
-
166
- // if we don't need to import anything, bail
167
- if ($_POST['save_to_db'] != 'true') {
168
- return;
169
- }
170
-
171
- // initialise the engine and import
172
- $engine = new rssPIEngine();
173
- $imported = $engine->import_feed();
174
- ?>
175
- <div id="message" class="updated">
176
- <p><strong><?php echo($imported); ?> <?php _e('new posts imported.', 'rss_pi') ?></strong></p>
177
- </div>
178
- <?php
179
- }
180
-
181
- /**
182
- * Filter settings for API key vs non-API key installs
183
- *
184
- * @param array $settings
185
- * @return array
186
- */
187
- private function filter($settings) {
188
-
189
- // if the key is not fine
190
- if (!empty($settings['feeds_api_key']) && !$this->is_key_valid) {
191
-
192
- // unset from settings
193
- unset($settings['feeds_api_key']);
194
- echo '<div class="error">
195
- <p>' . __('Invalid API key!', 'rss_api') . '</p>
196
- </div>';
197
- }
198
-
199
- // if the key is valid
200
- if ($this->is_key_valid) {
201
-
202
- // set up keywords (otherwise don't)
203
- $keyword_str = $_POST['keyword_filter'];
204
-
205
- $keywords = array();
206
-
207
- if (!empty($keyword_str)) {
208
- $keywords = explode(',', $keyword_str);
209
- }
210
- $settings['keywords'] = $keywords;
211
- }
212
-
213
- return $settings;
214
- }
215
-
216
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+
5
+ /**
6
+
7
+ * Processes the admin screen form submissions
8
+
9
+ *
10
+
11
+ * @author Saurabh Shukla <saurabh@yapapaya.com>
12
+
13
+ */
14
+
15
+ class rssPIAdminProcessor {
16
+
17
+
18
+
19
+ /**
20
+
21
+ * If we have a valid api key
22
+
23
+ *
24
+
25
+ * @var boolean
26
+
27
+ */
28
+
29
+ var $is_key_valid;
30
+
31
+
32
+
33
+ /**
34
+
35
+ * Process the form result
36
+
37
+ *
38
+
39
+ * @return null
40
+
41
+ */
42
+
43
+ function process() {
44
+
45
+
46
+
47
+ // if there's nothing for processing or invalid data, bail
48
+
49
+ if (!isset($_POST['info_update']) || !wp_verify_nonce($_POST['rss_pi_nonce'], 'settings_page')) {
50
+
51
+ return;
52
+
53
+ }
54
+
55
+
56
+
57
+ // Get ids of feed-rows
58
+
59
+ $ids = explode(",", $_POST['ids']);
60
+
61
+
62
+
63
+ // formulate the settings array
64
+
65
+ $settings = $this->process_settings();
66
+
67
+
68
+
69
+ // update cron settings
70
+
71
+ $this->update_cron($settings['frequency']);
72
+
73
+
74
+
75
+ // formulate the feeds array
76
+
77
+ $feeds = $this->process_feeds($ids);
78
+
79
+
80
+
81
+ // save and reload the options
82
+
83
+ $this->save_reload_options($settings, $feeds);
84
+
85
+
86
+
87
+ // display a success message
88
+
89
+ ?>
90
+
91
+ <div id="message" class="updated">
92
+
93
+ <p><strong><?php _e('Settings saved.', 'rss_pi') ?></strong></p>
94
+
95
+ </div>
96
+
97
+ <?php
98
+
99
+ // check if we need to and import feeds
100
+
101
+ $this->import();
102
+
103
+ }
104
+
105
+
106
+
107
+ /**
108
+
109
+ * Process submitted data to formulate settings array
110
+
111
+ *
112
+
113
+ * @global object $rss_post_importer
114
+
115
+ * @return array
116
+
117
+ */
118
+
119
+ private function process_settings() {
120
+
121
+
122
+
123
+ // Get selected settings for all imported posts
124
+
125
+ $settings = array(
126
+
127
+ 'frequency' => $_POST['frequency'],
128
+
129
+ 'feeds_api_key' => $_POST['feeds_api_key'],
130
+
131
+ 'post_template' => stripslashes_deep($_POST['post_template']),
132
+
133
+ 'post_status' => $_POST['post_status'],
134
+
135
+ 'author_id' => $_POST['author_id'],
136
+
137
+ 'allow_comments' => $_POST['allow_comments'],
138
+
139
+ 'block_indexing' => $_POST['block_indexing'],
140
+
141
+ 'nofollow_outbound' => $_POST['nofollow_outbound'],
142
+
143
+ 'enable_logging' => $_POST['enable_logging'],
144
+
145
+ 'import_images_locally' => $_POST['import_images_locally'],
146
+
147
+ 'keywords' => array()
148
+
149
+ );
150
+
151
+
152
+
153
+ global $rss_post_importer;
154
+
155
+
156
+
157
+ // check if submitted api key is valid
158
+
159
+ $this->is_key_valid = $rss_post_importer->is_valid_key($settings['feeds_api_key']);
160
+
161
+
162
+
163
+ // filter the settings and then send them back for saving
164
+
165
+ return $this->filter($settings);
166
+
167
+ }
168
+
169
+
170
+
171
+ /**
172
+
173
+ * Update the frequency of the import cron job
174
+
175
+ *
176
+
177
+ * @param string $frequency
178
+
179
+ */
180
+
181
+ private function update_cron($frequency) {
182
+
183
+
184
+
185
+ // If cron settings have changed
186
+
187
+ if (wp_get_schedule('rss_pi_cron') != $frequency) {
188
+
189
+
190
+
191
+ // Reset cron
192
+
193
+ wp_clear_scheduled_hook('rss_pi_cron');
194
+
195
+ wp_schedule_event(time(), $frequency, 'rss_pi_cron');
196
+
197
+ }
198
+
199
+ }
200
+
201
+
202
+
203
+ /**
204
+
205
+ * Forms the feeds array from submitted data
206
+
207
+ *
208
+
209
+ * @param array $ids feeds ids
210
+
211
+ * @return array
212
+
213
+ */
214
+
215
+ private function process_feeds($ids) {
216
+
217
+
218
+
219
+ $feeds = array();
220
+
221
+
222
+
223
+ foreach ($ids as $id) {
224
+
225
+ if ($id) {
226
+
227
+ array_push($feeds, array(
228
+
229
+ 'id' => $id,
230
+
231
+ 'url' => strtolower($_POST[$id . '-url']),
232
+
233
+ 'name' => $_POST[$id . '-name'],
234
+
235
+ 'max_posts' => $_POST[$id . '-max_posts'],
236
+
237
+ // different author ids depending on valid API keys
238
+
239
+ 'author_id' => $this->is_key_valid ? $_POST[$id . '-author_id'] : $_POST['author_id'],
240
+
241
+ 'category_id' => $_POST[$id . '-category_id'],
242
+
243
+ 'tags_id' => $_POST[$id . '-tags_id'],
244
+
245
+ 'strip_html' => $_POST[$id . '-strip_html']
246
+
247
+ ));
248
+
249
+ }
250
+
251
+ }
252
+
253
+
254
+
255
+ return $feeds;
256
+
257
+ }
258
+
259
+
260
+
261
+ /**
262
+
263
+ * Update options and reload global options
264
+
265
+ *
266
+
267
+ * @global type $rss_post_importer
268
+
269
+ * @param array $settings
270
+
271
+ * @param array $feeds
272
+
273
+ */
274
+
275
+ private function save_reload_options($settings, $feeds) {
276
+
277
+
278
+
279
+ global $rss_post_importer;
280
+
281
+
282
+
283
+ // existing options
284
+
285
+ $options = $rss_post_importer->options;
286
+
287
+
288
+
289
+ // new data
290
+
291
+ $new_options = array(
292
+
293
+ 'feeds' => $feeds,
294
+
295
+ 'settings' => $settings,
296
+
297
+ 'latest_import' => $options['latest_import'],
298
+
299
+ 'imports' => $options['imports']
300
+
301
+ );
302
+
303
+
304
+
305
+ // update in db
306
+
307
+ update_option('rss_pi_feeds', $new_options);
308
+
309
+
310
+
311
+ // reload so that the new options are used henceforth
312
+
313
+ $rss_post_importer->load_options();
314
+
315
+ }
316
+
317
+
318
+
319
+ /**
320
+
321
+ * Import feeds
322
+
323
+ *
324
+
325
+ * @return null
326
+
327
+ */
328
+
329
+ private function import() {
330
+
331
+
332
+
333
+ // if we don't need to import anything, bail
334
+
335
+ if ($_POST['save_to_db'] != 'true') {
336
+
337
+ return;
338
+
339
+ }
340
+
341
+
342
+
343
+ // initialise the engine and import
344
+
345
+ $engine = new rssPIEngine();
346
+
347
+ $imported = $engine->import_feed();
348
+
349
+ ?>
350
+
351
+ <div id="message" class="updated">
352
+
353
+ <p><strong><?php echo($imported); ?> <?php _e('new posts imported.', 'rss_pi') ?></strong></p>
354
+
355
+ </div>
356
+
357
+ <?php
358
+
359
+ }
360
+
361
+
362
+
363
+ /**
364
+
365
+ * Filter settings for API key vs non-API key installs
366
+
367
+ *
368
+
369
+ * @param array $settings
370
+
371
+ * @return array
372
+
373
+ */
374
+
375
+ private function filter($settings) {
376
+
377
+
378
+
379
+ // if the key is not fine
380
+
381
+ if (!empty($settings['feeds_api_key']) && !$this->is_key_valid) {
382
+
383
+
384
+
385
+ // unset from settings
386
+
387
+ unset($settings['feeds_api_key']);
388
+
389
+ echo '<div class="error">
390
+
391
+ <p>' . __('Invalid API key!', 'rss_api') . '</p>
392
+
393
+ </div>';
394
+
395
+ }
396
+
397
+
398
+
399
+ // if the key is valid
400
+
401
+ if ($this->is_key_valid) {
402
+
403
+
404
+
405
+ // set up keywords (otherwise don't)
406
+
407
+ $keyword_str = $_POST['keyword_filter'];
408
+
409
+
410
+
411
+ $keywords = array();
412
+
413
+
414
+
415
+ if (!empty($keyword_str)) {
416
+
417
+ $keywords = explode(',', $keyword_str);
418
+
419
+ }
420
+
421
+ $settings['keywords'] = $keywords;
422
+
423
+ }
424
+
425
+
426
+
427
+ return $settings;
428
+
429
+ }
430
+
431
+
432
+
433
+ }
434
+
app/classes/admin/class-rss-pi-admin.php CHANGED
@@ -1,285 +1,285 @@
1
- <?php
2
-
3
- /**
4
- * The class that handles the admin screen
5
- *
6
- * @author saurabhshukla
7
- */
8
- 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
-
24
- /**
25
- * Aprompt for invalid/absent API keys
26
- * @var string
27
- */
28
- var $key_prompt;
29
-
30
- /**
31
- * Start
32
- *
33
- * @global object $rss_post_importer
34
- */
35
- public function __construct() {
36
-
37
- $this->load_options();
38
-
39
- // add a key prompt
40
- $this->key_prompt = __('You need a <a href="http://www.feedsapi.com/?utm_source=rsspi-full-rss-key-here" target="_blank">Full Text RSS Key</a> to activate this section, please <a href="http://www.feedsapi.com/?utm_source=rsspi-full-rss-key-here" target="_blank">get one and try it free</a> for the next 14 days to see how it goes.', 'rss_pi');
41
-
42
- $this->key_prompt_multiple_category = __('Multiple Category selection available.You need a <a href="http://www.feedsapi.com/?utm_source=rsspi-full-rss-key-here" target="_blank">Full Text RSS Key</a> to activate this section, please <a href="http://www.feedsapi.com/?utm_source=rsspi-full-rss-key-here" target="_blank">get one and try it free</a> for the next 14 days to see how it goes.', 'rss_pi');
43
- $this->key_prompt_multiple_tags = __('Multiple Tags selection available.You need a <a href="http://www.feedsapi.com/?utm_source=rsspi-full-rss-key-here" target="_blank">Full Text RSS Key</a> to activate this section, please <a href="http://www.feedsapi.com/?utm_source=rsspi-full-rss-key-here" target="_blank">get one and try it free</a> for the next 14 days to see how it goes.', 'rss_pi');
44
-
45
- // initialise logging
46
- $this->log = new rssPILog();
47
- $this->log->init();
48
-
49
- // load the form processor
50
- $this->processor = new rssPIAdminProcessor();
51
- }
52
-
53
- private function load_options(){
54
- global $rss_post_importer;
55
-
56
- // add options
57
- $this->options = $rss_post_importer->options;
58
-
59
- // check if key is valid
60
- $this->is_key_valid = $rss_post_importer->is_valid_key($this->options['settings']['feeds_api_key']);
61
- }
62
-
63
- /**
64
- * Initialise and hook all actions
65
- */
66
- public function init() {
67
-
68
- // add to admin menu
69
- add_action('admin_menu', array($this, 'admin_menu'));
70
-
71
- // load scripts and styles we need
72
- add_action('admin_enqueue_scripts', array($this, 'enqueue'));
73
-
74
- // the ajax for adding new feeds (table rows)
75
- add_action('wp_ajax_rss_pi_add_row', array($this, 'add_row'));
76
-
77
- // disable the feed author dropdown for invalid/absent API keys
78
- add_filter('wp_dropdown_users', array($this, 'disable_user_dropdown'));
79
-
80
- // Add 10 minutes in frequency.
81
- add_filter('cron_schedules', array($this, 'rss_pi_cron_add'));
82
- }
83
-
84
- /**
85
- * Add to admin menu
86
- */
87
- function admin_menu() {
88
-
89
- add_options_page('Rss Post Importer', 'Rss Post Importer', 'manage_options', 'rss_pi', array($this, 'screen'));
90
- }
91
-
92
- /**
93
- * Enqueue our admin css and js
94
- *
95
- * @param string $hook The current screens hook
96
- * @return null
97
- */
98
- public function enqueue($hook) {
99
-
100
- // don't load if it isn't our screen
101
- if ($hook != 'settings_page_rss_pi') {
102
- return;
103
- }
104
-
105
- // register scripts & styles
106
- wp_enqueue_script('rss-pi', RSS_PI_URL . 'app/assets/js/main.js', array('jquery'), RSS_PI_VERSION);
107
- wp_enqueue_style('rss-pi', RSS_PI_URL . 'app/assets/css/style.css', array(), RSS_PI_VERSION);
108
-
109
- // localise ajaxuel for use
110
- $localise_args = array(
111
- 'ajaxurl' => admin_url('admin-ajax.php')
112
- );
113
- wp_localize_script('rss-pi', 'rss_pi', $localise_args);
114
- }
115
- function rss_pi_cron_add($schedules){
116
- $schedules['minutes_10'] = array(
117
- 'interval' => 600,
118
- 'display'=> '10 minutes'
119
- );
120
- return $schedules;
121
- }
122
- /**
123
- * Display the screen/ui
124
- */
125
- function screen() {
126
-
127
- // load the form processor first
128
- $this->processor->process();
129
- // it'll process any submitted form data
130
-
131
- // reload the options just in case
132
- $this->load_options();
133
-
134
- // include the template for the ui
135
- include( RSS_PI_PATH . 'app/templates/admin-ui.php');
136
- }
137
-
138
- /**
139
- * Display errors
140
- *
141
- * @param string $error The error message
142
- * @param boolean $inline Whether the error is inline or shown like regular wp errors
143
- */
144
- function key_error($error, $inline = false) {
145
-
146
- $class = ($inline) ? 'rss-pi-error' : 'error';
147
-
148
- echo '<div class="' . $class . '"><p>' . $error . '</p></div>';
149
- }
150
-
151
- /**
152
- * Add a new row for a new feed
153
- */
154
- function add_row() {
155
-
156
- include( RSS_PI_PATH . 'app/templates/feed-table-row.php');
157
- die();
158
- }
159
-
160
- /**
161
- * Disable the user dropdwon for each feed
162
- *
163
- * @param string $output The html of the select dropdown
164
- * @return string
165
- */
166
- function disable_user_dropdown($output) {
167
-
168
- // if we have a valid key we don't need to disable anything
169
- if ($this->is_key_valid) {
170
- return $output;
171
- }
172
-
173
- // check if this is the feed dropdown (and not any other)
174
- preg_match('/rss-pi-specific-feed-author/i', $output, $matched);
175
-
176
- // this is not our dropdown, no need to disable
177
- if (empty($matched)) {
178
- return $output;
179
- }
180
-
181
- // otherwise just disable the dropdown
182
- return str_replace('<select ', '<select disabled="disabled" ', $output);
183
- }
184
- /**
185
- * Walker class function for category multiple checkbox
186
- *
187
- *
188
- *
189
- */
190
- function wp_category_checklist_rss_pi($post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $walker = null, $checked_ontop = true)
191
- {
192
- $cat = "";
193
- if (empty($walker) || !is_a($walker, 'Walker'))
194
- $walker = new Walker_Category_Checklist;
195
- $descendants_and_self = (int) $descendants_and_self;
196
- $args = array();
197
- if (is_array($selected_cats))
198
- $args['selected_cats'] = $selected_cats;
199
- elseif ($post_id)
200
- $args['selected_cats'] = wp_get_post_categories($post_id);
201
- else
202
- $args['selected_cats'] = array();
203
-
204
- if ($descendants_and_self) {
205
- $categories = get_categories("child_of=$descendants_and_self&hierarchical=0&hide_empty=0");
206
- $self = get_category($descendants_and_self);
207
- array_unshift($categories, $self);
208
- } else {
209
- $categories = get_categories('get=all');
210
- }
211
- if ($checked_ontop) {
212
- // Post process $categories rather than adding an exclude to the get_terms() query to keep the query the same across all posts (for any query cache)
213
- $checked_categories = array();
214
- $keys = array_keys($categories);
215
- foreach ($keys as $k) {
216
- if (in_array($categories[$k]->term_id, $args['selected_cats'])) {
217
- $checked_categories[] = $categories[$k];
218
- unset($categories[$k]);
219
- }
220
- }
221
- // Put checked cats on top
222
- $cat = $cat . call_user_func_array(array(
223
- &$walker,
224
- 'walk'
225
- ), array(
226
- $checked_categories,
227
- 0,
228
- $args
229
- ));
230
- }
231
- // Then the rest of them
232
- $cat = $cat . call_user_func_array(array(
233
- &$walker,
234
- 'walk'
235
- ), array(
236
- $categories,
237
- 0,
238
- $args
239
- ));
240
- return $cat;
241
- }
242
-
243
- function rss_pi_tags_dropdown($fid,$seleced_tags){
244
- if ($tags = get_tags( array('orderby' => 'name','hide_empty' => false) ))
245
- {
246
-
247
- echo '<select name="'.$fid.'-tags_id[]" id="tag" class="postform">';
248
-
249
- foreach ($tags as $tag)
250
- {
251
- $strsel = "";
252
- if(!empty($seleced_tags)){
253
-
254
- if($seleced_tags[0] == $tag->term_id){
255
- $strsel = "selected='selected'";
256
-
257
- }
258
- }
259
- echo '<option value="'.$tag->term_id.'" '.$strsel.'>'.$tag->name.'</option>';
260
-
261
- }
262
- echo '</select> ';
263
-
264
- }
265
- }
266
- function rss_pi_tags_checkboxes($fid,$seleced_tags){
267
- $tags = get_tags(array('hide_empty' => false));
268
- if ($tags) {
269
- $checkboxes .= "<ul>";
270
-
271
- foreach($tags as $tag) :
272
- $strsel= "";
273
- if(in_array($tag->term_id, $seleced_tags))
274
- $strsel = "checked='checked'";
275
-
276
- $checkboxes .=
277
- '<li><label for="tag-'.$tag->term_id.'">
278
- <input type="checkbox" name="'.$fid.'-tags_id[]" value="'.$tag->term_id.'" id="tag-'.$tag->term_id.'" '.$strsel.' />'.$tag->name.'
279
- </label></li>';
280
- endforeach;
281
- $checkboxes .= "</ul>";
282
- print $checkboxes;
283
- }
284
- }
285
- }
1
+ <?php
2
+
3
+ /**
4
+ * The class that handles the admin screen
5
+ *
6
+ * @author saurabhshukla
7
+ */
8
+ 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
+
24
+ /**
25
+ * Aprompt for invalid/absent API keys
26
+ * @var string
27
+ */
28
+ var $key_prompt;
29
+
30
+ /**
31
+ * Start
32
+ *
33
+ * @global object $rss_post_importer
34
+ */
35
+ public function __construct() {
36
+
37
+ $this->load_options();
38
+
39
+ // add a key prompt
40
+ $this->key_prompt = __('You need a <a href="http://www.feedsapi.com/?utm_source=rsspi-full-rss-key-here" target="_blank">Full Text RSS Key</a> to activate this section, please <a href="http://www.feedsapi.com/?utm_source=rsspi-full-rss-key-here" target="_blank">get one and try it free</a> for the next 14 days to see how it goes.', 'rss_pi');
41
+
42
+ $this->key_prompt_multiple_category = __('Multiple Category selection available.You need a <a href="http://www.feedsapi.com/?utm_source=rsspi-full-rss-key-here" target="_blank">Full Text RSS Key</a> to activate this section, please <a href="http://www.feedsapi.com/?utm_source=rsspi-full-rss-key-here" target="_blank">get one and try it free</a> for the next 14 days to see how it goes.', 'rss_pi');
43
+ $this->key_prompt_multiple_tags = __('Multiple Tags selection available.You need a <a href="http://www.feedsapi.com/?utm_source=rsspi-full-rss-key-here" target="_blank">Full Text RSS Key</a> to activate this section, please <a href="http://www.feedsapi.com/?utm_source=rsspi-full-rss-key-here" target="_blank">get one and try it free</a> for the next 14 days to see how it goes.', 'rss_pi');
44
+
45
+ // initialise logging
46
+ $this->log = new rssPILog();
47
+ $this->log->init();
48
+
49
+ // load the form processor
50
+ $this->processor = new rssPIAdminProcessor();
51
+ }
52
+
53
+ private function load_options(){
54
+ global $rss_post_importer;
55
+
56
+ // add options
57
+ $this->options = $rss_post_importer->options;
58
+
59
+ // check if key is valid
60
+ $this->is_key_valid = $rss_post_importer->is_valid_key($this->options['settings']['feeds_api_key']);
61
+ }
62
+
63
+ /**
64
+ * Initialise and hook all actions
65
+ */
66
+ public function init() {
67
+
68
+ // add to admin menu
69
+ add_action('admin_menu', array($this, 'admin_menu'));
70
+
71
+ // load scripts and styles we need
72
+ add_action('admin_enqueue_scripts', array($this, 'enqueue'));
73
+
74
+ // the ajax for adding new feeds (table rows)
75
+ add_action('wp_ajax_rss_pi_add_row', array($this, 'add_row'));
76
+
77
+ // disable the feed author dropdown for invalid/absent API keys
78
+ add_filter('wp_dropdown_users', array($this, 'disable_user_dropdown'));
79
+
80
+ // Add 10 minutes in frequency.
81
+ add_filter('cron_schedules', array($this, 'rss_pi_cron_add'));
82
+ }
83
+
84
+ /**
85
+ * Add to admin menu
86
+ */
87
+ function admin_menu() {
88
+
89
+ add_options_page('Rss Post Importer', 'Rss Post Importer', 'manage_options', 'rss_pi', array($this, 'screen'));
90
+ }
91
+
92
+ /**
93
+ * Enqueue our admin css and js
94
+ *
95
+ * @param string $hook The current screens hook
96
+ * @return null
97
+ */
98
+ public function enqueue($hook) {
99
+
100
+ // don't load if it isn't our screen
101
+ if ($hook != 'settings_page_rss_pi') {
102
+ return;
103
+ }
104
+
105
+ // register scripts & styles
106
+ wp_enqueue_script('rss-pi', RSS_PI_URL . 'app/assets/js/main.js', array('jquery'), RSS_PI_VERSION);
107
+ wp_enqueue_style('rss-pi', RSS_PI_URL . 'app/assets/css/style.css', array(), RSS_PI_VERSION);
108
+
109
+ // localise ajaxuel for use
110
+ $localise_args = array(
111
+ 'ajaxurl' => admin_url('admin-ajax.php')
112
+ );
113
+ wp_localize_script('rss-pi', 'rss_pi', $localise_args);
114
+ }
115
+ function rss_pi_cron_add($schedules){
116
+ $schedules['minutes_10'] = array(
117
+ 'interval' => 600,
118
+ 'display'=> '10 minutes'
119
+ );
120
+ return $schedules;
121
+ }
122
+ /**
123
+ * Display the screen/ui
124
+ */
125
+ function screen() {
126
+
127
+ // load the form processor first
128
+ $this->processor->process();
129
+ // it'll process any submitted form data
130
+
131
+ // reload the options just in case
132
+ $this->load_options();
133
+
134
+ // include the template for the ui
135
+ include( RSS_PI_PATH . 'app/templates/admin-ui.php');
136
+ }
137
+
138
+ /**
139
+ * Display errors
140
+ *
141
+ * @param string $error The error message
142
+ * @param boolean $inline Whether the error is inline or shown like regular wp errors
143
+ */
144
+ function key_error($error, $inline = false) {
145
+
146
+ $class = ($inline) ? 'rss-pi-error' : 'error';
147
+
148
+ echo '<div class="' . $class . '"><p>' . $error . '</p></div>';
149
+ }
150
+
151
+ /**
152
+ * Add a new row for a new feed
153
+ */
154
+ function add_row() {
155
+
156
+ include( RSS_PI_PATH . 'app/templates/feed-table-row.php');
157
+ die();
158
+ }
159
+
160
+ /**
161
+ * Disable the user dropdwon for each feed
162
+ *
163
+ * @param string $output The html of the select dropdown
164
+ * @return string
165
+ */
166
+ function disable_user_dropdown($output) {
167
+
168
+ // if we have a valid key we don't need to disable anything
169
+ if ($this->is_key_valid) {
170
+ return $output;
171
+ }
172
+
173
+ // check if this is the feed dropdown (and not any other)
174
+ preg_match('/rss-pi-specific-feed-author/i', $output, $matched);
175
+
176
+ // this is not our dropdown, no need to disable
177
+ if (empty($matched)) {
178
+ return $output;
179
+ }
180
+
181
+ // otherwise just disable the dropdown
182
+ return str_replace('<select ', '<select disabled="disabled" ', $output);
183
+ }
184
+ /**
185
+ * Walker class function for category multiple checkbox
186
+ *
187
+ *
188
+ *
189
+ */
190
+ function wp_category_checklist_rss_pi($post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $walker = null, $checked_ontop = true)
191
+ {
192
+ $cat = "";
193
+ if (empty($walker) || !is_a($walker, 'Walker'))
194
+ $walker = new Walker_Category_Checklist;
195
+ $descendants_and_self = (int) $descendants_and_self;
196
+ $args = array();
197
+ if (is_array($selected_cats))
198
+ $args['selected_cats'] = $selected_cats;
199
+ elseif ($post_id)
200
+ $args['selected_cats'] = wp_get_post_categories($post_id);
201
+ else
202
+ $args['selected_cats'] = array();
203
+
204
+ if ($descendants_and_self) {
205
+ $categories = get_categories("child_of=$descendants_and_self&hierarchical=0&hide_empty=0");
206
+ $self = get_category($descendants_and_self);
207
+ array_unshift($categories, $self);
208
+ } else {
209
+ $categories = get_categories('get=all');
210
+ }
211
+ if ($checked_ontop) {
212
+ // Post process $categories rather than adding an exclude to the get_terms() query to keep the query the same across all posts (for any query cache)
213
+ $checked_categories = array();
214
+ $keys = array_keys($categories);
215
+ foreach ($keys as $k) {
216
+ if (in_array($categories[$k]->term_id, $args['selected_cats'])) {
217
+ $checked_categories[] = $categories[$k];
218
+ unset($categories[$k]);
219
+ }
220
+ }
221
+ // Put checked cats on top
222
+ $cat = $cat . call_user_func_array(array(
223
+ &$walker,
224
+ 'walk'
225
+ ), array(
226
+ $checked_categories,
227
+ 0,
228
+ $args
229
+ ));
230
+ }
231
+ // Then the rest of them
232
+ $cat = $cat . call_user_func_array(array(
233
+ &$walker,
234
+ 'walk'
235
+ ), array(
236
+ $categories,
237
+ 0,
238
+ $args
239
+ ));
240
+ return $cat;
241
+ }
242
+
243
+ function rss_pi_tags_dropdown($fid,$seleced_tags){
244
+ if ($tags = get_tags( array('orderby' => 'name','hide_empty' => false) ))
245
+ {
246
+
247
+ echo '<select name="'.$fid.'-tags_id[]" id="tag" class="postform">';
248
+
249
+ foreach ($tags as $tag)
250
+ {
251
+ $strsel = "";
252
+ if(!empty($seleced_tags)){
253
+
254
+ if($seleced_tags[0] == $tag->term_id){
255
+ $strsel = "selected='selected'";
256
+
257
+ }
258
+ }
259
+ echo '<option value="'.$tag->term_id.'" '.$strsel.'>'.$tag->name.'</option>';
260
+
261
+ }
262
+ echo '</select> ';
263
+
264
+ }
265
+ }
266
+ function rss_pi_tags_checkboxes($fid,$seleced_tags){
267
+ $tags = get_tags(array('hide_empty' => false));
268
+ if ($tags) {
269
+ $checkboxes .= "<ul>";
270
+
271
+ foreach($tags as $tag) :
272
+ $strsel= "";
273
+ if(in_array($tag->term_id, $seleced_tags))
274
+ $strsel = "checked='checked'";
275
+
276
+ $checkboxes .=
277
+ '<li><label for="tag-'.$tag->term_id.'">
278
+ <input type="checkbox" name="'.$fid.'-tags_id[]" value="'.$tag->term_id.'" id="tag-'.$tag->term_id.'" '.$strsel.' />'.$tag->name.'
279
+ </label></li>';
280
+ endforeach;
281
+ $checkboxes .= "</ul>";
282
+ print $checkboxes;
283
+ }
284
+ }
285
+ }
app/classes/helpers/class-rss-pi-featured-image.php CHANGED
@@ -1,117 +1,232 @@
1
- <?php
2
- /**
3
- * Sets a featured image
4
- *
5
- * @author Saurabh Shukla <saurabh@yapapaya.com>
6
- */
7
- if ( !function_exists('download_url') ) {
8
- require_once(ABSPATH.'/wp-admin/includes/file.php');
9
- };
10
-
11
- if ( !function_exists('media_handle_sideload') ) {
12
- require_once(ABSPATH . "wp-admin" . '/includes/image.php');
13
- require_once(ABSPATH . "wp-admin" . '/includes/file.php');
14
- require_once(ABSPATH . "wp-admin" . '/includes/media.php');
15
- };
16
- class rssPIFeaturedImage {
17
-
18
- /**
19
- * Sets featured image
20
- *
21
- * @param object $item Feed item
22
- * @param int $post_id Post id
23
- * @return boolean
24
- */
25
- function _set($item, $post_id) {
26
-
27
- $content = $item->get_content() != "" ? $item->get_content() : $item->get_description();
28
-
29
-
30
- // catch base url
31
- preg_match('/href="(.+?)"/i', $content, $matches);
32
- $baseref = (is_array($matches) && !empty($matches)) ? $matches[1] : '';
33
-
34
- // get the first image from content
35
- preg_match('/<img.+?src="(.+?)"[^}]+>/i', $content, $matches);
36
- $img_url = (is_array($matches) && !empty($matches)) ? $matches[1] : '';
37
-
38
- if (empty($img_url)) {
39
- return false;
40
- }
41
-
42
- $img_host = parse_url($img_url, PHP_URL_HOST);
43
-
44
- if (empty($img_host)) {
45
-
46
- if (empty($baseref)) {
47
- return false;
48
- };
49
-
50
- $bc = parse_url($baseref);
51
- $scheme = (empty($bc["scheme"])) ? "http" : $bc["scheme"];
52
- $port = $bc["port"];
53
- $host = $bc["host"];
54
- if (empty($host)) {
55
- return false;
56
- };
57
-
58
- $img_url = $scheme . ":" . $port . "//" . $host . $img_url;
59
- }
60
-
61
- // get the first image from content
62
- /*preg_match('/<img.+?src="(.+?)"[^}]+>/i', $content, $matches);
63
- $img_url = (is_array($matches) && !empty($matches)) ? $matches[1] : '';
64
-
65
- if (empty($img_url)) {
66
- return false;
67
- }
68
- */
69
- // sideload it
70
- $featured_id = $this->_sideload($img_url, $post_id, '');
71
-
72
- add_action('set_rss_pi_featured_image', $featured_id, $post_id);
73
-
74
- // set as featured image
75
- return $meta_id = set_post_thumbnail($post_id, $featured_id);
76
- }
77
-
78
- /**
79
- * Modification of default media_sideload_image
80
- *
81
- * @param type $file
82
- * @param type $post_id
83
- * @param type $desc
84
- * @return type
85
- */
86
- private function _sideload($file, $post_id, $desc = null) {
87
- $id = 0;
88
-
89
- if (!empty($file)) {
90
- // Set variables for storage, fix file filename for query strings.
91
- preg_match('/[^\?]+\.(jpe?g|jpe|gif|png)\b/i', $file, $matches);
92
- $file_array = array();
93
- $file_array['name'] = basename($file);
94
-
95
- // Download file to temp location.
96
- $file_array['tmp_name'] = download_url($file);
97
-
98
- // If error storing temporarily, return the error.
99
- if (is_wp_error($file_array['tmp_name'])) {
100
- return $file_array['tmp_name'];
101
- }
102
-
103
- // Do the validation and storage stuff.
104
- $id = media_handle_sideload($file_array, $post_id, $desc);
105
-
106
- // If error storing permanently, unlink.
107
- if (is_wp_error($id)) {
108
- @unlink($file_array['tmp_name']);
109
- return $id;
110
- }
111
- }
112
-
113
- return $id;
114
- }
115
-
116
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
  }
1
+ <?php
2
+
3
+ /**
4
+
5
+ * Sets a featured image
6
+
7
+ *
8
+
9
+ * @author Saurabh Shukla <saurabh@yapapaya.com>
10
+
11
+ */
12
+
13
+ if ( !function_exists('download_url') ) {
14
+
15
+ require_once(ABSPATH.'/wp-admin/includes/file.php');
16
+
17
+ };
18
+
19
+
20
+
21
+ if ( !function_exists('media_handle_sideload') ) {
22
+
23
+ require_once(ABSPATH . "wp-admin" . '/includes/image.php');
24
+
25
+ require_once(ABSPATH . "wp-admin" . '/includes/file.php');
26
+
27
+ require_once(ABSPATH . "wp-admin" . '/includes/media.php');
28
+
29
+ };
30
+
31
+ class rssPIFeaturedImage {
32
+
33
+
34
+
35
+ /**
36
+
37
+ * Sets featured image
38
+
39
+ *
40
+
41
+ * @param object $item Feed item
42
+
43
+ * @param int $post_id Post id
44
+
45
+ * @return boolean
46
+
47
+ */
48
+
49
+ function _set($item, $post_id) {
50
+
51
+
52
+
53
+ $content = $item->get_content() != "" ? $item->get_content() : $item->get_description();
54
+
55
+
56
+
57
+
58
+
59
+ // catch base url
60
+
61
+ preg_match('/href="(.+?)"/i', $content, $matches);
62
+
63
+ $baseref = (is_array($matches) && !empty($matches)) ? $matches[1] : '';
64
+
65
+
66
+
67
+ // get the first image from content
68
+
69
+ preg_match('/<img.+?src="(.+?)"[^}]+>/i', $content, $matches);
70
+
71
+ $img_url = (is_array($matches) && !empty($matches)) ? $matches[1] : '';
72
+
73
+
74
+
75
+ if (empty($img_url)) {
76
+
77
+ return false;
78
+
79
+ }
80
+
81
+
82
+
83
+ $img_host = parse_url($img_url, PHP_URL_HOST);
84
+
85
+
86
+
87
+ if (empty($img_host)) {
88
+
89
+
90
+
91
+ if (empty($baseref)) {
92
+
93
+ return false;
94
+
95
+ };
96
+
97
+
98
+
99
+ $bc = parse_url($baseref);
100
+
101
+ $scheme = (empty($bc["scheme"])) ? "http" : $bc["scheme"];
102
+
103
+ $port = $bc["port"];
104
+
105
+ $host = $bc["host"];
106
+
107
+ if (empty($host)) {
108
+
109
+ return false;
110
+
111
+ };
112
+
113
+
114
+
115
+ $img_url = $scheme . ":" . $port . "//" . $host . $img_url;
116
+
117
+ }
118
+
119
+
120
+
121
+ // get the first image from content
122
+
123
+ /*preg_match('/<img.+?src="(.+?)"[^}]+>/i', $content, $matches);
124
+
125
+ $img_url = (is_array($matches) && !empty($matches)) ? $matches[1] : '';
126
+
127
+
128
+
129
+ if (empty($img_url)) {
130
+
131
+ return false;
132
+
133
+ }
134
+
135
+ */
136
+
137
+ // sideload it
138
+
139
+ $featured_id = $this->_sideload($img_url, $post_id, '');
140
+
141
+
142
+
143
+ add_action('set_rss_pi_featured_image', $featured_id, $post_id);
144
+
145
+
146
+ // set as featured image
147
+
148
+ return $meta_id = set_post_thumbnail($post_id, $featured_id);
149
+
150
+ }
151
+
152
+
153
+
154
+ /**
155
+
156
+ * Modification of default media_sideload_image
157
+
158
+ *
159
+
160
+ * @param type $file
161
+
162
+ * @param type $post_id
163
+
164
+ * @param type $desc
165
+
166
+ * @return type
167
+
168
+ */
169
+
170
+ private function _sideload($file, $post_id, $desc = null) {
171
+
172
+ $id = 0;
173
+
174
+
175
+
176
+ if (!empty($file)) {
177
+
178
+ // Set variables for storage, fix file filename for query strings.
179
+
180
+ preg_match('/[^\?]+\.(jpe?g|jpe|gif|png)\b/i', $file, $matches);
181
+
182
+ $file_array = array();
183
+
184
+ $file_array['name'] = basename($file);
185
+
186
+
187
+
188
+ // Download file to temp location.
189
+
190
+ $file_array['tmp_name'] = download_url($file);
191
+
192
+
193
+
194
+ // If error storing temporarily, return the error.
195
+
196
+ if (is_wp_error($file_array['tmp_name'])) {
197
+
198
+ return $file_array['tmp_name'];
199
+
200
+ }
201
+
202
+
203
+
204
+ // Do the validation and storage stuff.
205
+
206
+ $id = media_handle_sideload($file_array, $post_id, $desc);
207
+
208
+
209
+
210
+ // If error storing permanently, unlink.
211
+
212
+ if (is_wp_error($id)) {
213
+
214
+ @unlink($file_array['tmp_name']);
215
+
216
+ return $id;
217
+
218
+ }
219
+
220
+ }
221
+
222
+
223
+
224
+ return $id;
225
+
226
+ }
227
+
228
+
229
+
230
+
231
+
232
  }
app/classes/import/class-rss-pi-engine.php CHANGED
@@ -682,10 +682,15 @@ class rssPIEngine {
682
 
683
 
684
 
685
-
 
 
 
 
 
686
 
687
- // insert as post
688
 
 
689
  $post_id = $this->_insert($post, $item->get_permalink());
690
 
691
 
@@ -695,7 +700,6 @@ class rssPIEngine {
695
  $thumbnail->_set($item, $post_id);
696
 
697
 
698
-
699
  array_push($saved_posts, $post);
700
 
701
  }
@@ -792,8 +796,6 @@ class rssPIEngine {
792
 
793
 
794
 
795
-
796
-
797
  $post_id = wp_insert_post($_post);
798
 
799
 
@@ -810,6 +812,79 @@ class rssPIEngine {
810
 
811
  }
812
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
813
 
814
 
815
  }
682
 
683
 
684
 
685
+ //download images and save them locally if setting suggests so
686
+ if($this->options['settings']['import_images_locally'] == "true") {
687
+
688
+ $post = $this->download_images_locally($post);
689
+
690
+ }
691
 
 
692
 
693
+ // insert as post
694
  $post_id = $this->_insert($post, $item->get_permalink());
695
 
696
 
700
  $thumbnail->_set($item, $post_id);
701
 
702
 
 
703
  array_push($saved_posts, $post);
704
 
705
  }
796
 
797
 
798
 
 
 
799
  $post_id = wp_insert_post($_post);
800
 
801
 
812
 
813
  }
814
 
815
+ public function pre($arr) {
816
+
817
+ echo "<pre>";
818
+ print_r($arr);
819
+ echo "</pre>";
820
+
821
+ }
822
+
823
+
824
+ function download_images_locally($post) {
825
+
826
+ $post_content = $post["post_content"];
827
+
828
+ // initializing DOMDocument to modify the img source
829
+ $dom = new DOMDocument;
830
+ libxml_use_internal_errors(true);
831
+ $dom->loadHTML( $post_content );
832
+ $xpath = new DOMXPath( $dom );
833
+ libxml_clear_errors();
834
+
835
+ //get all the src attribs and their values
836
+ $doc = $dom->getElementsByTagName("html")->item(0);
837
+ $src = $xpath->query(".//@src");
838
+
839
+ $count = 1;
840
+
841
+ foreach ( $src as $s ) {
842
+
843
+ $url = trim($s->nodeValue);
844
+ $attachment_id = $this->add_to_media($url , 0 , $post["post_title"]."-media-".$count );
845
+ $src = wp_get_attachment_url( $attachment_id );
846
+ $s->nodeValue = $src;
847
+ $count++;
848
+
849
+ }
850
+
851
+ $post["post_content"] = $dom->saveXML( $doc );
852
+
853
+ return $post;
854
+ }
855
+
856
+ function add_to_media($url , $associated_with_post , $desc ) {
857
+
858
+ $tmp = download_url( $url );
859
+ $post_id = $associated_with_post;
860
+ $desc = $desc;
861
+ $file_array = array();
862
+
863
+ // Set variables for storage
864
+ // fix file filename for query strings
865
+ preg_match('/[^\?]+\.(jpg|jpe|jpeg|gif|png)/i', $url, $matches);
866
+ $file_array['name'] = basename($matches[0]);
867
+ $file_array['tmp_name'] = $tmp;
868
+
869
+ // If error storing temporarily, unlink
870
+ if ( is_wp_error( $tmp ) ) {
871
+ @unlink($file_array['tmp_name']);
872
+ return false;
873
+ }
874
+
875
+ // do the validation and storage stuff
876
+ $id = media_handle_sideload( $file_array, $post_id, $desc );
877
+
878
+ // If error storing permanently, unlink
879
+ if ( is_wp_error($id) ) {
880
+ @unlink($file_array['tmp_name']);
881
+ return false;
882
+ }
883
+
884
+
885
+ return $id ;
886
+
887
+ }
888
 
889
 
890
  }
app/templates/settings-table.php CHANGED
@@ -1,188 +1,206 @@
1
- <table class="widefat rss_pi-table" id="rss_pi-table">
2
- <thead>
3
- <tr>
4
- <th colspan="5"><?php _e('Settings', 'rss_pi'); ?></th>
5
- </tr>
6
- </thead>
7
- <tbody class="setting-rows">
8
- <tr class="edit-row show">
9
- <td colspan="4">
10
- <table class="widefat edit-table">
11
- <tr>
12
- <td>
13
- <label for="frequency"><?php _e('Frequency', "rss_pi"); ?></label>
14
- <p class="description"><?php _e('How often will the import run.', "rss_pi"); ?></p>
15
- </td>
16
- <td>
17
- <select name="frequency" id="frequency">
18
- <?php $x = wp_get_schedules(); ?>
19
- <?php foreach (array_keys($x) as $interval) : ?>
20
- <option value="<?php echo $interval; ?>" <?php
21
- if ($this->options['settings']['frequency'] == $interval) : echo('selected="selected"');
22
- endif;
23
- ?>><?php echo $x[$interval]['display']; ?></option>
24
- <?php endforeach; ?>
25
- </select>
26
- </td>
27
- </tr>
28
- <tr>
29
- <td>
30
- <label for="feeds_api_key"><?php _e('Full Text RSS Feed API Key', "rss_pi"); ?></label>
31
- <p class="description">
32
- <?php _e('Boost Your traffic with Full RSS Content - ', "rss_pi"); ?>
33
- 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>
34
- </p>
35
- </td>
36
- <td>
37
- <?php $feeds_api_key = isset($this->options['settings']["feeds_api_key"]) ? $this->options['settings']["feeds_api_key"] : ""; ?>
38
- <input type="text" name="feeds_api_key" id="feeds_api_key" value="<?php echo $feeds_api_key; ?>" />
39
- </td>
40
- </tr>
41
-
42
- <tr>
43
- <td>
44
- <label for="post_template"><?php _e('Template', 'rss_pi'); ?></label>
45
- <p class="description"><?php _e('This is how the post will be formatted.', "rss_pi"); ?></p>
46
- <p class="description">
47
- <?php _e('Available tags:', "rss_pi"); ?>
48
- <dl>
49
- <dt><code>&lcub;$content&rcub;</code></dt>
50
- <dt><code>&lcub;$permalink&rcub;</code></dt>
51
- <dt><code>&lcub;$title&rcub;</code></dt>
52
- <dt><code>&lcub;$feed_title&rcub;</code></dt>
53
- <dt><code>&lcub;$excerpt:n&rcub;</code></dt>
54
- </dl>
55
- </p>
56
- </td>
57
- <td>
58
- <textarea name="post_template" id="post_template" cols="30" rows="10"><?php
59
- $value = (
60
- $this->options['settings']['post_template'] != '' ? $this->options['settings']['post_template'] : '{$content}' . "\nSource: " . '{$feed_title}'
61
- );
62
-
63
- $value = str_replace(array('\r', '\n'), array(chr(13), chr(10)), $value);
64
-
65
- echo stripslashes($value);
66
- ?></textarea>
67
- </td>
68
- </tr>
69
- <tr>
70
- <td>
71
- <label for="post_template"><?php _e('Keywords Filter', 'rss_pi'); ?></label>
72
- <p class="description"><?php _e('Enter keywords and/or regex, separated by commas', "rss_pi"); ?></p>
73
- <p class="description">
74
- <?php _e('Only posts matching these keywords/regex will be imported', "rss_pi"); ?>
75
- </p>
76
- </td>
77
- <td>
78
- <?php
79
- $disabled = '';
80
- if (!$this->is_key_valid) {
81
- $disabled= ' disabled="disabled"';
82
- $this->key_error($this->key_prompt, true);
83
- }
84
- ?>
85
- <textarea name="keyword_filter" id="post_template" cols="30" rows="10"<?php echo $disabled; ?>><?php
86
- echo implode(', ', $this->options['settings']['keywords']);
87
- ?></textarea>
88
- </td>
89
- </tr>
90
- <tr>
91
- <td><label for="post_status"><?php _e('Post status', "rss_pi"); ?></label></td>
92
- <td>
93
-
94
- <select name="post_status" id="post_status">
95
- <?php
96
- $statuses = get_post_stati('', 'objects');
97
-
98
- foreach ($statuses as $status) {
99
- ?>
100
- <option value="<?php echo($status->name); ?>" <?php
101
- if ($this->options['settings']['post_status'] == $status->name) : echo('selected="selected"');
102
- endif;
103
- ?>><?php echo($status->label); ?></option>
104
- <?php
105
- }
106
- ?>
107
- </select>
108
- </td>
109
- </tr>
110
- <tr>
111
- <td><?php _e('Author', 'rss_pi'); ?></td>
112
- <td>
113
- <?php
114
- $args = array(
115
- 'id' => 'author_id',
116
- 'name' => 'author_id',
117
- 'selected' => $this->options['settings']['author_id']
118
- );
119
- wp_dropdown_users($args);
120
- ?>
121
- </td>
122
- </tr>
123
- <tr>
124
- <td><?php _e('Allow comments', "rss_pi"); ?></td>
125
- <td>
126
- <ul class="radiolist">
127
- <li>
128
- <label><input type="radio" id="allow_comments" name="allow_comments" value="open" <?php echo($this->options['settings']['allow_comments'] == 'open' ? 'checked="checked"' : ''); ?> /> <?php _e('Yes', 'rss_pi'); ?></label>
129
- </li>
130
- <li>
131
- <label><input type="radio" id="allow_comments" name="allow_comments" value="false" <?php echo($this->options['settings']['allow_comments'] == 'false' ? 'checked="checked"' : ''); ?> /> <?php _e('No', 'rss_pi'); ?></label>
132
- </li>
133
- </ul>
134
- </td>
135
- </tr>
136
- <tr>
137
- <td>
138
- <?php _e('Block search indexing?', "rss_pi"); ?>
139
- <p class="description"><?php _e('Prevent your content from appearing in search results.', "rss_pi"); ?></p>
140
- </td>
141
- <td>
142
- <ul class="radiolist">
143
- <li>
144
- <label><input type="radio" id="block_indexing" name="block_indexing" value="true" <?php echo($this->options['settings']['block_indexing'] == 'true' ? 'checked="checked"' : ''); ?> /> <?php _e('Yes', 'rss_pi'); ?></label>
145
- </li>
146
- <li>
147
- <label><input type="radio" id="block_indexing" name="block_indexing" value="false" <?php echo($this->options['settings']['block_indexing'] == 'false' || $this->options['settings']['block_indexing'] == '' ? 'checked="checked"' : ''); ?> /> <?php _e('No', 'rss_pi'); ?></label>
148
- </li>
149
- </ul>
150
- </td>
151
- </tr>
152
- <tr>
153
- <td>
154
- <?php _e('Nofollow option for all outbound links?', "rss_pi"); ?>
155
- <p class="description"><?php _e('Add rel="nofollow" to all outbounded links.', "rss_pi"); ?></p>
156
- </td>
157
- <td>
158
- <ul class="radiolist">
159
- <li>
160
- <label><input type="radio" id="nofollow_outbound" name="nofollow_outbound" value="true" <?php echo($this->options['settings']['nofollow_outbound'] == 'true' ? 'checked="checked"' : ''); ?> /> <?php _e('Yes', 'rss_pi'); ?></label>
161
- </li>
162
- <li>
163
- <label><input type="radio" id="nofollow_outbound" name="nofollow_outbound" value="false" <?php echo($this->options['settings']['nofollow_outbound'] == 'false' || $this->options['settings']['nofollow_outbound'] == '' ? 'checked="checked"' : ''); ?> /> <?php _e('No', 'rss_pi'); ?></label>
164
- </li>
165
- </ul>
166
- </td>
167
- </tr>
168
- <tr>
169
- <td>
170
- <?php _e('Enable logging?', "rss_pi"); ?>
171
- <p class="description"><?php _e('The logfile can be found <a href="#" class="load-log">here</a>.', "rss_pi"); ?></p>
172
- </td>
173
- <td>
174
- <ul class="radiolist">
175
- <li>
176
- <label><input type="radio" id="enable_logging" name="enable_logging" value="true" <?php echo($this->options['settings']['enable_logging'] == 'true' ? 'checked="checked"' : ''); ?> /> <?php _e('Yes', 'rss_pi'); ?></label>
177
- </li>
178
- <li>
179
- <label><input type="radio" id="enable_logging" name="enable_logging" value="false" <?php echo($this->options['settings']['enable_logging'] == 'false' || $this->options['settings']['enable_logging'] == '' ? 'checked="checked"' : ''); ?> /> <?php _e('No', 'rss_pi'); ?></label>
180
- </li>
181
- </ul>
182
- </td>
183
- </tr>
184
- </table>
185
- </td>
186
- </tr>
187
- </tbody>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
188
  </table>
1
+ <table class="widefat rss_pi-table" id="rss_pi-table">
2
+ <thead>
3
+ <tr>
4
+ <th colspan="5"><?php _e('Settings', 'rss_pi'); ?></th>
5
+ </tr>
6
+ </thead>
7
+ <tbody class="setting-rows">
8
+ <tr class="edit-row show">
9
+ <td colspan="4">
10
+ <table class="widefat edit-table">
11
+ <tr>
12
+ <td>
13
+ <label for="frequency"><?php _e('Frequency', "rss_pi"); ?></label>
14
+ <p class="description"><?php _e('How often will the import run.', "rss_pi"); ?></p>
15
+ </td>
16
+ <td>
17
+ <select name="frequency" id="frequency">
18
+ <?php $x = wp_get_schedules(); ?>
19
+ <?php foreach (array_keys($x) as $interval) : ?>
20
+ <option value="<?php echo $interval; ?>" <?php
21
+ if ($this->options['settings']['frequency'] == $interval) : echo('selected="selected"');
22
+ endif;
23
+ ?>><?php echo $x[$interval]['display']; ?></option>
24
+ <?php endforeach; ?>
25
+ </select>
26
+ </td>
27
+ </tr>
28
+ <tr>
29
+ <td>
30
+ <label for="feeds_api_key"><?php _e('Full Text RSS Feed API Key', "rss_pi"); ?></label>
31
+ <p class="description">
32
+ <?php _e('Boost Your traffic with Full RSS Content - ', "rss_pi"); ?>
33
+ 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>
34
+ </p>
35
+ </td>
36
+ <td>
37
+ <?php $feeds_api_key = isset($this->options['settings']["feeds_api_key"]) ? $this->options['settings']["feeds_api_key"] : ""; ?>
38
+ <input type="text" name="feeds_api_key" id="feeds_api_key" value="<?php echo $feeds_api_key; ?>" />
39
+ </td>
40
+ </tr>
41
+
42
+ <tr>
43
+ <td>
44
+ <label for="post_template"><?php _e('Template', 'rss_pi'); ?></label>
45
+ <p class="description"><?php _e('This is how the post will be formatted.', "rss_pi"); ?></p>
46
+ <p class="description">
47
+ <?php _e('Available tags:', "rss_pi"); ?>
48
+ <dl>
49
+ <dt><code>&lcub;$content&rcub;</code></dt>
50
+ <dt><code>&lcub;$permalink&rcub;</code></dt>
51
+ <dt><code>&lcub;$title&rcub;</code></dt>
52
+ <dt><code>&lcub;$feed_title&rcub;</code></dt>
53
+ <dt><code>&lcub;$excerpt:n&rcub;</code></dt>
54
+ </dl>
55
+ </p>
56
+ </td>
57
+ <td>
58
+ <textarea name="post_template" id="post_template" cols="30" rows="10"><?php
59
+ $value = (
60
+ $this->options['settings']['post_template'] != '' ? $this->options['settings']['post_template'] : '{$content}' . "\nSource: " . '{$feed_title}'
61
+ );
62
+
63
+ $value = str_replace(array('\r', '\n'), array(chr(13), chr(10)), $value);
64
+
65
+ echo stripslashes($value);
66
+ ?></textarea>
67
+ </td>
68
+ </tr>
69
+ <tr>
70
+ <td>
71
+ <label for="post_template"><?php _e('Keywords Filter', 'rss_pi'); ?></label>
72
+ <p class="description"><?php _e('Enter keywords and/or regex, separated by commas', "rss_pi"); ?></p>
73
+ <p class="description">
74
+ <?php _e('Only posts matching these keywords/regex will be imported', "rss_pi"); ?>
75
+ </p>
76
+ </td>
77
+ <td>
78
+ <?php
79
+ $disabled = '';
80
+ if (!$this->is_key_valid) {
81
+ $disabled= ' disabled="disabled"';
82
+ $this->key_error($this->key_prompt, true);
83
+ }
84
+ ?>
85
+ <textarea name="keyword_filter" id="post_template" cols="30" rows="10"<?php echo $disabled; ?>><?php
86
+ echo implode(', ', $this->options['settings']['keywords']);
87
+ ?></textarea>
88
+ </td>
89
+ </tr>
90
+ <tr>
91
+ <td><label for="post_status"><?php _e('Post status', "rss_pi"); ?></label></td>
92
+ <td>
93
+
94
+ <select name="post_status" id="post_status">
95
+ <?php
96
+ $statuses = get_post_stati('', 'objects');
97
+
98
+ foreach ($statuses as $status) {
99
+ ?>
100
+ <option value="<?php echo($status->name); ?>" <?php
101
+ if ($this->options['settings']['post_status'] == $status->name) : echo('selected="selected"');
102
+ endif;
103
+ ?>><?php echo($status->label); ?></option>
104
+ <?php
105
+ }
106
+ ?>
107
+ </select>
108
+ </td>
109
+ </tr>
110
+ <tr>
111
+ <td><?php _e('Author', 'rss_pi'); ?></td>
112
+ <td>
113
+ <?php
114
+ $args = array(
115
+ 'id' => 'author_id',
116
+ 'name' => 'author_id',
117
+ 'selected' => $this->options['settings']['author_id']
118
+ );
119
+ wp_dropdown_users($args);
120
+ ?>
121
+ </td>
122
+ </tr>
123
+ <tr>
124
+ <td><?php _e('Allow comments', "rss_pi"); ?></td>
125
+ <td>
126
+ <ul class="radiolist">
127
+ <li>
128
+ <label><input type="radio" id="allow_comments" name="allow_comments" value="open" <?php echo($this->options['settings']['allow_comments'] == 'open' ? 'checked="checked"' : ''); ?> /> <?php _e('Yes', 'rss_pi'); ?></label>
129
+ </li>
130
+ <li>
131
+ <label><input type="radio" id="allow_comments" name="allow_comments" value="false" <?php echo($this->options['settings']['allow_comments'] == 'false' ? 'checked="checked"' : ''); ?> /> <?php _e('No', 'rss_pi'); ?></label>
132
+ </li>
133
+ </ul>
134
+ </td>
135
+ </tr>
136
+ <tr>
137
+ <td>
138
+ <?php _e('Block search indexing?', "rss_pi"); ?>
139
+ <p class="description"><?php _e('Prevent your content from appearing in search results.', "rss_pi"); ?></p>
140
+ </td>
141
+ <td>
142
+ <ul class="radiolist">
143
+ <li>
144
+ <label><input type="radio" id="block_indexing" name="block_indexing" value="true" <?php echo($this->options['settings']['block_indexing'] == 'true' ? 'checked="checked"' : ''); ?> /> <?php _e('Yes', 'rss_pi'); ?></label>
145
+ </li>
146
+ <li>
147
+ <label><input type="radio" id="block_indexing" name="block_indexing" value="false" <?php echo($this->options['settings']['block_indexing'] == 'false' || $this->options['settings']['block_indexing'] == '' ? 'checked="checked"' : ''); ?> /> <?php _e('No', 'rss_pi'); ?></label>
148
+ </li>
149
+ </ul>
150
+ </td>
151
+ </tr>
152
+ <tr>
153
+ <td>
154
+ <?php _e('Nofollow option for all outbound links?', "rss_pi"); ?>
155
+ <p class="description"><?php _e('Add rel="nofollow" to all outbounded links.', "rss_pi"); ?></p>
156
+ </td>
157
+ <td>
158
+ <ul class="radiolist">
159
+ <li>
160
+ <label><input type="radio" id="nofollow_outbound" name="nofollow_outbound" value="true" <?php echo($this->options['settings']['nofollow_outbound'] == 'true' ? 'checked="checked"' : ''); ?> /> <?php _e('Yes', 'rss_pi'); ?></label>
161
+ </li>
162
+ <li>
163
+ <label><input type="radio" id="nofollow_outbound" name="nofollow_outbound" value="false" <?php echo($this->options['settings']['nofollow_outbound'] == 'false' || $this->options['settings']['nofollow_outbound'] == '' ? 'checked="checked"' : ''); ?> /> <?php _e('No', 'rss_pi'); ?></label>
164
+ </li>
165
+ </ul>
166
+ </td>
167
+ </tr>
168
+ <tr>
169
+ <td>
170
+ <?php _e('Enable logging?', "rss_pi"); ?>
171
+ <p class="description"><?php _e('The logfile can be found <a href="#" class="load-log">here</a>.', "rss_pi"); ?></p>
172
+ </td>
173
+ <td>
174
+ <ul class="radiolist">
175
+ <li>
176
+ <label><input type="radio" id="enable_logging" name="enable_logging" value="true" <?php echo($this->options['settings']['enable_logging'] == 'true' ? 'checked="checked"' : ''); ?> /> <?php _e('Yes', 'rss_pi'); ?></label>
177
+ </li>
178
+ <li>
179
+ <label><input type="radio" id="enable_logging" name="enable_logging" value="false" <?php echo($this->options['settings']['enable_logging'] == 'false' || $this->options['settings']['enable_logging'] == '' ? 'checked="checked"' : ''); ?> /> <?php _e('No', 'rss_pi'); ?></label>
180
+ </li>
181
+ </ul>
182
+ </td>
183
+
184
+ </tr>
185
+ <tr>
186
+ <td>
187
+ <?php _e('Download and save images locally?', "rss_pi"); ?>
188
+ <p class="description"><?php _e('Images in the feeds will be downloaded and saved in the WordPress media.', "rss_pi"); ?></p>
189
+ </td>
190
+ <td>
191
+ <ul class="radiolist">
192
+ <li>
193
+ <label><input type="radio" id="import_images_locally" name="import_images_locally" value="true" <?php echo($this->options['settings']['import_images_locally'] == 'true' ? 'checked="checked"' : ''); ?> /> <?php _e('Yes', 'rss_pi'); ?></label>
194
+ </li>
195
+ <li>
196
+ <label><input type="radio" id="import_images_locally" 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_pi'); ?></label>
197
+ </li>
198
+ </ul>
199
+ </td>
200
+
201
+ </tr>
202
+ </table>
203
+ </td>
204
+ </tr>
205
+ </tbody>
206
  </table>
index.php CHANGED
@@ -1,141 +1,71 @@
1
  <?php
2
 
3
-
4
-
5
  /*
6
-
7
  Plugin Name: Rss Post Importer
8
-
9
  Plugin URI: https://wordpress.org/plugins/rss-post-importer/
10
-
11
  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.
12
-
13
  Author: feedsapi
14
-
15
- Version: 2.0.9
16
-
17
  Author URI: https://www.feedsapi.org/
18
-
19
  License: GPLv2 or later
20
-
21
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
22
-
23
  Text Domain: rss_pi
24
-
25
  Domain Path: /lang/
26
-
27
  */
28
 
29
 
30
-
31
-
32
-
33
  // define some constants
34
-
35
  if (!defined('RSS_PI_PATH')) {
36
-
37
  define('RSS_PI_PATH', trailingslashit(plugin_dir_path(__FILE__)));
38
-
39
  }
40
 
41
-
42
-
43
  if (!defined('RSS_PI_URL')) {
44
-
45
  define('RSS_PI_URL', trailingslashit(plugin_dir_url(__FILE__)));
46
-
47
  }
48
 
49
-
50
-
51
  if (!defined('RSS_PI_BASENAME')) {
52
-
53
  define('RSS_PI_BASENAME', plugin_basename(__FILE__));
54
-
55
  }
56
 
57
-
58
-
59
  if (!defined('RSS_PI_VERSION')) {
60
-
61
- define('RSS_PI_VERSION', '2.0.9');
62
-
63
  }
64
 
65
-
66
-
67
  if (!defined('RSS_PI_LOG_PATH')) {
68
-
69
  define('RSS_PI_LOG_PATH', trailingslashit(WP_CONTENT_DIR) . 'rsspi-log/');
70
-
71
  }
72
 
73
-
74
-
75
  if(!is_dir(RSS_PI_LOG_PATH)){
76
-
77
  mkdir(RSS_PI_LOG_PATH);
78
-
79
  }
80
 
81
-
82
-
83
  // helper classes
84
-
85
  include_once RSS_PI_PATH . 'app/classes/helpers/class-rss-pi-log.php';
86
-
87
  include_once RSS_PI_PATH . 'app/classes/helpers/class-rss-pi-featured-image.php';
88
-
89
  include_once RSS_PI_PATH . 'app/classes/helpers/class-rss-pi-parser.php';
90
 
91
-
92
-
93
  // admin classes
94
-
95
  include_once RSS_PI_PATH . 'app/classes/admin/class-rss-pi-admin-processor.php';
96
-
97
  include_once RSS_PI_PATH . 'app/classes/admin/class-rss-pi-admin.php';
98
 
99
-
100
-
101
  // Front classes
102
-
103
  include_once RSS_PI_PATH . 'app/classes/front/class-rss-pi-front.php';
104
 
105
-
106
-
107
  // main importers
108
-
109
  include_once RSS_PI_PATH . 'app/classes/import/class-rss-pi-engine.php';
110
-
111
  include_once RSS_PI_PATH . 'app/classes/import/class-rss-pi-cron.php';
112
 
113
-
114
-
115
  // the main loader class
116
-
117
  include_once RSS_PI_PATH . 'app/class-rss-post-importer.php';
118
 
119
 
120
-
121
-
122
-
123
  // initialise plugin as a global var
124
-
125
  global $rss_post_importer;
126
 
127
-
128
-
129
  $rss_post_importer = new rssPostImporter();
130
 
131
-
132
-
133
  $rss_post_importer->init();
134
 
135
 
136
 
137
-
138
-
139
-
140
-
141
 
1
  <?php
2
 
 
 
3
  /*
 
4
  Plugin Name: Rss Post Importer
 
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.0.10
 
 
9
  Author URI: https://www.feedsapi.org/
 
10
  License: GPLv2 or later
 
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
 
12
  Text Domain: rss_pi
 
13
  Domain Path: /lang/
 
14
  */
15
 
16
 
 
 
 
17
  // define some constants
 
18
  if (!defined('RSS_PI_PATH')) {
 
19
  define('RSS_PI_PATH', trailingslashit(plugin_dir_path(__FILE__)));
 
20
  }
21
 
 
 
22
  if (!defined('RSS_PI_URL')) {
 
23
  define('RSS_PI_URL', trailingslashit(plugin_dir_url(__FILE__)));
 
24
  }
25
 
 
 
26
  if (!defined('RSS_PI_BASENAME')) {
 
27
  define('RSS_PI_BASENAME', plugin_basename(__FILE__));
 
28
  }
29
 
 
 
30
  if (!defined('RSS_PI_VERSION')) {
31
+ define('RSS_PI_VERSION', '2.0.10');
 
 
32
  }
33
 
 
 
34
  if (!defined('RSS_PI_LOG_PATH')) {
 
35
  define('RSS_PI_LOG_PATH', trailingslashit(WP_CONTENT_DIR) . 'rsspi-log/');
 
36
  }
37
 
 
 
38
  if(!is_dir(RSS_PI_LOG_PATH)){
 
39
  mkdir(RSS_PI_LOG_PATH);
 
40
  }
41
 
 
 
42
  // helper classes
 
43
  include_once RSS_PI_PATH . 'app/classes/helpers/class-rss-pi-log.php';
 
44
  include_once RSS_PI_PATH . 'app/classes/helpers/class-rss-pi-featured-image.php';
 
45
  include_once RSS_PI_PATH . 'app/classes/helpers/class-rss-pi-parser.php';
46
 
 
 
47
  // admin classes
 
48
  include_once RSS_PI_PATH . 'app/classes/admin/class-rss-pi-admin-processor.php';
 
49
  include_once RSS_PI_PATH . 'app/classes/admin/class-rss-pi-admin.php';
50
 
 
 
51
  // Front classes
 
52
  include_once RSS_PI_PATH . 'app/classes/front/class-rss-pi-front.php';
53
 
 
 
54
  // main importers
 
55
  include_once RSS_PI_PATH . 'app/classes/import/class-rss-pi-engine.php';
 
56
  include_once RSS_PI_PATH . 'app/classes/import/class-rss-pi-cron.php';
57
 
 
 
58
  // the main loader class
 
59
  include_once RSS_PI_PATH . 'app/class-rss-post-importer.php';
60
 
61
 
 
 
 
62
  // initialise plugin as a global var
 
63
  global $rss_post_importer;
64
 
 
 
65
  $rss_post_importer = new rssPostImporter();
66
 
 
 
67
  $rss_post_importer->init();
68
 
69
 
70
 
 
 
 
 
71
 
readme.txt CHANGED
@@ -12,7 +12,7 @@ Requires at least: 3.5
12
 
13
  Tested up to: 4.1
14
 
15
- Stable tag: 2.0.9
16
 
17
  License: GPLv2 or later
18
 
@@ -162,6 +162,10 @@ WP-o-Matic , WP-o-Matic, RSSImport, FeedWordPress, Syndicate Press, FeedWeb, RSS
162
 
163
  == Change Log ==
164
 
 
 
 
 
165
  = Version 2.0.9 =
166
 
167
  * Bug fixed and Improvements in code.
12
 
13
  Tested up to: 4.1
14
 
15
+ Stable tag: 2.0.10
16
 
17
  License: GPLv2 or later
18
 
162
 
163
  == Change Log ==
164
 
165
+ = Version 2.0.10 =
166
+
167
+ * Added option to download images locally instead of hotlinking.
168
+
169
  = Version 2.0.9 =
170
 
171
  * Bug fixed and Improvements in code.