Skip to content

Commit

Permalink
Update version
Browse files Browse the repository at this point in the history
  • Loading branch information
dragomano committed May 27, 2024
1 parent ac54a96 commit fc273b6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 30 deletions.
21 changes: 7 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![SMF 2.1](https://img.shields.io/badge/SMF-2.1-ed6033.svg?style=flat)](https://github.com/SimpleMachines/SMF2.1)
![License](https://img.shields.io/github/license/dragomano/plugin-loader)
![Hooks only: Yes](https://img.shields.io/badge/Hooks%20only-YES-blue)
![PHP](https://img.shields.io/badge/PHP-^7.0-blue.svg?style=flat)
![PHP](https://img.shields.io/badge/PHP-^8.0-blue.svg?style=flat)
[![Crowdin](https://badges.crowdin.net/plugin-loader/localized.svg)](https://crowdin.com/project/plugin-loader)

[Описание на русском](README.ru.md)
Expand All @@ -12,7 +12,7 @@ This concept mod is inspired by the Wedge plugin system. It adds plugin support

Plugins are standalone modifications that do not need to be installed or removed through the Package Manager. They don't make changes to SMF files and run entirely on hooks.

The key source file of the plugin is **plugin.php** with the anonymous class and the **hooks** method, which is executed through the _integrate_pre_load_ hook. Also in the directory of each plugin should be a file **plugin-info.xml**, which contains the key data of the plugin:
The entry point of each plugin is **plugin.php** with an anonymous class inside. Also in the directory of each plugin should be a file **plugin-info.xml**, which contains the key data of the plugin:

* name
* description
Expand Down Expand Up @@ -93,7 +93,7 @@ Plugins that require creation of tables in the database for their work must cont
* @package Example
* @link https://plugin-site.com
* @author Author https://author-site.com
* @copyright 2023 Author
* @copyright 2024 Author
* @license https://opensource.org/licenses/MIT The MIT License
*
* @version 0.1
Expand All @@ -106,17 +106,9 @@ if (!defined('SMF'))

return class extends Plugin
{
public function getName(): string
{
return 'example';
}

public function hooks(): void
{
add_integration_function('integrate_load_theme', __CLASS__ . '::loadTheme#', false, __FILE__);
add_integration_function('integrate_menu_buttons', __CLASS__ . '::menuButtons#', false, __FILE__);
}
public const NAME = 'example';

#[Hook('integrate_load_theme', self::class . '::loadTheme#', __FILE__)]
public function loadTheme(): void
{
// Your code
Expand All @@ -141,6 +133,7 @@ return class extends Plugin
// var_dump($this->getSettings());
}

#[Hook('integrate_menu_buttons', self::class . '::menuButtons#', __FILE__)]
public function menuButtons($buttons): void
{
// var_dump($buttons);
Expand All @@ -149,7 +142,7 @@ return class extends Plugin

```

As you can see, all the hooks required by the plugin are listed in the `hooks` method, which is executed if the plugin is enabled.
As you can see, all hooks required by the plugin are defined using the `Hook` attribute.

## Example plugin language file

Expand Down
24 changes: 9 additions & 15 deletions README.ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![SMF 2.1](https://img.shields.io/badge/SMF-2.1-ed6033.svg?style=flat)](https://github.com/SimpleMachines/SMF2.1)
![License](https://img.shields.io/github/license/dragomano/plugin-loader)
![Hooks only: Yes](https://img.shields.io/badge/Hooks%20only-YES-blue)
![PHP](https://img.shields.io/badge/PHP-^7.0-blue.svg?style=flat)
![PHP](https://img.shields.io/badge/PHP-^8.0-blue.svg?style=flat)
[![Crowdin](https://badges.crowdin.net/plugin-loader/localized.svg)](https://crowdin.com/project/plugin-loader)

[Description in English](README.md)
Expand All @@ -12,7 +12,7 @@

Плагины — это автономные модификации, которым не требуется установка или удаление через Менеджер пакетов. Они не вносят изменения в файлы SMF и работают полностью на хуках.

Ключевым source-файлом у плагина является **plugin.php** с анонимным классом внутри и методом **hooks**, выполняемым через хук _integrate_pre_load_. Также в директории каждого плагина должен находиться файл **plugin-info.xml**, содержащий ключевые данные плагина:
Точкой входа каждого плагина является **plugin.php** с анонимным классом внутри. Также в директории каждого плагина должен находиться файл **plugin-info.xml**, содержащий ключевые данные плагина:

* название
* описание
Expand Down Expand Up @@ -93,30 +93,23 @@ example_plugin/
* @package Example
* @link https://plugin-site.com
* @author Author https://author-site.com
* @copyright 2023 Author
* @copyright 2024 Author
* @license https://opensource.org/licenses/MIT The MIT License
*
* @version 0.1
*/

use Bugo\PluginLoader\Hook;
use Bugo\PluginLoader\Plugin;

if (!defined('SMF'))
if (! defined('SMF'))
die('No direct access...');

return class extends Plugin
{
public function getName(): string
{
return 'example';
}

public function hooks(): void
{
add_integration_function('integrate_load_theme', __CLASS__ . '::loadTheme#', false, __FILE__);
add_integration_function('integrate_menu_buttons', __CLASS__ . '::menuButtons#', false, __FILE__);
}
public const NAME = 'example';

#[Hook('integrate_load_theme', self::class . '::loadTheme#', __FILE__)]
public function loadTheme(): void
{
// Ваш код
Expand All @@ -141,6 +134,7 @@ return class extends Plugin
// var_dump($this->getSettings());
}

#[Hook('integrate_menu_buttons', self::class . '::menuButtons#', __FILE__)]
public function menuButtons($buttons): void
{
// var_dump($buttons);
Expand All @@ -149,7 +143,7 @@ return class extends Plugin

```

Как видите, все требуемые плагином хуки перечисляются в методе `hooks`, который выполняется только при включении плагина.
Как видите, все требуемые плагином хуки определяются с помощью атрибута `Hook`.

## Пример языкового файла плагина

Expand Down
2 changes: 1 addition & 1 deletion package-info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<package-info xmlns="http://www.simplemachines.org/xml/package-info" xmlns:smf="http://www.simplemachines.org/">
<id>Bugo:PluginLoader</id>
<name>Plugin Loader</name>
<version>0.5</version>
<version>0.6</version>
<type>modification</type>

<install for="2.1.*">
Expand Down

0 comments on commit fc273b6

Please sign in to comment.