Option saving error with windows while network activated
-
When network activate on windows, when I try to save I get a file not found error because it tried to save to wp-admin/network/options.php.
in common.php–
if (function_exists('is_plugin_active_for_network') && is_plugin_active_for_network(EWWW_IMAGE_OPTIMIZER_PLUGIN_FILE_REL)) { $output[] = "<form method='post' action=''>\n"; } else { $output[] = "<form method='post' action='options.php'>\n"; }is_plugin_active_for_network(EWWW_IMAGE_OPTIMIZER_PLUGIN_FILE_REL) was returning false. Due to–
if ( strtoupper( substr( PHP_OS, 0, 3 ) ) == 'WIN' ) { // this is the path of the plugin file relative to the plugins\ folder define('EWWW_IMAGE_OPTIMIZER_PLUGIN_FILE_REL', 'ewww-image-optimizer\ewww-image-optimizer.php'); // the folder where we install optimization tools define('EWWW_IMAGE_OPTIMIZER_TOOL_PATH', WP_CONTENT_DIR . '\ewww\\'); } else { // this is the path of the plugin file relative to the plugins/ folder define('EWWW_IMAGE_OPTIMIZER_PLUGIN_FILE_REL', 'ewww-image-optimizer/ewww-image-optimizer.php'); // the folder where we install optimization tools define('EWWW_IMAGE_OPTIMIZER_TOOL_PATH', WP_CONTENT_DIR . '/ewww/'); }in ewww-image-optimizer.php. Not sure if it’s because you aren’t escaping all the backslashes or what. I don’t think \e means anything, but regardless, PHP treats / and \ the same on windows so there is no need to differentiate. If I change the above code to:
// this is the path of the plugin file relative to the plugins/ folder define('EWWW_IMAGE_OPTIMIZER_PLUGIN_FILE_REL', 'ewww-image-optimizer/ewww-image-optimizer.php'); // the folder where we install optimization tools define('EWWW_IMAGE_OPTIMIZER_TOOL_PATH', WP_CONTENT_DIR . '/ewww/');(removing the windows conditional) then the options saves correctly.
Reference: http://php.net/manual/en/function.basename.php
On Windows, both slash (/) and backslash (\) are used as directory separator character. In other environments, it is the forward slash (/).
The topic ‘Option saving error with windows while network activated’ is closed to new replies.