2012-09-01 59 views
0

我在wordpress主題的function.php文件中進行了更改。當我嘗試更新funtion.php文件時,它提供了一個錯誤:Wordpress function.php致命錯誤

Fatal error: Call to undefined function add_action() in /hermes/waloraweb088/b1248/moo.armaan815/Voga/fp/wp-content/themes/enterweb/functions.php on line 45.

我不知道如何解決它。我真的很感激反饋/幫助。謝謝。

這是function.php文件代碼。行號「45」在側邊欄功能之後被調用到第一次調用。

<?php 

if (function_exists('register_sidebar')) { 
register_sidebar(array(
    'name' => 'Sidebar Widget Area', 
    'id' => 'sidebar-widget-area', 
    'before_widget' => '<div id="%1$s" class="box widget %2$s">', 
    'before_title' => '<div class="wtitle"><h2>', 
    'after_title' => '</h2></div><!--/wtitle --><div class="content">', 
    'after_widget' => '</div><!--/content --></div><!--/box -->',  
)); 
register_sidebar(array(
    'name' => 'Single Sidebar Widget', 
    'id' => 'single-widget-area', 
    'before_widget' => '<div id="%1$s" class="cols %2$s">', 
    'before_title' => '<h2>', 
    'after_title' => '</h2>', 
    'after_widget' => '</div><!--/box -->',  
)); 
register_sidebar(array(
    'name' => 'Post Sidebar Widget', 
    'id' => 'post-widget-area', 
    'before_widget' => '<div class="boxx"><div id="%1$s" class="box   
widget_posts %2$s">', 
    'before_title' => '<div class="wtitle"><h2>', 
    'after_title' => '</h2></div><!--/wtitle --><div class="content">', 
    'after_widget' => '</div><!--/content --></div></div><!--/box -->', 
)); 
register_sidebar(array(
    'name' => 'Widget Ad Manager Small', 
    'id' => 'widget-ad-minister-small', 
    'before_widget' => '<div id="%1$s" class="box ads %2$s">', 
    'before_title' => '<div class="wtitle"><h2>', 
    'after_title' => '</h2></div><!--/wtitle --><div class="content">', 
    'after_widget' => '</div><!--/content --></div><!--/box -->', 
)); 
register_sidebar(array(
    'name' => 'Widget Ad Manager Big', 
    'id' => 'widget-ad-minister-big', 
    'before_widget' => '<div id="%1$s" class="box ads %2$s">', 
    'before_title' => '<div class="wtitle"><h2>', 
    'after_title' => '</h2></div><!--/wtitle --><div class="content">', 
    'after_widget' => '</div><!--/content --></div><!--/box -->', 
)); 
} 

add_action('admin_menu', 'taccess_theme_page'); 

function taccess_theme_page() 
{ 
    if (count($_POST) > 0 && isset($_POST['taccess_settings'])) 
{ 
    $options = array ('feedburner_id', 'advertise_page', 'flickr_group_id'); 

    foreach ($options as $opt) 
    { 
     delete_option ('taccess_'.$opt, $_POST[$opt]); 
     add_option ('taccess_'.$opt, $_POST[$opt]); 
    } 
    wp_redirect("themes.php?page=functions.php&saved=true"); 
    die; 
} 
add_theme_page(__('wpTheme Settings'), __('wpTheme Settings'), 'edit_themes', basename(__FILE__), 'taccess_settings'); 
} 

function taccess_settings() 
{ 

if (isset($_REQUEST['saved'])) echo '<div id="message" class="updated fade"><p>   
<strong>'.__('Options saved.').'</strong></p></div>'; 

echo <<<TT 
<div class="wrap"> 
<h2>wp Theme Settings</h2> 

<form method="post" action=""> 
<table class="form-table"> 
    <tr valign="top"> 
     <th scope="row"><label for="feedburner_id">FeedBurner ID</label>  
</th> 
     <td><input name="feedburner_id" type="text" id="feedburner_id"  
value="<?php echo htmlspecialchars(stripslashes(get_option('taccess_feedburner_id')));  
?>" class="regular-text" /></td> 
    </tr> 
    <tr valign="top"> 
     <th scope="row"><label for="advertise_page">Advertise Page</label> 
</th> 
     <td> 
      <?php  
wp_dropdown_pages("name=advertise_page&show_option_none=".__('- Select -')."&selected=" 

.get_option('taccess_advertise_page')); ?> 
     </td> 
    </tr> 
    <tr valign="top"> 
     <th scope="row"><label for="flickr_group_id">Flickr Group 
ID</label></th> 
     <td> 
      <input name="flickr_group_id" type="text"  
id="flickr_group_id" value="<?php echo  
htmlspecialchars(stripslashes(get_option('taccess_flickr_group_id'))); ?>"  
class="regular-text" /> 
     </td> 
    </tr> 
</table> 
<p class="submit"> 
    <input type="submit" name="Submit" class="button-primary" value="Save 

Changes" /> 
    <input type="hidden" name="taccess_settings" value="save"  

style="display:none;" /> 
</p> 
</form> 

</div> 
TT; 

} 

?> 
<?php 
/** 
* add a default-gravatar to options 
*/ 
if (!function_exists('fb_addgravatar')) { 
function fb_addgravatar($avatar_defaults) { 
    $myavatar = get_bloginfo('template_directory') . '/images/avatar.gif'; 
    $avatar_defaults[$myavatar] = 'people'; 

    $myavatar2 = get_bloginfo('template_directory') . '/images/myavatar.png'; 
    $avatar_defaults[$myavatar2] = 'wpengineer.com'; 

    return $avatar_defaults; 
} 

add_filter('avatar_defaults', 'fb_addgravatar'); 
} 

?> 

回答

0

我已經複製這個代碼的functions.php到測試環境並不能產生同樣的錯誤(唯一的一點是,在啓動時缺少的開始PHP標籤。

作爲一個稍微分開請注意,我想補充你的側邊欄登記到自己的功能與「widgets_init」鉤。像

add_action('widgets_init','register_my_sidebars'); 

東西,你就不會需要測試,如果再register_sidebar存在。This is a good article的話題。