Skip to content

Commit

Permalink
Add docblock noting JSON elements defined in spec
Browse files Browse the repository at this point in the history
  • Loading branch information
dshanske committed Jun 29, 2024
1 parent 70ca20e commit 15e4f6f
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions includes/class-indieauth-client-discovery.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class IndieAuth_Client_Discovery {
public $client_id = '';
public $client_name = '';
public $client_icon = '';
public $client_uri = '';
public $client_uri = '';

public function __construct( $client_id ) {
$this->client_id = $client_id;
Expand Down Expand Up @@ -83,6 +83,19 @@ private function parse( $url ) {
$content_type = wp_remote_retrieve_header( $response, 'content-type' );
if ( 'application/json' === $content_type ) {
$this->json = json_decode( wp_remote_retrieve_body( $response ), true );
/**
* Expected format is per the IndieAuth standard as revised 2024-06-23 to include a JSON Client Metadata File
*
* @param array $json {
* An array of metadata about a client
*
* @type string $client_uri URL of a webpage providing information about the client.
* @type string $client_id The client identifier.
* @type string $client_name Human Readable Name of the Client. Optional.
* @type string $logo_uri URL that references a logo or icon for the client. Optional.
* @type array $redirect_uris An array of redirect URIs. Optional.
* }
**/
if ( ! is_array( $this->json ) || empty( $this->json ) ) {
return new WP_Error( 'empty_json', __( 'Discovery Has Returned an Empty JSON Document', 'indieauth' ) );
}
Expand Down Expand Up @@ -151,7 +164,7 @@ private function get_mf2( $input, $url ) {
}

private function get_html( $input ) {
$xpath = new DOMXPath( $input );
$xpath = new DOMXPath( $input );
if ( ! empty( $xpath ) ) {
$title = $xpath->query( '//title' );
if ( ! empty( $title ) ) {
Expand Down

0 comments on commit 15e4f6f

Please sign in to comment.