WordPress.org

Make WordPress Core

Opened 5 weeks ago

Closed 5 weeks ago

Last modified 5 weeks ago

#54358 closed task (blessed) (fixed)

Add URL Details endpoint from Gutenberg plugin into Core

Reported by: hellofromTonya Owned by: hellofromTonya
Milestone: 5.9 Priority: normal
Severity: normal Version:
Component: Editor Keywords: has-patch has-unit-tests
Focuses: rest-api Cc:

Description

Adds the new URL Details endpoint to the REST API to allow retrieval of information about a remote URL.

Tests and code will need adjustment for newer changes in 5.9 including tests and PHP 8.1.

Change History (17)

This ticket was mentioned in PR #1794 on WordPress/wordpress-develop by hellofromtonya.


5 weeks ago

  • Keywords has-patch has-unit-tests added

Ports the URL Details from the Gutenberg repo to Core.

Updates the code to the newest changes in Core including: tests, PHP 8.1, standards, etc.

Trac ticket: https://core.trac.wordpress.org/ticket/54358

#2 @prbot
5 weeks ago

hellofromtonya commented on PR #1794:

Hey @TimothyBJacobs, If you get time, could you please do a confidence check review as @getdave is on holiday?

#3 @prbot
5 weeks ago

TimothyBJacobs commented on PR #1794:

This looks great to me!

#4 @TimothyBlynJacobs
5 weeks ago

  • Keywords commit added

#5 @hellofromTonya
5 weeks ago

  • Owner set to hellofromTonya
  • Status changed from new to accepted

#6 @hellofromTonya
5 weeks ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 51973:

REST API: Add URL Details endpoint.

Adds a new REST API endpoint (/wp-block-editor/v1/url-details) for retrieving information from an external URL.

Information retrieved:

  • Title: content of the <title> element
  • Icon: favicon image link
  • Description: content of the description or og:description meta element
  • Image: OG image link

This endpoint is used by the block editor for link previews.

Props get_dave, aduth, andraganescu, beaulebens, hellofromTonya, kevin940726, mamaduka, marekhrabe, mnelson4, noisysocks, obenland, ocean90, retrofox, shaunandrews, spacedmonkey, swissspidy, timothyblynjacobs, xknown, youknowriad.
Fixes #54358.

#7 @swissspidy
5 weeks ago

The translatable strings added in [51973] should use sprintf with placeholders instead of containg HTML tags correctly.

e.g. The OG image link of the <meta property="og:image"> or <meta property="og:image:url"> element from the URL. should really be The OG image link of the %1$s or %2$s element from the URL.. The placeholders can be explained in a translators comment.

Also, translators don't necessarily know what "OG" is. Maybe use "Open Graph image link" instead of "OG image link", or just "image link"?

#9 @swissspidy
5 weeks ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

Also, filters like rest_prepare_url_details need @since annotations.

#10 @hellofromTonya
5 weeks ago

  • Keywords commit removed

Thank you @swissspidy! I'll create a follow-up patch shortly with those changes.

#11 @swissspidy
5 weeks ago

The $remote_url_response of the rest_prepare_url_details filter is described as an array, but is a string.

This ticket was mentioned in PR #1797 on WordPress/wordpress-develop by hellofromtonya.


5 weeks ago

Follow-up to changeset https://core.trac.wordpress.org/changeset/51973 to improve:

  • Translations by removing HTML tags and spelling out OG
  • Adding @since param to new filters
  • Improving comments for code standards and consistency
  • Improving readability by making multiple args multiline
  • Micro-optimizations to avoid unnecessary variable assignments

Trac ticket: https://core.trac.wordpress.org/ticket/54358

#13 @prbot
5 weeks ago

hellofromtonya commented on PR #1797:

@swissspidy This PR addresses the code review improvements you mentioned in the ticket. Could you please review the PR? Thanks!

#14 @prbot
5 weeks ago

hellofromtonya commented on PR #1797:

Thank you @swissspidy!

Hey @SergeyBiryukov, Could you please review the PR? Thanks!

#15 @hellofromTonya
5 weeks ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 52008:

REST API: Improve translations, comments, and readability in URL Details endpoint.

Improvements:

  • Removes HTML tags from translatable strings. Uses sprintf with placeholder and translators comment.
  • Spells out "OG" to "Open Graph" to help translators.
  • Adds @since param to new filters.
  • Improves comments for code standards and consistency.
  • Improves readability by making multiple args multiline.
  • Micro-optimizations to avoid unnecessary variable assignments.

Follow-up to [51973].

Props hellofromTonya, sergeybiryukov, swissspidy.
Fixes #54358.

#17 @prbot
5 weeks ago

getdave commented on PR #1794:

Thank you @hellofromtonya 🙇

Note: See TracTickets for help on using tickets.