$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>filesystem - Failed opening required|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

filesystem - Failed opening required

matteradmin11PV0评论

I am new in wordpress development. Tried include a selfwritten php-file into htdocs/wp-content/plugins/abc/abc.php

IDE sugesting me to use: require_once '../WPNonce/WPNonce.php';

but WordPress contradicts when opening in webbrowser:

Fatal error: require_once(): Failed opening required '../WPNonce/WPNonce.php'

How could i include this php-file (its a class inside)?

I am new in wordpress development. Tried include a selfwritten php-file into htdocs/wp-content/plugins/abc/abc.php

IDE sugesting me to use: require_once '../WPNonce/WPNonce.php';

but WordPress contradicts when opening in webbrowser:

Fatal error: require_once(): Failed opening required '../WPNonce/WPNonce.php'

How could i include this php-file (its a class inside)?

Share Improve this question asked Mar 3, 2019 at 19:02 SL5netSL5net 1054 bronze badges 2
  • Is the file you want to include part of your plugin? – Qaisar Feroz Commented Mar 3, 2019 at 20:36
  • Later i want to be able to use it in all plugins. right now it is in the plugin folder. imgur/tif3vOv – SL5net Commented Mar 3, 2019 at 22:30
Add a comment  | 

1 Answer 1

Reset to default 1

WordPress includes many functions for determining paths and URLs to files or directories within plugins, themes, and WordPress itself.

 $plugin_dir = plugin_dir_path( __DIR__ ); // wp-content/plugins/
 require_once($plugin_dir.'WPNonce/WPNonce.php'); 

While using plugin_dir_path(), keep in mind that the “plugin” part of the name is misleading – it can be used for any file, and will not return the directory of a plugin unless you call it within a file in the plugin’s base directory.

or alternatively, you can also use WordPress constant WP_PLUGIN_DIR

 require_once(WP_PLUGIN_DIR.'/WPNonce/WPNonce.php'); 

I hope this helps.

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far