Call to undefined function convert_to_screen()

I am developing a plugin where i did have to extend the class WP_List_Table. I have extended the class within my plugin-file (I don't know if this is the right way to do this?) and included WP_List_Table like this:

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

Then comes the code for extending the class and then I do create an instance of my table class like this:

<?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'    => 'vasim@abc.com'                        
                ),
                array(
                        'id'        => 2,
                        'user_login'     => 'Asma',
                        'user_email'    => 'Asma@abc.com'                        
                ),
                array(
                        'id'        => 3,
                        'user_login'     => 'Nehal',
                        'user_email'    => 'nehal@abc.com'                        
                ),
            );

        $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();

But when i do this, i do get this error:

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

I did some research but did not understand how to fix it.

Does anybody knows how to fix this?

Thanks for your help!

Best regards.

php - Call to undefined function convert_to_screen(), I solved the problem using the code below: public function __construct() { add_action( 'wp', [$this,'after_load_wordpress'] ); } function  Fatal error: Call to undefined function the_archive_title () 0 Fatal error: Uncaught Error: Call to undefined function do_action_ref_array() when using wp_signon function

I had a working prototype of a class very similar to yours. I decided to conform to the WordPress best practices structure for my plugin, so I downloaded one of the suggested boilerplates and began adapting my code to the boilerplate class based structure. When I did, I ran into the same problem as you. Since I had a working example that created the admin page extended from WP_List_Table inside a class, I knew the issue wasn't adding the menu page inside the class. The issue is that the constructor

Class Wp_Ban_User extends WP_List_Table {

public function __construct()
{
         add_action('admin_menu',array($this,'WBU_adminMenu'));
         parent::__construct( array(...

is being called be before WordPress has finished initializing. I did some digging to find out what the initialization sequence is and came across this WordPress action_hook sequence list. I tried creating my equivalent to your Wp_Ban_User class using the wp_loaded action hook {This hook is fired once WP, all plugins, and the theme are fully loaded and instantiated.}, but it still crashed. A little further in the sequence is the wp action hook {Fires once the WordPress environment has been set up} and I thought it worked because my plugin didn't crash. But wp isn't a real action hook, so that meant my classes weren't being initialized.

So, my simple code change

function run_admin_page_init() {
    $myAdminPage = new Wp_Ban_User();
}
add_action( 'wp', 'run_admin_page_init' );

rather than having to hack up my class looked promising, but was a red herring.

Still confident that the problem is a sequencing issue during initialization, I finally tracked it down to the following fix (which actually worked). In the class that added my admin menu entry I had:

function __construct() {
    $this->pageTable = new WBU_adminMenu();
    add_action( 'admin_menu', [ $this, 'addAdminMenu' ] );
}
/**
 * Adds the Manage Mailing List label to the WordPress Admin Sidebar Menu
 */
public function addAdminMenu() {
    $hook = add_menu_page(
        'Page Title',
        'Menu Name',
        'manage_options',
        'menu_slug',
        [ $this, 'adminLayout' ] );

    add_action( "load-$hook", [ $this, 'screen_option' ] );
}

but I changed it to:

function __construct() {
    add_action( 'admin_menu', [ $this, 'addAdminMenu' ] );
}

/**
 * Adds the Manage Mailing List label to the WordPress Admin Sidebar Menu
 */
public function addAdminMenu() {
    $this->pageTable = new WBU_adminMenu();
    $hook = add_menu_page(
        'Page Title',
    ...

which deferred creating the child class of WP_LIST_TABLE until after the basic admin panel menu structure is in place.

I'm sure you've moved on to bigger and better projects and the hair you pulled out in frustration trying to track this down mystery has grown back in the two years that have elapsed since you cast your question into the community, but I posted my solution just in case someone else runs into the problem.

Fatal error: Uncaught Error: Call to undefined function , Fatal error: Call to undefined function convert_to_screen() in C:\Home\Projects\​htdocs\wp-admin\includes\template.php on line 854. Looking at this line, it is  Fatal error: Call to undefined function convert_to_screen() in C:\Home\Projects\htdocs\wp-admin\includes\template.php on line 854 Looking at this line, it is trying to call the function convert_to_screen to convert the name of the screen that meta box should be displayed on, since it is passed as one of

I have checked your code with my fresh wordpress using this link i think it solved your problem please check this link I want a pagination to my options page of wordpress plugin?

Let me know if you have any confusion.

#19342 (Call to undefined function convert_to_screen when using , Call to undefined function convert_to_screen(). Posted by: admin November 28, 2017 Leave a comment. Questions: I am developing a plugin where i did have  Hi @chrisipeters. This line should only be run if a user query is made, in administration and if it’s not an ajax request. So this is really weird. Can you share the plugin you activated on your site that are dealing with users ?

convert_to_screen() | Function, i do get this error: Fatal error: Call to undefined function convert_to_screen() in D:\xampp\htdocs\developplugin\wp-admin\includes\class-wp-list-table.php on  PHP Fatal error: Uncaught Error: Call to undefined function mysql_connect() This is because mysql_* functions are completely removed from PHP 7, it was get deprecated in PHP 5.5 but now it is completely removed. Not work on Object Oriented concept. Wont support transactions and prepared statements.

Call to undefined function convert_to_screen(), Error message: Fatal error: Uncaught Error: Call to undefined function convert_to_screen() /wp-admin/includes/class-wp-list-table.php:149. Fatal error: Call to undefined function curl_init() Essentially, PHP can’t find the curl_init function because the extension that defines it has not been loaded. This results in a fatal error, which kills the PHP script.

Call to undefined function convert_to_screen(), Call to undefined function convert_to_screen() (WordPress). i am developing a plugin where i did have to extend the class WP_List_Table . Call to undefined function oci_connect() Here is what I have tried: - uncommented "extension=php_oci8_11g.dl l" and restarted XAMPP server. - listed "C:\app\Administrator\prod uct\11.2.0 \client_1\ bin" first in my environment variables and restarted server. - made sure php_oci8_11g.dll existed in C:\xampp\php\ext. - oci8 is not listed in my

Comments
  • try to remove add_action('admin_menu',array($this,'WBU_adminMenu')); from constructor
  • Your class is being instantiated before Wordpress has loaded the necessary libraries.
  • @ShravanShrama Removed still same error
  • @Devon Where should I change?
  • @ShravanShrama If I remove that how can I access page?
  • Thank you, you've saved me a tonne of time.