Skip to content

Commit fc273b6

Browse files
committed
Update version
1 parent ac54a96 commit fc273b6

File tree

3 files changed

+17
-30
lines changed

3 files changed

+17
-30
lines changed

README.md

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![SMF 2.1](https://img.shields.io/badge/SMF-2.1-ed6033.svg?style=flat)](https://github.com/SimpleMachines/SMF2.1)
44
![License](https://img.shields.io/github/license/dragomano/plugin-loader)
55
![Hooks only: Yes](https://img.shields.io/badge/Hooks%20only-YES-blue)
6-
![PHP](https://img.shields.io/badge/PHP-^7.0-blue.svg?style=flat)
6+
![PHP](https://img.shields.io/badge/PHP-^8.0-blue.svg?style=flat)
77
[![Crowdin](https://badges.crowdin.net/plugin-loader/localized.svg)](https://crowdin.com/project/plugin-loader)
88

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

1313
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.
1414

15-
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:
15+
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:
1616

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

107107
return class extends Plugin
108108
{
109-
public function getName(): string
110-
{
111-
return 'example';
112-
}
113-
114-
public function hooks(): void
115-
{
116-
add_integration_function('integrate_load_theme', __CLASS__ . '::loadTheme#', false, __FILE__);
117-
add_integration_function('integrate_menu_buttons', __CLASS__ . '::menuButtons#', false, __FILE__);
118-
}
109+
public const NAME = 'example';
119110

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

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

150143
```
151144

152-
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.
145+
As you can see, all hooks required by the plugin are defined using the `Hook` attribute.
153146

154147
## Example plugin language file
155148

README.ru.md

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![SMF 2.1](https://img.shields.io/badge/SMF-2.1-ed6033.svg?style=flat)](https://github.com/SimpleMachines/SMF2.1)
44
![License](https://img.shields.io/github/license/dragomano/plugin-loader)
55
![Hooks only: Yes](https://img.shields.io/badge/Hooks%20only-YES-blue)
6-
![PHP](https://img.shields.io/badge/PHP-^7.0-blue.svg?style=flat)
6+
![PHP](https://img.shields.io/badge/PHP-^8.0-blue.svg?style=flat)
77
[![Crowdin](https://badges.crowdin.net/plugin-loader/localized.svg)](https://crowdin.com/project/plugin-loader)
88

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

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

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

1717
* название
1818
* описание
@@ -93,30 +93,23 @@ example_plugin/
9393
* @package Example
9494
* @link https://plugin-site.com
9595
* @author Author https://author-site.com
96-
* @copyright 2023 Author
96+
* @copyright 2024 Author
9797
* @license https://opensource.org/licenses/MIT The MIT License
9898
*
9999
* @version 0.1
100100
*/
101101

102+
use Bugo\PluginLoader\Hook;
102103
use Bugo\PluginLoader\Plugin;
103104

104-
if (!defined('SMF'))
105+
if (! defined('SMF'))
105106
die('No direct access...');
106107

107108
return class extends Plugin
108109
{
109-
public function getName(): string
110-
{
111-
return 'example';
112-
}
113-
114-
public function hooks(): void
115-
{
116-
add_integration_function('integrate_load_theme', __CLASS__ . '::loadTheme#', false, __FILE__);
117-
add_integration_function('integrate_menu_buttons', __CLASS__ . '::menuButtons#', false, __FILE__);
118-
}
110+
public const NAME = 'example';
119111

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

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

150144
```
151145

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

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

package-info.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<package-info xmlns="http://www.simplemachines.org/xml/package-info" xmlns:smf="http://www.simplemachines.org/">
55
<id>Bugo:PluginLoader</id>
66
<name>Plugin Loader</name>
7-
<version>0.5</version>
7+
<version>0.6</version>
88
<type>modification</type>
99

1010
<install for="2.1.*">

0 commit comments

Comments
 (0)