WordPress.org

Forums

Code reverts to '&#039' in header.php (13 posts)

  1. tee05
    Member
    Posted 2 years ago #

    Hi,

    I'm not sure how to explain this but the header.php file in my theme keeps changing by itself (or I'm guessing it's being hacked in some way or another.) All the quote marks in code convert to '&#039' html code and it's only happening in the header.php file in my theme. I have no idea how this is happening. I change the code back and re-upload the file but the code reverts back to '&#039' after every few hours. So strange!

    For example the code should look like this:

    <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />

    But then it converts to '&#039' by itself after few hours later:

    <meta http-equiv="Content-Type" content="<?php bloginfo( '&#039' html_type '&#039' ); ?>; charset=<?php bloginfo('&#039' charset '&#039' ); ?>" />

    This then causes a php error - Parse error: syntax error, unexpected ';' in ../wp-content/themes/A/header.php on line 21

    My files are set to the correct permissions via FTP.

    Please help! Anyone have any ideas why this could be happening?

    Thanks in advance.

  2. Pioneer Valley Web Design
    Member
    Posted 2 years ago #

    'html_type' - Returns the Content-Type of WordPress HTML pages (default: text/html). This data is retrieved from the 'html_type' record in the wp_options table. Themes and plugins can override the default value using the pre_option_html_type filter.

    Codex Reference

  3. tee05
    Member
    Posted 2 years ago #

    Thanks for the info! But I'm not sure I understand. How exactly can I fix the issue? Do I need to change the pre_option_html_type filter through the database to something else? I've never had this problem before with any other of my WP sites.

  4. Pioneer Valley Web Design
    Member
    Posted 2 years ago #

    Links are provided for a lengthy review by OP's.

  5. tee05
    Member
    Posted 2 years ago #

    Thanks Seacoast but I'm still not sure what exactly the issue is but I have for the meantime disabled the file editor in wordpress. (I think it might help security wise.)

    If anyone out there has any solutions please let me know thanks!

  6. Pioneer Valley Web Design
    Member
    Posted 2 years ago #

    What I meant is that you stated you did not understand the issue, but minutes later (a few) replied you had in fact studied the link and it was not helpful - it is...it's not an issue with the link...please study it in whole over time...

  7. haxxxton
    Member
    Posted 2 years ago #

    It looks like for some reason however you were editing the header.php wasnt decoding the html entities correctly

    &#039 is a '

    if you can.. use FTP and a php editor (Notepad++ is always good) to the changes to your header.php and then reupload it to your theme..

  8. tee05
    Member
    Posted 2 years ago #

    I have studied the link you provided and it was helpful but it doesn’t solve my issue. It's not about 'get_bloginfo()'. The problem is the quotation mark - ' - is automatically converted to '&#039' code in my header.php file (no other file).

  9. Pioneer Valley Web Design
    Member
    Posted 2 years ago #

    Did you download and edit this file at any time?

  10. tee05
    Member
    Posted 2 years ago #

    I always use FTP to edit the files and I haven’t had issues with it in the past (no one else edits the files expect me this why I was thinking it might be hacked?). When the PHP syntax error appeared I noticed through the WP editor all the ' were converted to &#039. So I disabled the editor by adding - define('DISALLOW_FILE_EDIT', TRUE); in the wp-config file just in case if it's being hacked somehow.

    It's very strange I haven’t had this issue before with WordPress.

  11. Pioneer Valley Web Design
    Member
    Posted 2 years ago #

    This file is likely corrupt, contains a BOM, or other error(s), recreate it.

  12. tee05
    Member
    Posted 2 years ago #

    Yes, I think your right. I have recreated the header file and uploaded it through FTP. The editor is disabled so I'm hoping this will work.

  13. Pioneer Valley Web Design
    Member
    Posted 2 years ago #

    This happens of late when one uses FileZilla, downloads, edits, does a save (in edit mode of file with default as notepad) but not : 'saveas UTF-8 with no BOM' and prior to opening Notepad does not have 'word-wrap off'... MS has promised to fix this occasional glitch once WP is nice again to them (oops). Darn BOM! What is BOM for?

Topic Closed

This topic has been closed to new replies.

About this Topic