/** * Test minifier action * * @return void */ function action_test_minifier() { w3_require_once(W3TC_LIB_W3_DIR . '/Request.php'); $engine = W3_Request::get_string('engine'); $path_java = W3_Request::get_string('path_java'); $path_jar = W3_Request::get_string('path_jar'); $result = false; $error = ''; if (!$path_java) { $error = __('Empty JAVA executable path.', 'w3-total-cache'); } elseif (!$path_jar) { $error = __('Empty JAR file path.', 'w3-total-cache'); } else { switch ($engine) { case 'yuijs': w3_require_once(W3TC_LIB_MINIFY_DIR . '/Minify/YUICompressor.php'); Minify_YUICompressor::setPathJava($path_java); Minify_YUICompressor::setPathJar($path_jar); $result = Minify_YUICompressor::testJs($error); break; case 'yuicss': w3_require_once(W3TC_LIB_MINIFY_DIR . '/Minify/YUICompressor.php'); Minify_YUICompressor::setPathJava($path_java); Minify_YUICompressor::setPathJar($path_jar); $result = Minify_YUICompressor::testCss($error); break; case 'ccjs': w3_require_once(W3TC_LIB_MINIFY_DIR . '/Minify/ClosureCompiler.php'); Minify_ClosureCompiler::setPathJava($path_java); Minify_ClosureCompiler::setPathJar($path_jar); $result = Minify_ClosureCompiler::test($error); break; default: $error = __('Invalid engine.', 'w3-total-cache'); break; } } $response = array('result' => $result, 'error' => $error); echo json_encode($response); }
/** * Test minifier action * * @return void */ function w3tc_test_minifier() { $engine = Util_Request::get_string('engine'); $path_java = Util_Request::get_string('path_java'); $path_jar = Util_Request::get_string('path_jar'); $result = false; $error = ''; if ($engine != 'googleccjs') { if (!$path_java) { $error = __('Empty JAVA executable path.', 'w3-total-cache'); } elseif (!$path_jar) { $error = __('Empty JAR file path.', 'w3-total-cache'); } } if (empty($error)) { switch ($engine) { case 'yuijs': Minify_YUICompressor::$tempDir = Util_File::create_tmp_dir(); Minify_YUICompressor::$javaExecutable = $path_java; Minify_YUICompressor::$jarFile = $path_jar; $result = Minify_YUICompressor::testJs($error); break; case 'yuicss': Minify_YUICompressor::$tempDir = Util_File::create_tmp_dir(); Minify_YUICompressor::$javaExecutable = $path_java; Minify_YUICompressor::$jarFile = $path_jar; $result = Minify_YUICompressor::testCss($error); break; case 'ccjs': Minify_ClosureCompiler::$tempDir = Util_File::create_tmp_dir(); Minify_ClosureCompiler::$javaExecutable = $path_java; Minify_ClosureCompiler::$jarFile = $path_jar; $result = Minify_ClosureCompiler::test($error); break; case 'googleccjs': $result = Minify_JS_ClosureCompiler::test($error); break; default: $error = __('Invalid engine.', 'w3-total-cache'); break; } } $response = array('result' => $result, 'error' => $error); echo json_encode($response); }