2

我創建了一個畫廊崗位類型(作爲一個插件的一部分),包含除了標題和一些元信息也wp_list_table,查詢那些具有當前崗位作爲post_parent附件。當我的發佈按鈕突然停止工作時,我遇到了一個問題。無論我是否創建一個新的畫廊,或者如果我正在編輯一箇舊的畫廊,一旦我點擊更新/發佈,我的更改就會丟失,最終我會在edit.php
有人知道這是什麼意思?WordPress的自定義文章類型 - 打破發布按鈕

我在哪裏可以找出問題的癥結所在。它在我的list_table類中,它繼承自wp_list_table。在評論出一些不重要的功能後,我最終得到了一個不同的錯誤,但仍然沒有新的或更新的圖庫。現在我得到are you sure you want to do this頁面。

即使是最基本的類將無法正常工作......

if(! class_exists('WP_List_Table')) { 
    require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php'); 
} 

class Yard_Attachment_Table extends WP_List_Table { 
function __construct() { 
    global $status, $page;  
    parent::__construct(array(
     'singular' => 'yard Attachment', 
     'plural' => 'yard Attachments', 
     'ajax'  => false 
    )); 

} 

function column_default($item, $column_name) { 
    return 'default'; 
} 
function get_columns(){ 
    $columns = array(
     'checkbox' => '<input type="checkbox" />', //for simplicity its not 'cb' 
     'thumb'  => 'Thumbnail', 
     'title'  => 'Titel', 
     'pos'  => 'Position' 
    ); 
    return $columns; 
} 
function prepare_items() { 
    global $wpdb; 
    $columns = $this->get_columns(); 
    $hidden = array(); 
    $sortable = $this->get_sortable_columns(); 

    $this->_column_headers = array($columns, $hidden, $sortable); 

    if (isset($_REQUEST['post'])) { 
     $query = " SELECT * 
        FROM $wpdb->posts 
        WHERE post_type = 'attachment' 
        AND post_parent = {$_REQUEST['post']}"; 
     $data = $wpdb->get_results($query, ARRAY_A); 
    } else { 
     $data = array(); 
    } 

    $this->items = $data; 

} 
} 

在插件類的構造函數我用
add_action('add_meta_boxes_yard_gallery', array($this, 'yard_metaboxes'));
yard_metaboxes我使用add_meta_box和功能我有一個回調我創建我的表類的實例new,我打電話prepare_items()display()



轉向使用error_reporting我的網頁上有這些消息去世:

Strict Standards: Only variables should be passed by reference in /Applications/MAMP/htdocs/Web/ChristophRokitta/wp v.1.0/wp-includes/pomo/mo.php on line 210 

Warning: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/Web/ChristophRokitta/wp v.1.0/wp-includes/pomo/mo.php:210) in /Applications/MAMP/htdocs/Web/ChristophRokitta/wp v.1.0/wp-includes/pluggable.php on line 876 

BTW我沒有本地化。
請幫忙!如果我有更多的聲譽,我會提供。

加元框代碼

在我的插件文件:

require_once(plugin_dir_path(__FILE__) . 'class-yard.php'); 
Yard::get_instance(); 
在我的課碼文件

元框的方法是在底部:

class Yard { 
    protected static $instance = null; 
    private function __construct() { 
     include_once('class-yard-attachments.php'); 

     add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_styles')); 

     add_action('after_setup_theme', array($this, 'yard_thumbnails')); 

     add_action('init', array($this, 'yard_post_type')); 
     add_action('init', array($this, 'yard_taxonomies')); 
     add_filter('manage_yard_gallery_posts_columns', array($this, 'yard_add_columns')); 
     add_action('manage_posts_custom_column', array($this, 'yard_fill_columns')); 
     add_action('add_meta_boxes_yard_gallery', array($this, 'yard_metaboxes')); 
    } 

    public static function get_instance() {// If the single instance hasn't been set, set it now. 
     if (null == self::$instance) { 
      self::$instance = new self; 
     } 
     return self::$instance; 
    } 

    public function enqueue_admin_styles() { 
     $screen = get_current_screen(); 
     if ($screen->post_type == 'yard_gallery') { 
      wp_register_style('yard-gallery-style', plugins_url('css/yard-gallery-style.css', __FILE__)); 
      wp_enqueue_style('yard-gallery-style'); 
     } 
    } 

    public function yard_thumbnails() { 
     //add_image_size('yard-thumbnail', 100, 100, true); 
    } 

    public function yard_post_type() { 
     $gallery_labels = array(
      'name' => 'Galerien', 
      'singular_name' => 'Galerie', 
      'all_items' => 'Alle Galerien', 
      'add_new' => 'Erstellen', 
      'add_new_item' => 'Neue Galerie erstellen', 
      'edit_item' => 'Galerie bearbeiten', 
      'new_item' => 'Neue Galerie', 
      'view' => 'Galerie anzeigen', 
      'view_item' => 'Gallerie anzeigen', 
      'search_items' => 'Galerie durchsuchen', 
      'not_found' => 'Keine Galerien gefunden', 
      'not_found_in_trash' => 'Es befinden sich keine Galerien im Papierkorb', 
      'parent_item_colon' => '' 
     ); 
     $gallery_args = array(
      'labels' => $gallery_labels, 
      'public' => true, 
      // 'publicly_queryable' => true, 
      // 'show_ui' => true, 
      // 'show_in_menu' => true, 
      // 'query_var' => true, 
      'rewrite' => true, 
      // 'capability_type' => 'post', 
      // 'hierarchical' => false, 
      'menu_position' => 12, 
      'supports' => array(
       'title' 
      ) 
      // 'menu_icon' => plugin_dir_url(__FILE__) . '/assets/icon_16_grey.png'//16x16 png if you want an icon 
     ); 
     register_post_type('yard_gallery', $gallery_args); 
    } 

    public function yard_taxonomies() { 
     register_taxonomy(
      'yard_work_type', 
      'yard_gallery', 
      array(
       'hierarchical' => true, 
       'label' => 'Art der Arbeit' 
      ) 
     ); 
     register_taxonomy(
      'yard_subject', 
      'yard_gallery', 
      array(
       'hierarchical' => true, 
       'label' => 'Motiv' 
      ) 
     ); 
    } 

    public function yard_add_columns($columns){ 
     $columns = array(
      'cb' => '<input type="checkbox">', 
      'yard_post_thumb' => 'Thumbnail', 
      'title' => 'Bezeichnung', 
      'yard_pos' => 'Position', 
      'date' => 'Datum' 
     ); 
     return $columns; 
    } 
    public function yard_fill_columns($column) { 
     global $post; 
     switch ($column) { 
      case 'yard_post_thumb' : 
       echo the_post_thumbnail('admin-list-thumb'); 
       break; 
     } 
    } 

    public function yard_metaboxes($post) { 
     global $wp_meta_boxes; 

     add_meta_box(
      'yard-attachments', 
      'Bilder', 
      array($this, 'get_yard_attachment_table'), 
      'yard_gallery' 
     ); 
    } 
    public function get_yard_attachment_table() { 
     $yard_list_table = new Yard_Attachment_Table(); 
     $yard_list_table->prepare_items(); 

     $yard_list_table->display(); 
    } 
} 
+1

您的問題出在您的Meta Box代碼中,但是您顯示的Table類代碼似乎與發佈操作無關...... – brasofilo

+0

@brasofilo幾乎是整個代碼。我希望你能找到一分鐘來看看 – yardarrat

+0

有點不可告人,因爲你發佈的代碼不是[SSCCE](http://sscce.org/)。檢查[this](https://github.com/brasofilo/Internal-Link-Check)以獲得擴展'WP_List_Table'並將其用作元框回調的示例。 – brasofilo

回答

0

嚴格的標準:只應在/ Applications/MAMP/htdocs/Web/Christoph中通過引用傳遞變量Rokitta/WP V.1.0 /可溼性粉劑包含/波莫/上線210

mo.php錯誤消息告訴它所有。 「.../popo/mo.php」文件與Wordpress翻譯有關(涉及)。 (我敢打賭你使用德語語言文件的Wordpress)。

我看不出您在此處發佈的代碼中可能出現了什麼問題,但有些內容會干擾翻譯。看看錯誤消息告訴我們什麼,Wordpress嘗試翻譯的一些變量由於不是正確的類型而無法翻譯。

警告:不能更改頭信息 - 頭已經發出(輸出開始/應用程序/ MAMP/htdocs中/網絡/ ChristophRokitta/WP V.1.0 /可溼性粉劑包含/潑墨/ mo.php:210)在/ Applications/MAMP/htdocs/Web/ChristophRokitta/wp v.1.0/wp-includes/pluggable。php on line 876

這是以前的錯誤信息和Wordpress試圖發送給瀏覽器的標題的邏輯結果。

發生了什麼:第一個錯誤消息被推送到客戶端並刷新到瀏覽器屏幕。接下來,Wordpress會嘗試發送正常的標題,並在執行時產生錯誤,因爲標題必須在ANY內容發送到客戶端之前發送。

換句話說:當您屏幕回顯某些內容並嘗試發送「header(...)」信息時,總是會出現「Can not modify header information」錯誤。在這種情況下,翻譯問題會產生第一條錯誤消息,然後Wordpress會嘗試發送標題,這會失敗並生成第二條錯誤消息。

TIPS

    你做的這是關係到翻譯
  • 檢查一切(讀:無論你是路過 「德國」 和/或 「英語」 語言的字符串)

和更重要

  • 請確保您確實傳遞了正確的類型 ...看着錯誤和你的代碼,它可能是你正在傳遞一個類,一個類的引用,或另一個對象而不是預期的變量。
相關問題