bb_slug_increment

Slugs.

Description

bb_slug_increment( $slug, $existing_slug, (int) $slug_length = 255 ); 

Parameters (3)

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

Usage

  1. if ( !function_exists( 'bb_slug_increment' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-includes/functions.bb-core.php'; 
  3.  
  4. // The slug. 
  5. $slug = null; 
  6.  
  7. // The existing slug. 
  8. $existing_slug = null; 
  9.  
  10. // The slug length. 
  11. $slug_length = 255; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = bb_slug_increment($slug, $existing_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_slug_increment( $slug, $existing_slug, $slug_length = 255 ) { 
  2. if ( preg_match('/^.*-([0-9]+)$/', $existing_slug, $m) ) 
  3. $number = (int) $m[1] + 1; 
  4. else 
  5. $number = 1; 
  6.  
  7. $r = bb_encoded_utf8_cut( $slug, $slug_length - 1 - strlen($number) ); 
  8. return apply_filters( 'bb_slug_increment', "$r-$number", $slug, $existing_slug, $slug_length );