Warning: include(C:somepathpluginsreactpress/templates/react-page-template.php): failed to open stream: No such file or directory in C:\some\path\wp-includes\template-loader.php on line 106
Warning: include(): Failed opening ‘C:somepathpluginsreactpress/templates/react-page-template.php’ for inclusion (include_path=’someotherpath\PEAR’) in C:\some\path\wp-includes\template-loader.php on line 106
Q: Why does this happen?
A: The Windows environment uses \ for directory separators. While normally this is represented internally in strings as \\, it is very likely that if these are present, at some point WordPress or ReactPress will print or otherwise resolve its value, causing it to act as an escape character in future strings.
What is the code?
Templates loaded in reactpress/admin/Admin.php from line 188:
public function repr_add_page_template($templates) {
$templates[REPR_PLUGIN_PATH . 'templates/empty-react-page-template.php'] = __('ReactPress Canvas', 'text-domain');
$templates[REPR_PLUGIN_PATH . 'templates/react-page-template.php'] = __('ReactPress Full Width', 'text-domain');
return $templates;
}
REPR_PLUGIN_PATH defined in reactpress/reactpress.php from line 58:
This definition resolves to "C:\\some\\path\\plugins\\reactpress/".
It should be noted that other defined PATHs and URLs in reactpress.php do make a distinction between Windows vs. standard separators, as seen on the line directly above the REPR_PLUGIN_PATH definition (shown below):
I have tested this on my machine to verify that it works. This should not cause any issues with non-Windows environments and will improve compatibility for Windows users.
I sincerely hope you make this adjustment, as I have spent nearly 3 hours debugging this for what ended up being a simple fix that you, being intimately familiar with the code, may have been able to catch within minutes.
SOLVES:
Q: Why does this happen? A: The Windows environment uses
\
for directory separators. While normally this is represented internally in strings as\\
, it is very likely that if these are present, at some point WordPress or ReactPress will print or otherwise resolve its value, causing it to act as an escape character in future strings.What is the code?
Templates loaded in
reactpress/admin/Admin.php
from line 188:REPR_PLUGIN_PATH
defined inreactpress/reactpress.php
from line 58:This definition resolves to
"C:\\some\\path\\plugins\\reactpress/"
.It should be noted that other defined PATHs and URLs in
reactpress.php
do make a distinction between Windows vs. standard separators, as seen on the line directly above theREPR_PLUGIN_PATH
definition (shown below):RECOMMENDATION:
Rewrite the
REPR_PLUGIN_PATH
definition to:I have tested this on my machine to verify that it works. This should not cause any issues with non-Windows environments and will improve compatibility for Windows users.
I sincerely hope you make this adjustment, as I have spent nearly 3 hours debugging this for what ended up being a simple fix that you, being intimately familiar with the code, may have been able to catch within minutes.