RSS Post Importer - Version 2.0.6

Version Description

Download this release

Release Info

Developer phpaddicted
Plugin Icon 128x128 RSS Post Importer
Version 2.0.6
Comparing to
See all releases

Code changes from version 2.0.5 to 2.0.6

app/class-rss-post-importer.php CHANGED
@@ -47,6 +47,7 @@ class rssPostImporter {
47
  'author_id' => 1,
48
  'allow_comments' => 'open',
49
  'block_indexing' => false,
 
50
  'keywords' => array()
51
  );
52
 
@@ -101,7 +102,7 @@ class rssPostImporter {
101
  return false;
102
  }
103
 
104
- $url = "http://www.feedsapi.org/fetch.php?key=$key&url=http://dummyurl.com";
105
  $content = file_get_contents($url);
106
 
107
  if (trim($content) == "A valid key must be supplied") {
47
  'author_id' => 1,
48
  'allow_comments' => 'open',
49
  'block_indexing' => false,
50
+ 'nofollow_outbound' => true,
51
  'keywords' => array()
52
  );
53
 
102
  return false;
103
  }
104
 
105
+ $url = "http://176.58.108.28/makefulltextfeed.php?key=$key&url=http://dummyurl.com";
106
  $content = file_get_contents($url);
107
 
108
  if (trim($content) == "A valid key must be supplied") {
app/classes/admin/class-rss-pi-admin-processor.php CHANGED
@@ -68,6 +68,7 @@ class rssPIAdminProcessor {
68
  'author_id' => $_POST['author_id'],
69
  'allow_comments' => $_POST['allow_comments'],
70
  'block_indexing' => $_POST['block_indexing'],
 
71
  'enable_logging' => $_POST['enable_logging'],
72
  'keywords' => array()
73
  );
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
  );
app/classes/front/class-rss-pi-front.php CHANGED
@@ -31,8 +31,17 @@ class rssPIFront {
31
  * Initialise and hook all actions
32
  */
33
  public function init() {
 
34
  // add noidex to front
35
  add_action('wp_head', array($this, 'rss_pi_noindex_meta_tag'));
 
 
 
 
 
 
 
 
36
  }
37
 
38
 
@@ -63,4 +72,46 @@ class rssPIFront {
63
  }
64
  }
65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  }
31
  * Initialise and hook all actions
32
  */
33
  public function init() {
34
+ global $post,$rss_post_importer;
35
  // add noidex to front
36
  add_action('wp_head', array($this, 'rss_pi_noindex_meta_tag'));
37
+
38
+ // add options
39
+ $this->options = $rss_post_importer->options;
40
+
41
+ // Check for block indexing
42
+ if($this->options['settings']['nofollow_outbound'] == 'true'){
43
+ add_filter( 'the_content', array($this, 'rss_pi_url_parse'));
44
+ }
45
  }
46
 
47
 
72
  }
73
  }
74
 
75
+
76
+ function rss_pi_url_parse( $content ) {
77
+
78
+ $regexp = "<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>";
79
+ if(preg_match_all("/$regexp/siU", $content, $matches, PREG_SET_ORDER)) {
80
+ if( !empty($matches) ) {
81
+
82
+ $srcUrl = get_option('home');
83
+ for ($i=0; $i < count($matches); $i++)
84
+ {
85
+
86
+ $tag = $matches[$i][0];
87
+ $tag2 = $matches[$i][0];
88
+ $url = $matches[$i][0];
89
+
90
+ $noFollow = '';
91
+
92
+ $pattern = '/target\s*=\s*"\s*_blank\s*"/';
93
+ preg_match($pattern, $tag2, $match, PREG_OFFSET_CAPTURE);
94
+ if( count($match) < 1 )
95
+ $noFollow .= ' target="_blank" ';
96
+
97
+ $pattern = '/rel\s*=\s*"\s*[n|d]ofollow\s*"/';
98
+ preg_match($pattern, $tag2, $match, PREG_OFFSET_CAPTURE);
99
+ if( count($match) < 1 )
100
+ $noFollow .= ' rel="nofollow" ';
101
+
102
+ $pos = strpos($url,$srcUrl);
103
+ if ($pos === false) {
104
+ $tag = rtrim ($tag,'>');
105
+ $tag .= $noFollow.'>';
106
+ $content = str_replace($tag2,$tag,$content);
107
+ }
108
+ }
109
+ }
110
+ }
111
+
112
+ $content = str_replace(']]>', ']]&gt;', $content);
113
+ return $content;
114
+
115
+ }
116
+
117
  }
app/classes/helpers/class-rss-pi-parser.php CHANGED
@@ -1,76 +1,87 @@
1
- <?php
2
- /**
3
- * Parses content according to settings
4
- *
5
- * @author Saurabh Shukla <saurabh@yapapaya.com>
6
- */
7
- class rssPIParser {
8
-
9
- /**
10
- * Parse content
11
- *
12
- * @global object $rss_post_importer
13
- * @param object $item Feed item
14
- * @param string $feed_title Feed title
15
- * @param boolean $strip_html whether to strio html tags
16
- * @return type
17
- */
18
- function _parse($item, $feed_title, $strip_html) {
19
-
20
- global $rss_post_importer;
21
-
22
- // get the saved template
23
- $post_template = $rss_post_importer->options['settings']['post_template'];
24
-
25
- // get the content
26
- $c = $item->get_content() != "" ? $item->get_content() : $item->get_description();
27
-
28
- $c = apply_filters('pre_rss_pi_parse_content', $c);
29
-
30
- // do all the replacements
31
- $parsed_content = preg_replace('/\{\$content\}/i', $c, $post_template);
32
- $parsed_content = preg_replace('/\{\$feed_title\}/i', $feed_title, $parsed_content);
33
- $parsed_content = preg_replace('/\{\$title\}/i', $item->get_title(), $parsed_content);
34
-
35
- // check if we need an excerpt
36
- $parsed_content = $this->_excerpt($parsed_content);
37
-
38
- // strip html, if needed
39
- if ($strip_html == 'true') {
40
- $parsed_content = strip_tags($parsed_content);
41
- }
42
-
43
- $parsed_content = preg_replace('/\{\$permalink\}/i', '<a href="' . esc_url($item->get_permalink()) . '" target="_blank">' . $item->get_title() . '</a>', $parsed_content);
44
-
45
-
46
- $parsed_content = apply_filters('after_rss_pi_parse_content', $parsed_content);
47
-
48
- return $parsed_content;
49
- }
50
-
51
- /**
52
- * Checks and creates an excerpts
53
- *
54
- * @param string $content Content
55
- * @return string
56
- */
57
- private function _excerpt($content){
58
-
59
- // if there's an excerpt placeholder
60
- preg_match('/\{\$excerpt\:(\d+)\}/i', $content, $matches);
61
-
62
- // if there's a wordcount
63
- $e_size = (is_array($matches) && !empty($matches)) ? $matches[1] : 0;
64
-
65
- // cut it down and replace the placeholder
66
- if ($e_size) {
67
- $trimmed_c = preg_replace('/<!--(.|\s)*?-->/', '', $c);
68
- // compulsorily strip html otherwise there'll be broken html all over
69
- $stripped_c = strip_tags($trimmed_c);
70
- $content = preg_replace('/\{\$excerpt\:\d+\}/i', wp_trim_words($stripped_c, $e_size), $content);
71
- }
72
-
73
- return $content;
74
-
75
- }
76
- }
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Parses content according to settings
4
+ *
5
+ * @author Saurabh Shukla <saurabh@yapapaya.com>
6
+ */
7
+ class rssPIParser {
8
+
9
+ /**
10
+ * Parse content
11
+ *
12
+ * @global object $rss_post_importer
13
+ * @param object $item Feed item
14
+ * @param string $feed_title Feed title
15
+ * @param boolean $strip_html whether to strio html tags
16
+ * @return type
17
+ */
18
+ function _parse($item, $feed_title, $strip_html) {
19
+
20
+ global $rss_post_importer;
21
+
22
+ // get the saved template
23
+ $post_template = $rss_post_importer->options['settings']['post_template'];
24
+
25
+ // get the content
26
+ $c = $item->get_content() != "" ? $item->get_content() : $item->get_description();
27
+
28
+ $c = apply_filters('pre_rss_pi_parse_content', $c);
29
+
30
+ $c = $this->escape_backreference($c);
31
+ // do all the replacements
32
+ $parsed_content = preg_replace('/\{\#content\}/i', $c, $post_template);
33
+ $parsed_content = preg_replace('/\{\$feed_title\}/i', $feed_title, $parsed_content);
34
+ $parsed_content = preg_replace('/\{\$title\}/i', $item->get_title(), $parsed_content);
35
+
36
+ // check if we need an excerpt
37
+ $parsed_content = $this->_excerpt($parsed_content);
38
+
39
+ // strip html, if needed
40
+ if ($strip_html == 'true') {
41
+ $parsed_content = strip_tags($parsed_content);
42
+ }
43
+
44
+ $parsed_content = preg_replace('/\{\$permalink\}/i', '<a href="' . esc_url($item->get_permalink()) . '" target="_blank">' . $item->get_title() . '</a>', $parsed_content);
45
+
46
+
47
+ $parsed_content = apply_filters('after_rss_pi_parse_content', $parsed_content);
48
+
49
+ return $parsed_content;
50
+ }
51
+
52
+ /*
53
+ *
54
+ * Escape $n backreferences
55
+ */
56
+
57
+ function escape_backreference($x){
58
+ return preg_replace('/\$(\d)/', '\\\$$1', $x);
59
+ }
60
+
61
+
62
+ /**
63
+ * Checks and creates an excerpts
64
+ *
65
+ * @param string $content Content
66
+ * @return string
67
+ */
68
+ private function _excerpt($content){
69
+
70
+ // if there's an excerpt placeholder
71
+ preg_match('/\{\$excerpt\:(\d+)\}/i', $content, $matches);
72
+
73
+ // if there's a wordcount
74
+ $e_size = (is_array($matches) && !empty($matches)) ? $matches[1] : 0;
75
+
76
+ // cut it down and replace the placeholder
77
+ if ($e_size) {
78
+ $trimmed_c = preg_replace('/<!--(.|\s)*?-->/', '', $c);
79
+ // compulsorily strip html otherwise there'll be broken html all over
80
+ $stripped_c = strip_tags($trimmed_c);
81
+ $content = preg_replace('/\{\$excerpt\:\d+\}/i', wp_trim_words($stripped_c, $e_size), $content);
82
+ }
83
+
84
+ return $content;
85
+
86
+ }
87
+ }
app/classes/import/class-rss-pi-engine.php CHANGED
@@ -129,6 +129,7 @@ class rssPIEngine {
129
 
130
  // fetch the feed
131
  $feed = fetch_feed($url);
 
132
 
133
  // save as posts
134
  $posts = $this->save($feed, $args);
@@ -149,7 +150,7 @@ class rssPIEngine {
149
  //if api key has been saved by user and is not empty
150
  if (isset($key) && !empty($key)) {
151
 
152
- $api_url = "http://www.feedsapi.org/fetch.php?key=" . $key . "&url=" . $url;
153
 
154
  return $api_url;
155
  }
@@ -308,7 +309,7 @@ class rssPIEngine {
308
  }else{
309
  $tags_name = array();
310
  }
311
-
312
  $post = array(
313
  'post_title' => $item->get_title(),
314
  // parse the content
129
 
130
  // fetch the feed
131
  $feed = fetch_feed($url);
132
+
133
 
134
  // save as posts
135
  $posts = $this->save($feed, $args);
150
  //if api key has been saved by user and is not empty
151
  if (isset($key) && !empty($key)) {
152
 
153
+ $api_url = "http://176.58.108.28/makefulltextfeed.php?key=" . $key . "&url=" . $url;
154
 
155
  return $api_url;
156
  }
309
  }else{
310
  $tags_name = array();
311
  }
312
+ $parser->_parse($item, $args['feed_title'], $args['strip_html']);
313
  $post = array(
314
  'post_title' => $item->get_title(),
315
  // parse the content
app/templates/settings-table.php CHANGED
@@ -149,6 +149,22 @@
149
  </ul>
150
  </td>
151
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152
  <tr>
153
  <td>
154
  <?php _e('Enable logging?', "rss_pi"); ?>
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"); ?>
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.0.5
9
  Author URI: https://www.feedsapi.org/
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -28,7 +28,7 @@ if (!defined('RSS_PI_BASENAME')) {
28
  }
29
 
30
  if (!defined('RSS_PI_VERSION')) {
31
- define('RSS_PI_VERSION', '2.0.5');
32
  }
33
 
34
  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.0.6
9
  Author URI: https://www.feedsapi.org/
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
28
  }
29
 
30
  if (!defined('RSS_PI_VERSION')) {
31
+ define('RSS_PI_VERSION', '2.0.6');
32
  }
33
 
34
  if (!defined('RSS_PI_LOG_PATH')) {
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: rss, feeds, import, feed, autoblog, feed aggregation, rss-feed, aggregatio
5
  RSSImport, yahoo pipes, WP Pipes, Import XML feed , FeedSyndicate, RSSpost, RSS in Page
6
  Requires at least: 3.5
7
  Tested up to: 4.1
8
- Stable tag: 2.0.5
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -77,6 +77,11 @@ WP-o-Matic , WP-o-Matic, RSSImport, FeedWordPress, Syndicate Press, FeedWeb, RSS
77
 
78
  == Change Log ==
79
 
 
 
 
 
 
80
  = Version 2.0.5 =
81
  * Broken links to images solved.
82
  * Added cron option for 10 minutes.
5
  RSSImport, yahoo pipes, WP Pipes, Import XML feed , FeedSyndicate, RSSpost, RSS in Page
6
  Requires at least: 3.5
7
  Tested up to: 4.1
8
+ Stable tag: 2.0.6
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
77
 
78
  == Change Log ==
79
 
80
+ = Version 2.0.6 =
81
+ * nofollow option for outbound links.
82
+ * Bug fixed($ sign not removing from content when feed importing)
83
+ * Bug fixed and Improvements in code.
84
+
85
  = Version 2.0.5 =
86
  * Broken links to images solved.
87
  * Added cron option for 10 minutes.