Skip to content

Commit

Permalink
fix undefined function and variable found via PHP Intelephense
Browse files Browse the repository at this point in the history
  • Loading branch information
MichelleBlanchette committed May 1, 2024
1 parent 4d7b8eb commit 5d64f79
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
34 changes: 32 additions & 2 deletions src/includes/class-html-builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ public static function get_relative_due( \stdClass $task ) : \stdClass {

} else {

$dt_string = $dt->format( 'M j' );
$dt_string = $dt_due->format( 'M j' );
$relative_due->status = 'later';
}

Expand Down Expand Up @@ -530,7 +530,8 @@ public static function get_oembed_for_url( string $url ) : string {
}

/**
* Gets the local API endpoint for retrieving an attachment.
* Gets the local API endpoint for retrieving an attachment's content
* for viewing.
*
* @since 3.7.0 Deprecated $post_id parameter.
* @since 3.5.0
Expand Down Expand Up @@ -570,6 +571,35 @@ public static function get_local_attachment_view_url(
);
}

/**
* Gets the local API endpoint for retrieving an attachment with
* the provided arguments.
*
* @see PTC_Completionist\REST_API\Attachments::handle_get_attachment()
*
* @since [unreleased]
*
* @param string $attachment_gid The Asana attachment's GID.
* @param array $args Optional. Additional arguments for the
* API endpoint which retrieves the attachment's data.
* @return string The local API endpoint URL.
*/
public static function get_local_attachment_url(
string $attachment_gid,
array $args = array()
) : string {

$args['_cache_key'] = 'get_local_attachment_url';
$args['attachment_gid'] = $attachment_gid;

$token = Request_Token::save( $args );

return add_query_arg(
array( 'token' => $token ),
rest_url( REST_API_NAMESPACE_V1 . '/attachments' )
);
}

/**
* Sanitizes content for allowed HTML tags for post content.
*
Expand Down
3 changes: 1 addition & 2 deletions src/public/rest-api/class-attachments.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,7 @@ public static function handle_get_attachment(
// Add request token for retrieving the attachment again.
$attachment->_ptc_refresh_url = HTML_Builder::get_local_attachment_url(
$attachment->gid,
-1,
$args['auth_user']
array( 'auth_user' => $args['auth_user'] )
);

// Ensure GID is stripped.
Expand Down

0 comments on commit 5d64f79

Please sign in to comment.