-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Add Threads as an oEmbed provider #11252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
pestevez
wants to merge
10
commits into
WordPress:trunk
Choose a base branch
from
pestevez:add/threads-oembed-provider
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+124
−0
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ec8f627
Add Threads as an oEmbed provider
pestevez 8555167
Fix array alignment per WordPress coding standards
pestevez 46af13b
Merge branch 'trunk' into add/threads-oembed-provider
pestevez fb03e0e
Update src/wp-includes/class-wp-oembed.php
pestevez d8d4009
Update tests/phpunit/tests/oembed/wpOembedThreadsProvider.php
pestevez 18172d2
Update tests/phpunit/tests/oembed/wpOembedThreadsProvider.php
pestevez 09ff93f
Update tests/phpunit/tests/oembed/wpOembedThreadsProvider.php
pestevez 660939a
Update tests/phpunit/tests/oembed/wpOembedThreadsProvider.php
pestevez 301ead7
Update tests/phpunit/tests/oembed/wpOembedThreadsProvider.php
pestevez 2794932
Update tests/phpunit/tests/oembed/wpOembedThreadsProvider.php
pestevez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * Tests for the Threads oEmbed provider. | ||
| * | ||
| * @group oembed | ||
| * | ||
| * @covers WP_oEmbed::get_provider | ||
| */ | ||
| class Tests_oEmbed_wpOembedThreadsProvider extends WP_UnitTestCase { | ||
|
|
||
| protected WP_oEmbed $oembed; | ||
|
|
||
| public function set_up(): void { | ||
| parent::set_up(); | ||
|
|
||
| require_once ABSPATH . WPINC . '/class-wp-oembed.php'; | ||
| $this->oembed = _wp_oembed_get_object(); | ||
| } | ||
|
|
||
| /** | ||
| * @dataProvider data_threads_provider_urls | ||
| * | ||
| * @param string $url The URL to test. | ||
| * @param string $expected The expected oEmbed provider URL. | ||
| */ | ||
| public function test_threads_provider_url( string $url, string $expected ): void { | ||
| $provider = $this->oembed->get_provider( $url, array( 'discover' => false ) ); | ||
| $this->assertSame( $expected, $provider ); | ||
| } | ||
|
|
||
| /** | ||
| * Data provider for valid Threads URLs. | ||
| * | ||
| * @return array<string, array{ 0: string, 1: string }> | ||
| */ | ||
| public function data_threads_provider_urls(): array { | ||
| return array( | ||
| // threads.com post URLs. | ||
| 'threads.com post URL' => array( | ||
| 'https://www.threads.com/@zuck/post/C1234567890', | ||
| 'https://graph.threads.com/oembed', | ||
| ), | ||
| 'threads.com post URL no www' => array( | ||
| 'https://threads.com/@zuck/post/C1234567890', | ||
| 'https://graph.threads.com/oembed', | ||
| ), | ||
| 'threads.com post URL http' => array( | ||
| 'http://www.threads.com/@zuck/post/C1234567890', | ||
| 'https://graph.threads.com/oembed', | ||
| ), | ||
|
|
||
| // threads.com short URLs. | ||
| 'threads.com short URL' => array( | ||
| 'https://www.threads.com/t/C1234567890', | ||
| 'https://graph.threads.com/oembed', | ||
| ), | ||
| 'threads.com short URL no www' => array( | ||
| 'https://threads.com/t/C1234567890', | ||
| 'https://graph.threads.com/oembed', | ||
| ), | ||
| 'threads.com short URL http' => array( | ||
| 'http://www.threads.com/t/C1234567890', | ||
| 'https://graph.threads.com/oembed', | ||
| ), | ||
|
|
||
| // threads.net post URLs. | ||
| 'threads.net post URL' => array( | ||
| 'https://www.threads.net/@zuck/post/C1234567890', | ||
| 'https://graph.threads.com/oembed', | ||
| ), | ||
| 'threads.net post URL no www' => array( | ||
| 'https://threads.net/@zuck/post/C1234567890', | ||
| 'https://graph.threads.com/oembed', | ||
| ), | ||
|
|
||
| // threads.net short URLs. | ||
| 'threads.net short URL' => array( | ||
| 'https://www.threads.net/t/C1234567890', | ||
| 'https://graph.threads.com/oembed', | ||
| ), | ||
| 'threads.net short URL no www' => array( | ||
| 'https://threads.net/t/C1234567890', | ||
| 'https://graph.threads.com/oembed', | ||
| ), | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * @dataProvider data_threads_non_matching_urls | ||
| * | ||
| * @param string $url The URL to test. | ||
| */ | ||
| public function test_threads_provider_does_not_match_non_post_urls( string $url ): void { | ||
| $provider = $this->oembed->get_provider( $url, array( 'discover' => false ) ); | ||
| $this->assertFalse( $provider ); | ||
| } | ||
|
|
||
| /** | ||
| * Data provider for URLs that should not match the Threads provider. | ||
| * | ||
| * @return array<string, array{ 0: string }> | ||
| */ | ||
| public function data_threads_non_matching_urls(): array { | ||
| return array( | ||
| 'threads.com profile URL' => array( | ||
| 'https://www.threads.com/@zuck', | ||
| ), | ||
| 'threads.com homepage' => array( | ||
| 'https://www.threads.com/', | ||
| ), | ||
| 'threads.com search' => array( | ||
| 'https://www.threads.com/search', | ||
| ), | ||
| 'non-threads URL with threads in path' => array( | ||
| 'https://example.com/threads/post/123', | ||
| ), | ||
| ); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add
@ticketannotation to all new tests