Stupid is probably a question, but where can I connect my class in wordpress so that I can use it in the theme and plugin? I tried to connect from the plugin to the theme via require_once but it doesn’t work for some reason, and copying the class to the plugin and the theme is completely silly

    1 answer 1

    Since the plugins are initialized before the theme, it is necessary to declare such a class in the plugin. In the subject you can simply use it. For example, many themes work with WooCommerce classes.

    So that when a plugin is disabled, the site does not fall when accessing a class from a topic, you should check its presence in the topic with class_exists()