@@ -550,18 +550,22 @@ function ifset( &$var, $return = false ) { // phpcs:ignore Universal.NamingConve
550550 * @return boolean if webmentions are open
551551 */
552552function 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 */
604591function 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/**
0 commit comments