0

I created a mu-plugins directory in wp-content

As long as it is empty, I have no issue, but the moment I put a file in there, even if the file is like this:

filename: somecode.php
filecontent:
<?php
?>

and that be all, no blank spaces or lines after the closing php tag, or after the first line of <?php

I get issues with the CSS on the website, stuff not working right.

I have no clue as to why it would be doing that. I even put the file in there blank, not even a single blank line. Same thing. Once I delete the file, everything is fine.

I've tested LOTS of stuff, any file in that directory breaks the website.

I've even tested it with different themes. Same thing.

So am I doing something wrong?

All I did was create the mu-plugins directory. was I supposed to do something extra? Like put any code in my wordpress installation?

Please help.

-Richard

4

The file you put in there is automatically loaded and executed by PHP before any of the normal plugins are loaded.

The issue you're seeing is because you have a "malformed" PHP file, in that you end with a closing PHP tag ?>. If there is anything else after this closing tag, even only a line-break, this causes PHP to immediately send its headers and start echoing output.

If you file immediately starts with the opening PHP tag <?php and does not include a closing tag ?>, you should not see this issue.

The same problem was when you had an empty file. This was interpreted by PHP as a normal HTML file (PHP is a preprocessor for HTML) and simply echoed.

  • I logged into shell, created the file using: nano filename.php, added content, saved it, and that worked. So I guess it was the way I uploaded it. Maybe it uploaded in binary and needed to be ascii... not sure. anyhow, it is working now. Thank you for your message, that helped me test it that way. – Rich Feb 12 '16 at 16:11
  • Different operating systems use different line endings. So, for example, if you use a basic text editor on Windows, and upload that file to a Linux server without converting it first, you'll end up with line-ending characters that are wrong for the Linux system. See the section "Common problems" here: en.wikipedia.org/wiki/Newline – Alain Schlesser Feb 12 '16 at 18:36
  • if your FTP username and shell username are different, the "owner" or "group" permissions for the file could possibly have been causing problems (though it is unlikely for read this is mostly for write)... thought this was worth a mention since it worked via shell for you. – majick Feb 13 '16 at 2:03

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.