Hi!
I’ve added few customizer controls classes to my App\Controls directory. However, I can’t find out how to use them properly.
In App\Controls I’ve placed class Category_Control which extends \WP_Customize_Control
In app\admin.php inside customize_register hook I’m trying to call Category_Control class.
And there is two scenarios:
-
I’am adding ‘app\controls\category_control’ to functions.php inside sage required files block. Then everything works fine in customizer, however my site is broken - “PHP Fatal error: Class ‘WP_Customize_Control’ not found in”. It happens because “WP_Customize_Control” has to be called from “customize_register” hook only. The moment it tries to add it to whole container it breaks.
-
I’am skipping part with functions.php. Then error is: Uncaught Error: Class ‘App\Controls\Category_Control’ not found in …
How can I properly call my custom classes which I need to use only in specific places rather than inserting it to global container?