Skip to content

Commit

Permalink
Update class-webmention-sender.php
Browse files Browse the repository at this point in the history
  • Loading branch information
janboddez authored Nov 28, 2023
1 parent f9e83cd commit c6241a8
Showing 1 changed file with 19 additions and 28 deletions.
47 changes: 19 additions & 28 deletions includes/class-webmention-sender.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,24 +62,20 @@ public static function schedule_webmention( $obj_id, $obj = null, $deprecated =

$urls = array();

// Fetch our post or comment's HTML.
if ( $obj instanceof \WP_Post ) {
// Fetch our post's HTML.
$html = apply_filters( 'the_content', $obj->post_content );
} else {
$html = make_clickable( get_comment_text( $obj ) );

if ( ! empty( $obj->comment_parent ) ) {
// Add in the parent's, if any, Webmention source.
$source = get_comment_meta( $obj->comment_parent, 'indieblocks_webmention_source', true );
if ( ! empty( $source ) ) {
$urls[] = $source;
}

// Scan it for outgoing links.
$urls = static::find_outgoing_links( $html );
} elseif ( ! empty( $obj->comment_parent ) ) {
// Add in the parent's, if any, Webmention source.
$source = get_comment_meta( $obj->comment_parent, 'indieblocks_webmention_source', true );
if ( ! empty( $source ) ) {
$urls[] = $source;
}
}

// Scan it for outgoing links.
$urls = array_merge( $urls, static::find_outgoing_links( $html ) );

// Parse in targets that may have been there previously, but don't
// delete them, yet.
$history = get_meta( $obj, '_indieblocks_webmention_history' );
Expand All @@ -93,8 +89,7 @@ public static function schedule_webmention( $obj_id, $obj = null, $deprecated =
return;
}

$urls = array_unique( $urls );

$urls = array_unique( $urls );
$schedule = false;

foreach ( $urls as $url ) {
Expand Down Expand Up @@ -158,24 +153,20 @@ public static function send_webmention( $obj ) {

$urls = array();

// Fetch our post or comment's HTML.
if ( $obj instanceof \WP_Post ) {
// Fetch our post's HTML.
$html = apply_filters( 'the_content', $obj->post_content );
} else {
$html = make_clickable( get_comment_text( $obj ) );

if ( ! empty( $obj->comment_parent ) ) {
// Add in the parent's, if any, Webmention source.
$source = get_comment_meta( $obj->comment_parent, 'indieblocks_webmention_source', true );
if ( ! empty( $source ) ) {
$urls[] = $source;
}

// Scan it for outgoing links.
$urls = static::find_outgoing_links( $html );
} elseif ( ! empty( $obj->comment_parent ) ) {
// Add in the parent's, if any, Webmention source.
$source = get_comment_meta( $obj->comment_parent, 'indieblocks_webmention_source', true );
if ( ! empty( $source ) ) {
$urls[] = $source;
}
}

// Scan it for outgoing links.
$urls = array_merge( $urls, static::find_outgoing_links( $html ) );

// Parse in (_and_ then forget) targets that may have been there before.
// This also means that "historic" targets are excluded from retries!
// Note that we _also_ retarget pages that threw an error or we
Expand Down

0 comments on commit c6241a8

Please sign in to comment.