function print_script() { ?> <script type="text/javascript"> function w3tc_start_minify_try_solve() { var testUrl = '<?php echo w3_filename_to_url(w3_cache_blog_dir('minify') . '/'); ?> '; w3tc_filename_auto_solve(testUrl); } </script> <?php }
/** * Formats custom URL * * @param array $files * @param string $type * @return array */ function get_minify_urls_for_files($files, $type) { $w3_minify = w3_instance('W3_Minify'); $url = array(); $minify_filenames = $w3_minify->compress_minify_files($files, $type); foreach ($minify_filenames as $minify_filename) { $filename = w3_cache_blog_dir('minify') . '/' . $minify_filename; if ($this->_config->get_boolean('minify.rewrite')) { $url[] = w3_filename_to_url($filename); } else { $url[] = plugins_url('pub/minify.php?file=' . $minify_filename, W3TC_FILE); } } return $url; }
private function verify_rewrite_working() { $url = w3_filename_to_url(w3_cache_blog_dir('minify') . '/w3tc_rewrite_test'); if (!$this->test_rewrite($url)) { $key = sprintf('w3tc_rewrite_test_result_%s', substr(md5($url), 0, 16)); $result = get_transient($key); $home_url = w3_get_home_url(); $tech_message = (w3_is_nginx() ? 'nginx configuration file' : '.htaccess file') . ' contains rules to rewrite url ' . $url . '. If handled by ' . 'plugin, it returns "OK" message.<br/>'; $tech_message .= 'The plugin made a request to ' . $url . ' but received: <br />' . $result . '<br />'; $tech_message .= 'instead of "OK" response. <br />'; $error = '<strong>W3 Total Cache error:</strong>It appears Minify ' . '<acronym title="Uniform Resource Locator">URL</acronym> ' . 'rewriting is not working. '; if (w3_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 .= '<br />Unfortunately minification will ' . 'not function without custom rewrite rules. ' . 'Please ask your server administrator for assistance. ' . 'Also refer to <a href="' . admin_url('admin.php?page=w3tc_install') . '">the install page</a> for the rules for your server.'; throw new SelfTestFailedException($error, $tech_message); } }
function print_script() { ?> <script type="text/javascript"> var w3_use_network_link = <?php echo w3_force_master() ? 'true' : 'false'; ?> ; function w3tc_start_minify_try_solve() { var testUrl = '<?php echo w3_filename_to_url(w3_cache_blog_dir('minify') . '/'); ?> '; w3tc_filename_auto_solve(testUrl); } </script> <?php }
/** * Gets regexp for minified files * * @return string */ function _minify_url_regexp($filename_mask) { $minify_base_url = w3_filename_to_url(w3_cache_blog_dir('minify')); $matches = null; if (!preg_match('~((https?://)?([^/]+))(.+)~i', $minify_base_url, $matches)) { return ''; } $protocol_domain_regexp = w3_get_url_regexp($matches[1]); $path_regexp = w3_preg_quote($matches[4]); $regexp = '(' . '(' . $protocol_domain_regexp . ')?' . '(' . $path_regexp . $filename_mask . ')' . ')'; return $regexp; }
function print_script() { ?> <script type="text/javascript"> var w3_use_network_link = <?php echo is_network_admin() || w3_is_multisite() && w3_force_master() ? 'true' : 'false'; ?> ; function w3tc_start_minify_try_solve() { var testUrl = '<?php echo w3_filename_to_url(w3_cache_blog_dir('minify') . '/', w3_get_domain(w3_get_home_url()) != w3_get_domain(w3_get_site_url())); ?> '; w3tc_filename_auto_solve(testUrl); } </script> <?php }
/** * Perform minify rules rewrite test * * @return bool */ function test_rewrite_minify() { $url = w3_filename_to_url(w3_cache_blog_dir('minify') . '/w3tc_rewrite_test'); return $this->test_rewrite($url); }