forked from mirror/_s
Only generate pingback url header tag when relevant.
Rationale: 1. The principle of pingbacks is based on articles. Pingbacks are a special kind of comments and the article being 'pinged-back' has to be identifiable (which they're not on archive pages and the like). 2. WP only registers a ping if it can identify the article which is supposed to have been 'pung'. See: https://developer.wordpress.org/reference/classes/wp_xmlrpc_server/pingback_ping/ 3. Pingbacks, like comments, can be disabled on a per article basis. Therefore, having the pingback url auto-discovery header in place, only makes sense on singular pages where pings are open.
This commit is contained in:
parent
e57d8c38b4
commit
9638b7e3c6
|
@ -15,7 +15,6 @@
|
||||||
<meta charset="<?php bloginfo( 'charset' ); ?>">
|
<meta charset="<?php bloginfo( 'charset' ); ?>">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<link rel="profile" href="http://gmpg.org/xfn/11">
|
<link rel="profile" href="http://gmpg.org/xfn/11">
|
||||||
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
|
|
||||||
|
|
||||||
<?php wp_head(); ?>
|
<?php wp_head(); ?>
|
||||||
</head>
|
</head>
|
||||||
|
|
|
@ -27,3 +27,13 @@ function _s_body_classes( $classes ) {
|
||||||
return $classes;
|
return $classes;
|
||||||
}
|
}
|
||||||
add_filter( 'body_class', '_s_body_classes' );
|
add_filter( 'body_class', '_s_body_classes' );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a pingback url auto-discovery header for singularly identifiable articles.
|
||||||
|
*/
|
||||||
|
function _s_pingback_header() {
|
||||||
|
if ( is_singular() && pings_open() ) {
|
||||||
|
echo '<link rel="pingback" href="', bloginfo( 'pingback_url' ), '">';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
add_action( 'wp_head', '_s_pingback_header' );
|
||||||
|
|
Reference in New Issue