• Resolved SpinoWeb

    (@spinoweb)


    Hello,

    I’d want to use a custom php class to control my custom type endpoint in rest api.

    I add php class here, but it does not work:

    function cptui_load_ui_class() {
    	require_once plugin_dir_path( __FILE__ ) . 'classes/class.cptui_admin_ui.php';
    	require_once plugin_dir_path( __FILE__ ) . 'classes/class.cptui_debug_info.php';
    
    	require_once plugin_dir_path( __FILE__ ) . 'classes/class.cptui_rest_controller.php';
    }
    add_action( 'init', 'cptui_load_ui_class' );

    Do I have to put php class in another folder?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Folder location shouldn’t really matter as long as it’s loaded by the time you’re needing to invoke it, so that the class is available to use.

    Also, you shouldn’t be editing our custom-post-type-ui.php file for this, it’d be better off in your active theme’s functions.php file or somewhere else similar.

    Thread Starter SpinoWeb

    (@spinoweb)

    Thank You!

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Did you get this working finally? or are you still struggling with the initial issue?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘REST API controller class’ is closed to new replies.