From 9638b7e3c6c321793240a0dcd2cca116967c219f Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 4 Dec 2015 16:44:38 +0100 Subject: [PATCH] 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. --- header.php | 1 - inc/extras.php | 10 ++++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/header.php b/header.php index d309fe90dc..0c5a7d43f9 100644 --- a/header.php +++ b/header.php @@ -15,7 +15,6 @@ - diff --git a/inc/extras.php b/inc/extras.php index d3bf8fb160..8475ff8aaf 100644 --- a/inc/extras.php +++ b/inc/extras.php @@ -27,3 +27,13 @@ function _s_body_classes( $classes ) { return $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 ''; + } +} +add_action( 'wp_head', '_s_pingback_header' );