- WordPress 3 Plugin Development Essentials
- Brian Bondari Everett Griffiths
- 269字
- 2021-04-09 21:19:58
Understanding the Includes
When you activate a plugin, the name of the file containing the information header is stored in the WordPress database. Each time a page is requested, WordPress goes through a laundry list of PHP files it needs to load, so activating a plugin ensures that your own files are on that list. To help illustrate this concept, let's break WordPress again.
Exercise – parse errors
Try the following exercise:
- Ensure that the "Hello Dolly" plugin is active.
- Open the
/wp-content/plugins/hello.php
file in your text editor. - Immediately before the line that contains function hello_dolly_get_lyric, type in some gibberish text, such as "asdfasdf" and save the file.
- Reload the plugins page in your browser.
- This should generate a parse error, something like:
Parse error: syntax error, unexpected T_FUNCTION in /path/to/wordpress/html/wp-content/plugins/hello.php on line 16
Yikes! Your site is now broken. Why did this happen? We introduced errors into the plugin's main file (hello.php
), so including it caused PHP and WordPress to choke. If you did not see any errors and instead saw only a blank white page, you need to refer back to the previous chapter and the section on debugging to ensure that you have configured PHP to report errors. This is vital!
Delete the gibberish line from the hello.php
file and save to return the plugin back to normal.
The parse error only occurs if there is an error in an active plugin. Deactivated plugins are not included by WordPress and therefore their code is not parsed. You can try the same exercise after deactivating the plugin and you'll notice that WordPress does not raise any errors.
- iPad+Procreate數字插畫設計案例教程(全彩微課版)
- 持續演進的Cloud Native:云原生架構下微服務最佳實踐
- Excel圖表與表格實戰技巧精粹
- JasperReports for Java Developers
- 剪映專業版(電腦版)視頻剪輯全攻略:音效添加+轉場特效+視頻制作
- Drupal Multimedia
- 移動App測試的22條軍規
- CorelDRAW服裝設計實用教程(第四版)
- Illustrator CC 2018中文版入門與提高
- PowerPoint 2016實戰從入門到精通(超值版)
- 中文版CINEMA 4D R20 實用教程
- Photoshop攝影后期必修5項核心技法 基本調整+光影校正+色彩修飾+局部處理+銳化降噪
- Moodle 1.9 for Design and Technology
- AutoCAD 2021中文版從入門到精通
- 圖像處理系統