/** * Minifies collected scripts */ private function flush_collected() { if (count($this->files_to_minify) <= 0) { return; } // find embed position $embed_pos = $this->embed_pos; if ($this->minify_group_number <= 0 && $this->group_type == 'head') { // try forced embed position $forced_embed_pos = strpos($this->buffer, '<!-- W3TC-include-js-head -->'); if ($forced_embed_pos !== false) { $this->buffer = str_replace('<!-- W3TC-include-js-head -->', '', $this->buffer); $embed_pos = $forced_embed_pos; } } // build minified script tag $urls = $this->minify_helpers->get_minify_urls_for_files($this->files_to_minify, 'js'); $script = ''; if (is_array($urls)) { foreach ($urls as $url) { $script .= $this->minify_helpers->generate_script_tag($url, $this->embed_type); } } // replace $this->buffer = substr_replace($this->buffer, $script, $embed_pos, 0); $this->files_to_minify = array(); $this->minify_group_number++; }