get_the_generator( string $type = '' )

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


Description

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


Parameters

$type

(Optional) The type of generator to return

  • (html|xhtml|atom|rss2|rdf|comment|export).

Default value: ''


Return

(string|void) The HTML content for the generator.


Source

File: wp-includes/general-template.php

function get_the_generator( $type = '' ) {
	global $wp_version;

	if ( empty( $type ) ) {

		$current_filter = current_filter();
		if ( empty( $current_filter ) )
			return;

		switch ( $current_filter ) {
			case 'rss2_head' :
			case 'commentsrss2_head' :
				$type = 'rss2';
				break;
			case 'rss_head' :
			case 'opml_head' :
				$type = 'comment';
				break;
			case 'rdf_header' :
				$type = 'rdf';
				break;
			case 'atom_head' :
			case 'comments_atom_head' :
			case 'app_head' :
				$type = 'atom';
				break;
		}
	}

	$esc_wp_version = esc_attr( $wp_version );
	$esc_cp_version = esc_attr( classicpress_version_short() );
	$esc_cp_url = esc_url_raw(
		'https://www.classicpress.net/?v='
		. $wp_version . '-cp-' . classicpress_version_short()
	);

	switch ( $type ) {
		case 'html':
			$gen = "<meta name=\"generator\" content=\"WordPress $esc_wp_version (compatible; ClassicPress $esc_cp_version)\">";
			break;
		case 'xhtml':
			$gen = "<meta name=\"generator\" content=\"WordPress $esc_wp_version (compatible; ClassicPress $esc_cp_version)\">";
			break;
		case 'atom':
			$gen = "<generator uri=\"https://www.classicpress.net/\" version=\"$esc_wp_version-cp-$esc_cp_version\">ClassicPress</generator>";
			break;
		case 'rss2':
			$gen = "<generator>$esc_cp_url</generator>";
			break;
		case 'rdf':
			$gen = "<admin:generatorAgent rdf:resource=\"$esc_cp_url\" />";
			break;
		case 'comment':
			$gen = "<!-- generator=\"WordPress/$esc_wp_version (compatible; ClassicPress/$esc_cp_version)\" -->";
			break;
		case 'export':
			$gen = "<!-- generator=\"ClassicPress/$esc_cp_version\" created=\"" . date( "Y-m-d H:i" ) . "\" -->";
			break;
	}

	/**
	 * Filters the HTML for the retrieved generator type.
	 *
	 * The dynamic portion of the hook name, `$type`, refers to the generator type.
	 *
	 * @since WP-2.5.0
	 *
	 * @param string $gen  The HTML markup output to wp_head().
	 * @param string $type The type of generator. Accepts 'html', 'xhtml', 'atom',
	 *                     'rss2', 'rdf', 'comment', 'export'.
	 */
	return apply_filters( "get_the_generator_{$type}", $gen, $type );
}


Changelog

Changelog
Version Description
WP-2.5.0 Introduced.