• Resolved taskylon

    (@taskylon)


    After seeking a solution about thumbnail size, I found in wordpress codex some codes and when i add them in editor in function php my blog stopped working. It is a blank page with this error message :

    Parse error: syntax error, unexpected end of file in /home/taskylon/public_html/wp-content/themes/easel/functions.php on line 487

    I opened my cplesk profile but I cant see the specific line. I assume the problem is here:

    if (!function_exists(‘easel_display_post_thumbnail’)) {
    function easel_display_post_thumbnail($size = ‘thumbnail’) {
    global $post, $wp_query;
    if ($post->post_type == ‘post’) {
    $post_thumbnail = ”;
    $link = get_post_meta( $post->ID, ‘link’, true );
    if (empty($link)) $link = get_permalink();
    if ( has_post_thumbnail() ) {
    if (is_home()) {
    $post_thumbnail = ‘<div class=”post-image”><center>‘.get_the_post_thumbnail($post->ID, $size).’</center></div>’.”\r\n”;
    } else
    $post_thumbnail = ‘<div class=”post-image”><center>’.get_the_post_thumbnail($post->ID, $size).'</center></div>’.”\r\n”;
    } else {
    $url_image = get_post_meta($post->ID, ‘featured-image’, true);
    if (!empty($url_image)) $post_thumbnail = ‘<div class=”post-image”><center><img src=”‘.$url_image.'” title=”‘.get_the_title().'” alt=”‘.get_the_title().'”></center></div>’.”\r\n”;
    }
    echo apply_filters(‘easel_display_post_thumbnail’, $post_thumbnail);
    }
    }
    }

    Could you please tell me where exactly is the problem and how to fix it?
    Thank you

    My blog is http://www.taskylonea.com

Viewing 15 replies - 1 through 15 (of 21 total)
  • Most often, that error is due to a missing ‘}’ – looking at this bit of code, it doesn’t look like you’re missing one.

    In this case, the line number that it’s complaining about is the end of the file (hence the “unexpected end of file” warning), which may not be where the missing ‘}’ needs to be.

    I would recommend undoing your changes – or re-installing an original copy of the functions.php file, if possible. Then, inspect the code that you are pasting in and make sure that all of the ‘{‘ have a corresponding ‘}’. When pasting the code into the functions.php file, make sure that you’re not inadvertently removing any braces. Also make sure that the code you’re pasting in is before the ‘?>’ at the end of the file – if it is there.

    Apologies if any of this is overly basic, but I don’t know your level of expertise and want to make sure that these things are covered.

    Just as an FYI – in other cases, the line number is useful. The built-in theme editor in WordPress doesn’t display line numbers, but you could copy the code from the built-in editor to a text editor like Notepad++, Text Wrangler, or any other editor that displays line numbers. On Windows, you could even paste it into Notepad, then use Ctrl-G to go to the line number in question.

    Thread Starter taskylon

    (@taskylon)

    That is the problem. My changes are not there as like it never happened. Where can I find the original copy of functions.php file? And how to install it? Please, excuse me by asking so many questions but I’m totally unaware!
    Another issue is that the code ends in line 276 and not in 487 as is says.

    The best place would be from a fresh copy of the theme. However, it appears that the theme is not currently available on the author’s site. Where did you originally install the theme from?

    Additionally, I would recommend against modifying the theme directly, as your changes would be removed if you install an update to the theme from the author. The better option is to create a child theme and put your code in the child theme’s functions.php (thus leaving the original functions.php alone).

    Thread Starter taskylon

    (@taskylon)

    <?php
    
    if ( isset( $_GET['latestblogpost'] ) )
    	add_action( 'template_redirect', 'easel_latest_blog_post_jump' );
    
    function easel_latest_blog_post_jump() {
    	$catnum = 0;
    	if (isset($_GET['latestblogpost'])) $catnum = (int)esc_attr($_GET['latestblogpost']);
    	if (!empty($catnum)) {
    		$args = array(
    				'numberposts' => 1,
    				'post_type' => 'post',
    				'orderby' => 'post_date',
    				'order' => 'DESC',
    				'post_status' => 'publish',
    				'category__in' => array($catnum)
    				);
    		$qposts = get_posts( $args );
    	} else {
    		$args = array(
    				'numberposts' => 1,
    				'post_type' => 'post',
    				'orderby' => 'post_date',
    				'order' => 'DESC',
    				'post_status' => 'publish'
    				);
    		$qposts = get_posts( $args );
    	}
    	if (is_array($qposts)) {
    		$qposts = reset($qposts);
    		wp_redirect( get_permalink( $qposts->ID ) );
    	} else {
    		wp_redirect( home_url() );
    	}
    	wp_reset_query();
    	exit;
    }
    
    if (!function_exists('easel_display_post_title')) {
    	function easel_display_post_title() {
    		global $post, $wp_query;
    		$get_post_title = '';
    		if ((easel_themeinfo('disable_page_titles') && is_page()) || (easel_themeinfo('disable_post_titles') && !is_page()) || (is_page('chat') || is_page('forum'))) return;
    		if (is_page()) {
    			$post_title = "<h2 class=\"page-title\">";
    		} else {
    			$post_title = "<h2 class=\"post-title\">";
    		}
    		if (is_home() || is_search() || is_archive() && !is_page()) $post_title .= "<a href=\"".get_permalink()."\">";
    		$get_post_title .= get_the_title();
    		if (!$get_post_title) $get_post_title = '( No Title )';
    		$post_title .= $get_post_title;
    		if (is_home() || is_search() || is_archive() && !is_page()) $post_title .= "</a>";
    		$post_title .= "</h2>\r\n";
    		echo apply_filters('easel_display_post_title',$post_title);
    	}
    }
    
    if (!function_exists('easel_display_post_thumbnail')) {
    	function easel_display_post_thumbnail() {
    		global $post, $wp_query;
    		if ($post->post_type == 'post') {
    			$post_thumbnail = '';
    			$link = get_post_meta( $post->ID, 'link', true );
    			if (empty($link)) $link = get_permalink();
    			if ( has_post_thumbnail() ) {
    			the_post_thumbnail();
    				if (is_home()) {
    					$post_thumbnail = '<div class="post-image"><center><a href="'.$link.'" rel="featured-image" title="Link to '.get_the_title().'">'.get_the_post_thumbnail($post->ID, $size).'</a></center></div>'."\r\n";
    						} else {
    						$post_thumbnail = '<div class="post-image"><center>'.get_the_post_thumbnail($post->ID, $size).'</center></div>'."\r\n";
    			 } else {
    				$url_image = get_post_meta($post->ID, 'featured-image', true);
    				if (!empty($url_image)) $post_thumbnail = '<div class="post-image"><center><a href="'.$link.'" rel="featured-image" title="Link to "'.get_the_title().'"><img src="'.$url_image.'" title="'.get_the_title().'" alt="'.get_the_title().'"></a></center></div>'."\r\n";
    			}
    			echo apply_filters('easel_display_post_thumbnail', $post_thumbnail);}
    		}
    	}
    }
    
    if (!function_exists('easel_display_author_gravatar')) {
    	function easel_display_author_gravatar() {
    		global $post, $wp_query, $is_IE;
    		if (is_page()) return;
    		if (easel_themeinfo('enable_post_author_gravatar')) {
    			$author_get_gravatar = get_avatar(get_the_author_meta('email'), 82, easel_random_default_avatar(get_the_author_meta('email'),get_the_author_meta('display_name')));
    			if (!$is_IE) $author_get_gravatar = str_replace('photo', 'photo instant nocorner itxtalt', $author_get_gravatar);
    			$author_gravatar = "<div class=\"post-author-gravatar\">".$author_get_gravatar."</div>\r\n";
    			echo apply_filters('easel_display_author_gravatar', $author_gravatar);
    		}
    	}
    }
    
    if (!function_exists('easel_display_post_calendar')) {
    	function easel_display_post_calendar() {
    		global $post, $wp_query;
    		if (is_page()) return;
    		if (easel_themeinfo('enable_post_calendar')) {
    			$post_calendar = "<div class=\"post-calendar-date\"><div class=\"calendar-date\"><span>".get_the_time('M')."</span>".get_the_time('d')."</div></div>\r\n";
    			echo apply_filters('easel_display_post_calendar', $post_calendar);
    		}
    	}
    }
    
    if (!function_exists('easel_display_post_author')) {
    	function easel_display_post_author() {
    		global $post, $authordata;
    		if (!easel_themeinfo('disable_author_info_in_posts')) {
    			$post_author = "<span class=\"post-author\">".__('by','easel')." <a href=\"".get_author_posts_url( $authordata->ID, $authordata->user_nicename )."\">".get_the_author()."</a></span>\r\n";
    			echo apply_filters('easel_display_post_author',$post_author);
    		}
    	}
    }
    
    if (!function_exists('easel_display_post_date')) {
    	function easel_display_post_date() {
    		global $post;
    		if (!easel_themeinfo('disable_date_info_in_posts')) {
    			$post_date = "<span class=\"posted-on\">".__('on&nbsp;','easel')."</span><span class=\"post-date\">".get_the_date(get_option('date_format'))."</span>\r\n";
    			echo apply_filters('easel_display_post_date',$post_date);
    		}
    	}
    }
    
    if (!function_exists('easel_display_post_time')) {
    	function easel_display_post_time() {
    		global $post;
    		if (!easel_themeinfo('disable_date_info_in_posts') && !easel_themeinfo('disable_posted_at_time_in_posts')) {
    			$post_time = "<span class=\"posted-at\">".__('at&nbsp;','easel')."</span><span class=\"post-time\">".get_the_time(get_option('time_format'))."</span>\r\n";
    			echo apply_filters('easel_display_post_time',$post_time);
    		}
    	}
    }
    
    if (!function_exists('easel_display_modified_date_time')) {
    	function easel_display_modified_date_time() {
    		global $post;
    		if (!easel_themeinfo('disable_date_info_in_posts') && easel_themeinfo('enable_last_modified_in_posts')) {
    			$u_time = get_the_time('U');
    			$u_modified_time = get_the_modified_time('U');
    			if ($u_modified_time != $u_time) {
    				$post_date_time = '<span class="posted-last-modified"> '.__('and modified on','easel').' '.get_the_modified_date(get_option('date_format')).'. ';
    				if (!easel_themeinfo('disable_posted_at_time_in_posts')) $post_date_time .= '<span class="posted-last-modified-time"> '.__('at','easel').' '.get_the_modified_time(get_option('time_format')).'</span>'."\r\n";
    				echo apply_filters('easel_display_modified_date_time', $post_date_time);
    			}
    		}
    	}
    }
    
    if (!function_exists('easel_display_post_category')) {
    	function easel_display_post_category() {
    		global $post;
    		$post_category = '';
    		if (!easel_is_bbpress() && !easel_themeinfo('disable_categories_in_posts') && !is_attachment() && ($post->post_type == 'post')) {
    			$post_category = "<div class=\"post-cat\">". __('Posted In: ','easel') .get_the_category_list(', ')."</div>\r\n";
    		}
    		echo apply_filters('easel_display_post_category', $post_category);
    	}
    }
    
    if (!function_exists('easel_display_post_tags')) {
    	function easel_display_post_tags() {
    		global $post;
    		if (!easel_themeinfo('disable_tags_in_posts')) {
    			$post_tags = "<div class=\"post-tags\">".get_the_tag_list(__('└ Tags: ','easel'), ', ', '<br />')."</div>\r\n";
    			echo apply_filters('easel_display_post_tags', $post_tags);
    		}
    	}
    }
    
    if (!function_exists('easel_display_comment_link')) {
    	function easel_display_comment_link() {
    		global $post;
    		if ($post->comment_status == 'open' && !is_singular()) { ?>
    			<div class="comment-link">
    				<?php comments_popup_link('<span class="comment-balloon comment-balloon-empty">&nbsp;</span>'.__('Comment&nbsp;','easel'), '<span class="comment-balloon">1</span> '.__('Comment ','easel'), '<span class="comment-balloon">%</span> '.__('Comments ','easel')); ?>
    			</div>
    			<?php
    		}
    	}
    }
    
    if (!function_exists('easel_display_blog_navigation')) {
    	function easel_display_blog_navigation() {
    		global $post, $wp_query;
    		if (easel_themeinfo('enable_comments_on_homepage') && (easel_themeinfo('home_post_count') == '1')) {
    			$temp_single = $wp_query -> is_single;
    			$wp_query -> is_single = true;
    		}
    		if (is_single() && !is_page() && !is_archive() && !is_search() && ($post->post_type == 'post')) { ?>
    			<div class="blognav">
    				<?php previous_post_link('<span class="blognav-prev">%link</span>',__('&lsaquo; Prev','easel'), false); ?>
    				<?php next_post_link('<span class="blognav-next">%link</span>',__('Next &rsaquo;','easel'), false); ?>
    				<div class="clear"></div>
    			</div>
    		<?php }
    		if (easel_themeinfo('enable_comments_on_homepage') && (easel_themeinfo('home_post_count') == '1')) {
    			$wp_query -> is_single = $temp_single;
    		}
    	}
    }
    
    if (!function_exists('easel_display_the_content')) {
    	function easel_display_the_content() {
    		global $post, $wp_query;
    		if ((is_archive() || is_search()) && (easel_themeinfo('excerpt_or_content_in_archive') == 'excerpt')) {
    			do_action('easel-display-the-content-before');
    			the_excerpt();
    			do_action('easel-display-the-content-after');
    		} else {
    			if (!is_single()) { global $more; $more = 0; }
    			do_action('easel-display-the-content-before');
    			the_content(__('&darr; Read the rest of this entry...','easel'));
    			do_action('easel-display-the-content-after');
    		}
    	}
    }
    
    if (!function_exists('easel_display_post')) {
    	function easel_display_post() {
    		global $post, $wp_query;
    		if (!easel_is_bbpress()) easel_display_blog_navigation(); ?>
    		<div <?php post_class(); ?>>
    			<?php easel_display_post_thumbnail(); ?>
    			<div class="post-head"><?php do_action('easel-post-head'); ?></div>
    			<div class="post-content">
    				<div class="post-info">
    					<?php
    						if (!easel_is_bbpress()) easel_display_author_gravatar();
    						if (!easel_is_bbpress()) easel_display_post_calendar();
    						if (is_sticky()) { ?><div class="sticky-image">Featured Post</div><?php }
    						if (function_exists('easel_show_mood_in_post')) easel_show_mood_in_post();
    					?>
    					<div class="post-text">
    						<?php
    						easel_display_post_title();
    						if (!is_page()) {
    							easel_display_post_author();
    							easel_display_post_date();	easel_display_post_time(); easel_display_modified_date_time();
    							if ($post->post_type == 'post') { edit_post_link(__('Edit','easel'), ' <span class="post-edit">', '</span>'); }
    							easel_display_post_category();
    							if (function_exists('the_ratings') && $post->post_type == 'post') { the_ratings(); }
    							do_action('easel-post-info');
    							do_action('comic-post-info');
    						} ?>
    					</div>
    				</div>
    				<div class="clear"></div>
    				<div class="entry">
    					<?php easel_display_the_content(); ?>
    					<div class="clear"></div>
    					<?php do_action('comic-transcript'); ?>
    				</div>
    				<?php wp_link_pages(array('before' => '<div class="linkpages"><span class="linkpages-pagetext">Pages:</span> ', 'after' => '</div>', 'next_or_number' => 'number')); ?>
    				<div class="clear"></div>
    				<?php if (!is_page()) { ?>
    				<div class="post-extras">
    					<?php
    						easel_display_post_tags();
    						do_action('easel-post-extras');
    						easel_display_comment_link();
    					?>
    					<div class="clear"></div>
    				</div>
    				<?php } else
    					edit_post_link(__('Edit this page.','easel'), '', ''); ?>
    			</div>
    			<div class="post-foot"><?php do_action('comic-post-foot'); ?><?php do_action('easel-post-foot'); ?></div>
    		</div>
    		<?php
    			do_action('comic-post-extras');
    			comments_template('', true);
    	}
    }
    
    ?>

    If you please, have a look in all the code. Is there problem in the end?

    My PHP parser threw an error on line 72:

    syntax error, unexpected ‘else’ (T_ELSE) in html/test.php on line 72

    It appears that there were some bracket issues there in the easel_display_post_thumbnail function.

    I give no guarantees on this code’s functionality, as I can’t test it without the rest of the theme, but I’ve cleaned up that section of code into what I believe is the correct logic, with brackets in the right places. Replace that entire section (lines 59-79 in the code you posted above) with this:

    if (!function_exists('easel_display_post_thumbnail')) {
    	function easel_display_post_thumbnail() {
    		global $post, $wp_query;
    		if ($post->post_type == 'post') {
    			$post_thumbnail = '';
    			$link = get_post_meta( $post->ID, 'link', true );
    			if (empty($link)) $link = get_permalink();
    			if ( has_post_thumbnail() ) {
    				the_post_thumbnail();
    				if (is_home()) {
    					$post_thumbnail = '<div class="post-image"><center><a href="'.$link.'" rel="featured-image" title="Link to '.get_the_title().'">'.get_the_post_thumbnail($post->ID, $size).'</a></center></div>'."\r\n";
    				} else {
    					$post_thumbnail = '<div class="post-image"><center>'.get_the_post_thumbnail($post->ID, $size).'</center></div>'."\r\n";
    				}
    			} else {
    				$url_image = get_post_meta($post->ID, 'featured-image', true);
    				if (!empty($url_image)) $post_thumbnail = '<div class="post-image"><center><a href="'.$link.'" rel="featured-image" title="Link to "'.get_the_title().'"><img src="'.$url_image.'" title="'.get_the_title().'" alt="'.get_the_title().'"></a></center></div>'."\r\n";
    			}
    			echo apply_filters('easel_display_post_thumbnail', $post_thumbnail);
    		}
    	}
    }

    This is a functions.php file, correct?
    If so, remove the ?> and any spaces below the last “}”
    https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#remove-trailing-spaces

    Thread Starter taskylon

    (@taskylon)

    Phil Erb, unfortunately nothing happened. I copied the section but the problem remains. I’am in desperation!

    Thread Starter taskylon

    (@taskylon)

    NeoTechnomad, I did what you said, but… nothing. I’m here again.

    Moderator bcworkz

    (@bcworkz)

    I hate to say this, but this may be a good time to consider switching to a different theme. It’s not good to use an unsupported theme. Any security issues that may develop will never be fixed.

    Find a theme that is regularly updated and the author is actively involved in support. Avoid commercial themes if you like these forums, we cannot help folks with commercial themes much, if any. If you do go commercial, do not buy one of those themes that are installed as children, where they all have one common parent serving as a base theme – there is no way to add a custom grand-child theme.

    Develop a work flow that does not involve the theme editor – that thing is a recipe for disaster! Work locally, keep incremental backups, and FTP the revised files. Yes, it’s not as convenient as the theme editor, but it’s infinitely safer. Use a good code editor, it will make the theme editor less tempting to use. The syntax highlighting alone makes it worthwhile.

    When you get tired of FTPing every little change, you will be in a better frame of mind to consider setting up a local development environment. Then you only FTP once everything is fully developed, debugged, and working perfectly.

    Thread Starter taskylon

    (@taskylon)

    This theme was free on wordpress themes. What kind of themes do you propose to use, free or paid ones? And suppose I want to switch to another theme, how can I do it since I can’t log in? Through cplesk do you mean? And how can I do it?
    And if i change the theme the parse error will vanish and the blog open again?or the problem will remain?

    It is the functions.php file that is preventing you from logging in, correct?
    If so, can you access the File Manager through your hosting account cPanel?
    Or, do you have a FTP client, such as Filezilla, installed on your computer?

    Thread Starter taskylon

    (@taskylon)

    Yes, I have access at the file manager through cPanel.

    Your theme is Graphene, which you can get here: https://wordpress.org/themes/graphene/
    Download it to your computer and unzip it.

    Through cPanel’s File Manager, go to wp-content > themes > graphene.
    Find the “functions.php” file, which should be with all the other files in the root (public_html).
    Download the current “functions.php” file into a folder on your computer named “broken theme functions” (…saving this, just in case) – then delete the one in your theme.
    Upload the functions.php from the new copy of your theme.
    See if you can log in.

    taskylon: I believe bcworkz mentioned the option of finding a new theme, because the easel theme is no longer supported by the author and no longer available on wordpress.org. I don’t believe he was questioning why you originally chose easel, as it was likely available on wordpress.org and supported at the time you chose it. You certainly could choose to continue with it, but there would be no updates or help from the author, most likely.

    It appears that you took bcworkz’s advice and are now trying out the Graphene theme, as NeoTechnomad pointed out. If you intend to add a function for thumbnail size, as was your original intent in this thread, I would again strongly urge you to create a child theme and do not modify the main theme – otherwise, your changes will be wiped out when an update to the theme is installed. Information on child themes is available at https://codex.wordpress.org/Child_Themes.

    Thread Starter taskylon

    (@taskylon)

    I want to thank you all for your help! No matter how helpful were your advice I appreciate the time you spent for getting a solution for my problem.

    Now, let me explain what I did in order to…revive my wordpress blog again and work properly…
    Yes! I decided to switch the old theme with a new one (as the most of you advised me to do) in order to overcome the problem with the broken code. As I have mentioned before that I’m totally unaware of coding and php things.

    So, for the record, I downloaded a new theme and through cpanel I upload it and… voila! The blog works! In new appearance though but it works!

    **Thanks again from my heart all of you for your precious help!**

    [http://www.taskylonea.com]

Viewing 15 replies - 1 through 15 (of 21 total)
  • The topic ‘Parse error after editin theme editor’ is closed to new replies.