bb_get_sql_from_slug

The BuddyPress bb get sql from slug function.

Description

bb_get_sql_from_slug( $table, $slug, (int) $slug_length = 255 ); 

Parameters (3)

0. $table
The table.
1. $slug
The slug.
2. $slug_length — Optional. (int) => 255
The slug length.

Usage

  1. if ( !function_exists( 'bb_get_sql_from_slug' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-includes/functions.bb-core.php'; 
  3.  
  4. // The table. 
  5. $table = null; 
  6.  
  7. // The slug. 
  8. $slug = null; 
  9.  
  10. // The slug length. 
  11. $slug_length = 255; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = bb_get_sql_from_slug($table, $slug, $slug_length); 
  15.  

Defined (1)

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

/bp-forums/bbpress/bb-includes/functions.bb-core.php  
  1. function bb_get_sql_from_slug( $table, $slug, $slug_length = 255 ) { 
  2. global $bbdb; 
  3.  
  4. // Look for new style equiv of old style slug 
  5. $_slug = bb_slug_sanitize( (string) $slug ); 
  6. if ( strlen( $_slug ) < 1 ) 
  7. return ''; 
  8.  
  9. if ( strlen($_slug) > $slug_length && preg_match('/^.*-([0-9]+)$/', $_slug, $m) ) { 
  10. $_slug = bb_encoded_utf8_cut( $_slug, $slug_length - 1 - strlen($number) ); 
  11. $number = (int) $m[1]; 
  12. $_slug = "$_slug-$number"; 
  13.  
  14. return array( $_slug, $bbdb->prepare( "${table}_slug = %s", $_slug ) ); 
  15. }