get_the_generator

Creates the generator XML or Comment for RSS, ATOM, etc.

Description

(string|void) get_the_generator( (string) $type = '' ); 

Returns the correct generator type for the requested output format. Allows for a plugin to filter generators on an individual basis using the filter.

Returns (string|void)

The HTML content for the generator.

Parameters (1)

0. $type — Optional. (string) => ''
The type of generator to return - (html|xhtml|atom|rss2|rdf|comment|export).

Usage

  1. if ( !function_exists( 'get_the_generator' ) ) { 
  2. require_once ABSPATH . WPINC . '/general-template.php'; 
  3.  
  4. // The type of generator to return - (html|xhtml|atom|rss2|rdf|comment|export). 
  5. $type = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = get_the_generator($type); 
  9.  

Defined (1)

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

/wp-includes/general-template.php  
  1. function get_the_generator( $type = '' ) { 
  2. if ( empty( $type ) ) { 
  3.  
  4. $current_filter = current_filter(); 
  5. if ( empty( $current_filter ) ) 
  6. return; 
  7.  
  8. switch ( $current_filter ) { 
  9. case 'rss2_head' : 
  10. case 'commentsrss2_head' : 
  11. $type = 'rss2'; 
  12. break; 
  13. case 'rss_head' : 
  14. case 'opml_head' : 
  15. $type = 'comment'; 
  16. break; 
  17. case 'rdf_header' : 
  18. $type = 'rdf'; 
  19. break; 
  20. case 'atom_head' : 
  21. case 'comments_atom_head' : 
  22. case 'app_head' : 
  23. $type = 'atom'; 
  24. break; 
  25.  
  26. switch ( $type ) { 
  27. case 'html': 
  28. $gen = '<meta name="generator" content="WordPress ' . get_bloginfo( 'version' ) . '">'; 
  29. break; 
  30. case 'xhtml': 
  31. $gen = '<meta name="generator" content="WordPress ' . get_bloginfo( 'version' ) . '" />'; 
  32. break; 
  33. case 'atom': 
  34. $gen = '<generator uri="https://wordpress.org/" version="' . get_bloginfo_rss( 'version' ) . '">WordPress</generator>'; 
  35. break; 
  36. case 'rss2': 
  37. $gen = '<generator>https://wordpress.org/?v=' . get_bloginfo_rss( 'version' ) . '</generator>'; 
  38. break; 
  39. case 'rdf': 
  40. $gen = '<admin:generatorAgent rdf:resource="https://wordpress.org/?v=' . get_bloginfo_rss( 'version' ) . '" />'; 
  41. break; 
  42. case 'comment': 
  43. $gen = '<!-- generator="WordPress/' . get_bloginfo( 'version' ) . '" -->'; 
  44. break; 
  45. case 'export': 
  46. $gen = '<!-- generator="WordPress/' . get_bloginfo_rss('version') . '" created="'. date('Y-m-d H:i') . '" -->'; 
  47. break; 
  48.  
  49. /** 
  50. * Filters the HTML for the retrieved generator type. 
  51. * The dynamic portion of the hook name, `$type`, refers to the generator type. 
  52. * @since 2.5.0 
  53. * @param string $gen The HTML markup output to wp_head(). 
  54. * @param string $type The type of generator. Accepts 'html', 'xhtml', 'atom',  
  55. * 'rss2', 'rdf', 'comment', 'export'. 
  56. */ 
  57. return apply_filters( "get_the_generator_{$type}", $gen, $type );