Class ‘FT_WP_Table’ not found

I’m building a WP plugin and I get this error:

Fatal error: Class ‘FT_WP_Table’ not found in
/var/www/html/wp-content/plugins/frequent-traveler/frequent-traveler.php
on line 90

Read More

This is what I did in my code:

add_action('init', 'uploadFileImportCSV');

function uploadFileImportCSV()
{
    $wp_error = true;
    global $wpdb;
    $nonce = isset($_POST['_wpnonce']) ? $_POST['_wpnonce'] : null;

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

        class FT_WP_Table extends WP_List_Table
        {
            .....
        }

    }

}   

Should I get out the class from uploadFileImportCSV() method? Where is my error?

Related posts

Leave a Reply

1 comment

  1. You have to check for WP_List_Table and declare the class at the root of the plugin:

    <?php
    /**
     * Plugin Name: Test
     */
    
    if( is_admin() && !class_exists( 'WP_List_Table' ) )
        require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
    
    class FT_WP_Table extends WP_List_Table
    {
        // etc
    }
    

    Here’s a full example.