wc_sanitize_permalink

Sanitize permalink values before insertion into DB.

Description

(string) wc_sanitize_permalink( (string) $value ); 

Cannot use wc_clean because it sometimes strips % chars and breaks the user's setting.

Returns (string)

Parameters (1)

0. $value (string)
The value.

Usage

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

Defined (1)

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

/includes/wc-formatting-functions.php  
  1. function wc_sanitize_permalink( $value ) { 
  2. global $wpdb; 
  3.  
  4. $value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value ); 
  5.  
  6. if ( is_wp_error( $value ) ) { 
  7. $value = ''; 
  8.  
  9. $value = esc_url_raw( $value ); 
  10. $value = str_replace( 'http://', '', $value ); 
  11. return untrailingslashit( $value );