Support » Plugins » Hacks » Tried to edit theme functions.php and failed

  • Resolved rubawayrunner


    Hi, I have a problem and I was hoping somebody could please help. My theme is Golden Eagle Lite.
    I was trying to make shortcodes work in a widget. I found an online tutorial that said

    “Look in the list of Template Files on the right of the page for one called Theme Functions or functions.php and click on it to load it into the editor. Find a place between the <?php and ?> tags which is not in the middle one of the functions that may already be in the file (the very top or bottom of the file are both good places) and add the following line: add_filter(‘widget_text’, ‘do_shortcode’);”

    So first, I copy pasted everything on a text file to back it up. I followed the instructions and got the following error.

    Parse error: syntax error, unexpected T_INCLUDE_ONCE in /home/ on line 4

    So that was fine. I copied the original text back in its place and got the same error. Then I looked up the original code online to see if I missed something and tried that – same error. Then I changed my other website to the same theme and copy pasted the same file and still got the error. I can’t figure out what’s wrong. I can’t uninstall the template, it seems like I am frozen on that error message.

    Here is my Theme functions.php file, which is still getting an error even though it seems to be same as the original.

    include_once get_template_directory() . '/functions/goldeneagle-functions.php';
    $functions_path = get_template_directory() . '/functions/';
    /* These files build out the options interface.  Likely won't need to edit these. */
    require_once ($functions_path . 'admin-functions.php');  // Custom functions and plugins
    require_once ($functions_path . 'admin-interface.php');  // Admin Interfaces (options,framework, seo)
    /* These files build out the theme specific options and associated functions. */
    require_once ($functions_path . 'theme-options.php');   // Options panel settings and custom settings
    require_once ($functions_path . 'dynamic-image.php');
    require_once ($functions_path . 'themes-page.php');
    /* ----------------------------------------------------------------------------------- */
    /* Styles Enqueue */
    /* ----------------------------------------------------------------------------------- */
    function goldeneagle_add_stylesheet() {
    	 wp_enqueue_style('shortcodes', get_template_directory_uri() . "/css/shortcode.css", '', '', 'all');
    add_action('init', 'goldeneagle_add_stylesheet');
    /* ----------------------------------------------------------------------------------- */
    /* jQuery Enqueue */
    /* ----------------------------------------------------------------------------------- */
    function goldeneagle_wp_enqueue_scripts() {
        if (!is_admin()) {
            wp_enqueue_script('goldeneagle-ddsmoothmenu', get_stylesheet_directory_uri() . '/js/ddsmoothmenu.js', array('jquery'));
            wp_enqueue_script('goldeneagle-slider', get_stylesheet_directory_uri() . '/js/slides.min.jquery.js', array('jquery'));
            wp_enqueue_script('goldeneagle-jquery.prettyPhoto', get_stylesheet_directory_uri() . '/js/jquery.prettyPhoto.js', array('jquery'));
            wp_enqueue_script('goldeneagle-tipsy', get_stylesheet_directory_uri() . '/js/jquery.tipsy.js', array('jquery'));
    		wp_enqueue_script('goldeneagle-validate', get_stylesheet_directory_uri() . '/js/jquery.validate.min.js', array('jquery'));
    		wp_enqueue_script('goldeneagle-effect', get_stylesheet_directory_uri() . '/js/frontend-effect.js', array('jquery'));
    		 wp_enqueue_script('goldeneagle-mobilemenu', get_stylesheet_directory_uri() . '/js/mobilemenu.js', array('jquery'));
    		  wp_enqueue_script('gall-effect', get_stylesheet_directory_uri() . '/js/gall-effect.js', array('jquery'));
            wp_enqueue_script('goldeneagle-custom', get_stylesheet_directory_uri() . '/js/custom.js', array('jquery'));
        } elseif (is_admin()) {
    add_action('init', 'goldeneagle_wp_enqueue_scripts');
    //Front Page Rename
    $get_status = get_option('re_nm');
    $get_file_ac = get_template_directory() . '/front-page.php';
    $get_file_dl = get_template_directory() . '/front-page-hold.php';
    //True Part
    if ($get_status === 'off' && file_exists($get_file_ac)) {
        rename("$get_file_ac", "$get_file_dl");
    //False Part
    if ($get_status === 'on' && file_exists($get_file_dl)) {
        rename("$get_file_dl", "$get_file_ac");
    function goldeneagle_get_option($name) {
        $options = get_option('goldeneagle_options');
        if (isset($options[$name]))
            return $options[$name];
    function goldeneagle_update_option($name, $value) {
        $options = get_option('goldeneagle_options');
        $options[$name] = $value;
        return update_option('goldeneagle_options', $options);
    function goldeneagle_delete_option($name) {
        $options = get_option('goldeneagle_options');
        return update_option('goldeneagle_options', $options);
    //Enqueue comment thread js
    function goldeneagle_enqueue_scripts() {
    	if ( is_singular() && get_option( 'thread_comments' ) ) {
    		wp_enqueue_script( 'comment-reply' );
    add_action('wp_enqueue_scripts', 'goldeneagle_enqueue_scripts');

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz


    There’s nothing wrong with the include_once line, so the syntax error must be before this line, but it looks OK. The only explanation is your text editor is not saving the file in a format that your server’s php interpreter is expecting. Ensure your text editor is saving text as actual plain text without fingerprint headers or anything. If you open the file in a hex editor, the initial hex values should be 3C 3F 70 68 70 0D 0A. (‘<?php’ plus end of line characters) The last two hex values might be 0A 0A or 0D 0D, depending on your system’s handling of end of line characters.

    Or just try again with a different text editor. Next time you back up a file, just down load it to a safe place via FTP, then there’s no risk of a text editor mangling things.

    I think I locked myself out of my wordpress template. I finally opened my control panel from my domain and edited the file through there and it worked fine! Still wish I could add some code so that I can use shortcodes though 🙂 Thanks for your help!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Tried to edit theme functions.php and failed’ is closed to new replies.