This message will automatically disappear once the issue is resolved.'; $exs->push( new Util_Environment_Exception( $minify_error ) ); } } /** * Verifies that URL rewriting functionality for Minify is working. * * @return void * * @throws \Util_Environment_Exception If URL rewriting fails. */ private function verify_rewrite_working() { $url = Minify_Core::minified_url( wp_rand() . 'w3tc_rewrite_test.css' ); $result = $this->test_rewrite( $url ); if ( 'ok' !== $result ) { $home_url = get_home_url(); $tech_message = ( Util_Environment::is_nginx() ? 'nginx configuration file' : '.htaccess file' ) . ' contains rules to rewrite url ' . $url . '. If handled by plugin, it returns "Minify OK"' . ' message.The plugin made a request to ' . $url . ' but received: ' . $result . 'instead of "Minify OK" response. '; $error = 'W3 Total Cache error:It appears Minify ' . 'URL rewriting is not working. '; if ( Util_Environment::is_nginx() ) { $error .= 'Please verify that all configuration files are included in the configuration file ' . '(and that you have reloaded / restarted nginx).'; } else { $error .= 'Please verify that the server configuration allows .htaccess'; } $error .= 'Unfortunately minification will not function without custom rewrite rules. ' . 'Please ask your server administrator for assistance. Also refer to the install page for the rules for your server.'; throw new Util_Environment_Exception( esc_html( $error ), esc_html( $tech_message ) ); } } /** * Tests the rewrite rules by sending a request to a test Minify URL. * * @param string $url The URL to test for rewriting functionality. * * @return string 'ok' if successful, or an error message otherwise. */ private function test_rewrite( $url ) { $key = sprintf( 'w3tc_rewrite_test_%s', substr( md5( $url ), 0, 16 ) ); $result = get_site_transient( $key ); if ( 'ok' !== $result ) { $response = Util_Http::get( $url ); $is_ok = ( ! is_wp_error( $response ) && 200 === $response['response']['code'] && 'Minify OK' === trim( $response['body'] ) ); if ( $is_ok ) { $result = 'ok'; } elseif ( is_wp_error( $response ) ) { $result = $response->get_error_message(); } else { $result = '
' . print_r( $response['response'], true ) . '