A Custom Function Parse Error in WordPress Design Editor
The WordPress Theme Editor screen offers an alternative to downloading your WordPress theme files, editing them and uploading them again. However, under certain circumstances you may see a Parse Error when you try to access the Theme Editor or other pages in your WordPress administration area. If you've edited the custom functions file for the Thesis WordPress theme, it may be the cause.
-
PHP Parse Errors
-
A parse error in PHP simply means that the PHP interpreter couldn't parse something in the PHP code. Normally this is an error in syntax, such as a missing brace or semicolon. When you encounter a parse error it usually includes the path to the file and exact line it couldn't parse, such as the following:
Parse error: syntax error, unexpected T_STRING in /folder/path/file.php on line 17
Other PHP errors known as fatal errors may also occur, and also indicate problems with the PHP code in a certain file and location.
Thesis Custom Functions
-
When you edit a WordPress theme, you risk losing those changes if you reinstall or update the theme. For this reason, the Thesis WordPress theme offers a custom functions file, named custom_functions.php, where you may add changes to the theme's PHP code without editing the theme pages directly. Custom functions include "hooks" that you use to add, move or remove a specific function on your blog's pages. When you edit the custom functions file, you're still editing PHP code, which may cause a problem if the code is improperly written.
-
Repair in the Thesis Editor
-
If you encounter a parse error when you attempt to open the WordPress Theme Editor, write down the exact location and file name in the error message. If the file is the Thesis custom_functions.php, go to the Thesis Custom File Editor instead by clicking "Thesis" and clicking "Custom File Editor." Count down to the line number specified in the error message to find the problem function (it may not match exactly). Repair or remove the function and click "Big Ass Save Button."
Repair Using FTP
-
If you can't open the Thesis Custom File Editor, use an FTP program to download the custom_functions.php file from your server using the path specified in the error message. Open the file in a text editor, count down to the line specified in the error message (in some text editors the line number may not be exact) and repair or remove the function. Some editors, such as BBEdit, Dreamweaver and PHPEdit, highlight the syntax in PHP files, which may assist you in locating a missing element. After you repair the file, upload it to its original location, replacing the existing version.
Install a Clean Custom Functions File
-
If the problem persists, download and save the damaged custom_functions.php file to your hard drive and replace the file on your server with a backup or a clean copy. To obtain a clean copy, sign into your account at diythemes.org and download a new copy of Thesis. Unzip the file, open the "Thesis" folder and find the file in the "Custom" folder.
-
References
- Photo Credit Pixland/Pixland/Getty Images