This is kind of a long explanation because I want to make sure I don't leave out any important info in gaining advice for this issue.

I was attempting to add the following code (from http://sillybean.net/2010/02/using-shortcodes-everywhere/) to a functions.php in a Wordpress installation:

add_filter( 'widget_text', 'shortcode_unautop');
add_filter( 'widget_text', 'do_shortcode');

I added a comment explaining the purpose of the code and enclosed it in <!-- HTML --> comments, which of course was a mistake. I updated the file in Wordpress and received this error:

Parse error: syntax error, unexpected '<' in /home/websitename/websitename.com/wp-content/themes/bold-life/functions.php on line 226

As I was not editing line 226, I decided to just go back, erase my comments, and update the file again. When I did this, I received the same error again.

Now the site only resolves to the error, even when in WP-admin. I am waiting to receive FTP info so I can login and update the file that way, returning it to the original.

I also plan to uninstall all plugins and possibly re-install the theme files. Do you think this should work?

Here is the original code, minus any of my additions. Is there anything wrong here?

Any advice or constructive comments would be appreciated.

<?php
/**
 * Bold Life functions and definitions
 *
 * @package WordPress
 * @subpackage Bold Life
 */

/**
 * Set the content width based on the theme's design and stylesheet.
 */
if ( ! isset( $content_width ) )
	$content_width = 538;

/**
 * Define Theme Colors
 */
if ( ! isset( $themecolors ) ) {
	$themecolors = array(
		'bg' => 'f2efe8',
		'text' => '474534',
		'link' => 'da0a0a',
		'border' => '9d9474',
		'url' => 'da0a0a',
	);
}

/**
 * Tell WordPress to run boldlife_setup() when the 'after_setup_theme' hook is run.
 */
add_action( 'after_setup_theme', 'boldlife_setup' );

if ( ! function_exists( 'boldlife_setup' ) ) :
/**
 * Sets up theme defaults and registers support for various WordPress features.
 *
 * Note that this function is hooked into the after_setup_theme hook, which runs
 * before the init hook. The init hook is too late for some features, such as indicating
 * support post thumbnails.
 *
 * To override boldlife_setup() in a child theme, add your own boldlife_setup to your child theme's
 * functions.php file.
 *
 * @uses load_theme_textdomain() For translation/localization support.
 * @uses add_theme_support() To add support for post thumbnails, automatic feed links, and Post Formats.
 * @uses register_nav_menus() To add support for navigation menus.
 * @uses add_custom_background() To add support for a custom background.
 * @uses set_post_thumbnail_size() To set a custom post thumbnail size.
 *
 */
function boldlife_setup() {

// Automatic Feed Links
add_theme_support( 'automatic-feed-links' );

// I18n
load_theme_textdomain( 'bold-life', get_template_directory_uri() . '/languages' );

$locale = get_locale();
$locale_file = get_template_directory_uri() . "/languages/$locale.php";
if ( is_readable( $locale_file ) )
	require_once( $locale_file );

// Navigation Menu
register_nav_menu( 'primary', __( 'Primary Menu', 'bold-life' ) );

// Custom Background
add_custom_background();

}
endif; // boldlife_setup

/**
 * Register our sidebars and widgetized areas.
 */
add_action( 'widgets_init', 'boldlife_register_sidebars' );

if ( ! function_exists( 'boldlife_register_sidebars' ) ) :

function boldlife_register_sidebars() {

	/*
		Add theme support for widgetized sidebars.
	*/
	register_sidebar( array(
		'name' => __( 'Primary Sidebar', 'bold-life' ),
		'id' => 'primary-sidebar',
		'description' => __( 'Widgets in this sidebar will be shown adjacent to all site content (with the exception of individual image attachment pages).', 'bold-life' )
	) );

	/*
		Add Bold Life-specific RSS subscription button widget
	*/
	wp_register_sidebar_widget( 
		'boldlife-rss', 								// unique widget ID
		__( 'Subscribe to RSS Button', 'bold-life' ),   // widget name
		'widget_boldlife_rss', 							// callback function
		array( 											// options
			'description' => 'Add a large, bright "Subscribe to RSS" button to your sidebar.',
			'classname' => 'widget-boldlife-rss'
		)
	);

}

endif; // boldlife_register_sidebars

/**
 * Modify the font sizes of WordPress' tag cloud
 */
if ( ! function_exists( 'boldlife_widget_tag_cloud_args' ) ) :

function boldlife_widget_tag_cloud_args( $args ) {
	$args['smallest'] = 12;
	$args['largest']= 20;
	$args['unit']= 'px';
	return $args;
}
add_filter( 'widget_tag_cloud_args', 'boldlife_widget_tag_cloud_args' );

endif; // boldlife_widget_tag_cloud_args

/**
 * Build Subscribe to RSS widget
 */
if ( ! function_exists( 'widget_boldlife_rss' ) ) :

function widget_boldlife_rss($args) {
	extract($args);
	echo $before_widget; ?>

		<a href="<?php bloginfo('rss2_url'); ?>" class="rss"><?php _e( 'Subscribe to RSS', 'bold-life' ); ?></a>

	<?php echo $after_widget;
}

endif; // widget_boldlife_rss

if ( ! function_exists( 'boldlife_comment' ) ) :
/**
 * Template for comments and pingbacks.
 *
 * To override this walker in a child theme without modifying the comments template
 * simply create your own boldlife_comment(), and that function will be used instead.
 *
 * Used as a callback by wp_list_comments() for displaying the comments.
 */
function boldlife_comment( $comment, $args, $depth ) {
	$GLOBALS['comment'] = $comment;
	switch ( $comment->comment_type ) :
		case 'pingback' :
		case 'trackback' :
	?>
	<li class="post pingback">
		<p><?php _e( 'Pingback:', 'bold-life' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( 'Edit', 'bold-life' ), '<span class="edit-link">', '</span>' ); ?></p>
	<?php
			break;
		default :
	?>
	<li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
		<div id="comment-<?php comment_ID(); ?>" class="comment">
			<div class="comment-meta">
				<div class="comment-author vcard">
					<?php
						$avatar_size = 60;
						if ( '0' != $comment->comment_parent )
							$avatar_size = 36;

					echo get_avatar( $comment, $avatar_size );

					/* translators: 1: comment author, 2: date and time */
					printf( __( '%1$s on %2$s <span class="says">said:</span>', 'bold-life' ),
						sprintf( '<span class="fn">%s</span>', get_comment_author_link() ),
						sprintf( '<a href="%1$s"><time pubdate datetime="%2$s">%3$s</time></a>',
							esc_url( get_comment_link( $comment->comment_ID ) ),
							get_comment_time( 'c' ),
							/* translators: 1: date, 2: time */
							sprintf( __( '%1$s at %2$s', 'bold-life' ), get_comment_date(), get_comment_time() )
						)
					);
				?>

				<?php edit_comment_link( __( 'Edit', 'bold-life' ), '<span class="edit-link">', '</span>' ); ?>
			</div><!-- .comment-author .vcard -->

			<?php if ( $comment->comment_approved == '0' ) : ?>
				<em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'bold-life' ); ?></em>
				<br />
			<?php endif; ?>

		</div>

		<div class="comment-content"><?php comment_text(); ?></div>

		<div class="reply">
			<?php comment_reply_link( array_merge( $args, array( 'reply_text' => __( 'Reply <span>&darr;</span>', 'bold-life' ), 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
		</div><!-- .reply -->
	</div><!-- #comment-## -->

<?php
		break;
endswitch;
}
endif; // ends check for boldlife_comment()

if ( ! function_exists( 'boldlife_get_the_password_form' ) ) :
/**
 * Add HTML classes to protected post/page forms. See http://core.trac.wordpress.org/ticket/18729
 * for more information about why this is needed. It may no longer be needed in future versions of WordPress.
 */
function boldlife_get_the_password_form( $output ) {
	global $post;
	$label = 'pwbox-' . ( empty( $post->ID ) ? rand() : $post->ID );
	$output = '<form class="post-password-form" action="' . get_option( 'siteurl' ) . '/wp-pass.php" method="post">
		<p>' . __( 'This post is password protected. To view it please enter your password below:', 'bold-life' ) . '</p>
		<p><label class="screen-reader-text" for="' . $label . '">' . __( 'Password:', 'bold-life' ) . '</label></p>
		<p><input class="post-password-input" name="post_password" id="' . $label . '" type="password" size="20" /><input class="post-password-submit" type="submit" name="Submit" value="' . esc_attr__( 'Submit', 'bold-life' ) . '" /></p>
	</form>
	';
	return $output;
}
add_filter( 'the_password_form', 'boldlife_get_the_password_form' );

endif; // ends check for boldlife_get_the_password_form()
    heymagnolia;10988490 wrote:

    I added a comment explaining the purpose of the code and enclosed it in <!-- HTML --> comments, which of course was a mistake.

    Of course it was; why would you expect that syntax from one language would work in a completely different language? PHP is not HTML, and HTML is not PHP. Use PHP syntax in PHP code, and HTML syntax in HTML code.

    heymagnolia;10988490 wrote:

    I updated the file in Wordpress and received this error:

    Parse error: syntax error, unexpected '<' in /home/websitename/websitename.com/wp-content/themes/bold-life/functions.php on line 226

    ...which is exactly as expected, given the above statements.

    heymagnolia;10988490 wrote:

    As I was not editing line 226, I decided to just go back, erase my comments, and update the file again. When I did this, I received the same error again.

    I'll simply quote a man much wiser than I:

    Albert Einstein wrote:

    Insanity: doing the same thing over and over again and expecting different results.

    :p

    heymagnolia;10988490 wrote:

    Now the site only resolves to the error, even when in WP-admin.

    Well that makes sense, "functions.php" sounds mildly important at the least, so any PHP script that attempts to include/require() it is going to fail since PHP can't understand how to parse that file.

    heymagnolia;10988490 wrote:

    I am waiting to receive FTP info so I can login and update the file that way, returning it to the original.

    Oh, so you weren't even editing the file directly before? How do you know that you "[were] not editing line 226" then if you can't even inspect the original file?

    heymagnolia;10988490 wrote:

    I also plan to uninstall all plugins and possibly re-install the theme files. Do you think this should work?

    It'll work just fine until you try to add invalid syntax again.

    heymagnolia;10988490 wrote:

    Here is the original code, minus any of my additions. Is there anything wrong here?

    If it's the original code, then why would there be anything wrong? There are no parse errors in that code snippet (as reported by PHP's 'lint/syntax check' command line option), if that's what you're asking.

    heymagnolia;10988490 wrote:

    Any advice or constructive comments would be appreciated.

    I would advise using the correct syntax for PHP comments. 😉 To that end, take a look at the following PHP manual page: [man]basic-syntax.comments[/man].

      Of course it was; why would you expect that syntax from one language would work in a completely different language? PHP is not HTML, and HTML is not PHP. Use PHP syntax in PHP code, and HTML syntax in HTML code.

      I understand that; hence my acknowledgement that I made simple mistake. I have been editing mostly html all day and was just on autopilot for the comment. I obviously did expect that syntax from two different codes would work in conjunction with one another. Like I said - mistake.

      Oh, so you weren't even editing the file directly before? How do you know that you "[were] not editing line 226" then if you can't even inspect the original file?

      You can directly edit files in your ftp via the Editor on Wordpress. However, that won't work if you don't have access to the WP-admin backend of Wordpress, which, since the error won't let me access the backend, I obviously cannot do.

      When I edit the files, I copy and paste them from the editor in Wordpress, make the changes in a PHP editor on my desktop, then copy and paste them back into the editor in Wordpress. In my past experience, the lines numbers cited have been accurate between the two. That is how I can tell what line of code I actually edited.

      The fact that the error cited was NOT where I added the code made me suspect that perhaps there was also something off with the original code.

      If it's the original code, then why would there be anything wrong? There are no parse errors in that code snippet (as reported by PHP's 'lint/syntax check' command line option), if that's what you're asking.

      As far as I know, there could be something mildly wonky with this that I cannot see that just doesn't result in a critical error. Since I was going over everything else, I wanted to check this as well.

      You may want to try phrasing answers to simple requests for advice with a little less rudeness. Adding a smiley face after snarky comments does not hide your underlying petty meanness. If my question offends your sensitivities regarding human intellect and ability, you need not answer it.

        heymagnolia;10988495 wrote:

        I understand that; hence my acknowledgement that I made simple mistake.

        Normally people don't acknowledge "simple mistakes" by prefacing them with "kind of a long explanation," hence I didn't realize you were doing as such.

        heymagnolia;10988495 wrote:

        You can directly edit files in your ftp via the Editor on Wordpress. However, that won't work if you don't have access to the WP-admin backend of Wordpress, which, since the error won't let me access the backend, I obviously cannot do.

        For one, there are no "files in your ftp" - FTP is a protocol that allows you to access files on another computer's filesystem.

        Ignoring that, I personally have never (extensively) used/administered Wordpress, so I have no idea what features it may or may not have and what those features may or may not do behind-the-scenes. As such, my post was based only on the statements made in your post (since I had nothing else to go on).

        heymagnolia;10988495 wrote:

        When I edit the files, I copy and paste them from the editor in Wordpress, make the changes in a PHP editor on my desktop, then copy and paste them back into the editor in Wordpress. In my past experience, the lines numbers cited have been accurate between the two. That is how I can tell what line of code I actually edited.

        Seems like a sketchy way of doing things; I think you'd be much better off once you get FTP access and just edit files directly.

        Even better would be to setup a development environment on your own PC, for example, and make changes there.

        heymagnolia;10988495 wrote:

        The fact that the error cited was NOT where I added the code made me suspect that perhaps there was also something off with the original code.

        That could've been a possibility, I suppose, but note that PHP can't always give exact line numbers where the problem occurred (in fact, it never does - it only tells you the line number where it suddenly realized that something it has read is amiss; whether or not the actual error is anywhere near that point in the code is variable). There might be other reasons why the line number was off, but I'd be speculating unless you posted the contents of the actual file.

        heymagnolia;10988495 wrote:

        As far as I know, there could be something mildly wonky with this that I cannot see that just doesn't result in a critical error. Since I was going over everything else, I wanted to check this as well.

        Fair point, but know that it's quite unlikely that "mildly wonky" code that doesn't generate parse errors before any modifications probably won't start producing parse errors on its own after your modifications (in other words, it's most likely the modifications to blame for the newly-introduced parse error).

        heymagnolia;10988495 wrote:

        You may want to try phrasing answers to simple requests for advice with a little less rudeness.

        Rudeness? I was simply being thorough, trying to educate you rather than just saying "oh just do <this>" (which isn't really 'educating' at all, IMHO).

        And again, a "simple request" in my eyes isn't usually a 200-word post prefaced with text like "This is kind of a long explanation...", hence the reason for the thoroughness in my response.

        heymagnolia;10988495 wrote:

        Adding a smiley face after snarky comments does not hide your underlying petty meanness.

        If I had any sort of "underlying petty meanness," then I a) wouldn't have tried to help you by addressing all parts of your post, and b) probably wouldn't have tried to help you at all.

        heymagnolia;10988495 wrote:

        If my question offends your sensitivities regarding human intellect and ability, you need not answer it.

        And if appearing as a "newbie" on a programming forum which subsequently elicits lengthy replies offends you, perhaps you need not visit such forums? 😉 (Can't forget that smiley face, now can I...)

          2 years later

          Wow, bradgrafelman is a know-it-all jerk.

            imrubi92;11038515 wrote:

            Wow, bradgrafelman is a know-it-all

            Aww, you flatter me. :o

              bradgrafelman;11038521 wrote:

              Aww, you flatter me. :o

              +1

                Write a Reply...