pods_create_slug

Create a slug from an input string.

Description

(string) pods_create_slug( $orig, (bool) $strict = true ); 

Returns (string)

Sanitized slug

Parameters (2)

0. $orig
The orig.
1. $strict — Optional. (bool) => true
The strict.

Usage

  1. if ( !function_exists( 'pods_create_slug' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'pods-custom-content-types-and-fields/includes/data.php'; 
  3.  
  4. // The orig. 
  5. $orig = null; 
  6.  
  7. // The strict. 
  8. $strict = true; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = pods_create_slug($orig, $strict); 
  12.  

Defined (1)

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

/includes/data.php  
  1. function pods_create_slug ( $orig, $strict = true ) { 
  2. $str = preg_replace( "/([_ \\/])/", "-", trim( $orig ) ); 
  3.  
  4. if ( $strict ) 
  5. $str = preg_replace( "/([^0-9a-z\-])/", "", strtolower( $str ) ); 
  6. else 
  7. $str = urldecode( sanitize_title( strtolower( $str ) ) ); 
  8.  
  9. $str = preg_replace( "/(\-) {2, }/", "-", $str ); 
  10. $str = trim( $str, '-' ); 
  11. $str = apply_filters( 'pods_create_slug', $str, $orig ); 
  12.  
  13. return $str;