RSS Post Importer - Version 2.0.15

Version Description

Download this release

Release Info

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

Code changes from version 2.0.14 to 2.0.15

app/classes/admin/class-rss-pi-admin-processor.php CHANGED
@@ -323,9 +323,9 @@ class rssPIAdminProcessor {
323
 
324
  'author_id' => $this->is_key_valid ? $_POST[$id . '-author_id'] : $_POST['author_id'],
325
 
326
- 'category_id' => $_POST[$id . '-category_id'],
327
 
328
- 'tags_id' => $_POST[$id . '-tags_id'],
329
 
330
  'strip_html' => $_POST[$id . '-strip_html']
331
 
323
 
324
  'author_id' => $this->is_key_valid ? $_POST[$id . '-author_id'] : $_POST['author_id'],
325
 
326
+ 'category_id' => (isset($_POST[$id . '-category_id']))? $_POST[$id . '-category_id'] : "" ,
327
 
328
+ 'tags_id' => (isset($_POST[$id . '-tags_id']))? $_POST[$id . '-tags_id'] : "",
329
 
330
  'strip_html' => $_POST[$id . '-strip_html']
331
 
app/classes/admin/class-rss-pi-admin.php CHANGED
@@ -266,7 +266,7 @@ class rssPIAdmin {
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= "";
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= "";
app/classes/import/class-rss-pi-engine.php CHANGED
@@ -600,7 +600,7 @@ class rssPIEngine {
600
 
601
  foreach ($items as $item) {
602
 
603
- if (!$this->post_exists($item->get_permalink())) {
604
 
605
  /* Code to convert tags id array to tag name array **/
606
 
@@ -690,13 +690,14 @@ class rssPIEngine {
690
  }
691
 
692
 
 
 
 
693
  // insert as post
694
  $post_id = $this->_insert($post, $item->get_permalink());
695
 
696
 
697
-
698
  // set thumbnail
699
-
700
  $thumbnail->_set($item, $post_id);
701
 
702
 
@@ -726,32 +727,55 @@ class rssPIEngine {
726
 
727
  */
728
 
729
- private function post_exists($permalink) {
730
 
 
731
 
 
 
 
 
 
732
 
733
- // get all posts where the meta is stored
 
734
 
735
- $args = array(
 
736
 
737
- 'post_status' => 'any',
 
 
 
 
 
 
738
 
739
- 'meta_key' => 'rss_pi_source_url',
740
-
741
- 'meta_value' => esc_url($permalink)
742
-
743
- );
744
 
 
745
 
 
 
746
 
747
- $posts = get_posts($args);
 
 
748
 
749
 
 
750
 
751
- // Not already imported
752
 
753
- return(count($posts) > 0);
754
 
 
 
 
 
 
 
 
755
  }
756
 
757
 
@@ -807,6 +831,14 @@ class rssPIEngine {
807
  add_post_meta($post_id, 'rss_pi_source_url', esc_url($url));
808
 
809
 
 
 
 
 
 
 
 
 
810
 
811
  return $post_id;
812
 
@@ -856,6 +888,7 @@ class rssPIEngine {
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();
@@ -887,5 +920,7 @@ class rssPIEngine {
887
  }
888
 
889
 
 
 
890
  }
891
 
600
 
601
  foreach ($items as $item) {
602
 
603
+ if (!$this->post_exists($item)) {
604
 
605
  /* Code to convert tags id array to tag name array **/
606
 
690
  }
691
 
692
 
693
+ //elminatins unnecessary characterss
694
+ $post["post_content"] = str_replace("Â", "", $post["post_content"]);
695
+
696
  // insert as post
697
  $post_id = $this->_insert($post, $item->get_permalink());
698
 
699
 
 
700
  // set thumbnail
 
701
  $thumbnail->_set($item, $post_id);
702
 
703
 
727
 
728
  */
729
 
730
+ private function post_exists($item) {
731
 
732
+ global $wpdb;
733
 
734
+ $permalink = $item->get_permalink();
735
+ $title = $item->get_title();
736
+ $domain_old = $this->get_domain($item->get_permalink());
737
+
738
+ $post_exists = 0;
739
 
740
+ //checking if post title already exists
741
+ if( $posts = $wpdb->get_results("SELECT ID FROM ".$wpdb->prefix."posts WHERE post_title = '" . $title . "' and post_status = 'publish' ", 'ARRAY_A') ) {
742
 
743
+ //checking if post source is also same
744
+ foreach($posts as $post) {
745
 
746
+ $post_id = $post["ID"];
747
+ $source_url = get_post_meta($post_id , "rss_pi_source_url" , true);
748
+ $domain_new = $this->get_domain($source_url);
749
+
750
+ if($domain_new == $domain_old) {
751
+ $post_exists = 1;
752
+ }
753
 
754
+ }
 
 
 
 
755
 
756
+ }
757
 
758
+ //check if the post has already been imported and then deleted
759
+ $rss_pi_imported_posts = get_option("rss_pi_imported_posts");
760
 
761
+ if(in_array( $permalink , $rss_pi_imported_posts)) {
762
+ $post_exists = 1;
763
+ }
764
 
765
 
766
+ return $post_exists;
767
 
768
+ }
769
 
770
+ private function get_domain($url){
771
 
772
+ $pieces = parse_url($url);
773
+ $domain = isset($pieces['host']) ? $pieces['host'] : '';
774
+ if (preg_match('/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i', $domain, $regs)) {
775
+ return $regs['domain'];
776
+ }
777
+ return false;
778
+
779
  }
780
 
781
 
831
  add_post_meta($post_id, 'rss_pi_source_url', esc_url($url));
832
 
833
 
834
+ //saving each post URL in option table
835
+ $rss_pi_imported_posts = get_option("rss_pi_imported_posts");
836
+ if( !is_array($rss_pi_imported_posts) ) {
837
+ $rss_pi_imported_posts = array();
838
+ }
839
+ $rss_pi_imported_posts[] = $url;
840
+ update_option( "rss_pi_imported_posts" , $rss_pi_imported_posts );
841
+
842
 
843
  return $post_id;
844
 
888
  function add_to_media($url , $associated_with_post , $desc ) {
889
 
890
  $tmp = download_url( $url );
891
+
892
  $post_id = $associated_with_post;
893
  $desc = $desc;
894
  $file_array = array();
920
  }
921
 
922
 
923
+
924
+
925
  }
926
 
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.14
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.14');
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.15
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.15');
32
  }
33
 
34
  if (!defined('RSS_PI_LOG_PATH')) {
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.14
16
 
17
  License: GPLv2 or later
18
 
@@ -163,6 +163,12 @@ WP-o-Matic , WP-o-Matic, RSSImport, FeedWordPress, Syndicate Press, FeedWeb, RSS
163
 
164
  == Change Log ==
165
 
 
 
 
 
 
 
166
  = Version 2.0.14 =
167
 
168
  * Added option to import/export settings
12
 
13
  Tested up to: 4.1
14
 
15
+ Stable tag: 2.0.15
16
 
17
  License: GPLv2 or later
18
 
163
 
164
  == Change Log ==
165
 
166
+ = Version 2.0.15 =
167
+
168
+ * Duplicate post issue
169
+ * Warning messages
170
+ * Encoding issue
171
+
172
  = Version 2.0.14 =
173
 
174
  * Added option to import/export settings