Skip to content

Commit 2e295de

Browse files
committed
Remove dependence on pings_open for whether a webmention was open.
1 parent de1fa5a commit 2e295de

File tree

2 files changed

+15
-38
lines changed

2 files changed

+15
-38
lines changed

includes/functions.php

Lines changed: 15 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -550,18 +550,22 @@ function ifset( &$var, $return = false ) { // phpcs:ignore Universal.NamingConve
550550
* @return boolean if webmentions are open
551551
*/
552552
function webmentions_open( $post = null ) {
553-
$_post = get_post( $post );
554-
$post_id = $_post ? $_post->ID : 0;
555-
556-
// If the post type does not support Webmentions do not even check further
557-
if ( ! post_type_supports( get_post_type( $post_id ), 'webmentions' ) ) {
558-
return false;
553+
$post = get_post( $post );
554+
$post_id = $post ? $post->ID : 0;
555+
if ( $post ) {
556+
// Always consider the home mention link page to be open.
557+
if ( get_option( 'webmention_home_mentions' ) === $post->ID ) {
558+
$open = true;
559+
} elseif ( ! post_type_supports( get_post_type( $post ), 'webmentions' ) ) {
560+
// If the post type does not support Webmentions do not even check further.
561+
$open = false;
562+
} else {
563+
// If the webmentions_closed meta ID has a value then consider webmentions to be open.
564+
$open = get_post_meta( $post->ID, 'webmentions_closed', true );
565+
$open = empty( $open ) ? true : false;
566+
}
559567
}
560568

561-
if ( get_option( 'webmention_home_mentions' ) === $post_id ) {
562-
return true;
563-
}
564-
$open = ( $_post && ( pings_open( $post ) ) );
565569
/**
566570
* Filters whether the current post is open for webmentions.
567571
*
@@ -572,23 +576,6 @@ function webmentions_open( $post = null ) {
572576
return apply_filters( 'webmentions_open', $open, $post_id );
573577
}
574578

575-
/**
576-
* Return enabled status of Homepage Webmentions.
577-
*
578-
* @since 3.8.9
579-
*
580-
* @param bool $open Whether the current post is open for pings.
581-
* @param int $post_id The post ID.
582-
* @return boolean if pings are open
583-
*/
584-
function webmention_pings_open( $open, $post_id ) {
585-
if ( get_option( 'webmention_home_mentions' ) === $post_id ) {
586-
return true;
587-
}
588-
589-
return $open;
590-
}
591-
592579
/**
593580
* Retrieve the default comment status for a given post type.
594581
*
@@ -602,16 +589,7 @@ function webmention_pings_open( $open, $post_id ) {
602589
* @return string
603590
*/
604591
function webmention_get_default_comment_status( $status, $post_type, $comment_type ) {
605-
if ( 'webmention' === $comment_type ) {
606-
return post_type_supports( $post_type, 'webmentions' ) ? 'open' : 'closed';
607-
}
608-
609-
// Since support for the pingback comment type is used to keep pings open...
610-
if ( ( 'pingback' === $comment_type ) ) {
611-
return ( post_type_supports( $post_type, 'webmentions' ) ? 'open' : $status );
612-
}
613-
614-
return $status;
592+
return is_registered_webmention_comment_type( $comment_type ) ? 'open' : $status;
615593
}
616594

617595
/**

webmention.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ function init() {
128128

129129
// Default Comment Status.
130130
add_filter( 'get_default_comment_status', 'webmention_get_default_comment_status', 11, 3 );
131-
add_filter( 'pings_open', 'webmention_pings_open', 10, 2 );
132131

133132
// Load language files.
134133
load_plugin_textdomain( 'webmention', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );

0 commit comments

Comments
 (0)