- WordPress 3 Plugin Development Essentials
- Brian Bondari Everett Griffiths
- 237字
- 2021-04-09 21:19:57
Deconstructing an existing plugin: "Hello Dolly"
WordPress ships with a simple plugin named "Hello Dolly". Its name is a whimsical take on the programmer's obligatory "Hello, World!", and it is trotted out only for pedantic explanations like the one that follows (unless, of course, you really do want random lyrics by Jerry Herman to grace your administration screens).
Activating the plugin
Let's activate this plugin so we can have a look at what it does:
You should now see a random lyric appear in the top-right portion of the Dashboard. Refresh the page a few times to get the full effect.
Examining the hello.php file
Now that we've tried out the "Hello Dolly" plugin, let's have a closer look. In your favorite text editor, open up the /wp-content/plugins/hello.php
file. Can you identify the following integral parts?
- The Information Header which describes details about the plugin (author and description). This is contained in a large PHP /* comment */.
- User-defined functions, such as the hello_dolly() function.
- The
add_action()
and/oradd_filter()
functions, which hook a WordPress event to a user-defined function.
It looks pretty simple, right? That's all you need for a plugin:
- An information header
- Some user-defined functions
add_action()
and/oradd_filter()
functions
Now that we've identified the critical component parts, let's examine them in more detail.
- ERP沙盤模擬簡明教程
- CoffeeScript Application Development
- 數(shù)字孿生體:第四次工業(yè)革命的通用目的技術(shù)
- Blender 3D 2.49 Architecture, Buidlings, and Scenery
- Photoshop 平面廣告設(shè)計從入門到精通
- Liferay User Interface Development
- Moodle JavaScript Cookbook
- AI繪畫實戰(zhàn):Midjourney從新手到高手
- 計算機(jī)圖形圖像處理Photoshop CS6項目教程
- Photoshop CS6案例教程(第3版)
- 中文版Photoshop CS6從新手到高手·全彩版
- 中文版Flash CS6動畫制作(慕課版)
- LaTeX入門與實戰(zhàn)應(yīng)用
- Instant Markdown
- 邊做邊學(xué):CorelDRAW X6圖形設(shè)計案例教程(第2版)(微課版)