Ticket #5085 (closed enhancement: fixed)
Unify generator strings
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| 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
Change History
comment:3
follow-up:
↓ 4
JeremyVisser — 4 years ago
- Owner changed from anonymous to docwhat
- Milestone changed from 2.5 to 2.4
I like it. It's somewhat related to #4803, also.
comment:4
in reply to:
↑ 3
;
follow-up:
↓ 7
foolswisdom — 4 years ago
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 .
- Keywords privacy generator added
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!
comment:7
in reply to:
↑ 4
JeremyVisser — 4 years ago
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.
comment:8
follow-up:
↓ 9
JeremyVisser — 4 years ago
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');") );
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!
comment:10
westi — 4 years ago
- Owner changed from docwhat to westi
- Status changed from new to assigned
I will take a look at these patches and review them.
comment:11
westi — 4 years ago
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(-)
comment:12
Otto42 — 4 years ago
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.
comment:13
westi — 4 years ago
Note to self: We also need to include the generator for the export file in these changes
comment:14
westi — 4 years ago
- Status changed from assigned to closed
- Resolution set to fixed
comment:15
Viper007Bond — 4 years ago
- Status changed from closed to reopened
- Type changed from defect to enhancement
- Version set to 2.3
- Resolution fixed 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().
comment:16
Viper007Bond — 4 years ago
- Status changed from reopened to closed
- Resolution set to fixed
Sorry, I'll make a new ticket.
I always forget.


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.