Skip to content
Merged
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
12 changes: 10 additions & 2 deletions includes/rest/class-endpoint-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -674,13 +674,21 @@ protected function insert_post( &$args ) {

\kses_remove_filters();
$args['ID'] = $this->check_error( \wp_insert_post( $args, true ) );
\kses_init_filters();

// check_error() returns an Error object rather than throwing, and an object
// is truthy, so the insert failure has to be tested for explicitly before
// the ID is used as a post ID. The caller checks for it too, but only after
// this method has returned.
if ( \is_micropub_error( $args['ID'] ) ) {
return;
}

if ( $args['ID'] && array_key_exists( 'client_uid', $this->micropub_auth_response ) ) {
if ( array_key_exists( 'client_uid', $this->micropub_auth_response ) ) {
\wp_set_object_terms( $args['ID'], array( $this->micropub_auth_response['client_uid'] ), 'indieauth_client' );
}

$args['post_url'] = \get_permalink( $args['ID'] );
\kses_init_filters();
}

/**
Expand Down