Get the App
SLTechnology News&Howtos  ›  Development  › 

How to write plug-in mount code for typecho plug-in

Shulou Source: shulou.com Published: 2022-06-03 17:33:07 10月04日 Update

Typecho plug-in how to write plug-in mount code, in view of this problem, this article introduces the corresponding analysis and answers in detail, hoping to help more partners who want to solve this problem to find a more simple and easy way.

Finally, after we are able to save the configuration information, we can begin to write the mount function of the plug-in.

First of all, we need to know that the system has reserved plug-in points for us in all key links. When the system runs to the plug-in point, it will detect whether there is a plug-in hanging on this point, and then execute the logic of the plug-in!

The job of the plug-in is to find the right plug-in point, hang it, and execute its own logic.

Plug-in point, plug-in hook, plug-in interface. It's a concept here in Lao Gao.

Official plug-in interface and feature list

The logic that our plug-in needs to execute is here, the finishPublish method of the Widget_Contents_Post_Edit class

As you can see in the file path var/Widget/Contents/Post/Edit.php:736, the interface passes us two parameters, one is the published content, and the other is the class itself. With the class itself, we can call its public methods at will in the plug-in!

The copy code is as follows:

/ / the article completes the release plug-in interface

$this- > pluginHandle ()-> finishPublish ($contents, $this)

There is also a page publishing interface, which is mentioned in the following code.

How to mount

The code is as follows, with omission.

The copy code is as follows:

Tags: Plug-ins code interfaces methods two parameters systems logic questions content functions articles more pages help solutions appropriate easy successful simple Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL MariaDB Huawei NVidia Shulou Information