bb_get_theme_data

The BuddyPress bb get theme data function.

Description

bb_get_theme_data( $theme_file ); 

Parameters (1)

0. $theme_file
The theme file.

Usage

  1. if ( !function_exists( 'bb_get_theme_data' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-admin/includes/functions.bb-admin.php'; 
  3.  
  4. // The theme file. 
  5. $theme_file = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bb_get_theme_data($theme_file); 
  9.  

Defined (1)

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

/bp-forums/bbpress/bb-admin/includes/functions.bb-admin.php  
  1. function bb_get_theme_data( $theme_file ) 
  2. if ( strpos($theme_file, '#') !== false ) { 
  3. $theme_file = bb_get_theme_directory( $theme_file ) . 'style.css'; 
  4. $theme_code = implode( '', file( $theme_file ) ); 
  5. $theme_code = str_replace ( '\r', '\n', $theme_code ); 
  6. // Grab just the first commented area from the file 
  7. preg_match( '|/\*(.*)\*/|msU', $theme_code, $theme_block ); 
  8. $theme_data = trim( $theme_block[1] ); 
  9. preg_match( '|Theme Name:(.*)|i', $theme_data, $theme_name ); 
  10. preg_match( '|Theme URI:(.*)|i', $theme_data, $theme_uri ); 
  11. preg_match( '|Description:(.*)|i', $theme_data, $description ); 
  12. preg_match( '|Author:(.*)|i', $theme_data, $author_name ); 
  13. preg_match( '|Author URI:(.*)|i', $theme_data, $author_uri ); 
  14. preg_match( '|Ported By:(.*)|i', $theme_data, $porter_name ); 
  15. preg_match( '|Porter URI:(.*)|i', $theme_data, $porter_uri ); 
  16. // preg_match( '|Template:(.*)|i', $theme_data, $template ); 
  17. if ( preg_match( '|Version:(.*)|i', $theme_data, $version ) ) 
  18. $version = esc_html( trim( $version[1] ) ); 
  19. else 
  20. $version =''; 
  21. if ( preg_match('|Status:(.*)|i', $theme_data, $status) ) 
  22. $status = esc_html( trim($status[1]) ); 
  23. else 
  24. $status = 'publish'; 
  25.  
  26. $description = trim($description[1]); 
  27. $description = bb_encode_bad( $description ); 
  28. $description = bb_code_trick( $description ); 
  29. $description = force_balance_tags( $description ); 
  30. $description = bb_filter_kses( $description ); 
  31. $description = bb_autop( $description ); 
  32.  
  33. $name = $theme_name[1]; 
  34. $name = esc_html( trim($name) ); 
  35. $theme = $name; 
  36.  
  37. if ( $author_name || $author_uri ) { 
  38. if ( empty($author_uri[1]) ) { 
  39. $author = bb_filter_kses( trim($author_name[1]) ); 
  40. } else { 
  41. $author = '<a href="' . esc_url( trim($author_uri[1]) ) . '" title="' . esc_attr__( 'Visit author homepage' ) . '">' . bb_filter_kses( trim($author_name[1]) ) . '</a>'; 
  42. } else { 
  43. $author = ''; 
  44.  
  45. if ( $porter_name || $porter_uri ) { 
  46. if ( empty($porter_uri[1]) ) { 
  47. $porter = bb_filter_kses( trim($porter_name[1]) ); 
  48. } else { 
  49. $porter = '<a href="' . esc_url( trim($porter_uri[1]) ) . '" title="' . esc_attr__( 'Visit porter homepage' ) . '">' . bb_filter_kses( trim($porter_name[1]) ) . '</a>'; 
  50. } else { 
  51. $porter = ''; 
  52.  
  53. global $bb; 
  54.  
  55. // Normalise the path to the theme 
  56. $theme_file = str_replace( '\\', '/', $theme_file ); 
  57.  
  58. foreach ( $bb->theme_locations as $_name => $_data ) { 
  59. $_directory = str_replace( '\\', '/', $_data['dir'] ); 
  60. if ( 0 === strpos( $theme_file, $_directory ) ) { 
  61. $location = $_name; 
  62. break; 
  63.  
  64. return array( 
  65. 'Location' => $location,  
  66. 'Name' => $name,  
  67. 'Title' => $theme,  
  68. 'Description' => $description,  
  69. 'Author' => $author,  
  70. 'Porter' => $porter,  
  71. 'Version' => $version,  
  72. // 'Template' => $template[1],  
  73. 'Status' => $status,  
  74. 'URI' => esc_url( $theme_uri[1] ) 
  75. );