Version Description
Download this release
Release Info
Developer | took77 |
Plugin | RSSImport |
Version | 4.5.0 |
Comparing to | |
See all releases |
Code changes from version 4.4.18 to 4.5.0
- readme.txt +5 -1
- rssimport.php +53 -18
readme.txt
CHANGED
@@ -7,7 +7,7 @@ Donate link: https://bueltge.de/wunschliste/
|
|
7 |
Tags: rss, post, content, post, feed
|
8 |
Requires at least: 1.5
|
9 |
Tested up to: 4.9
|
10 |
-
Stable tag: 4.
|
11 |
|
12 |
Display feeds on your blog, using PHP in your templates or Shortcode in your posts and pages.
|
13 |
|
@@ -69,6 +69,7 @@ For all (bool) parameters you can either use the strings `true` and `false` or t
|
|
69 |
1. `next_paging_title` - The title attribute of the next page link. Default is `more items`.
|
70 |
1. `use_simplepie` - (bool) If true, use SimplePie to parse the feed. SimplePie is included in WordPress 2.8 and newer and can parse both RSS and ATOM feeds. Default is `false` if used with Shortcode, `true` if used with the PHP function.
|
71 |
1. `view` - (bool) If true, calling the `RSSImport()` function will print the rendered HTML directly to the output. If false, the rendered HTML will be returned by the function as a string value and nothing will be output. Default when using PHP code is `true`. Default when using Shortcode is `false`.
|
|
|
72 |
|
73 |
The parameters `before_desc`, `after_desc`, `start_item` and `end_item` accepts the following variables which will be replaced:
|
74 |
|
@@ -142,6 +143,9 @@ or
|
|
142 |
1. Widget support
|
143 |
|
144 |
== Changelog ==
|
|
|
|
|
|
|
145 |
= v4.4.18 (2017-11-30) =
|
146 |
* Small code changes for more strict coding.
|
147 |
* Fix formatting topics on readme.
|
7 |
Tags: rss, post, content, post, feed
|
8 |
Requires at least: 1.5
|
9 |
Tested up to: 4.9
|
10 |
+
Stable tag: 4.5.0
|
11 |
|
12 |
Display feeds on your blog, using PHP in your templates or Shortcode in your posts and pages.
|
13 |
|
69 |
1. `next_paging_title` - The title attribute of the next page link. Default is `more items`.
|
70 |
1. `use_simplepie` - (bool) If true, use SimplePie to parse the feed. SimplePie is included in WordPress 2.8 and newer and can parse both RSS and ATOM feeds. Default is `false` if used with Shortcode, `true` if used with the PHP function.
|
71 |
1. `view` - (bool) If true, calling the `RSSImport()` function will print the rendered HTML directly to the output. If false, the rendered HTML will be returned by the function as a string value and nothing will be output. Default when using PHP code is `true`. Default when using Shortcode is `false`.
|
72 |
+
1. `random_sort` - (bool) If true, Items will be displayed in random order. Default when using Shortcode is `false`.
|
73 |
|
74 |
The parameters `before_desc`, `after_desc`, `start_item` and `end_item` accepts the following variables which will be replaced:
|
75 |
|
143 |
1. Widget support
|
144 |
|
145 |
== Changelog ==
|
146 |
+
= v4.5.0 (2017-12-01) =
|
147 |
+
* Added new parameter random_sort
|
148 |
+
|
149 |
= v4.4.18 (2017-11-30) =
|
150 |
* Small code changes for more strict coding.
|
151 |
* Fix formatting topics on readme.
|
rssimport.php
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
* Domain Path: /languages
|
7 |
* Description: Display Feeds in your blog. Use the function <code>RSSImport()</code>, a Widget or the Shortcode <code>[RSSImport]</code>.
|
8 |
* Author: Frank Bültge, took77
|
9 |
-
* Version: 4.
|
10 |
* License: GPLv3+
|
11 |
* Last change: 2017-11-29
|
12 |
*/
|
@@ -114,6 +114,7 @@ if ( ! defined( 'MAGPIE_CACHE_AGE' ) ) {
|
|
114 |
* @param string $next_paging_title
|
115 |
* @param int $use_simplepie
|
116 |
* @param int $view
|
|
|
117 |
*
|
118 |
* @return string
|
119 |
*/
|
@@ -156,7 +157,8 @@ function RSSImport(
|
|
156 |
$prev_paging_title = 'more items',
|
157 |
$next_paging_title = 'more items',
|
158 |
$use_simplepie = 1,
|
159 |
-
$view = 1
|
|
|
160 |
) {
|
161 |
|
162 |
// replace for yahoo pipes urls
|
@@ -177,6 +179,7 @@ function RSSImport(
|
|
177 |
$paging = (int) $paging;
|
178 |
$use_simplepie = (int) $use_simplepie;
|
179 |
$view = (int) $view;
|
|
|
180 |
|
181 |
if ( $use_simplepie ) {
|
182 |
if ( ! class_exists( 'SimplePie' ) ) {
|
@@ -256,27 +259,38 @@ function RSSImport(
|
|
256 |
$previousitems = true;
|
257 |
}
|
258 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
259 |
while ( $display < $displaylimit ) {
|
260 |
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
$
|
267 |
-
|
268 |
-
/** @var MagpieRSS $rss */
|
269 |
-
$items = $rss->items;
|
270 |
-
}
|
271 |
|
272 |
-
if ( array_key_exists( $
|
273 |
|
274 |
if ( $use_simplepie ) {
|
275 |
/** @var SimplePie $rss */
|
276 |
-
$item = $rss->get_item( $
|
277 |
} else {
|
278 |
/** @var MagpieRSS $rss */
|
279 |
-
$item = $rss->items[ $
|
280 |
}
|
281 |
// import title
|
282 |
$title = '';
|
@@ -1409,6 +1423,7 @@ function RSSImport_Shortcode( $atts ) {
|
|
1409 |
'next_paging_title' => __( 'more items', FB_RSSI_TEXTDOMAIN ),
|
1410 |
'use_simplepie' => 1,
|
1411 |
'view' => 0,
|
|
|
1412 |
),
|
1413 |
$atts
|
1414 |
);
|
@@ -1482,6 +1497,7 @@ function RSSImport_Shortcode( $atts ) {
|
|
1482 |
$next_paging_title = $args[ 'next_paging_title' ];
|
1483 |
$use_simplepie = (int) $args[ 'use_simplepie' ];
|
1484 |
$view = $args[ 'view' ];
|
|
|
1485 |
|
1486 |
$return = RSSImport(
|
1487 |
$display, $feedurl,
|
@@ -1500,7 +1516,8 @@ function RSSImport_Shortcode( $atts ) {
|
|
1500 |
$before_error, $error, $after_error,
|
1501 |
$paging, $prev_paging_link, $next_paging_link, $prev_paging_title, $next_paging_title,
|
1502 |
$use_simplepie,
|
1503 |
-
$view
|
|
|
1504 |
);
|
1505 |
|
1506 |
return $return;
|
@@ -1556,7 +1573,7 @@ function RSSImport_insert_button() {
|
|
1556 |
'desc4title="" charsetscan="FALSE" debug="FALSE" before_noitems="<p>" noitems="No items, feed is empty." ' +
|
1557 |
'after_noitems="</p>" before_error="<p>" error="Error: Feed has an error or is not valid" after_error="</p>" ' +
|
1558 |
'paging="FALSE" prev_paging_link="« Previous" next_paging_link="Next »" prev_paging_title="more items" ' +
|
1559 |
-
'next_paging_title="more items" use_simplepie="FALSE"]',
|
1560 |
end = '',
|
1561 |
access = 'r',
|
1562 |
title = '<?php _e( 'Import a feed with RSSImport', FB_RSSI_TEXTDOMAIN ); ?>';
|
@@ -1978,6 +1995,7 @@ if ( class_exists( 'WP_Widget' ) ) {
|
|
1978 |
: $instance[ 'next_paging_title' ];
|
1979 |
$use_simplepie = $instance[ 'use_simplepie' ];
|
1980 |
$view = $instance[ 'view' ];
|
|
|
1981 |
|
1982 |
echo $args[ 'before_widget' ];
|
1983 |
if ( '' !== $titlelink ) {
|
@@ -2000,7 +2018,8 @@ if ( class_exists( 'WP_Widget' ) ) {
|
|
2000 |
$before_error, $error, $after_error,
|
2001 |
$paging, $prev_paging_link, $next_paging_link, $prev_paging_title, $next_paging_title,
|
2002 |
$use_simplepie,
|
2003 |
-
$view
|
|
|
2004 |
);
|
2005 |
echo $args[ 'after_widget' ];
|
2006 |
}
|
@@ -2049,6 +2068,7 @@ if ( class_exists( 'WP_Widget' ) ) {
|
|
2049 |
$instance[ 'prev_paging_title' ] = $new_instance[ 'prev_paging_title' ];
|
2050 |
$instance[ 'next_paging_title' ] = $new_instance[ 'next_paging_title' ];
|
2051 |
$instance[ 'use_simplepie' ] = (int) $new_instance[ 'use_simplepie' ];
|
|
|
2052 |
|
2053 |
if ( current_user_can( 'unfiltered_html' ) ) {
|
2054 |
return $instance;
|
@@ -2103,6 +2123,7 @@ if ( class_exists( 'WP_Widget' ) ) {
|
|
2103 |
'prev_paging_title' => __( 'more items', FB_RSSI_TEXTDOMAIN ),
|
2104 |
'next_paging_title' => __( 'more items', FB_RSSI_TEXTDOMAIN ),
|
2105 |
'use_simplepie' => 1,
|
|
|
2106 |
)
|
2107 |
);
|
2108 |
|
@@ -2147,6 +2168,7 @@ if ( class_exists( 'WP_Widget' ) ) {
|
|
2147 |
$next_paging_title = $instance[ 'next_paging_title' ];
|
2148 |
$use_simplepie = (int) $instance[ 'use_simplepie' ];
|
2149 |
$view = (int) $instance[ 'view' ];
|
|
|
2150 |
?>
|
2151 |
<p>
|
2152 |
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', FB_RSSI_TEXTDOMAIN ) ?>
|
@@ -2443,6 +2465,19 @@ if ( class_exists( 'WP_Widget' ) ) {
|
|
2443 |
</select>
|
2444 |
</label>
|
2445 |
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2446 |
<?php
|
2447 |
|
2448 |
}
|
6 |
* Domain Path: /languages
|
7 |
* Description: Display Feeds in your blog. Use the function <code>RSSImport()</code>, a Widget or the Shortcode <code>[RSSImport]</code>.
|
8 |
* Author: Frank Bültge, took77
|
9 |
+
* Version: 4.5.0
|
10 |
* License: GPLv3+
|
11 |
* Last change: 2017-11-29
|
12 |
*/
|
114 |
* @param string $next_paging_title
|
115 |
* @param int $use_simplepie
|
116 |
* @param int $view
|
117 |
+
* @param int $random_sort
|
118 |
*
|
119 |
* @return string
|
120 |
*/
|
157 |
$prev_paging_title = 'more items',
|
158 |
$next_paging_title = 'more items',
|
159 |
$use_simplepie = 1,
|
160 |
+
$view = 1,
|
161 |
+
$random_sort = 0
|
162 |
) {
|
163 |
|
164 |
// replace for yahoo pipes urls
|
179 |
$paging = (int) $paging;
|
180 |
$use_simplepie = (int) $use_simplepie;
|
181 |
$view = (int) $view;
|
182 |
+
$random_sort = (int) $random_sort;
|
183 |
|
184 |
if ( $use_simplepie ) {
|
185 |
if ( ! class_exists( 'SimplePie' ) ) {
|
259 |
$previousitems = true;
|
260 |
}
|
261 |
|
262 |
+
$picked = array();
|
263 |
+
|
264 |
+
if ( $use_simplepie && ( 1 === $paging || $random_sort) ) {
|
265 |
+
/** @var SimplePie $rss */
|
266 |
+
$items = $rss->get_items();
|
267 |
+
} elseif ( $use_simplepie ) {
|
268 |
+
/** @var SimplePie $rss */
|
269 |
+
$items = $rss->get_items( 0, $displayitems );
|
270 |
+
} else {
|
271 |
+
/** @var MagpieRSS $rss */
|
272 |
+
$items = $rss->items;
|
273 |
+
}
|
274 |
+
$cnt_items = count($items);
|
275 |
+
|
276 |
while ( $display < $displaylimit ) {
|
277 |
|
278 |
+
$i = $display;
|
279 |
+
if ($random_sort) {
|
280 |
+
do {
|
281 |
+
$i = rand(0, $cnt_items-1);
|
282 |
+
} while (in_array($i, $picked) && count($picked) < $cnt_items);
|
283 |
+
$picked[] = $i;
|
284 |
+
}
|
|
|
|
|
|
|
285 |
|
286 |
+
if ( array_key_exists( $i, $items ) ) {
|
287 |
|
288 |
if ( $use_simplepie ) {
|
289 |
/** @var SimplePie $rss */
|
290 |
+
$item = $rss->get_item( $i );
|
291 |
} else {
|
292 |
/** @var MagpieRSS $rss */
|
293 |
+
$item = $rss->items[ $i ];
|
294 |
}
|
295 |
// import title
|
296 |
$title = '';
|
1423 |
'next_paging_title' => __( 'more items', FB_RSSI_TEXTDOMAIN ),
|
1424 |
'use_simplepie' => 1,
|
1425 |
'view' => 0,
|
1426 |
+
'random_sort' => 0,
|
1427 |
),
|
1428 |
$atts
|
1429 |
);
|
1497 |
$next_paging_title = $args[ 'next_paging_title' ];
|
1498 |
$use_simplepie = (int) $args[ 'use_simplepie' ];
|
1499 |
$view = $args[ 'view' ];
|
1500 |
+
$random_sort = $args[ 'random_sort' ];
|
1501 |
|
1502 |
$return = RSSImport(
|
1503 |
$display, $feedurl,
|
1516 |
$before_error, $error, $after_error,
|
1517 |
$paging, $prev_paging_link, $next_paging_link, $prev_paging_title, $next_paging_title,
|
1518 |
$use_simplepie,
|
1519 |
+
$view,
|
1520 |
+
$random_sort
|
1521 |
);
|
1522 |
|
1523 |
return $return;
|
1573 |
'desc4title="" charsetscan="FALSE" debug="FALSE" before_noitems="<p>" noitems="No items, feed is empty." ' +
|
1574 |
'after_noitems="</p>" before_error="<p>" error="Error: Feed has an error or is not valid" after_error="</p>" ' +
|
1575 |
'paging="FALSE" prev_paging_link="« Previous" next_paging_link="Next »" prev_paging_title="more items" ' +
|
1576 |
+
'next_paging_title="more items" use_simplepie="FALSE" random_sort="FALSE"]',
|
1577 |
end = '',
|
1578 |
access = 'r',
|
1579 |
title = '<?php _e( 'Import a feed with RSSImport', FB_RSSI_TEXTDOMAIN ); ?>';
|
1995 |
: $instance[ 'next_paging_title' ];
|
1996 |
$use_simplepie = $instance[ 'use_simplepie' ];
|
1997 |
$view = $instance[ 'view' ];
|
1998 |
+
$random_sort = $instance[ 'random_sort' ];
|
1999 |
|
2000 |
echo $args[ 'before_widget' ];
|
2001 |
if ( '' !== $titlelink ) {
|
2018 |
$before_error, $error, $after_error,
|
2019 |
$paging, $prev_paging_link, $next_paging_link, $prev_paging_title, $next_paging_title,
|
2020 |
$use_simplepie,
|
2021 |
+
$view,
|
2022 |
+
$random_sort
|
2023 |
);
|
2024 |
echo $args[ 'after_widget' ];
|
2025 |
}
|
2068 |
$instance[ 'prev_paging_title' ] = $new_instance[ 'prev_paging_title' ];
|
2069 |
$instance[ 'next_paging_title' ] = $new_instance[ 'next_paging_title' ];
|
2070 |
$instance[ 'use_simplepie' ] = (int) $new_instance[ 'use_simplepie' ];
|
2071 |
+
$instance[ 'random_sort' ] = (int) $new_instance[ 'random_sort' ];
|
2072 |
|
2073 |
if ( current_user_can( 'unfiltered_html' ) ) {
|
2074 |
return $instance;
|
2123 |
'prev_paging_title' => __( 'more items', FB_RSSI_TEXTDOMAIN ),
|
2124 |
'next_paging_title' => __( 'more items', FB_RSSI_TEXTDOMAIN ),
|
2125 |
'use_simplepie' => 1,
|
2126 |
+
'random_sort' => 0,
|
2127 |
)
|
2128 |
);
|
2129 |
|
2168 |
$next_paging_title = $instance[ 'next_paging_title' ];
|
2169 |
$use_simplepie = (int) $instance[ 'use_simplepie' ];
|
2170 |
$view = (int) $instance[ 'view' ];
|
2171 |
+
$random_sort = (int) $instance[ 'random_sort' ];
|
2172 |
?>
|
2173 |
<p>
|
2174 |
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', FB_RSSI_TEXTDOMAIN ) ?>
|
2465 |
</select>
|
2466 |
</label>
|
2467 |
</p>
|
2468 |
+
<p>
|
2469 |
+
<label for="<?php echo $this->get_field_id( 'random_sort' ); ?>"><?php _e( 'Random Order:',
|
2470 |
+
FB_RSSI_TEXTDOMAIN ) ?>
|
2471 |
+
<select id="<?php echo $this->get_field_id( 'random_sort' ); ?>" name="<?php echo $this->get_field_name( 'random_sort' ); ?>">
|
2472 |
+
<option value="0"<?php if ( ! $random_sort ) {
|
2473 |
+
echo ' selected="selected"';
|
2474 |
+
} ?>><?php _e( 'False', FB_RSSI_TEXTDOMAIN ); ?></option>
|
2475 |
+
<option value="1"<?php if ( $random_sort ) {
|
2476 |
+
echo ' selected="selected"';
|
2477 |
+
} ?>><?php _e( 'True', FB_RSSI_TEXTDOMAIN ); ?></option>
|
2478 |
+
</select>
|
2479 |
+
</label>
|
2480 |
+
</p>
|
2481 |
<?php
|
2482 |
|
2483 |
}
|