나는 WP_List_Table 클래스를 확장해야하는 곳에서 플러그인을 개발 중입니다.정의되지 않은 함수를 호출하십시오. convert_to_screen()
if(!class_exists('WP_List_Table')){
require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php');
}
그런 다음 다음 클래스를 확장하고 대한 코드를 제공 : 내 플러그인 파일 내에서 클래스를 확장 한 (? I는이 작업을 수행하는 올바른 방법 인 경우 모르는)와 같은 WP_List_Table 포함 이 같은 내 테이블 클래스의 인스턴스 생성을 수행
<?php
if (! class_exists('WP_List_Table')) {
require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php');
}
Class Wp_Ban_User extends WP_List_Table
{
public function __construct()
{
add_action('admin_menu',array($this,'WBU_adminMenu'));
parent::__construct(array(
'singular'=> 'wp_list_text_link', //Singular label
'plural' => 'wp_list_test_links', //plural label, also this well be one of the table css class
'ajax' => false //We won't support Ajax for this table
));
$this->prepare_items();
$this->display();
}
function get_columns() {
$columns = array(
'id' => 'ID',
'user_login' => 'User Name',
'user_email' => 'User Email'
);
return $columns;
}
function column_default($item, $column_name) {
switch($column_name) {
case 'id':
case 'user_login':
case 'user_email':
return $item[ $column_name ];
default:
return print_r($item, true) ;
}
}
function prepare_items() {
$example_data = array(
array(
'id' => 1,
'user_login' => 'vasim',
'user_email' => '[email protected]'
),
array(
'id' => 2,
'user_login' => 'Asma',
'user_email' => '[email protected]'
),
array(
'id' => 3,
'user_login' => 'Nehal',
'user_email' => '[email protected]'
),
);
$columns = $this->get_columns();
$hidden = array();
$sortable = $this->get_sortable_columns();
$this->_column_headers = array($columns, $hidden, $sortable);
$this->items = $example_data;
}
public function WBU_adminMenu()
{
add_menu_page('Currently Logged In User', 'Banned User', 'manage_options', 'ban_admin_init', array($this,'ban_admin_init'));
}
function ban_admin_init(){
global $wpdb;
$sql="SELECT * from {$wpdb->prefix}users";
$sql_result=$wpdb->get_results($sql,'ARRAY_A');
print_r($sql_result);
//$this->items=$sql_result;
}
}
global $Obj_Wp_Ban_User;
$Obj_Wp_Ban_User=new Wp_Ban_User();
을하지만 난이 작업을 수행 할 때이 오류받을 수 있나요 :
Fatal error: Call to undefined function convert_to_screen() in D:\xampp\htdocs\developplugin\wp-admin\includes\class-wp-list-table.php on line 143
나는 몇 가지 조사를했지만 그것을 해결하는 방법을 이해하지 못했다을 .
아무도이 문제를 해결하는 방법을 알고 있습니까?
도움 주셔서 감사합니다.
감사합니다.
'add_action ('admin_menu', array ($ this, 'WBU_adminMenu'))'from 생성자 –
Wordpress에서 필요한 라이브러리를로드하기 전에 클래스가 인스턴스화 중입니다. – Devon
@ShravanShrama 여전히 동일한 오류가 제거되었습니다. –