RSS Post Importer - Version 1.0.1

Version Description

Download this release

Release Info

Developer jenswaern
Plugin Icon 128x128 RSS Post Importer
Version 1.0.1
Comparing to
See all releases

Version 1.0.1

css/rss_pi.css ADDED
@@ -0,0 +1 @@
 
1
+ .rss_pi-table{margin-bottom:20px}.rss_pi-table tbody tr.edit-row{display:none}.rss_pi-table tbody tr.edit-row.show{display:table-row}.rss_pi-table tbody tr.edit-row>td{padding:0;border-top:0 none}.rss_pi-table tbody tr.edit-row table{border:0 none;margin:0}.rss_pi-table tbody tr.edit-row table tr td{border:0 none;border-top:1px solid #f0f0f0;background:#fff}.rss_pi-table tbody tr.edit-row table tr td:first-child{background:#f9f9f9;border-right:1px solid #e1e1e1;width:440px}.rss_pi-table tbody tr.edit-row table tr td label{font-weight:bold}.rss_pi-table tbody tr.edit-row table tr td p.description{color:#9f9f9f;font-size:.8em;font-style:normal}.rss_pi-table tbody tr.edit-row table tr td input,.rss_pi-table tbody tr.edit-row table tr td textarea{padding:8px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;width:100%}.rss_pi-table tbody tr.edit-row table tr td .radiolist li label{font-weight:normal;display:inline-block}.rss_pi-table tbody tr.edit-row table tr td .radiolist li label input{display:inline-block;width:auto;margin-right:10px}.rss_pi-table tbody tr.data-row.show td{background:#2a95c5;background:-webkit-gradient(linear,left bottom,left top,color-stop(0,#185571),color-stop(1,#2a95c5));background:-ms-linear-gradient(bottom,#185571,#2a95c5);background:-moz-linear-gradient(center bottom,#185571 0,#2a95c5 100%);background:-o-linear-gradient(#2a95c5,#185571);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#2a95c5',endColorstr='#185571',GradientType=0);border-top:1px solid #2a95c5;color:white;text-shadow:0 1px 1px rgba(0,0,0,0.5)}.rss_pi-table tbody tr.data-row.show td a{color:white;text-shadow:0 1px 1px rgba(0,0,0,0.5)}.rss_pi-table tbody tr td{border-bottom:1px solid #e1e1e1;padding:10px}.rss_pi-table tbody tr td .row-options{visibility:hidden}.rss_pi-table tbody tr td:hover .row-options{visibility:visible}.rss_pi-table tfoot tr td{padding:10px;text-align:right}
js/rss_pi.js ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function($){
2
+
3
+ // Edit-buttons
4
+ $('body').delegate('a.toggle-edit', 'click', function() {
5
+ $('#edit_' + $(this).attr('data-target')).toggleClass('show');
6
+ $('#display_' + $(this).attr('data-target')).toggleClass('show');
7
+ return false;
8
+ });
9
+
10
+ // Delete-buttons
11
+ $('body').delegate('a.delete-row', 'click', function() {
12
+ $('#edit_' + $(this).attr('data-target')).remove();
13
+ $('#display_' + $(this).attr('data-target')).remove();
14
+ update_ids();
15
+ return false;
16
+ });
17
+
18
+
19
+ $('a.add-row').click(function() {
20
+ $.ajax({
21
+ type: 'POST',
22
+ url: rss_pi_ajax.ajaxurl,
23
+ data: ({
24
+ action: 'rss_pi_add_row'
25
+ }),
26
+ success: function(data) {
27
+ $('.rss-rows').append( data );
28
+ $('.empty_table').remove();
29
+ update_ids();
30
+ }
31
+ });
32
+ return false;
33
+ });
34
+
35
+ $('#save_and_import').click(function() {
36
+ $('#save_to_db').val('true');
37
+ });
38
+
39
+ })(jQuery);
40
+
41
+ function update_ids()
42
+ {
43
+ ids = jQuery('input[name="id"]').map(function() {
44
+ return jQuery(this).val();
45
+ }).get().join();
46
+
47
+ jQuery('#ids').val(ids);
48
+ }
lang/rss_pi-es_ES.mo ADDED
Binary file
lang/rss_pi-es_ES.po ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Rss Post Importer v1.0.1\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: \n"
6
+ "PO-Revision-Date: 2013-09-09 11:28:50+0000\n"
7
+ "Last-Translator: admin <jens@simmalugnt.se>\n"
8
+ "Language-Team: \n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "Plural-Forms: nplurals=2; plural=n != 1;\n"
13
+ "X-Generator: CSL v1.x\n"
14
+ "X-Poedit-Language: Spanish\n"
15
+ "X-Poedit-Country: SPAIN\n"
16
+ "X-Poedit-SourceCharset: utf-8\n"
17
+ "X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;\n"
18
+ "X-Poedit-Basepath: ../\n"
19
+ "X-Poedit-Bookmarks: \n"
20
+ "X-Poedit-SearchPath-0: .\n"
21
+ "X-Textdomain-Support: yes"
22
+
23
+ #: parts/table_row.php:26
24
+ #@ default
25
+ msgid "Edit"
26
+ msgstr ""
27
+
28
+ #: parts/table_row.php:27
29
+ #@ default
30
+ msgid "Delete"
31
+ msgstr ""
32
+
33
+ #: parts/table_row.php:38
34
+ #: rss_pi-ui.php:25
35
+ #@ rss_pi
36
+ msgid "Feed name"
37
+ msgstr ""
38
+
39
+ #: parts/table_row.php:45
40
+ #: rss_pi-ui.php:26
41
+ #@ rss_pi
42
+ msgid "Feed url"
43
+ msgstr ""
44
+
45
+ #: parts/table_row.php:51
46
+ #: rss_pi-ui.php:27
47
+ #@ rss_pi
48
+ msgid "Max posts / import"
49
+ msgstr "Puestos / importación Máx"
50
+
51
+ #: parts/table_row.php:55
52
+ #: rss_pi-ui.php:28
53
+ #@ default
54
+ msgid "Category"
55
+ msgstr ""
56
+
57
+ #: parts/table_row.php:63
58
+ #: rss_pi-ui.php:138
59
+ #@ default
60
+ msgid "Yes"
61
+ msgstr ""
62
+
63
+ #: parts/table_row.php:66
64
+ #: rss_pi-ui.php:141
65
+ #@ default
66
+ msgid "No"
67
+ msgstr ""
68
+
69
+ #: parts/table_row.php:73
70
+ #@ default
71
+ msgid "Close"
72
+ msgstr ""
73
+
74
+ #: rss_pi-ui.php:2
75
+ #@ rss_pi
76
+ msgid "Rss import settings"
77
+ msgstr "Ajustes de importación rss"
78
+
79
+ #: rss_pi-ui.php:15
80
+ #@ default
81
+ msgid "Save"
82
+ msgstr ""
83
+
84
+ #: rss_pi-ui.php:16
85
+ #@ rss_pi
86
+ msgid "Save and import"
87
+ msgstr "Guardar e importar"
88
+
89
+ #: rss_pi-ui.php:43
90
+ #@ rss_pi
91
+ msgid "You haven't specified any feeds to import yet, why don't you <a href=\"#\" class=\"add-row\">add one now</a>?"
92
+ msgstr "Usted no se ha especificado ninguna fuente para importar, sin embargo, ¿por qué no <a href=\"#\" class=\"add-row\"> agrega uno ahora </ a>?"
93
+
94
+ #: rss_pi-ui.php:53
95
+ #@ rss_pi
96
+ msgid "Add new feed"
97
+ msgstr "Añadir nuevo"
98
+
99
+ #: rss_pi-ui.php:65
100
+ #@ default
101
+ msgid "Settings"
102
+ msgstr ""
103
+
104
+ #: rss_pi-ui.php:74
105
+ #@ rss_pi
106
+ msgid "Frequency"
107
+ msgstr "Frecuencia"
108
+
109
+ #: rss_pi-ui.php:75
110
+ #@ rss_pi
111
+ msgid "How often will the import run."
112
+ msgstr "¿Con qué frecuencia se ejecutará la importación."
113
+
114
+ #: rss_pi-ui.php:88
115
+ #@ default
116
+ msgid "Template"
117
+ msgstr ""
118
+
119
+ #: rss_pi-ui.php:89
120
+ #@ rss_pi
121
+ msgid "This is how the post will be formatted."
122
+ msgstr "Así es como se formatea el mensaje."
123
+
124
+ #: rss_pi-ui.php:91
125
+ #@ rss_pi
126
+ msgid "Available tags:"
127
+ msgstr "Etiquetas disponibles:"
128
+
129
+ #: rss_pi-ui.php:103
130
+ #@ rss_pi
131
+ msgid "Post status"
132
+ msgstr "Publique estado"
133
+
134
+ #: rss_pi-ui.php:121
135
+ #@ default
136
+ msgid "Author"
137
+ msgstr ""
138
+
139
+ #: rss_pi-ui.php:134
140
+ #@ rss_pi
141
+ msgid "Allow comments"
142
+ msgstr "Permitir comentarios"
143
+
144
+ #: rss_pi.php:95
145
+ #@ default
146
+ msgid "Settings saved."
147
+ msgstr ""
148
+
149
+ #: rss_pi.php:103
150
+ #@ default
151
+ msgid "new posts imported."
152
+ msgstr ""
153
+
154
+ #: parts/table_row.php:59
155
+ #@ rss_pi
156
+ msgid "Strip html tags"
157
+ msgstr "Strip etiquetas HTML"
158
+
lang/rss_pi-sv_SE.mo ADDED
Binary file
lang/rss_pi-sv_SE.po ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Rss Post Importer v1.0.1\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: \n"
6
+ "PO-Revision-Date: 2013-09-09 11:28:16+0000\n"
7
+ "Last-Translator: admin <jens@simmalugnt.se>\n"
8
+ "Language-Team: \n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "Plural-Forms: nplurals=2; plural=n != 1;\n"
13
+ "X-Generator: CSL v1.x\n"
14
+ "X-Poedit-Language: Swedish\n"
15
+ "X-Poedit-Country: SWEDEN\n"
16
+ "X-Poedit-SourceCharset: utf-8\n"
17
+ "X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;\n"
18
+ "X-Poedit-Basepath: \n"
19
+ "X-Poedit-Bookmarks: \n"
20
+ "X-Poedit-SearchPath-0: .\n"
21
+ "X-Textdomain-Support: yes"
22
+
23
+ #: parts/table_row.php:26
24
+ #@ default
25
+ msgid "Edit"
26
+ msgstr ""
27
+
28
+ #: parts/table_row.php:27
29
+ #@ default
30
+ msgid "Delete"
31
+ msgstr ""
32
+
33
+ #: parts/table_row.php:38
34
+ #: rss_pi-ui.php:25
35
+ #@ rss_pi
36
+ msgid "Feed name"
37
+ msgstr "Flödesnamn"
38
+
39
+ #: parts/table_row.php:45
40
+ #: rss_pi-ui.php:26
41
+ #@ rss_pi
42
+ msgid "Feed url"
43
+ msgstr "Url"
44
+
45
+ #: parts/table_row.php:51
46
+ #: rss_pi-ui.php:27
47
+ #@ rss_pi
48
+ msgid "Max posts / import"
49
+ msgstr "Max poster / import"
50
+
51
+ #: parts/table_row.php:55
52
+ #: rss_pi-ui.php:28
53
+ #@ default
54
+ msgid "Category"
55
+ msgstr ""
56
+
57
+ #: rss_pi-ui.php:2
58
+ #@ rss_pi
59
+ msgid "Rss import settings"
60
+ msgstr "Rss import inställningar"
61
+
62
+ #: rss_pi-ui.php:15
63
+ #@ default
64
+ msgid "Save"
65
+ msgstr ""
66
+
67
+ #: rss_pi-ui.php:16
68
+ #@ rss_pi
69
+ msgid "Save and import"
70
+ msgstr "Spara och importera"
71
+
72
+ #: rss_pi-ui.php:43
73
+ #@ rss_pi
74
+ msgid "You haven't specified any feeds to import yet, why don't you <a href=\"#\" class=\"add-row\">add one now</a>?"
75
+ msgstr "Du har inte lagt till några flöden att importera, varför inte <a href=\"#\" class=\"add-row\">lägga till ett nu</a>?"
76
+
77
+ #: rss_pi-ui.php:53
78
+ #@ rss_pi
79
+ msgid "Add new feed"
80
+ msgstr "Lägg till flöde"
81
+
82
+ #: rss_pi-ui.php:65
83
+ #@ default
84
+ msgid "Settings"
85
+ msgstr ""
86
+
87
+ #: rss_pi-ui.php:74
88
+ #@ rss_pi
89
+ msgid "Frequency"
90
+ msgstr "Frekvens"
91
+
92
+ #: rss_pi-ui.php:88
93
+ #@ default
94
+ msgid "Template"
95
+ msgstr ""
96
+
97
+ #: rss_pi-ui.php:103
98
+ #@ rss_pi
99
+ msgid "Post status"
100
+ msgstr "Post status"
101
+
102
+ #: rss_pi-ui.php:121
103
+ #@ default
104
+ msgid "Author"
105
+ msgstr ""
106
+
107
+ #: rss_pi-ui.php:134
108
+ #@ rss_pi
109
+ msgid "Allow comments"
110
+ msgstr "Tillåt kommentarer"
111
+
112
+ #: rss_pi.php:95
113
+ #@ default
114
+ msgid "Settings saved."
115
+ msgstr ""
116
+
117
+ #: rss_pi.php:103
118
+ #@ default
119
+ msgid "new posts imported."
120
+ msgstr ""
121
+
122
+ #: rss_pi-ui.php:75
123
+ #@ rss_pi
124
+ msgid "How often will the import run."
125
+ msgstr "Hur ofta skall importen köras?"
126
+
127
+ #: rss_pi-ui.php:89
128
+ #@ rss_pi
129
+ msgid "This is how the post will be formatted."
130
+ msgstr "Så här kommer innehållet formatteras."
131
+
132
+ #: rss_pi-ui.php:91
133
+ #@ rss_pi
134
+ msgid "Available tags:"
135
+ msgstr "Tillgängliga taggar:"
136
+
137
+ #: parts/table_row.php:63
138
+ #: rss_pi-ui.php:138
139
+ #@ default
140
+ msgid "Yes"
141
+ msgstr ""
142
+
143
+ #: parts/table_row.php:66
144
+ #: rss_pi-ui.php:141
145
+ #@ default
146
+ msgid "No"
147
+ msgstr ""
148
+
149
+ #: parts/table_row.php:59
150
+ #@ rss_pi
151
+ msgid "Strip html tags"
152
+ msgstr "Ta bort html-taggar"
153
+
154
+ #: parts/table_row.php:73
155
+ #@ default
156
+ msgid "Close"
157
+ msgstr ""
158
+
parts/table_row.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $show = '';
3
+
4
+ if(!isset($f))
5
+ {
6
+ $f = array(
7
+ 'id' => uniqid(),
8
+ 'name' => 'New feed',
9
+ 'url' => '',
10
+ 'max_posts' => 5,
11
+ 'category_id' => 1,
12
+ 'strip_html' => 'false'
13
+ );
14
+
15
+ $show = 'show';
16
+ }
17
+
18
+ $category = get_the_category_by_ID( intval($f['category_id']) );
19
+
20
+ ?>
21
+
22
+ <tr id="display_<?php echo ($f['id']); ?>" class="data-row <?php echo $show; ?>">
23
+ <td>
24
+ <strong><a href="#" class="toggle-edit" data-target="<?php echo ($f['id']); ?>"><?php echo $f['name']; ?></a></strong>
25
+ <div class="row-options">
26
+ <a href="#" class="toggle-edit" data-target="<?php echo ($f['id']); ?>"><?php _e('Edit'); ?></a> |
27
+ <a href="#" class="delete-row" data-target="<?php echo ($f['id']); ?>"><?php _e('Delete'); ?></a>
28
+ </div>
29
+ </td>
30
+ <td><?php echo $f['url']; ?></td>
31
+ <td><?php echo $f['max_posts']; ?></td>
32
+ <td><?php echo $category; ?></td>
33
+ </tr>
34
+ <tr id="edit_<?php echo ($f['id']); ?>" class="edit-row <?php echo $show; ?>">
35
+ <td colspan="4">
36
+ <table class="widefat edit-table">
37
+ <tr>
38
+ <td><label for="<?php echo ($f['id']); ?>-name"><?php _e("Feed name", 'rss_pi'); ?></label></td>
39
+ <td>
40
+ <input type="text" name="<?php echo ($f['id']); ?>-name" id="<?php echo ($f['id']); ?>-name" value="<?php echo ($f['name']); ?>" />
41
+ </td>
42
+ </tr>
43
+ <tr>
44
+ <td>
45
+ <label for="<?php echo ($f['id']); ?>"><?php _e("Feed url", 'rss_pi'); ?></label>
46
+ <p class="description">ie "http://news.google.com/?output=rss"</p>
47
+ </td>
48
+ <td><input type="text" name="<?php echo ($f['id']); ?>-url" id="<?php echo ($f['id']); ?>-url" value="<?php echo ($f['url']); ?>" /></td>
49
+ </tr>
50
+ <tr>
51
+ <td><label for=""><?php _e("Max posts / import", 'rss_pi'); ?></label></td>
52
+ <td><input type="number" name="<?php echo ($f['id']); ?>-max_posts" id="<?php echo ($f['id']); ?>-max_posts" value="<?php echo ($f['max_posts']); ?>" min="1" max="100" /></td>
53
+ </tr>
54
+ <tr>
55
+ <td><label for=""><?php _e("Category"); ?></label></td>
56
+ <td><?php wp_dropdown_categories( array('hide_empty' => 0, 'name' => 'select_name', 'hierarchical' => true, 'id' => $f['id'] . '-category_id', 'name' => $f['id'] . '-category_id', 'selected' => $f['category_id'] )); ?></td>
57
+ </tr>
58
+ <tr>
59
+ <td><label for=""><?php _e("Strip html tags", 'rss_pi'); ?></label></td>
60
+ <td>
61
+ <ul class="radiolist">
62
+ <li>
63
+ <label><input type="radio" id="<?php echo($f['id']); ?>-strip_html" name="<?php echo($f['id']); ?>-strip_html" value="true" <?php echo($f['strip_html'] == 'true' ? 'checked="checked"' : ''); ?> /> <?php _e('Yes'); ?></label>
64
+ </li>
65
+ <li>
66
+ <label><input type="radio" id="<?php echo($f['id']); ?>-strip_html" name="<?php echo($f['id']); ?>-strip_html" value="false" <?php echo($f['strip_html'] == 'false' ? 'checked="checked"' : ''); ?> /> <? _e('No'); ?></label>
67
+ </li>
68
+ </ul>
69
+ </td>
70
+ </tr>
71
+ <tr>
72
+ <td><input type="hidden" name="id" value="<?php echo($f['id']); ?>" /></td>
73
+ <td><a id="close-edit-table" class="button button-large toggle-edit" data-target="<?php echo ($f['id']); ?>"><?php _e('Close'); ?></a></td>
74
+ </tr>
75
+ </table>
76
+
77
+ </td>
78
+ </tr>
readme.txt ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Rss Post Importer ===
2
+ Contributors: jenswaern
3
+ Donate link: https://inspirepay.com/pay/simmalugnt
4
+ Tags: rss, feeds, import, feed, autoblog, feed aggregation, rss-feed
5
+ Requires at least: 3.5
6
+ Tested up to: 3.6
7
+ Stable tag: trunk
8
+ License: GPLv2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
+
11
+ 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
+ == Description ==
14
+
15
+ This plugin is not a shortcode for just displaying displaying a bunch of links from an rss feeds, it imports data from a feed and saves it as posts.
16
+
17
+ Features include:
18
+ * Importing feeds automatically using cron.
19
+ * Set number of posts and category per feed.
20
+ * Set what author to assign imported content to.
21
+ * Simple template for formatting imported content.
22
+
23
+ == Installation ==
24
+
25
+ 1. Upload the files to the `/wp-content/plugins/` directory
26
+ 1. Activate the plugin through the 'Plugins' menu in WordPress
27
+ 1. Set up what feeds to import and when!
28
+
29
+ == Screenshots ==
30
+
31
+ 1. This is the combined settings- and feed-management-screen.
rss_pi-ui.php ADDED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="wrap">
2
+ <h2><?php _e("Rss import settings", 'rss_pi'); ?></h2>
3
+ <form method="post">
4
+ <input type="hidden" name="save_to_db" id="save_to_db" />
5
+ <?php wp_nonce_field('settings_page','rss_pi_nonce'); ?>
6
+ <div id="poststuff">
7
+ <div id="post-body" class="metabox-holder columns-2">
8
+ <div id="postbox-container-1" class="postbox-container">
9
+ <div class="postbox">
10
+ <div class="inside">
11
+ <div class="misc-pub-section">
12
+ Latest import: <strong><?php echo($options['latest_import']); ?></strong>
13
+ </div>
14
+ <div id="major-publishing-actions">
15
+ <input class="button button-primary button-large right" type="submit" name="info_update" value="<?php _e('Save'); ?>" />
16
+ <input class="button button-large" type="submit" name="info_update" value="<?php _e('Save and import', "rss_pi"); ?>" id="save_and_import" />
17
+ </div>
18
+ </div>
19
+ </div>
20
+ </div>
21
+ <div id="postbox-container-2" class="postbox-container">
22
+ <table class="widefat rss_pi-table" id="rss_pi-table">
23
+ <thead>
24
+ <tr>
25
+ <th><?php _e("Feed name", 'rss_pi'); ?></th>
26
+ <th><?php _e("Feed url", 'rss_pi'); ?></th>
27
+ <th><?php _e("Max posts / import", 'rss_pi'); ?></th>
28
+ <th><?php _e("Category"); ?></th>
29
+ </tr>
30
+ </thead>
31
+ <tbody class="rss-rows">
32
+ <?php
33
+ if(is_array($options['feeds']) && count($options['feeds']) > 0) :
34
+ foreach($options['feeds'] as $f) :
35
+ $category = get_the_category( $f['category_id'] );
36
+ array_push($ids, $f['id']);
37
+ include( plugin_dir_path( __FILE__ ) . 'parts/table_row.php');
38
+ endforeach;
39
+ else :
40
+ ?>
41
+ <tr>
42
+ <td colspan="4" class="empty_table">
43
+ <?php _e('You haven\'t specified any feeds to import yet, why don\'t you <a href="#" class="add-row">add one now</a>?', "rss_pi"); ?>
44
+ </td>
45
+ </tr>
46
+ <?php
47
+ endif
48
+ ?>
49
+ </tbody>
50
+ <tfoot>
51
+ <tr>
52
+ <td colspan="4">
53
+ <a href="#" class="button button-large button-primary add-row"><?php _e('Add new feed', "rss_pi"); ?></a>
54
+ <input type="hidden" name="ids" id="ids" value="<?php echo(join($ids, ',')); ?>" />
55
+ </td>
56
+ </tr>
57
+ </tfoot>
58
+ </table>
59
+
60
+
61
+
62
+ <table class="widefat rss_pi-table" id="rss_pi-table">
63
+ <thead>
64
+ <tr>
65
+ <th colspan="5"><?php _e('Settings'); ?></th>
66
+ </tr>
67
+ </thead>
68
+ <tbody class="setting-rows">
69
+ <tr class="edit-row show">
70
+ <td colspan="4">
71
+ <table class="widefat edit-table">
72
+ <tr>
73
+ <td>
74
+ <label for="frequency"><?php _e('Frequency', "rss_pi"); ?></label>
75
+ <p class="description"><?php _e('How often will the import run.', "rss_pi"); ?></p>
76
+ </td>
77
+ <td>
78
+ <select name="frequency" id="frequency">
79
+ <?php $x = wp_get_schedules(); ?>
80
+ <?php foreach(array_keys($x) as $interval) : ?>
81
+ <option value="<?php echo $interval; ?>" <?php if($options['settings']['frequency'] == $interval) : echo('selected="selected"'); endif; ?>><?php echo $x[$interval][ 'display' ]; ?></option>
82
+ <?php endforeach; ?>
83
+ </select>
84
+ </td>
85
+ </tr>
86
+ <tr>
87
+ <td>
88
+ <label for="post_template"><?php _e('Template'); ?></label>
89
+ <p class="description"><?php _e('This is how the post will be formatted.', "rss_pi"); ?></p>
90
+ <p class="description">
91
+ <?php _e('Available tags:', "rss_pi"); ?>
92
+ <code>{$content}</code>
93
+ <code>{$permalink}</code>
94
+ <code>{$title}</code>
95
+ <code>{$feed_title}</code>
96
+ </p>
97
+ </td>
98
+ <td>
99
+ <textarea name="post_template" id="post_template" cols="30" rows="10"><?php echo($options['settings']['post_template'] != '' ? $options['settings']['post_template'] : "{\$content}\nSource: {\$feed_title}"); ?></textarea>
100
+ </td>
101
+ </tr>
102
+ <tr>
103
+ <td><?php _e('Post status', "rss_pi"); ?></td>
104
+ <td>
105
+
106
+ <select name="post_status" id="post_status">
107
+ <?php
108
+ $statuses = get_post_stati('', 'objects');
109
+
110
+ foreach($statuses as $status)
111
+ {
112
+ ?>
113
+ <option value="<?php echo($status->name);?>" <?php if($options['settings']['post_status'] == $status->name) : echo('selected="selected"'); endif; ?>><?php echo($status->label);?></option>
114
+ <?php
115
+ }
116
+ ?>
117
+ </select>
118
+ </td>
119
+ </tr>
120
+ <tr>
121
+ <td><?php _e('Author'); ?></td>
122
+ <td>
123
+ <?php
124
+ $args = array(
125
+ 'id' => 'author_id',
126
+ 'name' => 'author_id',
127
+ 'selected' => $options['settings']['author_id']
128
+ );
129
+ wp_dropdown_users( $args );
130
+ ?>
131
+ </td>
132
+ </tr>
133
+ <tr>
134
+ <td><?php _e('Allow comments', "rss_pi"); ?></td>
135
+ <td>
136
+ <ul class="radiolist">
137
+ <li>
138
+ <label><input type="radio" id="allow_comments" name="allow_comments" value="true" <?php echo($options['settings']['allow_comments'] == 'true' || $options['settings']['allow_comments'] == '' ? 'checked="checked"' : ''); ?> /> <?php _e('Yes'); ?></label>
139
+ </li>
140
+ <li>
141
+ <label><input type="radio" id="allow_comments" name="allow_comments" value="false" <?php echo($options['settings']['allow_comments'] == 'false' ? 'checked="checked"' : ''); ?> /> <?php _e('No'); ?></label>
142
+ </li>
143
+ </ul>
144
+ </td>
145
+ </tr>
146
+ </table>
147
+ </td>
148
+ </tr>
149
+ </tbody>
150
+ </table>
151
+ </div>
152
+ </div>
153
+ <br class="clear" />
154
+ </div>
155
+ </form>
156
+ </div>
rss_pi.php ADDED
@@ -0,0 +1,256 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Rss Post Importer
4
+ Plugin URI: -
5
+ 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.
6
+ Author: Jens Waern
7
+ Version: 1.0.1
8
+ Author URI: http://www.simmalugnt.se
9
+ License: GPLv2 or later
10
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
+ */
12
+
13
+
14
+ add_action('wp_ajax_rss_pi_add_row', 'rss_pi_add_row');
15
+
16
+ function rss_pi_add_row()
17
+ {
18
+ include( plugin_dir_path( __FILE__ ) . 'parts/table_row.php');
19
+ exit;
20
+ }
21
+
22
+ class rss_pi {
23
+
24
+ function __construct() {
25
+ add_action('admin_menu', array(&$this, 'admin_menu'));
26
+
27
+ $this->settings = array(
28
+ 'version' => '1.0',
29
+ 'dir' => plugin_dir_path( __FILE__ )
30
+ );
31
+
32
+ load_textdomain('rss_pi', $this->settings['dir'] . 'lang/rss_pi-' . get_locale() . '.mo');
33
+ }
34
+
35
+
36
+ // On an early action hook, check if the hook is scheduled - if not, schedule it.
37
+ function rss_pi_setup_schedule() {
38
+ if ( ! wp_next_scheduled( 'rss_pi_cron' ) ) {
39
+ wp_schedule_event( time(), 'hourly', 'rss_pi_cron');
40
+ }
41
+ }
42
+
43
+ // On the scheduled action hook, run a function.
44
+ function rss_pi_do_this_hourly()
45
+ {
46
+ $this->import_all_feeds();
47
+ }
48
+
49
+ // Add to settings-menu
50
+ function admin_menu () {
51
+ add_options_page('Rss Post Importer','Rss Post Importer','manage_options','rss_pi', array($this, 'settings_page'));
52
+ }
53
+
54
+ function settings_page () {
55
+ // Changes submitted, correct nonce
56
+ if( isset($_POST['info_update']) && wp_verify_nonce($_POST['rss_pi_nonce'],'settings_page')) :
57
+
58
+ // Get ids of feed-rows
59
+ $ids = explode(",", $_POST['ids']);
60
+
61
+ $feeds = array();
62
+
63
+
64
+ $settings = array(
65
+ 'frequency' => $_POST['frequency'],
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
+ );
71
+
72
+ // Reset cron
73
+ wp_clear_scheduled_hook( 'rss_pi_cron' );
74
+ wp_schedule_event( time(), $settings['frequency'], 'rss_pi_cron');
75
+
76
+ foreach($ids as $id)
77
+ {
78
+ if($id)
79
+ {
80
+ array_push($feeds, array(
81
+ 'id' => $id,
82
+ 'url' => strtolower($_POST[$id . '-url']),
83
+ 'name' => $_POST[$id . '-name'],
84
+ 'max_posts' => $_POST[$id . '-max_posts'],
85
+ 'category_id' => $_POST[$id . '-category_id'],
86
+ 'strip_html' => $_POST[$id . '-strip_html']
87
+ ));
88
+ }
89
+ }
90
+
91
+ update_option('rss_pi_feeds', array('feeds' => $feeds, 'settings' => $settings, 'latest_import' => ''));
92
+
93
+ ?>
94
+ <div id="message" class="updated">
95
+ <p><strong><?php _e('Settings saved.') ?></strong></p>
96
+ </div>
97
+ <?php
98
+
99
+ if($_POST['save_to_db'] == 'true') :
100
+ $imported = $this->import_all_feeds();
101
+ ?>
102
+ <div id="message" class="updated">
103
+ <p><strong><?php echo($imported); ?> <?php _e('new posts imported.') ?></strong></p>
104
+ </div>
105
+ <?php
106
+ endif;
107
+ endif;
108
+
109
+ $options = get_option('rss_pi_feeds');
110
+
111
+ $ids = array();
112
+
113
+
114
+ $this->input_admin_enqueue_scripts();
115
+
116
+ include( plugin_dir_path( __FILE__ ) . 'rss_pi-ui.php');
117
+ }
118
+
119
+
120
+ function import_feed($url, $feed_title, $max_posts, $category_id, $strip_html, $save_to_db)
121
+ {
122
+ include_once( ABSPATH . WPINC . '/feed.php' );
123
+
124
+ // Get a SimplePie feed object from the specified feed source.
125
+ $rss = fetch_feed( $url );
126
+
127
+ $options = get_option('rss_pi_feeds');
128
+
129
+ // Remove the surrounding <div> from XHTML content in Atom feeds.
130
+
131
+ if ( ! is_wp_error( $rss ) ) : // Checks that the object is created correctly
132
+
133
+ // Figure out how many total items there are, but limit it to 5.
134
+ $maxitems = $rss->get_item_quantity( $max_posts );
135
+
136
+ // Build an array of all the items, starting with element 0 (first element).
137
+ $rss_items = $rss->get_items( 0, $max_posts );
138
+
139
+ if($save_to_db)
140
+ {
141
+ $saved_posts = array();
142
+
143
+ foreach ( $rss_items as $item )
144
+ {
145
+ if (!$this->post_exists($item->get_permalink()))
146
+ {
147
+ $new_post = array(
148
+ 'post_title' => $item->get_title(),
149
+ 'post_content' => $this->parse_content($item, $feed_title, $strip_html),
150
+ 'post_status' => $options['settings']['post_status'],
151
+ 'post_author' => $options['settings']['author_id'],
152
+ 'post_category' => array($category_id),
153
+ 'comment_status'=> $options['settings']['allow_comments'],
154
+ 'post_date' => $item->get_date('Y-m-d H:i:s')
155
+ );
156
+
157
+ $post_id = wp_insert_post( $new_post );
158
+
159
+ add_post_meta( $post_id, 'rss_pi_source_url', esc_url($item->get_permalink()) );
160
+
161
+ array_push($saved_posts, $new_post);
162
+ }
163
+ }
164
+ return $saved_posts;
165
+ exit;
166
+ }
167
+ return $rss_items;
168
+ endif;
169
+ }
170
+
171
+ function return_frequency($seconds)
172
+ {
173
+ $options = get_option('rss_pi_feeds');
174
+ return $options['settings']['frequency'];
175
+ }
176
+
177
+ function import_all_feeds()
178
+ {
179
+
180
+ $post_count = 0;
181
+
182
+ $options = get_option('rss_pi_feeds');
183
+
184
+ add_filter( 'wp_feed_cache_transient_lifetime', array(&$this, 'return_frequency' ) );
185
+
186
+ foreach($options['feeds'] as $f)
187
+ {
188
+ $rss_items = $this->import_feed($f['url'], $f['name'], $f['max_posts'], $f['category_id'], $f['strip_html'], true);
189
+ $post_count += count($rss_items);
190
+ }
191
+
192
+ update_option('rss_pi_feeds', array(
193
+ 'feeds' => $options['feeds'],
194
+ 'settings' => $options['settings'],
195
+ 'latest_import' => date("Y-m-d H:i:s")
196
+ ));
197
+
198
+ remove_filter( 'wp_feed_cache_transient_lifetime', array(&$this, 'return_frequency' ) );
199
+
200
+ return $post_count;
201
+ }
202
+
203
+ function parse_content($item, $feed_title, $strip_html)
204
+ {
205
+ $options = get_option('rss_pi_feeds');
206
+ $post_template = $options['settings']['post_template'];
207
+ $c = $item->get_content() != "" ? $item->get_content() : $item->get_description();
208
+
209
+ $parsed_content = str_replace('{$content}', $c, $post_template);
210
+ $parsed_content = str_replace('{$permalink}', esc_url( $item->get_permalink() ), $parsed_content);
211
+ $parsed_content = str_replace('{$feed_title}', $feed_title, $parsed_content);
212
+ $parsed_content = str_replace('{$title}', $item->get_title(), $parsed_content);
213
+
214
+ if($strip_html == 'true')
215
+ {
216
+ $parsed_content = strip_tags($parsed_content);
217
+ }
218
+ return $parsed_content;
219
+ }
220
+
221
+ function post_exists($permalink)
222
+ {
223
+
224
+ $args = array(
225
+ 'meta_key' => 'rss_pi_source_url',
226
+ 'meta_value' => esc_url($permalink)
227
+ );
228
+
229
+ $posts = get_posts( $args );
230
+
231
+ // Not already imported
232
+ return(count($posts) > 0);
233
+ }
234
+
235
+ function input_admin_enqueue_scripts()
236
+ {
237
+ // register scripts & styles
238
+ wp_register_script( 'rss_pi', plugins_url( 'js/rss_pi.js', __FILE__ ), array('jquery'), $this->settings['version'] );
239
+ wp_register_style( 'rss_pi', plugins_url( 'css/rss_pi.css', __FILE__ ) , array(), $this->settings['version'] );
240
+ wp_localize_script('rss_pi', 'rss_pi_ajax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );
241
+
242
+ // scripts
243
+ wp_enqueue_script(array(
244
+ 'rss_pi'
245
+ ));
246
+
247
+ // styles
248
+ wp_enqueue_style(array(
249
+ 'rss_pi'
250
+ ));
251
+
252
+ }
253
+
254
+ }
255
+ new rss_pi;
256
+ ?>
screenshot-1.png ADDED
Binary file
uninstall.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ //if uninstall not called from WordPress exit
4
+ if ( !defined( 'WP_UNINSTALL_PLUGIN' ) )
5
+ exit();
6
+
7
+ $option_name = 'rss_pi_feeds';
8
+
9
+ // For Single site
10
+ if ( !is_multisite() )
11
+ {
12
+ delete_option( $option_name );
13
+ wp_clear_scheduled_hook( 'rss_pi_cron' );
14
+ }
15
+ // For Multisite
16
+ else
17
+ {
18
+ global $wpdb;
19
+ $blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
20
+ $original_blog_id = get_current_blog_id();
21
+ foreach ( $blog_ids as $blog_id )
22
+ {
23
+ switch_to_blog( $blog_id );
24
+ delete_site_option( $option_name );
25
+ wp_clear_scheduled_hook( 'rss_pi_cron' );
26
+ }
27
+ switch_to_blog( $original_blog_id );
28
+ }
29
+
30
+ ?>