0


Warning: require_once(/assets/MCAPI.class.php): failed to open stream: No such file or directory in /home2/....../wp-content/plugins/bplugin/shortcodes.php on line 148

Fatal error: require_once(): Failed opening required '/assets/MCAPI.class.php' (include_path='.:/opt/php54/lib/php') in /......./wp-content/plugins/bplugin/shortcodes.php on line 148

require_once(plugin_dir_path( __FILE__ ) . '/assets/MCAPI.class.php');

Am I not using the correct path method?

This file is called inside a rest API function → https://www.screencast.com/t/5mhWur8hmR

Update: If I transfer file from assets to the plugin directory then things work →

require_once(plugin_dir_path(__FILE__).'MCAPI.class.php');

but that's not the very clean method of handling files.

1

https://developer.wordpress.org/reference/functions/plugin_dir_path/

It looks like this function adds a trailing slash, so starting your string with a slash is not required try;

require_once(plugin_dir_path( __FILE__ ) . 'assets/MCAPI.class.php');
  • I tried the one you suggested, but that generates the error → – The WP Intermediate Oct 9 '17 at 10:33
  • Oh God assets was written as assests – The WP Intermediate Oct 9 '17 at 10:35
  • It was my silly mistake. does this question make any sense? or should I delete the question? – The WP Intermediate Oct 9 '17 at 10:36
  • Lol I think just leave it for that comment. 'assests' – ngearing Oct 9 '17 at 19:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.