wc_ms_protect_download_rewite_rules

Protect downloads from ms-files.php in multisite.

Description

(string) wc_ms_protect_download_rewite_rules( (mixed) $rewrite ); 

Returns (string)

Parameters (1)

0. $rewrite (mixed)
The rewrite.

Usage

  1. if ( !function_exists( 'wc_ms_protect_download_rewite_rules' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-core-functions.php'; 
  3.  
  4. // The rewrite. 
  5. $rewrite = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wc_ms_protect_download_rewite_rules($rewrite); 
  9.  

Defined (1)

The function is defined in the following location(s).

/includes/wc-core-functions.php  
  1. function wc_ms_protect_download_rewite_rules( $rewrite ) { 
  2. if ( ! is_multisite() || 'redirect' == get_option( 'woocommerce_file_download_method' ) ) { 
  3. return $rewrite; 
  4.  
  5. $rule = "\n# WooCommerce Rules - Protect Files from ms-files.php\n\n"; 
  6. $rule .= "<IfModule mod_rewrite.c>\n"; 
  7. $rule .= "RewriteEngine On\n"; 
  8. $rule .= "RewriteCond %{QUERY_STRING} file=woocommerce_uploads/ [NC]\n"; 
  9. $rule .= "RewriteRule /ms-files.php$ - [F]\n"; 
  10. $rule .= "</IfModule>\n\n"; 
  11.  
  12. return $rule . $rewrite;