- 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.
- PS是這樣玩的:輕松掌握 Photoshop 通關(guān)秘籍
- Photoshop CC 2018實(shí)用教程
- 做合成:Photoshop構(gòu)圖+透視+紋理+造型+調(diào)色技術(shù)修煉
- CorelDRAW服裝設(shè)計(jì)實(shí)用教程(第四版)
- Photoshop日系少女寫真后期解密
- ImageMagick Tricks
- 零基礎(chǔ)學(xué)數(shù)碼攝影后期
- Drupal: Creating Blogs, Forums, Portals, and Community Websites
- 深入理解OpenCV:實(shí)用計(jì)算機(jī)視覺項(xiàng)目解析(原書第3版)
- Premiere Pro影視后期編輯:短視頻制作實(shí)戰(zhàn)寶典
- 零基礎(chǔ)學(xué)會聲會影2018(全視頻教學(xué)版)
- PostgreSQL 9.0 High Performance
- ASP.NET Core 3從入門到實(shí)戰(zhàn)
- 零基礎(chǔ)學(xué)Premiere Pro短視頻制作
- AutoCAD 2024室內(nèi)設(shè)計(jì)從入門到精通(升級版)