== Documentation == = Editor file data = `inc/editors.php` **Themes:** * `$_REQUEST['theme']` contains the theme-slug. * `$_REQUEST['file']` contains the file name without any path information. The theme editor only allows editing for files in the specific theme's root directory. * If no specific file was selected both variables are empty and the editor displays the current active theme's `style.css`. The absolute path to the file can be built like this: `get_theme_root()/$_REQUEST['theme']/$_REQUEST['file']` or `get_theme_root()/current_theme_slug/style.css` **Plugins:** * `$_REQUEST['file']` contains the file' relative path from `WP_PLUGIN_DIR`. E.g. `plugin-slug/subfolder/filename.php` * One would expect `$_REQUEST['plugin']` to hold the currently viewed plugin's basename or relative url to main file, but it doesn't. It contains the last viewed file (as in `$_REQUEST['file']`). For easier processing we retrieve the plugin main file using the first part of the file path in a call to `get_plugins()`. * If no specific file was selected both variables are empty and the editor displays the first file retrieved using `get_plugins()` and `get_plugin_files()`. **File/Post connection** Posts get a title in the style "Package: File" and an slug structured accordingly. Further more the file information (type ['theme'/'plugin'], the package [theme-slug/plugin-main-file] and the file [as in `$_REQUEST['file']`) is saved in a custom post meta associated with the file's post. When the editor is opened we check if a post associated with it exists using the slug. = Revision viewing = `js/editors.js`, `inc/ajax.php`, `inc/metabox.php`, `css/editors.css` Below the editors a revision list is added. It uses WordPress core functionality for generation and tries to replicate the metabox style known from WordPress post editor pages. To add it we rely on JS and an AJAX request. For viewing revisions we rely on the native revision viewer, located in `wp-admin/revision.php`. For code viewing purposes some modifications to provide a better (more code-editor like) feeling are applied. For example to handle multi-space indentations at line beginnings and inbetween words (for multi-line alignment) and smaller line spacings.