get_stylesheet_directory_uri()
returns an URL. The requested file is called like any other publicly available resource: without the context of the include
statement. This is like opening the PHP file in a browser directly. There is no WordPress context, and the functions add_action()
or add_filter()
are not defined.
Use get_template_directory()
in parent themes and get_stylesheet_directory()
in child themes.
Disable allow_url_fopen
and allow_url_include
in your development environment to catch errors like this early and with better error messages.