I am attempting to get the ACE editor to display wp-config.php for editing within the admin area (writing a plugin to do this). I assume I need to specify the server path for file_get_contents() but it’s not working. Also, specifying the server path to the editor, as currently I am using the url. Any assistance would be greatly appreciated.🙏

<!DOCTYPE html>
<html lang="en">
<title>ACE in Action</title>
<style type="text/css" media="screen">
    #editor { 
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
   $s = file_get_contents('var/www/html/wp-config.php');
<div id="editor"></div>
<script src="https://sketchwhatyousee.com/wp-content/plugins/wp-config-editor/ace/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
    var s = '<?= $s ?>';
    var editor = ace.edit("editor");
  • 1
    Editing config files in the browser doesn't seem like a good idea to me, but the path to WordPress's installation directory should be available to you as the constant ABSPATH.
    – Pat J
    Jan 25 at 20:05
  • Thank you! It’s no different than opening another app to ftp into the site, download the file and edit, then upload. All just to turn on/off debug. The plugin just makes it convenient without leaving WordPress. Only accessible to admin user.👍
    – Dwest
    Jan 25 at 23:34
  • Just be careful you don't make any errors when editing; if you drop a ; or forget to close " you can render your site unreachable.
    – Pat J
    Jan 25 at 23:38
  • 1
    Yep! Learned that a long time ago lol! Thanks for the reminder though. I appreciate it!👍
    – Dwest
    Jan 26 at 2:59


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.