116 lines
3.7 KiB
Markdown
116 lines
3.7 KiB
Markdown
# Super Simple RSS Reader
|
|
|
|
A minimal WordPress plugin that reads an RSS feed and displays it as a simple
|
|
link list. Set the feed URL in WP Admin and drop the shortcode
|
|
`[super_simple_rssreader]` anywhere you want the list to appear.
|
|
|
|
This plugin is a WordPress port of the standalone `rss-feed.php` template. The
|
|
rendered output is intentionally kept the same.
|
|
|
|
## Features
|
|
|
|
- Admin settings page under **Settings → RSS Reader**.
|
|
- `[super_simple_rssreader]` shortcode for posts, pages, widgets or theme templates.
|
|
- Same markup as the original file: `div.rss-feed` with an optional
|
|
`h3.rss-title` heading and a `<ul>` of items.
|
|
- Google News style titles are cleaned up: the trailing `" - Source"` is removed
|
|
from the title because the source is already shown separately.
|
|
- Responses are cached with a transient (15 minutes by default) so the feed is
|
|
not fetched on every page load.
|
|
- Output is escaped and feed URLs are validated before use.
|
|
|
|
## Installation
|
|
|
|
1. Copy the `super-simple-rssreader` folder (containing
|
|
`super-simple-rssreader.php`) into `wp-content/plugins/`.
|
|
2. Activate **Super Simple RSS Reader** under **Plugins** in WP Admin.
|
|
|
|
## Configuration
|
|
|
|
Go to **Settings → RSS Reader** and set:
|
|
|
|
| Field | Description |
|
|
|-----------|-----------------------------------------------------------------------------|
|
|
| Feed URL | Full URL of the RSS feed to read. |
|
|
| Heading | Optional heading shown above the list. Leave empty for no heading. |
|
|
| Max items | Maximum number of items to show. Use `0` to show all items. |
|
|
|
|
The defaults match the original `rss-feed.php` (a Google News search feed and the
|
|
heading "Tau- og kabelbanenytt"), so the plugin looks the same right after
|
|
activation. Change them as needed.
|
|
|
|
## Shortcode
|
|
|
|
Place the shortcode where you want the feed:
|
|
|
|
```
|
|
[super_simple_rssreader]
|
|
```
|
|
|
|
### Shortcode attributes
|
|
|
|
Attributes override the saved settings for that single usage:
|
|
|
|
| Attribute | Default | Description |
|
|
|-----------|--------------------|----------------------------------------------|
|
|
| `url` | Saved feed URL | Feed URL to read. |
|
|
| `title` | Saved heading | Heading text. Empty string hides the heading.|
|
|
| `limit` | Saved max items | Max number of items (`0` = all). |
|
|
|
|
Example:
|
|
|
|
```
|
|
[super_simple_rssreader url="https://example.com/feed" title="Latest news" limit="5"]
|
|
```
|
|
|
|
You can also call it directly from a theme template:
|
|
|
|
```php
|
|
echo do_shortcode( '[super_simple_rssreader limit="10"]' );
|
|
```
|
|
|
|
## Output markup
|
|
|
|
```html
|
|
<div class="rss-feed">
|
|
<h3 class="rss-title">Heading</h3>
|
|
<ul>
|
|
<li><a href="https://example.com/article" target="_blank" rel="noopener noreferrer">Article title</a> <span> | Source name</span></li>
|
|
</ul>
|
|
</div>
|
|
```
|
|
|
|
If the feed cannot be loaded, or it contains no items, the shortcode outputs
|
|
nothing.
|
|
|
|
## Caching
|
|
|
|
Fetched items are cached in a transient for 15 minutes. The cache is cleared
|
|
automatically when the settings are saved.
|
|
|
|
The cache lifetime can be changed with a filter (value in seconds):
|
|
|
|
```php
|
|
add_filter( 'ssrss_cache_ttl', function () {
|
|
return 5 * MINUTE_IN_SECONDS;
|
|
} );
|
|
```
|
|
|
|
## Notes
|
|
|
|
- Only standard RSS feeds (`<channel><item>`) are supported, matching the
|
|
original script.
|
|
- The feed is fetched with the WordPress HTTP API (`wp_remote_get`) instead of
|
|
`simplexml_load_file`, so it respects the site's HTTP configuration and does
|
|
not depend on `allow_url_fopen`.
|
|
- Feed URLs must start with `http://` or `https://`.
|
|
|
|
## Requirements
|
|
|
|
- WordPress 5.0 or later
|
|
- PHP 7.0 or later
|
|
|
|
## License
|
|
|
|
GPL-2.0-or-later
|