2014-02-14 122 views
0

我最近繼承並轉讓了一個包含各種自定義插件的wordpress網站。除了與插件關聯的管理部分中的一個鏈接之外,一切似乎都正常工作。當鏈接被點擊時,頁面應該列出所有的預訂。沒有語法錯誤。WordPress的插件功能錯誤?

我知道這是一個遠射,但我想知道是否有人可以注意到下面的函數處理頁面的任何問題?任何有識之士將不勝感激。

/** 
* List all bookings 
*/ 
function admin_list_bookings($class_id = false, $wrapper=true) { 
    global $ae_EventManager; 
    // View single? 
    if (isset($_GET['view_booking']) && is_numeric($_GET['view_booking'])) { $this->admin_view_booking($_GET['view_booking']); return; } 
    // Delete posts? 
    if (isset($_POST['DeleteLogs']) && !empty($_POST['sel_bookings']) && is_array($_POST['sel_bookings'])) { 
     foreach ($_POST['sel_bookings'] as $delete_id) { 
      wp_delete_post($delete_id, true); 
     } 
     echo '<div class="updated"><p>Selected logs have been deleted.</p></div>'."\n"; 
    } 
    // Load all bookings 
    $booking_log_type = 'private'; 
    if (isset($_GET['logtype'])) $booking_log_type = 'any'; 
    $bookings = get_posts(array(
     'post_type'  => $this->booking_type, 
     'numberposts' => -1, 
     'post_status' => $booking_log_type, 
     'post_parent' => (is_numeric($class_id) ? $class_id : false), 
    )); 

    // Output 
    if ($wrapper) { 
    echo '<div class="wrap">'."\n"; 
    echo '<h2>View Class Bookings</h2>'."\n"; 
    echo '<form class="plugin_settings" method="post" action="'.esc_url($_SERVER['REQUEST_URI']).'">'."\n"; 
    echo wp_nonce_field($this->nonce); 
    } 
    ?> 
    <table class="widefat"> 
     <thead><tr><?php if ($wrapper) { ?><th><input type="checkbox" id="check_all" /></th><?php } ?> 
     <th>Date</th><th>Class</th><th>Name</th><th># Seats</th><th>Booking Cost</th><th>Status</th></tr></thead> 
     <tbody> 
    <?php 
    foreach ($bookings as $booking) { 
     $booking->post_content = $this->__unserialize($booking->post_content); 
     $log = $booking->post_content; 
    //   echo '<pre>'; print_r($booking); echo '</pre>'; 
     $view_link = 'edit.php?post_type='.$ae_EventManager->course_type.'&page&view_booking='.$booking->ID; 
     ?> 
     <tr> 
      <?php if ($wrapper) {  ?> 
      <td class="ctrl"><input type="checkbox" name="sel_bookings[]" value="<?php echo $booking->ID; ?>" /></td> 
      <?php }     ?> 
      <td><a href="<?php echo $view_link; ?>"><?php echo $this->format_time_ago($booking->post_date); ?></a></td> 
      <td><?php echo $log['course_name'].'<br />'.date('d-m-Y H:ia', strtotime($log['class_date'].' '.$log['class_time'])); ?></td> 
      <td><?php echo $log['tickets'][0]['firstname'].' '.$log['tickets'][0]['lastname']; ?></td> 
      <td><?php echo $log['number_seats']; ?></td> 
      <td><?php echo '$'.number_format($log['transaction_total'], 2); ?></td> 
      <td><?php echo $log['payment_method'].'<br />'.$log['eway_response']['ResponseMessage']; ?></td> 
     </tr> 
     <?php 
    } 
    ?> 
+0

的末尾添加結束花括號}這是作爲有無數的可能性在黑暗中拍攝。首先,嘗試開啓[WP Debug](http://codex.wordpress.org/WP_DEBUG)。如果發生這種情況是由於PHP錯誤(我敢打賭這是錯誤的),那麼您將能夠看到發生了什麼情況並修復錯誤。同樣,'admin_menu()'和'admin_enqueue()'對於函數來說太簡單了,可能會拋出'致命錯誤:無法重新聲明admin_menu()[...]'等等。 – mathielo

回答

1

就在admin_list_bookings功能

+1

除非他複製粘貼不正確,否則應該這樣做。 –

+0

對不起,我沒有粘貼錯誤..沒有語法錯誤。 – user1615837