Ticket #5085 (closed enhancement: fixed)

Opened 10 months ago

Last modified 10 months ago

Unify generator strings

Reported by: docwhat Assigned to: westi
Priority: normal Milestone: 2.5
Component: General Version: 2.3
Severity: normal Keywords: privacy generator has-patch
Cc:

Description

In WordPress 2.3, there are about a dozen plus places that use a generator comment or a generator XML element.

I would like to suggest adding an API for building the generator interfaces. However, to me, the only obvious (and consistent) generator string is the XML comment.

wp_generator_comment() would generate an XML comment such as:

<!-- generator="wordpress/2.3" -->

I need help figuring out an API for the various XML node formats, such as:

<generator uri="http://wordpress.com/" version="1.0.5-dc">WordPress.com Atom API</generator>
<generator>http://wordpress.org/?v=<?php bloginfo_rss('version'); ?></generator>
<generator>http://wordpress.org/?v=<?php echo $wp_version ?></generator>
<generator uri="http://wordpress.org/" version="<?php bloginfo_rss('version'); ?>">WordPress</generator>
<generator uri="http://wordpress.org/" version="<?php bloginfo('version'); ?>">WordPress</generator>
<admin:generatorAgent rdf:resource="http://wordpress.org/?v=<?php echo $wp_version ?>"/>

Tracing through the code I couldn't easily tell what bloginfo_rss returns, I assume it returns $wp_version;

This would prevent repetition of code and allow for admins or plugin developers to add or remove information they are not comfortable sending out.

Ciao!

PS: This is related to bug #5065 in spirit.

Attachments

wp-generator.patch (8.8 kB) - added by docwhat on 09/27/07 04:43:55.
wp-free-gen.php (0.8 kB) - added by docwhat on 09/27/07 04:44:31.
generator.diff (9.6 kB) - added by westi on 09/29/07 12:19:18.
Updated patch

Change History

09/26/07 22:02:14 changed by Otto42

Most of the feeds and such have their own syntax for expressing the generator. So there's no one universal way.

I'd suggest something like this:

function get_generator($type='comment')
{
	switch ($type) {
	case 'meta':
		$gen = '<meta name="generator" content="WordPress/'. bloginfo('version') .'" />';
		break;
	case 'atom':
		$gen = '<generator uri="http://wordpress.org/" version="'.bloginfo_rss('version').'">WordPress</generator>';
		break;
	case 'rss2':
		$gen = '<generator>http://wordpress.org/?v='.bloginfo_rss('version').'</generator>';
		break;
	case 'rdf':
		$gen = '<admin:generatorAgent rdf:resource="http://wordpress.org/?v='.bloginfo_rss('version').'" />';
		break;
	default: // case 'comment':
		$gen = '<!-- generator="WordPress/'.bloginfo('version').'" -->";
		break;
	}
	
	return apply_filters('get_generator',$gen);
}

Then call the appropriate one with <?php echo get_generator('whatever'); ?> at the right point in the code.

09/27/07 00:37:42 changed by docwhat

Thank you, I think that's a great idea. I'll do that.

Ciao!

(follow-up: ↓ 4 ) 09/27/07 02:48:36 changed by JeremyVisser

  • owner changed from anonymous to docwhat.
  • milestone changed from 2.5 to 2.4.

I like it. It's somewhat related to #4803, also.

(in reply to: ↑ 3 ; follow-up: ↓ 7 ) 09/27/07 04:32:03 changed by foolswisdom

Replying to JeremyVisser:

milestone changed from 2.5 to 2.4.

Generally, I've been leaving things without core developer owner or patch to trunk+1 .

09/27/07 04:43:55 changed by docwhat

  • attachment wp-generator.patch added.

09/27/07 04:44:31 changed by docwhat

  • attachment wp-free-gen.php added.

09/27/07 04:47:18 changed by docwhat

  • keywords set to privacy generator.

JeremyVisser?: Thanks for the info. Some of the concerns there applied to my patch, too.

Everyone: I have attached a patch. The only problems I can think of is where it's located in the file or it's name. I can make those changes quickly, feel free to give me feedback.

Ciao!

09/27/07 04:47:55 changed by docwhat

  • keywords changed from privacy generator to privacy generator has-patch.

(in reply to: ↑ 4 ) 09/27/07 07:03:06 changed by JeremyVisser

Replying to foolswisdom:

Replying to JeremyVisser:

milestone changed from 2.5 to 2.4.

Generally, I've been leaving things without core developer owner or patch to trunk+1 .

Thanks for that Lloyd. I'll try and remember that for next time. :) Part of the reason I changed it to 2.4 was that #4803's milestone was 2.4.

(follow-up: ↓ 9 ) 09/27/07 07:12:49 changed by JeremyVisser

In line with #4803, the generator tags could then be stripped out of the templates, and adding something like this somewhere:

add_action( 'wp_head', create_function('', "wp_get_generator('xhtml');") );

(in reply to: ↑ 8 ) 09/27/07 13:17:28 changed by docwhat

Replying to JeremyVisser:

In line with #4803, the generator tags could then be stripped out of the templates, and adding something like this somewhere:

Even better, you can detect the DTD and user 'xhtml' or 'html' as appropriate!

Ciao!

09/27/07 16:54:58 changed by westi

  • owner changed from docwhat to westi.
  • status changed from new to assigned.

I will take a look at these patches and review them.

09/29/07 12:18:59 changed by westi

Ok I've reworked the patch to include the changes from #4803 and to improve the functionality a little bit.

New patch about to be attached.

Here is a summary of the changes:

 wp-app.php                           |    2 -
 wp-content/themes/classic/header.php |    2 -
 wp-content/themes/default/header.php |    2 -
 wp-includes/default-filters.php      |    3 +-
 wp-includes/feed-atom-comments.php   |    2 -
 wp-includes/feed-atom.php            |    2 -
 wp-includes/feed-rdf.php             |    4 +--
 wp-includes/feed-rss.php             |    2 -
 wp-includes/feed-rss2-comments.php   |    4 +--
 wp-includes/feed-rss2.php            |    4 +--
 wp-includes/general-template.php     |   43 +++++++++++++++++++++++++++++++++++
 wp-links-opml.php                    |    2 -
 12 files changed, 56 insertions(+), 16 deletions(-)

09/29/07 12:19:18 changed by westi

  • attachment generator.diff added.

Updated patch

09/29/07 21:55:48 changed by Otto42

Suggestion: In feed-rss2.php, feed-rss2-comments.php, and feed-rdf.php, remove the call to <?php the_generator( 'comment' ); ?>. It's unnecessary, the rss2 format contains the stuff for a generator explicitly, we don't need an extra comment type thing in there. It's just taking up space to give the same information that's available in there already.

Other than that, +1.

09/30/07 10:31:27 changed by westi

Note to self: We also need to include the generator for the export file in these changes

10/06/07 06:55:24 changed by westi

  • status changed from assigned to closed.
  • resolution set to fixed.

(In [6195]) Centralise generator generation, move theme generator generation to wp-head hook. Fixes #5085, #4803. props docwhat, Viper007Bond.

10/06/07 08:07:44 changed by Viper007Bond

  • status changed from closed to reopened.
  • type changed from defect to enhancement.
  • version set to 2.3.
  • resolution deleted.

Shouldn't we use GMT for the generation time (in the export one)?

Also, a small nitpick: spaces after the commas in the_generator().

10/06/07 08:08:38 changed by Viper007Bond

  • status changed from reopened to closed.
  • resolution set to fixed.

Sorry, I'll make a new ticket.

I always forget.