Can't access my website. Something called a parse error?

I cant access my website meework.com now. It say this:
Parse error: syntax error, unexpected '<' in /home/meeworkc/public_html/wp-content/plugins/buddypress/bp-themes/bp-default/functions.php on line 790

What is that? And how do I make it right?

  • sorensen84

    Hi Mike

    I had just recently installed wordpress seo by yoast. But there was a seo button visible in the admin bar, that users also can see. Then I tried put this code into my function.php:

    <?php
    function mytheme_admin_bar_render() {
    global $wp_admin_bar;
    $wp_admin_bar->remove_menu('wpseo-menu');
    }
    // and we hook our function via
    add_action( 'wp_before_admin_bar_render', 'mytheme_admin_bar_render' );
    ?>

    But it did not work, and when i deleted the code again the parse error came. I have put the function.php in pastebin.

    http://pastebin.com/68qcjJtP

  • sorensen84

    Hi Mike

    I seemed to make it work again. This is how my last sentence in the function.php is looking:
    add_action( 'bp_before_header', 'bp_dtheme_remove_nojs_body_class' );

    My site works fine now. But I cant remember if the sentence should end with: ?>

    So it looks like this:
    add_action( 'bp_before_header', 'bp_dtheme_remove_nojs_body_class' );
    ?>

    It works both with and without the ?>

  • Mike

    Hi @sorensen84

    Thanks for the reply, I've had a look at the code and the section you are talking about is on the line that previously there was a problem with:

    <?php
        }
        add_action( 'bp_before_header', 'bp_dtheme_remove_nojs_body_class' );
        <?php
        function mytheme_admin_bar_render() {
                global $wp_admin_bar;
                $wp_admin_bar->remove_menu('wpseo-menu');
        }
        // and we hook our function via
        add_action( 'wp_before_admin_bar_render', 'mytheme_admin_bar_render' );
        ?>

    After "add_action( 'bp_before_header', 'bp_dtheme_remove_nojs_body_class' );" you have "<?php" this is not needed so just remove that line and all should be fine.

    Cheers,
    Mike

  • Mike

    Hi @sorensen84

    Thanks for replying!

    When you use "?>" that means you are not using PHP anymore, but the next line that starts with "function mytheme_admin_bar_render" is more PHP.

    If you close using ?> it should still work, but is not good coding and may cause problems because after you close you should immediately need to open again with"<?php" however that is not necessary, so I would just remove the "?>"

    I hope that all makes sense!

    Cheers,
    Mike

  • Mike

    Hi @sorensen84

    Not the last line, it should end like this:

    add_filter( 'bp_get_the_body_class', 'bp_dtheme_add_nojs_body_class' );
    
    /**
     * Dynamically removes the no-js class from the <body> element.
     *
     * By default, the no-js class is added to the body (see bp_dtheme_add_no_js_body_class()). The
     * JavaScript in this function is loaded into the <body> element immediately after the <body> tag
     * (note that it's hooked to bp_before_header), and uses JavaScript to switch the 'no-js' body class
     * to 'js'. If your theme has styles that should only apply for JavaScript-enabled users, apply them
     * to body.js.
     *
     * This technique is borrowed from WordPress, wp-admin/admin-header.php.
     *
     * @package BuddyPress
     * @since BuddyPress (1.5).1
     * @see bp_dtheme_add_nojs_body_class()
     */
    function bp_dtheme_remove_nojs_body_class() {
    ?><script type="text/javascript">//<![CDATA[
    (function(){var c=document.body.className;c=c.replace(/no-js/,'js');document.body.className=c;})();
    //]]></script>
    <?php
    }
    add_action( 'bp_before_header', 'bp_dtheme_remove_nojs_body_class' );
    
    function mytheme_admin_bar_render() {
            global $wp_admin_bar;
            $wp_admin_bar->remove_menu('wpseo-menu');
    }
    // and we hook our function via
    add_action( 'wp_before_admin_bar_render', 'mytheme_admin_bar_render' );
    ?>

    Cheers,
    Mike

  • sorensen84

    Hi Mike

    I have removed Wordpress Seo and have installed the plugin you have on this site "Infinite SEO" So I have removed the last code again, this:

    unction mytheme_admin_bar_render() {
    global $wp_admin_bar;
    $wp_admin_bar->remove_menu('wpseo-menu');
    }
    // and we hook our function via
    add_action( 'wp_before_admin_bar_render', 'mytheme_admin_bar_render' );
    ?>

    So now it ends with the orginal code ending, this:
    'bp_dtheme_remove_nojs_body_class' );

    Is that fine? There is no need to put a ?> to the last? It works fine as it is now

  • Mike

    Hi @sorensen84

    In that case your code will look something like this:

    add_filter( 'bp_get_the_body_class', 'bp_dtheme_add_nojs_body_class' );
    
    /**
     * Dynamically removes the no-js class from the <body> element.
     *
     * By default, the no-js class is added to the body (see bp_dtheme_add_no_js_body_class()). The
     * JavaScript in this function is loaded into the <body> element immediately after the <body> tag
     * (note that it's hooked to bp_before_header), and uses JavaScript to switch the 'no-js' body class
     * to 'js'. If your theme has styles that should only apply for JavaScript-enabled users, apply them
     * to body.js.
     *
     * This technique is borrowed from WordPress, wp-admin/admin-header.php.
     *
     * @package BuddyPress
     * @since BuddyPress (1.5).1
     * @see bp_dtheme_add_nojs_body_class()
     */
    function bp_dtheme_remove_nojs_body_class() {
    ?><script type="text/javascript">//<![CDATA[
    (function(){var c=document.body.className;c=c.replace(/no-js/,'js');document.body.className=c;})();
    //]]></script>
    <?php
    }
    add_action( 'bp_before_header', 'bp_dtheme_remove_nojs_body_class' );
    
    ?>

    Ending with the ?> is not strictly necessary, but it's good coding practice and avoids problems later on.

    Cheers,
    Mike

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.