Esempio n. 1
0
 public function get_wp_rewrite_rules()
 {
     // make use of WordPress's base, with blog path removed if any
     $base = $this->main->get_wp_base();
     $fly_min_path = $this->main->get_fly_min_path();
     $rules = array();
     $rules[] = 'set $zip_ext "";';
     $rules[] = 'if ($http_accept_encoding ~* gzip) {';
     $rules[] = '    set $zip_ext ".gz";';
     $rules[] = '}';
     $rules[] = 'set $minify_static "";';
     $rules[] = 'if ($http_cache_control = false) {';
     $rules[] = '    set $minify_static "C";';
     $rules[] = '    set $http_cache_control "";';
     $rules[] = '}';
     $rules[] = 'if ($http_cache_control !~* no-cache) {';
     $rules[] = '    set $minify_static "C";';
     $rules[] = '}';
     $rules[] = 'if ($http_if_modified_since = false) {';
     $rules[] = '    set $minify_static "${minify_static}M";';
     $rules[] = '}';
     $rules[] = 'if (-f $request_filename$zip_ext) {';
     $rules[] = '    set $minify_static "${minify_static}E";';
     $rules[] = '}';
     $rules[] = 'if ($minify_static = CME) {';
     $rules[] = '    rewrite (.*) $1$zip_ext break;';
     $rules[] = '}';
     // nginx rewrite rules and location directive do not match query
     // variable so `/path/to/file.js` is the same as `/path/to/file.js?ver=1`
     if (BWP_MINIFY::is_multisite() && !BWP_MINIFY::is_subdomain_install()) {
         // special rewrite rules for sub-directory multisite environment
         $blog_regex = '/[_0-9a-zA-Z-]+';
         $rules[] = 'rewrite ^' . $blog_regex . '(' . $fly_min_path . 'minify-b\\d+-[a-zA-Z0-9-_.]+\\.(css|js))$ $1;';
     }
     $rules[] = 'rewrite ^' . $fly_min_path . 'minify-b(\\d+)-([a-zA-Z0-9-_.]+)\\.(css|js)$ ' . $base . 'index.php?blog=$1&min_group=$2&min_type=$3 last;';
     $rules[] = "\n";
     $rules = $this->get_cache_response_headers() . implode("\n", $rules);
     return $rules;
 }
Esempio n. 2
0
 public function add_wp_rewrite_rules()
 {
     if (!BWP_MINIFY::is_multisite() || BWP_MINIFY::is_subdomain_install()) {
         return true;
     }
     $this->prepare_wp_rewrite_rules();
     // only add these rules if `wp-content` is not already in fly min path
     $fly_min_path = $this->main->get_fly_min_path();
     if (false === strpos($fly_min_path, 'wp-content') && file_exists($this->config_file)) {
         return $this->write_rewrite_rules($this->rules);
     }
 }
Esempio n. 3
0
 public function is_wp_rewrite_rules_needed()
 {
     if (!BWP_MINIFY::is_multisite() || BWP_MINIFY::is_subdomain_install()) {
         return false;
     }
     $fly_min_path = $this->main->get_fly_min_path();
     // only add these rules if `wp-content` is not already in fly min path
     if (false !== strpos($fly_min_path, 'wp-content')) {
         return false;
     }
     return true;
 }