mirror of
https://github.com/mivodev/plugin-example.git
synced 2026-01-26 05:15:25 +07:00
Initial commit
This commit is contained in:
52
.github/workflows/release.yml
vendored
Normal file
52
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
name: Release Plugin
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*' # Trigger on version tags, e.g. v1.0.0
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Create Release
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write # Needed to create releases
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Get Version
|
||||||
|
id: get_version
|
||||||
|
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Create ZIP Archive
|
||||||
|
run: |
|
||||||
|
# Create a temporary directory for the zip
|
||||||
|
mkdir temp_zip
|
||||||
|
|
||||||
|
# Copy files to temp directory, excluding unwanted files
|
||||||
|
rsync -av --progress . temp_zip --exclude .git --exclude .github --exclude .gitignore --exclude LICENSE --exclude README.md --exclude temp_zip
|
||||||
|
|
||||||
|
# Create the zip file
|
||||||
|
cd temp_zip
|
||||||
|
zip -r ../plugin-example.zip .
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
echo "Created plugin-example.zip"
|
||||||
|
|
||||||
|
- name: Create Release
|
||||||
|
uses: softprops/action-gh-release@v1
|
||||||
|
with:
|
||||||
|
files: plugin-example.zip
|
||||||
|
name: Release ${{ steps.get_version.outputs.VERSION }}
|
||||||
|
body: |
|
||||||
|
Automatic release for version ${{ steps.get_version.outputs.VERSION }}
|
||||||
|
|
||||||
|
**Installation:**
|
||||||
|
1. Download `plugin-example.zip`
|
||||||
|
2. Upload in Mivo > Settings > Plugins
|
||||||
|
draft: false
|
||||||
|
prerelease: false
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2026 DyzulkDev
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
26
README.md
Normal file
26
README.md
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
# Example Plugin for Mivo
|
||||||
|
|
||||||
|
**Category:** System Tools
|
||||||
|
**Author:** DyzulkDev
|
||||||
|
**Version:** 1.0.0
|
||||||
|
|
||||||
|
This is a **developer example** demonstrating how to create plugins for the Mivo Hotspot Manager. It showcases the use of Hooks and Routers to extend core functionality.
|
||||||
|
|
||||||
|
## Features
|
||||||
|
- **Router Hook**: Registers a custom page at `/plugin-test`.
|
||||||
|
- **Head Hook**: Injects custom CSS (green border) into the page head.
|
||||||
|
- **Footer Hook**: Injects a custom message into the page footer.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
1. Download the plugin ZIP file.
|
||||||
|
2. Go to **Mivo > Settings > Plugins**.
|
||||||
|
3. Click **Upload Plugin** and select the ZIP file.
|
||||||
|
4. The plugin will immediately activate.
|
||||||
|
|
||||||
|
## Verification
|
||||||
|
- **Visual Check**: You should see a green top border on all pages.
|
||||||
|
- **Footer Check**: A message "Plugin System is Working! 🚀" appears in the footer.
|
||||||
|
- **Route Check**: Visit `/plugin-test` to see the custom page.
|
||||||
|
|
||||||
|
## For Developers
|
||||||
|
Check the `plugin.php` file source code to understand how `Hooks::addAction` works for `router_init`, `mivo_head`, and `mivo_footer`.
|
||||||
40
plugin.php
Normal file
40
plugin.php
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plugin Name: Example Plugin
|
||||||
|
* Description: A sample plugin to demonstrate Mivo's hook system.
|
||||||
|
* Version: 1.0.0
|
||||||
|
* Author: DyzulkDev
|
||||||
|
*
|
||||||
|
* Category: System Tools
|
||||||
|
* Scope: Global
|
||||||
|
* Tags: example, demo, hooks
|
||||||
|
* Core Version: >= 1.0.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
use App\Core\Hooks;
|
||||||
|
use App\Core\Router;
|
||||||
|
|
||||||
|
// 1. Hook into Router to add a custom page
|
||||||
|
Hooks::addAction('router_init', function(Router $router) {
|
||||||
|
$router->get('/plugin-test', function() {
|
||||||
|
echo "<h1>Hello from Example Plugin!</h1>";
|
||||||
|
echo "<p>This page is registered via <code>router_init</code> hook.</p>";
|
||||||
|
echo "<a href='/'>Back to Home</a>";
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// 2. Hook into Head to add custom CSS
|
||||||
|
Hooks::addAction('mivo_head', function() {
|
||||||
|
echo "<!-- Example Plugin CSS -->";
|
||||||
|
echo "<style>body { border-top: 5px solid #10b981; }</style>";
|
||||||
|
});
|
||||||
|
|
||||||
|
// 3. Hook into Footer to add custom JS or Text
|
||||||
|
Hooks::addAction('mivo_footer', function() {
|
||||||
|
echo "<!-- Example Plugin Footer -->";
|
||||||
|
echo "<div style='text-align:center; padding: 10px; background: #f0fdf4; color: #166534; font-weight: bold;'>
|
||||||
|
Plugin System is Working! 🚀
|
||||||
|
<a href='/plugin-test' target=_blank>Plugin Test</a>
|
||||||
|
</div>";
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user