Compare commits
4 Commits
Author | SHA1 | Date |
---|---|---|
|
3611c00ffa | |
|
3ac9376ce8 | |
|
7aad00ded7 | |
|
89a3371df6 |
34
README.md
34
README.md
|
@ -1,11 +1,11 @@
|
|||
# Simple Tracking Plugin Installation
|
||||
# SimpleRss Plugin Installation
|
||||
|
||||
## Installation
|
||||
|
||||
To install or update the Simple Tracking plugin, run the following command from the root of your WordPress HTML directory:
|
||||
To install or update the SimpleRss plugin, run the following command from the root of your WordPress HTML directory:
|
||||
|
||||
```sh
|
||||
curl -sSL https://git.nixc.us/colin/SimpleTracking/raw/branch/main/install.sh | bash
|
||||
curl -sSL https://git.nixc.us/colin/SimpleRss/raw/branch/main/install.sh | bash
|
||||
```
|
||||
|
||||
## Enabling the Plugin
|
||||
|
@ -14,21 +14,33 @@ After running the install script, you need to activate the plugin. You can do th
|
|||
|
||||
1. Log in to your WordPress admin dashboard.
|
||||
2. Navigate to `Plugins > Installed Plugins`.
|
||||
3. Find `Simple Tracking` in the list and click `Activate`.
|
||||
3. Find `SimpleRss` in the list and click `Activate`.
|
||||
|
||||
Alternatively, you can activate the plugin using WP-CLI:
|
||||
|
||||
```sh
|
||||
wp plugin activate simple-tracking --allow-root
|
||||
wp plugin activate simplerss --allow-root
|
||||
```
|
||||
|
||||
## What `install.sh` Does
|
||||
|
||||
The `install.sh` script performs the following actions:
|
||||
|
||||
1. Defines the URL for downloading the `simple-tracking.php` file.
|
||||
2. Creates the target directory (`wp-content/plugins/simple-tracking`) if it doesn't exist.
|
||||
3. Downloads the `simple-tracking.php` file into the target directory.
|
||||
4. Creates a blank `tracking-code.php` file if it doesn't already exist and instructs the user to add their tracking code to it.
|
||||
5. Sets the correct permissions for the `simple-tracking.php` and `tracking-code.php` files.
|
||||
6. Prints a message indicating that the Simple Tracking plugin has been installed or updated successfully.
|
||||
1. Defines the URL for downloading the `simplerss.php` file.
|
||||
2. Creates the target directory (`wp-content/plugins/simplerss`) if it doesn't exist.
|
||||
3. Downloads the `simplerss.php` file into the target directory.
|
||||
4. Sets the correct permissions for the `simplerss.php` file.
|
||||
5. Prints a message indicating that the SimpleRss plugin has been installed or updated successfully.
|
||||
|
||||
# How it works:
|
||||
|
||||
The shortcode [simple_rss url="RSS_FEED_URL" items="NUMBER_OF_ITEMS"] will display the feed.
|
||||
You can embed the shortcode in any post or page to show the feed.
|
||||
url is the link to the RSS feed.
|
||||
items is optional (defaults to 5), and it controls the number of feed items to display.
|
||||
|
||||
## Example of usage:
|
||||
|
||||
[simple_rss url="https://example.com/feed" items="3"]
|
||||
|
||||
This will display the latest 3 items from the specified feed.
|
19
install.sh
19
install.sh
|
@ -1,26 +1,17 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Define plugin details
|
||||
PLUGIN_URL="https://git.nixc.us/colin/SimpleTracking/raw/branch/main/simple-tracking.php"
|
||||
PLUGIN_DIR="./wp-content/plugins/simple-tracking"
|
||||
PLUGIN_URL="https://git.nixc.us/colin/SimpleRss/raw/branch/main/simplerss.php"
|
||||
PLUGIN_DIR="./wp-content/plugins/simplerss"
|
||||
|
||||
# Create plugin directory if it doesn't exist
|
||||
mkdir -p "$PLUGIN_DIR"
|
||||
|
||||
# Download the plugin file
|
||||
curl -o "$PLUGIN_DIR/simple-tracking.php" "$PLUGIN_URL"
|
||||
|
||||
# Create a blank tracking-code.php file if it doesn't exist
|
||||
if [ ! -f "$PLUGIN_DIR/tracking-code.php" ]; then
|
||||
touch "$PLUGIN_DIR/tracking-code.php"
|
||||
echo "Please add your tracking code to wp-content/plugins/simple-tracking/tracking-code.php."
|
||||
else
|
||||
echo "tracking-code.php already exists."
|
||||
fi
|
||||
curl -o "$PLUGIN_DIR/simplerss.php" "$PLUGIN_URL"
|
||||
|
||||
# Set correct permissions
|
||||
chmod 644 "$PLUGIN_DIR/simple-tracking.php"
|
||||
chmod 644 "$PLUGIN_DIR/tracking-code.php"
|
||||
chmod 644 "$PLUGIN_DIR/simplerss.php"
|
||||
|
||||
# Inform user
|
||||
echo "Simple Tracking plugin installed/updated successfully."
|
||||
echo "SimpleRss plugin installed/updated successfully."
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
/*
|
||||
Plugin Name: Simple RSS Embedder
|
||||
Description: A simple plugin to embed RSS feeds via shortcode.
|
||||
Version: 1.0
|
||||
Author: Your Name
|
||||
*/
|
||||
|
||||
// Function to fetch and display the RSS feed
|
||||
function simple_rss_display($atts) {
|
||||
$atts = shortcode_atts(
|
||||
array(
|
||||
'url' => '', // RSS feed URL
|
||||
'items' => 5 // Number of items to display
|
||||
),
|
||||
$atts,
|
||||
'simple_rss'
|
||||
);
|
||||
|
||||
if (empty($atts['url'])) {
|
||||
return '<p>No RSS feed URL provided.</p>';
|
||||
}
|
||||
|
||||
$rss = fetch_feed($atts['url']);
|
||||
|
||||
if (is_wp_error($rss)) {
|
||||
return '<p>Unable to fetch the RSS feed.</p>';
|
||||
}
|
||||
|
||||
$maxitems = $rss->get_item_quantity($atts['items']);
|
||||
$rss_items = $rss->get_items(0, $maxitems);
|
||||
|
||||
if ($maxitems == 0) {
|
||||
return '<p>No items found in the RSS feed.</p>';
|
||||
}
|
||||
|
||||
$output = '<ul>';
|
||||
foreach ($rss_items as $item) {
|
||||
$output .= '<li>';
|
||||
$output .= '<a href="' . esc_url($item->get_permalink()) . '">' . esc_html($item->get_title()) . '</a>';
|
||||
$output .= '<p>' . esc_html($item->get_date('j F Y | g:i a')) . '</p>';
|
||||
$output .= '</li>';
|
||||
}
|
||||
$output .= '</ul>';
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
// Register the shortcode [simple_rss]
|
||||
function simple_rss_shortcode() {
|
||||
add_shortcode('simple_rss', 'simple_rss_display');
|
||||
}
|
||||
add_action('init', 'simple_rss_shortcode');
|
|
@ -1,16 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
Plugin Name: Simple Tracking
|
||||
Description: Embeds tracking code into your WordPress site.
|
||||
Version: 1.0
|
||||
Author: Colin
|
||||
Author URI: https://git.nixc.us/colin/SimpleTracking.git
|
||||
*/
|
||||
|
||||
function add_simple_tracking_code() {
|
||||
$tracking_code_path = plugin_dir_path(__FILE__) . 'tracking-code.php';
|
||||
if (file_exists($tracking_code_path)) {
|
||||
include $tracking_code_path;
|
||||
}
|
||||
}
|
||||
add_action('wp_head', 'add_simple_tracking_code');
|
Loading…
Reference in New Issue