Open johnalarcon opened 4 years ago
Well it's an interesting question...to which I don't really have an answer but here are my thoughts.
The generator tag, as I'm sure you know, is mostly used by sites like BuiltWith and w3Techs to help determine what technology is used on a site (it's one of several indicators). From what I can tell, it doesn't seem to matter if there's more than one but I've always assumed that only the last one is used. But I could well be wrong about this.
However, some plugins and themes replace the core generator tag with their own and that's something I don't like. As a result, and since I consider the ClassicPress generator tag to be more important than any other, I use a MU plugin on all of my sites that aims to restore the core tag (code provided by @nylen ).
function cp_restore_default_generator( $gen, $type ) {
global $wp_version;
$esc_wp_version = esc_attr( $wp_version );
$esc_cp_version = esc_attr( classicpress_version_short() );
return "<meta name=\"generator\" content=\"WordPress $esc_wp_version (compatible; ClassicPress $esc_cp_version)\">";
}
add_filter( 'get_the_generator_html', 'cp_restore_default_generator', 9999, 2 );
add_filter( 'get_the_generator_xhtml', 'cp_restore_default_generator', 9999, 2 );
So, even the CC generator tag doesn't show up although it'd be easy enough to tweak that code to re-insert it.
classicpress.net only has the core generator tag in its headers but if you look on BuiltWith https://builtwith.com/classicpress.net you'll see that it thinks both WordPress and ClassicPress are installed. It also thinks Woo is installed when actually it's CC.
Maybe we could try our own experiment.
If you and @simplycomputing could check some of your own sites that are a) running CP / CC and b) have both generator tags in the header, we can see how much BW knows about CC. We could monitor this over time.
I'll also tweak the mu plugin code to add the CC tag for those sites where CC is installed.
As for separating CP and WP in the core generator tag, I think that's something we'd need to discuss with James elsewhere but as we're doing here, maybe we could conduct a similar experiment.
Yeah, after scouring the net for quite some time, I couldn't find a dang thing on it. I'm glad you didn't just pop up with a spec and say, "Oh, here it is" after all that! 👍
I agree about replacing the core generator tag – it's bad form. I would tend to agree about the last tag being the one that gets the weight, like CSS...just a guess, though.
Regarding restoring the core tag (presuming you mean removing the CC tag), whereas that code snip overwrites the filters, it can be done with 2 lines by simply removing the filters – yeah, I built in CC support in today. ...which is why I even ended up down this dual-tag rabbit hole. :)
I'm afraid I won't be much help with an experiment. I've only got live 2 sites; one is a headless update server and the other doesn't have any commerce at all. I just have CC installed locally to ensure my upcoming plugin titles play well with it.
Five of my seven CC sites have this (the remaining two only have the first line). No idea why two missed out.
<meta name="generator" content="WordPress 4.9.15 (compatible; ClassicPress 1.2.0)">
<meta name="generator" content="Classic Commerce 3.5.3" />
What do those five sites show when you check them at https://builtwith.com/ ?
WooCommerce
Hopefully, over time, it will recognise that it's Classic Commerce and not Woo. It took BW a while to recognise CP.
Activating CC causes a meta generator tag to be added to the header after ClassicPress' own generator tag. To me, having two generator tags seems invalid, however, after reviewing the specs here and here, it's not clear either way. Do you have any additional insight/info on using multiple generator tags? I'd like to learn more.
It occurs to me that if using more than one generator tag is a viable technique, then ClassicPress could possibly benefit from having its own, rather than tacking on to the WordPress generator tag.