2011-12-07 233 views
4

新手到PHP在这里。我收到以下错误:PHP语法错误意外'}'

Parse error: syntax error, unexpected '}' in ... on line 1

下面是代码,我很难找到这个简单的错误。任何人都可以帮忙吗?该文件是wordpress论文主题中的一个文件,位于PHP中。

<?php 

// Using hooks is absolutely the smartest, most bulletproof way to implement things like plugins, 
// custom design elements, and ads. You can add your hook calls below, and they should take the 
// following form: 
// add_action('thesis_hook_name', 'function_name'); 
// The function you name above will run at the location of the specified hook. The example 
// hook below demonstrates how you can insert Thesis' default recent posts widget above 
// the content in Sidebar 1: 
// add_action('thesis_hook_before_sidebar_1', 'thesis_widget_recent_posts'); 

// Delete this line, including the dashes to the left, and add your hooks in its place. 

/** 
* function custom_bookmark_links() - outputs an HTML list of bookmarking links 
* NOTE: This only works when called from inside the WordPress loop! 
* SECOND NOTE: This is really just a sample function to show you how to use custom functions! 
* 
* @since 1.0 
* @global object $post 
*/ 

function custom_bookmark_links() { 
    global $post; 
?> 
<ul class="bookmark_links"> 
    <li><a rel="nofollow" href="http://delicious.com/save?url=<?php urlencode(the_permalink()); ?>&amp;title=<?php urlencode(the_title()); ?>" onclick="window.open('http://delicious.com/save?v=5&amp;noui&amp;jump=close&amp;url=<?php urlencode(the_permalink()); ?>&amp;title=<?php urlencode(the_title()); ?>', 'delicious', 'toolbar=no,width=550,height=550'); return false;" title="Bookmark this post on del.icio.us">Bookmark this article on Delicious</a></li> 
</ul> 
<?php 
} 

/*** HEADER AD WIDGET***/ 
register_sidebars(1, 
array(
'name' => 'HeaderAd', 
'before_widget' => '<li id="%1$s">', 
'after_widget' => '</li>', 
'before_title' => '<h3>', 
'after_title' => '</h3>' 
) 
); 
function header_widget() { ?> 
<div id="header_widget_1"> 
<ul class="sidebar_list"> 
<?php thesis_default_widget(3); ?> 
</ul> 
</div> 
<?php } 

add_action('thesis_hook_header', 'header_widget', '1'); 
/*** HEADER WIDGET END***/ 

/*remove footer attribution*/ 
remove_action('thesis_hook_footer', 'thesis_attribution'); 

function seth_godin_stuff_1() { 
if (is_single()) { 
?> 
<p class="alert" style="text-align:center;">Interested in a free 25+ eBook on the 7 Wastes? Please <a href="http://www.shmula.com/7-wastes-of-lean/">DOWNLOAD HERE</a>.</p> 
<?php 
} 
} 

add_action('thesis_hook_before_post', 'seth_godin_stuff_1', '1'); 

function single_post_ads() { 
if (is_single()) { ?> 
<BR> 
<div align="center"> 
<table border="0" cellspacing="0" cellpadding="0" align="center"> 
<tbody> 
<tr> 
<td rowspan="2"><script type="text/javascript" src="http://forms.aweber.com/form/06/1421749706.js"></script></td> 
<td><a target="new" href="http://amzn.to/ddLMpa"><img class="alignnone size-full wp-image-4151" title="the-toyota-way-ad-unit" src="http://www.shmula.com/http://www.shmula.com/wp-content/uploads/Image/2010/08/the-toyota-way-ad-unit.jpg" alt="" width="102" height="157" /></a></td> 
<td><a target="new" href="http://amzn.to/9epSyC"><img class="alignnone size-full wp-image-4152" title="the-toyota-way-fieldbook-ad-unit" src="http://www.shmula.com/http://www.shmula.com/wp-content/uploads/Image/2010/08/the-toyota-way-fieldbook-ad-unit.jpg" alt="" width="111" height="158" /></a></td> 
<td><a target="new" href="http://amzn.to/ac4i1v"><img class="alignnone size-full wp-image-4149" title="the-toyota-culture-ad-unit" src="http://www.shmula.com/http://www.shmula.com/wp-content/uploads/Image/2010/08/the-toyota-culture-ad-unit.jpg" alt="" width="98" height="161" /></a></td> 
</tr> 
<tr><td colspan="5"><div align="center"><h5>This post was written by <a href="http://www.shmula.com/about-peter-abilla/" rel="author">Pete Abilla</a></h5> 
</div></td></tr> 
</tbody> 
</table> 
</div> 
<?php } 
} 

add_action('thesis_hook_after_post', 'single_post_ads'); 

remove_action('thesis_hook_after_post', 'thesis_post_tags'); 


/*social bookmarks right header*/ 
function thesis_header_ad() { 
?> 
<div id="banner_ad"> 
<div align="center"> 
<a rel="nofollow" href="http://www.linkedin.com/in/shmula"> 
<img src="http://www.shmula.com/wp-content/uploads/image/social-icons/linkedin.jpg" 
height="68" width="68" border="0" alt="" /></a>&nbsp; <a rel="nofollow" href="http://twitter.com/shmula"> 
<img src="http://www.shmula.com/http://www.shmula.com/wp-content/uploads/Image/2011/04/Twitter.png" height="70" width="70" border="0" 
alt="follow shmula on twitter" /></a>&nbsp; <a rel="nofollow" 
href="http://www.facebook.com/shmula"> 
<img src="http://www.shmula.com/http://www.shmula.com/wp-content/uploads/Image/2011/04/FaceBook.png" 
height="70" width="70" border="0" alt="" /></a>&nbsp;<a href="http://feeds.feedburner.com/shmula/dfYo"> 
<img src="http://www.shmula.com/http://www.shmula.com/wp-content/uploads/Image/2011/04/Feed.png" 
height="70" width="70" border="0" alt="" /></a>&nbsp; <a href="http://forms.aweber.com/form/77/1324894377.htm"> 
<img src="http://www.shmula.com/wp-content/uploads/image/social-icons/Email.gif" 
height="70" width="70" border="0" alt="" /></a> 
</div> 
</div> 
<?php 
}//end of php block 

/* BEGIN Custom Widgetized Footer */ 
if (function_exists('register_sidebar')) {  

register_sidebar(array('name' => 'Footer Widget ', 'id' => 'footer-widget-', 'before_widget' => '<div class="widget">', 'after_widget' => '</div>', 'before_title' => '<h3>', 'after_title' => '</h3>'));} 

function widgetized_footer() { ?><div id="widgetized_wrapper"> <?php 

    if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Footer Widget')) : ?> 
    <?php endif; ?> 
    </div> 
    <?php 
} 

remove_action('thesis_hook_footer', 'thesis_attribution');add_action('thesis_hook_footer', 'widgetized_footer'); 
/* END Custom Widgetized Footer *//*footer widget*/ 

/*custom popular posts thumbnails*/ 
function pop_posts_with_thumbs() { ?> 
    <li class="widget popular_posts"> 
     <h3>POPULAR POSTS</h3> 
     <ul> 
     <? $args = array('posts_per_page' => 28, 'orderby' => 'comment_count', 'category__in' => array(131,16,29,17,281,651,120,193,650,135,147,9,508,64,613,654,655)); 
     global $post; 
     $popular = get_posts($args); 
     foreach($popular as $post) { 
      setup_postdata($post); ?> 
      <li> 
       <a href="<?php the_permalink(); ?>" title="Permalink to <?php the_title(); ?>"> 
        <?php if(has_post_thumbnail()) { the_post_thumbnail('thumb'); } ?><?php the_title(); ?> 
       </a> 
      </li> 
      <!--[if lte IE 6]> 
       <div class="clear"></div> 
      <![endif]--> 
     <? } ?> 
     </ul> 
    </li> 
<? } 
add_action('thesis_hook_after_sidebar_1', 'pop_posts_with_thumbs'); 

/*thumbnail functions*/ 
add_theme_support('post-thumbnails'); 
set_post_thumbnail_size(610, 9999, true); 
add_image_size('teaser', 150, 150, true); 
add_image_size('thumb', 50, 50, true); 

/*link rel for next/prev*/ 
add_action('wp_head', 'index_rel_link'); // Relational link for site index 
add_action('wp_head', 'start_post_rel_link'); // Relational link for first post 
add_action('wp_head', 'adjacent_posts_rel_link_wp_head'); // Relational links for adjacent posts 
add_action('wp_head', 'parent_post_rel_link'); // Relational link for parent item 
+9

我希望你知道这是*意大利面代码* .. –

+0

你使用的是什么样的编辑器?它支持语法检查吗?你到达什么样的信息;或者你使用记事本? – Dan

+0

顺便说一句,搜索'http://www.shmula.com/http:// www.shmula.com /',我想你会惊讶你的代码经常出现。 – sarnold

回答

0

确保您的标签只在您的文件的开头&结束,对于初学者。这段代码有点乱。你是如何在模板中找到它的?

+0

是的,模板已经是这样了。我添加了一些函数,但是我在调​​试时删除了这些函数,但仍然出现错误,所以根本原因不是我的补充。有任何想法吗? – shmula

0

基本上,你的PHP代码没有语法错误。第1行中显示的错误不在此代码片段中。由于它是Wordpress,因此您可能会在另一个文件中更改主题的其他部分,并显示错误。或者您在服务器中有部分上传的文件。