• I have installed my theme on server but I get class Fatal error: Class ‘XYZ’ not found in ‘PQR.php’ file at line 2 when clicked on the Menupage ( I have named it ‘Addinfo’) which was added by using add_menu_page() function.

    Other information:

    I have a list table in the ‘Addinfo’ which is done by extending file in my project which has WP_List_Table(class is renamed in my file.)

    I have added below lines in wp-config.php hence i get to see the above mentioned error in dashboard when clicked on ‘Addinfo’.


    ini_set('log_errors',TRUE);
    ini_set('error_reporting', E_ALL);
    ini_set('error_log', dirname(__FILE__) . '/error_log.txt');

    If I remove these lines then I get 500 inernal error and it says ‘ There is a problem with the resource you are looking for, and it cannot be displayed.’

    My server runs php version 5.4.45 version . local has 5.5.15
    Wordpress on server is 4.3.1 and local it is 4.3

    I used require_once to include the files whereever required in my project.

    It seems like I have added my classes and files correctly to extend the classes but still the class is not found. Does the sequence matter while using require_once?

    Can anyone help me with this or give me a clue?

    Sorry..I m pretty new to wordpress and php stuff.. Help appreciated!.

Viewing 1 replies (of 1 total)
  • Moderator Marius L. J.

    (@clorith)

    Hi,

    The sequence matters, since you can’t extend a class that doesn’t exist yet.

    You also need to manually include the WP_List_Table class file (it’s not added to the pages automatically), I don’t know your code, so I’m guessing this is what’s causing the error for you.

    At the start of my table-controller.php file I use this:

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

    Which is how I pull in the class it self and after this I have my class extender.

    If this isn’t what your error is relating too, please pastebin your code so we can have a look, and pleas use the actual error message without replacing names with ‘XYZ’ and such 🙂

Viewing 1 replies (of 1 total)

The topic ‘Fatal error: Class not found’ is closed to new replies.