Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/wp-content/themes/twentyeleven/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
</title>
<link rel="profile" href="https://gmpg.org/xfn/11" />
<link rel="stylesheet" media="all" href="<?php echo esc_url( get_stylesheet_uri() ); ?>?ver=20260520" />
<link rel="pingback" href="<?php echo esc_url( get_bloginfo( 'pingback_url' ) ); ?>">
<?php
/*
* We add some JavaScript to pages with the comment form
Expand Down
1 change: 0 additions & 1 deletion src/wp-content/themes/twentyfifteen/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="profile" href="https://gmpg.org/xfn/11">
<link rel="pingback" href="<?php echo esc_url( get_bloginfo( 'pingback_url' ) ); ?>">
<?php wp_head(); ?>
</head>

Expand Down
1 change: 0 additions & 1 deletion src/wp-content/themes/twentyfourteen/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?php wp_title( '|', true, 'right' ); ?></title>
<link rel="profile" href="https://gmpg.org/xfn/11">
<link rel="pingback" href="<?php echo esc_url( get_bloginfo( 'pingback_url' ) ); ?>">
<?php wp_head(); ?>
</head>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,8 @@ function twentynineteen_post_classes( $classes ) {
* Adds a pingback url auto-discovery header for single posts, pages, or attachments.
*/
function twentynineteen_pingback_header() {
if ( is_singular() && pings_open() ) {
echo '<link rel="pingback" href="', esc_url( get_bloginfo( 'pingback_url' ) ), '">';
}
wp_pingback_link();
}
add_action( 'wp_head', 'twentynineteen_pingback_header' );

/**
* Changes comment form default fields.
Expand Down
5 changes: 1 addition & 4 deletions src/wp-content/themes/twentyseventeen/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -427,11 +427,8 @@ function twentyseventeen_javascript_detection() {
* Adds a pingback url auto-discovery header for singularly identifiable articles.
*/
function twentyseventeen_pingback_header() {
if ( is_singular() && pings_open() ) {
printf( '<link rel="pingback" href="%s">' . "\n", esc_url( get_bloginfo( 'pingback_url' ) ) );
}
wp_pingback_link();
}
add_action( 'wp_head', 'twentyseventeen_pingback_header' );

/**
* Displays custom color CSS.
Expand Down
3 changes: 0 additions & 3 deletions src/wp-content/themes/twentysixteen/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="profile" href="https://gmpg.org/xfn/11">
<?php if ( is_singular() && pings_open( get_queried_object() ) ) : ?>
<link rel="pingback" href="<?php echo esc_url( get_bloginfo( 'pingback_url' ) ); ?>">
<?php endif; ?>
<?php wp_head(); ?>
</head>

Expand Down
1 change: 0 additions & 1 deletion src/wp-content/themes/twentyten/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
</title>
<link rel="profile" href="https://gmpg.org/xfn/11" />
<link rel="stylesheet" media="all" href="<?php echo esc_url( get_stylesheet_uri() ); ?>?ver=20260520" />
<link rel="pingback" href="<?php echo esc_url( get_bloginfo( 'pingback_url' ) ); ?>">
<?php
/*
* We add some JavaScript to pages with the comment form
Expand Down
1 change: 0 additions & 1 deletion src/wp-content/themes/twentythirteen/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?php wp_title( '|', true, 'right' ); ?></title>
<link rel="profile" href="https://gmpg.org/xfn/11">
<link rel="pingback" href="<?php echo esc_url( get_bloginfo( 'pingback_url' ) ); ?>">
<?php wp_head(); ?>
</head>

Expand Down
1 change: 0 additions & 1 deletion src/wp-content/themes/twentytwelve/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title><?php wp_title( '|', true, 'right' ); ?></title>
<link rel="profile" href="https://gmpg.org/xfn/11" />
<link rel="pingback" href="<?php echo esc_url( get_bloginfo( 'pingback_url' ) ); ?>">
<?php wp_head(); ?>
</head>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,8 @@ function twenty_twenty_one_post_classes( $classes ) {
* @return void
*/
function twenty_twenty_one_pingback_header() {
if ( is_singular() && pings_open() ) {
echo '<link rel="pingback" href="', esc_url( get_bloginfo( 'pingback_url' ) ), '">';
}
wp_pingback_link();
}
add_action( 'wp_head', 'twenty_twenty_one_pingback_header' );

/**
* Removes the `no-js` class from body if JS is supported.
Expand Down
1 change: 1 addition & 0 deletions src/wp-includes/default-filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@
add_action( 'wp_head', 'feed_links', 2 );
add_action( 'wp_head', 'feed_links_extra', 3 );
add_action( 'wp_head', 'rsd_link' );
add_action( 'wp_head', 'wp_pingback_link' );
add_action( 'wp_head', 'locale_stylesheet' );
add_action( 'publish_future_post', 'check_and_publish_future_post', 10, 1 );
add_action( 'wp_head', 'wp_robots', 1 );
Expand Down
18 changes: 18 additions & 0 deletions src/wp-includes/general-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -3561,6 +3561,24 @@ function rsd_link() {
);
}

/**
* Displays the link to the pingback XML-RPC endpoint.
*
* @since 7.1.0
*
* @return void
*/
function wp_pingback_link() {
if ( ! is_singular() || ! pings_open( get_queried_object() ) ) {
return;
}

printf(
'<link rel="pingback" href="%s" />' . "\n",
esc_url( get_bloginfo( 'pingback_url', 'display' ) )
);
}

/**
* Displays a referrer `strict-origin-when-cross-origin` meta tag.
*
Expand Down
1 change: 0 additions & 1 deletion src/wp-includes/theme-compat/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
<title><?php echo wp_get_document_title(); ?></title>

<link rel="stylesheet" href="<?php bloginfo( 'stylesheet_url' ); ?>" media="screen" />
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />

<?php if ( file_exists( get_stylesheet_directory() . '/images/kubrickbgwide.jpg' ) ) { ?>
<style media="screen">
Expand Down
94 changes: 94 additions & 0 deletions tests/phpunit/tests/general/wpPingbackLink.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?php
/**
* Test wp_pingback_link().
*
* @group general
* @group template
*
* @covers ::wp_pingback_link
*/
class Tests_General_WpPingbackLink extends WP_UnitTestCase {
/**
* @ticket 43791
*/
public function test_wp_pingback_link_is_hooked_to_wp_head() {
$this->assertSame( 10, has_action( 'wp_head', 'wp_pingback_link' ) );
}

/**
* @ticket 43791
*/
public function test_wp_pingback_link_outputs_link_on_singular_when_pings_are_open() {
$post_id = self::factory()->post->create(
array(
'ping_status' => 'open',
)
);

$this->go_to( get_permalink( $post_id ) );

$expected = sprintf(
'<link rel="pingback" href="%s" />' . "\n",
esc_url( get_bloginfo( 'pingback_url', 'display' ) )
);

$this->assertSame( $expected, get_echo( 'wp_pingback_link' ) );
}

/**
* @ticket 43791
*/
public function test_wp_pingback_link_respects_filtered_pingback_url() {
$post_id = self::factory()->post->create(
array(
'ping_status' => 'open',
)
);
$filter = static function ( $output, $show ) {
if ( 'pingback_url' === $show ) {
return 'https://example.com/pingback';
}

return $output;
};

add_filter( 'bloginfo_url', $filter, 10, 2 );
$this->go_to( get_permalink( $post_id ) );

$this->assertSame(
'<link rel="pingback" href="https://example.com/pingback" />' . "\n",
get_echo( 'wp_pingback_link' )
);
remove_filter( 'bloginfo_url', $filter, 10 );
}

/**
* @ticket 43791
*/
public function test_wp_pingback_link_outputs_nothing_when_pings_are_closed() {
$post_id = self::factory()->post->create(
array(
'ping_status' => 'closed',
)
);

$this->go_to( get_permalink( $post_id ) );

$this->assertEmpty( get_echo( 'wp_pingback_link' ) );
}

/**
* @ticket 43791
*/
public function test_wp_pingback_link_outputs_nothing_when_not_singular() {
self::factory()->post->create(
array(
'ping_status' => 'open',
)
);

$this->go_to( home_url( '/' ) );

$this->assertEmpty( get_echo( 'wp_pingback_link' ) );
}
}
Loading