


Typecho plug-in writing tutorial (1): Hello World_PHP tutorial
Typecho plug-in writing tutorial (1): Hello World
This article mainly introduces the typecho plug-in writing tutorial (1): Hello World. This article explains the file structure of the plug-in. For plug-in information, plug-in structure, plug-in process, etc., friends in need can refer to it
Recently, Lao Gao is writing a plug-in about typecho. Since typecho is not like WordPress, there are so many document references. There are still many pitfalls in writing a plug-in. However, as the research continues to deepen, Lao Gao gradually I got started, so I summarized this writing tutorial to share with everyone!
I. Starting from HelloWorld
Basic information
If you want to develop typecho, you must have read the source code of the official sample plug-in HelloWorld, right?
Let’s first look at the first few lines of the usr/plugins/HelloWorld/Plugin.php file
The code is as follows:
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
/**
* Hello World
*
* @package HelloWorld
* @author qining
* @version 1.0.0
* @link http://typecho.org
*/
…
…
These lines of code are the basic information of a plug-in. From the code, we can get the following basic information related to the plug-in
Plug-in description ---> Hello World
Plug-in package name ---> HelloWorld
Plug-in author ---> qining
Plug-in version ---> 1.0.0
Plug-in link ---> http://typecho.org
At the same time, this information will be displayed on the plug-in page, as shown below

Plug-in structure
We continue to look at the following code. The simplest plug-in structure is as follows (in order to shorten the length, Lao Gao has removed the implementation of specific methods)
Each method basically has comments, so I won’t go into details.
It seems simple, right? In fact, there are still many pitfalls.
The code is as follows:
class HelloWorld_Plugin implements Typecho_Plugin_Interface
{
/**
* Activate plug-in method. If activation fails, an exception will be thrown directly
*
* @access public
* @return void
* @throws Typecho_Plugin_Exception
*/
public static function activate(){}
/**
* Disable plug-in method, if the disablement fails, an exception will be thrown directly
*
* @static
* @access public
* @return void
* @throws Typecho_Plugin_Exception
*/
Public static function deactivate(){}
/**
* Get the plug-in configuration panel
*
* @access public
* @param Typecho_Widget_Helper_Form $form configuration panel
* @return void
*/
Public static function config(Typecho_Widget_Helper_Form $form){}
/**
* Configuration panel for individual users
*
* @access public
* @param Typecho_Widget_Helper_Form $form
* @return void
*/
Public static function personalConfig(Typecho_Widget_Helper_Form $form){}
/**
* Plug-in implementation method
*
* @access public
* @return void
*/
public static function render(){}
}
Plug-in process
The basic process of the plug-in is as follows.
1. When our plug-in is written, it will appear in the background
2. After clicking the enable button, the activate method of the corresponding plug-in class will be executed
3. The plug-in is associated with the target plug-in point and is waiting to be triggered
4. Call the deactivate method when you click to deactivate
This section is over.
In the next section, Lao Gao will explain the plug-in class methods in more detail.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Dewu APP is currently a very popular brand shopping software, but most users do not know how to use the functions in Dewu APP. The most detailed usage tutorial guide is compiled below. Next is the Dewuduo that the editor brings to users. A summary of function usage tutorials. Interested users can come and take a look! Tutorial on how to use Dewu [2024-03-20] How to use Dewu installment purchase [2024-03-20] How to obtain Dewu coupons [2024-03-20] How to find Dewu manual customer service [2024-03-20] How to check the pickup code of Dewu [2024-03-20] Where to find Dewu purchase [2024-03-20] How to open Dewu VIP [2024-03-20] How to apply for return or exchange of Dewu

What is the Chrome plug-in extension installation directory? Under normal circumstances, the default installation directory of Chrome plug-in extensions is as follows: 1. The default installation directory location of chrome plug-ins in windowsxp: C:\DocumentsandSettings\username\LocalSettings\ApplicationData\Google\Chrome\UserData\Default\Extensions2. chrome in windows7 The default installation directory location of the plug-in: C:\Users\username\AppData\Local\Google\Chrome\User

When users use the Edge browser, they may add some plug-ins to meet more of their needs. But when adding a plug-in, it shows that this plug-in is not supported. How to solve this problem? Today, the editor will share with you three solutions. Come and try it. Method 1: Try using another browser. Method 2: The Flash Player on the browser may be out of date or missing, causing the plug-in to be unsupported. You can download the latest version from the official website. Method 3: Press the "Ctrl+Shift+Delete" keys at the same time. Click "Clear Data" and reopen the browser.

1. First open WeChat. 2. Click [+] in the upper right corner. 3. Click the QR code to collect payment. 4. Click the three small dots in the upper right corner. 5. Click to close the voice reminder for payment arrival.

After rain in summer, you can often see a beautiful and magical special weather scene - rainbow. This is also a rare scene that can be encountered in photography, and it is very photogenic. There are several conditions for a rainbow to appear: first, there are enough water droplets in the air, and second, the sun shines at a low angle. Therefore, it is easiest to see a rainbow in the afternoon after the rain has cleared up. However, the formation of a rainbow is greatly affected by weather, light and other conditions, so it generally only lasts for a short period of time, and the best viewing and shooting time is even shorter. So when you encounter a rainbow, how can you properly record it and photograph it with quality? 1. Look for rainbows. In addition to the conditions mentioned above, rainbows usually appear in the direction of sunlight, that is, if the sun shines from west to east, rainbows are more likely to appear in the east.

PhotoshopCS is the abbreviation of Photoshop Creative Suite. It is a software produced by Adobe and is widely used in graphic design and image processing. As a novice learning PS, let me explain to you today what software photoshopcs5 is and how to use photoshopcs5. 1. What software is photoshop cs5? Adobe Photoshop CS5 Extended is ideal for professionals in film, video and multimedia fields, graphic and web designers who use 3D and animation, and professionals in engineering and scientific fields. Render a 3D image and merge it into a 2D composite image. Edit videos easily

With the continuous development of smart phones, the functions of mobile phones have become more and more powerful, among which the function of taking long pictures has become one of the important functions used by many users in daily life. Long screenshots can help users save a long web page, conversation record or picture at one time for easy viewing and sharing. Among many mobile phone brands, Huawei mobile phones are also one of the brands highly respected by users, and their function of cropping long pictures is also highly praised. This article will introduce you to the correct method of taking long pictures on Huawei mobile phones, as well as some expert tips to help you make better use of Huawei mobile phones.

PHP Tutorial: How to Convert Int Type to String In PHP, converting integer data to string is a common operation. This tutorial will introduce how to use PHP's built-in functions to convert the int type to a string, while providing specific code examples. Use cast: In PHP, you can use cast to convert integer data into a string. This method is very simple. You only need to add (string) before the integer data to convert it into a string. Below is a simple sample code
