Support » Theme: Tiny Framework » HELP Parse error: syntax error, unexpected

  • Resolved tamia

    (@tamia)



    I’ve just started up a new website with this great theme. I consulted Thomas’ website “How to use Tiny Framework Child themes” for how to enable HTML code in title, and then took a look at the functions.php in the (non-child) TF theme. In this document, I referred to:

    “If you use Tiny Framework without a child theme, open functions.php in a text editor, find section 5.11 (Change title for protected and private posts…) and in tinyforge_the_title_trim function comment out this line:…”

    I copied the functions.php from the WP editor into a text editor, tried following instructions, then pasted the whole document back into the proper place in the WP editor, then updated. WHen I did this is what happened:

    Parse error: syntax error, unexpected ‘}’, expecting elseif (T_ELSEIF) or else (T_ELSE) or endif (T_ENDIF) in /home/bitsb/backinthesameboat.com/wp-content/themes/tiny-framework/functions.php on line 721

    I used the back button on my browser to return to the editor. I’d somehow introduced a problem and don’t know how, but then I copied the original functions.php document from my backup and pasted it into the WP editor, then updated. The parse error returned.

    Now I don’t know what to do, and I can’t leave the WP editor page for fear that I won’t be able to fix this problem. My website is now unfunctional and I’m in a panic. What do I do?

    If it would help, here are the lines in question as they appear in the original functions.php file (they look the same to me on the WP editor page, too):

    function tinyframework_the_title_trim($title) {
    $title = esc_attr($title); // Sanitize HTML characters in the title. Comment out this line if you want to use HTML in post titles.
    $findthese = array(
    ‘#Protected:#’,
    ‘#Private:#’
    );
    $replacewith = array(
    // What to replace “Protected:” with
    ‘<span class=”screen-reader-text”>Protected article:</span>’,
    // What to replace “Private:” with
    ‘<span class=”screen-reader-text”>Private article:</span>’
    );
    $title = preg_replace($findthese, $replacewith, $title);
    return $title;
    }
    endif;
    add_filter( ‘the_title’, ‘tinyframework_the_title_trim’ );

    • This topic was modified 1 year, 1 month ago by  tamia. Reason: supplied additional information

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Just an update to say that I’ve fixed my website, and to tell how I’d done so in case anyone runs into this problem themselves.

    Summary: The syntax error essentially locked me out of my website. I could not log onto the dashboard using another user’s account on another computer. The public site brought up the syntax error.

    The fix: With FTP, I logged onto the website successfully. Then I downloaded the backup file from the website (thank goodness for backups!) to my computer, unzipped it, and then uploaded the backup functions.php file to the website. This overwrote the existing functions.php file with one from a backup I’d run yesterday. My site was repaired. I could log on and out of WordPress, and the site is visible again.

    Observations:

    1. Make backups! I was glad I’d done so.

    2. I’d copied the relevant document from the Appearance > Editor > functions.php page, then pasted it into a Text Wrangler document on my computer. Using the theme author’s help guide mentioned in my original post, I commented-out the portion of code that I thought should allow me to use html code in post titles. Then I copied this edited document and pasted it back into the edit window. When hitting the Update button, I got the parse error. I then restored what I thought was the original php document into the edit window and updated, but the parse error remained.

    I’ve repeated myself here, I know, but this seems critical. It would seem possible that in using a text editor application (TextWrangler) I managed to unwittingly introduce a character or spacing not found in the original “pure” document created by the theme author. I’ve still not figured out how this happened — soft wrapped text? line breaks? — but there it is. People much better at this than I might have the answer.

    The takeaway lesson? Be very cautious about making changes. And use a child theme. I’ve not yet uploaded a child theme (graciously provided by the theme author right in the Tiny Framework theme itself). Hubris let me believe I could do this one seemingly simple change to the main theme’s functions.php file.

    Thanks for sitting through this long-winded explanation. I hope this helps someone else.

    Theme Author Tomas Mackevicius

    (@tomasm)

    Thanks for the update!

    I would recommend using the Notepad++ or Atom as your editor.

    hello, I do have the same problem with my page:
    Parse error: syntax error, unexpected ‘)’ in /home/teicos/domains/technicos.lt/public_html/wp-content/themes/tiny-framework-child/functions.php on line 252. I tried to change header size via child theme and lost one “)” in functions php. The problem is, that I can not connect to my web page and fix the code, the second is that I don’t have back up, because i’m few days in wordpress.. I have connected to WordPress thru my server provider, so I dont need nothing to install – everithing is made automaticaly.
    so my question is – is there some possibilities to fix code without backup and how? 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘HELP Parse error: syntax error, unexpected’ is closed to new replies.