опубликовать Я создал тип галереи поста (как часть плагина), который содержит, кроме названия и некоторых метаинформаций также 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();
}
}
Ваша проблема кроется в коде Meta Box, но вы показываете код класса таблицы, который, похоже, не имеет ничего общего с действием публикации ... – brasofilo
@brasofilo - это почти весь код. Надеюсь, вы сможете найти минуту, чтобы посмотреть его. – yardarrat
Невозможно сказать, поскольку код, который вы опубликовали, не является [SSCCE] (http://sscce.org/). Проверьте [this] (https://github.com/brasofilo/Internal-Link-Check) для рабочего примера расширения 'WP_List_Table' и используйте его как обратный вызов мета-окна. – brasofilo