• Resolved Matt

    (@syntax53)


    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 (/).

    https://wordpress.org/plugins/ewww-image-optimizer/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author nosilver4u

    (@nosilver4u)

    Unfortunately, other problems arise when we use forward slashes on Windows, so I’ll have to come up with a better fix for those.

    Plugin Author nosilver4u

    (@nosilver4u)

    Try this out: https://downloads.wordpress.org/plugin/ewww-image-optimizer.zip

    And if you have a non-production site you can test it on, would you mind installing Nextgen and activating it, just to make sure it doesn’t break something again? I don’t have a dev site on Windows readily accessible.

    Plugin Author nosilver4u

    (@nosilver4u)

    Nevermind, the nextgen stuff, I found I had done it better in another function, so I’ve reverted the EWWW_IMAGE_OPTIMIZER_PLUGIN_FILE_REL constant, and I’m using a built in WordPress constant for the plugins/ folder.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Option saving error with windows while network activated’ is closed to new replies.