/**
  * Writes rewrite rules to server config file when needed
  *
  * This function is called whenever friendly minify url feature is enabled,
  * and based on current server certain actions are taken accordingly.
  *
  * @since 1.3.0
  * @return void
  */
 private function _toggle_rewrite_rules(&$options)
 {
     // do not suppress error
     $this->rewriter->no_suppress();
     // try to add required rewrite rules to wp's main .htaccess file
     $result = $this->rewriter->add_wp_rewrite_rules();
     // could not write rewrite rules to wp's main .htaccess file
     if (true !== $result && 'written' !== $result) {
         $config_file = $this->rewriter->get_wp_config_file();
         $error = $this->_get_rewrite_rules_error($result, $config_file);
         $this->add_error($error);
         /* $form['container']['h1'][] = $this->_show_generated_wp_rewrite_rules(); */
     }
     // asumming apache, need to add rules to cache directory too
     if (false == self::is_nginx()) {
         $result = $this->rewriter->add_cache_rewrite_rules();
         $config_file = $this->rewriter->get_cache_config_file();
         if (true !== $result && 'written' !== $result) {
             // get appropriate error messages and show it to admin
             $error = $this->_get_rewrite_rules_error($result, $config_file);
             $this->add_error($error);
             // in any case rewrite rules were NOT successfully written,
             // except for when rewrite rules are already found,
             // turn off this setting to prevent site from breaking,
             // and show the auto-generated rules to admin
             $options['enable_fly_min'] = '';
             update_option(BWP_MINIFY_OPTION_ADVANCED, $options);
             $this->add_notice('<strong>' . __('Notice') . ':</strong> ' . __('Friendly minify url feature has been turned off ' . 'automatically to prevent your site from breaking. ', $this->domain));
             /* $form['container']['h1'][] = $this->_show_generated_cache_rewrite_rules(); */
         } else {
             if (true === $result) {
                 // successfully enable friendly minify url feature,
                 // flush all cached files and auto-detect groups
                 $this->_flush_cache();
                 $this->detector->auto_detect();
             }
         }
     }
 }