Editing Files « Wordpress Codex
Total Page:16
File Type:pdf, Size:1020Kb
Editing Files « WordPress Codex http://codex.wordpress.org/Editing_Files Codex Codex tools: Log in Editing Files Home Page WordPress Lessons Languages : English • Français • Português do Brasil • 中文 (简体) • (Add your language ) Getting Started Working with WordPress There are times when you will need to edit the WordPress files, especially if you want to Contents Design and Layout make changes in your WordPress Theme . WordPress features a built-in editor for editing Advanced Topics files from within your browser whilst online: The Theme Editor . You can also edit files [hide ] copied or stored on your computer and then upload them to your site using an FTP client . 1 Using the Theme Editor and Plugin Troubleshooting Editor Developer Docs Before editing any of your WordPress files, check the following: 1.1 What Files Can Be Edited? About WordPress 1.2 Things You Need to Know BACKUP! And Work from Backups 2 Editing Files Offline Codex Resources Work from copies of backup files when possible and/or make sure that you backup your 3 Using Text Editors information frequently as you work and make changes. Keep backups in a safe place. 3.1 Editors to Avoid Community portal 3.2 Text Editors Current events File Permissions 3.3 IDEs Recent changes When working online, you need to set the appropriate file permissions to modify and Random page save them. If you see a note at the bottom of the WordPress Built-in Editor panel that says "If this file was writable you could edit it." , this means you need to change the file permissions before you can make any changes. Help Use a Text Editor to Edit Files To make changes to files outside of the built-in Plugin or Theme Editor, use a text editor. DO NOT USE A WORD PROCESSING PROGRAM. Word processors change the quote marks to characters and may convert other characters or bring in unwanted code; these changes will cause the file to break. There are also some HTML generator programs that should not be used for similar reasons. Using the Theme Editor and Plugin Editor WordPress contains two built-in editors that allows you to edit Theme files directly from within your browser. They are called the Theme Editor and Plugin Editor . Access the Theme Editor from the Administration > Appearance > Editor menu. The Plugin Editor is located at Administration > Plugins > Editor . To view a file in these editors, click on the file from the right-hand side list. More information on editing themes is available at Theme Development and Using Themes . You can learn more about editing plugins at Writing a Plugin and Plugin Resources . Be aware that if the theme you edit is updated, your changes will be overwritten. To better organize your changes and protect them from updates, consider creating a Child Theme in which to keep all your changes. What Files Can Be Edited? From within the WordPress Built-in Editor, the following file types may be edited, if writable : HTML PHP CSS .htaccess TXT (and related text-like files such as RTF) Things You Need to Know 1 of 3 13-10-2013 00:10 Editing Files « WordPress Codex http://codex.wordpress.org/Editing_Files Instant Changes AboutThe changes you make toSupport files using the WordPress eShowcaseditors are instant; the changesWordCamp happen online, in real-time.WordPress.com You and any Follow @WordPress Blogvisitors to your will see theGet changes Involved immediately. Plugins WordPress.TV Matt Like 753k Hosting Learn Themes BuddyPress Privacy JobsBecause of the immediate nature of the changes, it's Ideasusually safer to edit copies ofbbPress your files offline, test, andLicense upload your / GPLv2 changes when they are verified. Always make sure you have a current backup before editing files. Editor Features The built-in WordPress Plugin and Theme editors are very basic, allowing easy access to view and edit plugin and theme files on your site only. There are no built-in editor features for search and replace, line numbers, syntax highlighting, code completion, or other advanced editing features. Hint: Use your browsers internal search to help find code within the visual editors. File Permissions To edit a file using the built-in WordPress Plugin or Theme Editors, the permissions for that file must be set to writable (at least 666). You can change the permissions on files by using a FTP client program , web-based file manager provided by your host, or from the command-line using SSH (secure shell). Your options depend on the type of access your host offers. Make a Mistake? Use the Backup Files Backup all files before editing. If you make a mistake that causes errors, a site crash, a blank screen, or blocks access to your WordPress Dashboard, delete the changed file and replace it with a good one from your backup. No backup? Download a fresh copy of the file you edited from the original source, replace it, and start over. BACKUP FIRST. Security Warning By default, any user that logs in with administrative permissions can access the WordPress Plugin and Theme editors, and change any theme or plugin file on your site in real-time. To combat accidents, errors, and even hacking, you may wish to disable the ability to edit files within the WordPress theme by adding the DISALLOW_FILE_EDIT function to your wp-config.php file. Editing Files Offline To edit files offline, you can use any of the recommended text editors to create and edit files and an FTP client to upload them. Make sure to view the results in your browser to check if the desired change has taken effect. Note: It is not recommended to change core WordPress files other than wp-config.php . If you must change anything else, take notes and store them in a text file in your WordPress root directory and make a backup copy of them for future reference and upgrades. Using Text Editors Editors to Avoid Note: If you use an external editor to create and edit files, such as a standard word-processor, it can corrupt the file you are editing. See Text Editor in the Glossary for a short explanation on why you should avoid these editors. Editors to avoid include: Microsoft Word WordPerfect OpenOffice/LibreOffice Apple iWork Pages Microsoft Publisher Microsoft Works Microsoft Excel Adobe Photoshop Adobe Illustrator Adobe Dreamweaver Any do-it-yourself instant web page software. To use Adobe Dreamweaver or Microsoft FrontPage , keep these guidelines in mind: Adobe Dreamweaver: To make sure your files work properly, delete Dreamweaver content, copy your content from the WordPress 2 of 3 13-10-2013 00:10 Editing Files « WordPress Codex http://codex.wordpress.org/Editing_Files editor, and paste it into the Dreamweaver file. Microsoft FrontPage: Do not use built-in templates. Avoid Internet Explorer-specific code. Text Editors The following Text Editors are acceptable for file editing: BBEdit (Classic Mac OS, Mac OS X, $$$) Boxer Text Editor (Windows) Coda (Mac OS X, Shareware) Crimson Editor (Windows, Freeware) EditPad (cross-platform) EditPlus (Windows) Editra (cross-platform, Open Source, Free) emacs ( Unices, Windows, Mac OS X, Open Source, Free ) Fraise (Mac OS X, Open Source, Free, based on Smultron) gedit ( Unices ) JEdit (cross-platform) Kate ( Unices ) Komodo Edit (cross-platform, Open Source, Free) Kwrite ( Unices ) Notepad++ (Windows, Open Source, Free) phpDesigner (Windows) pico ( Unices ) PSPad (Windows, Free) Smultron (Mac OS X, Open Source, Free/$) Smultron 4 (req OS-X Lion) (v.cheap in MacApp store) SubEthaEdit (Mac OS X, $) Sublime Text 2 (Windows, Linux, Mac OS X) TextEdit (comes with Mac OS X) TextMate (Mac OS X, $) TextPad (Windows) TextWrangler (Mac OS X, Free) UltraEdit-32 vim ( Unices, Windows, Mac OS X, Open Source, Free ) Notepad2 (Windows, Freeware) WebTide Editor (Windows, Linux, Mac OS X, Freeware, Java) IDEs The following IDEs are acceptable for file editing: Aptana Studio (Cross platform, Freeware) Codelobster (Windows only, Freeware) Eclipse (Cross platform, Freeware) NetBeans (Cross platform, Freeware) This article is marked as in need of editing. You can help Codex by editing it . Categories : Getting Started | Design and Layout | WordPress Lessons | UI Link | Copyedit 3 of 3 13-10-2013 00:10.