From 6b8f579cd0da97314c357c6fb948b4632428ab30 Mon Sep 17 00:00:00 2001 From: Justin Maurer Date: Tue, 26 Aug 2025 16:37:01 -0700 Subject: [PATCH 1/3] use Wp_Oembed singleton when working with providers --- features/add-oembed-provider.feature | 314 +++++++++++++++++++++++++++ src/Provider_Command.php | 3 +- 2 files changed, 316 insertions(+), 1 deletion(-) create mode 100644 features/add-oembed-provider.feature diff --git a/features/add-oembed-provider.feature b/features/add-oembed-provider.feature new file mode 100644 index 0000000..77b7ed8 --- /dev/null +++ b/features/add-oembed-provider.feature @@ -0,0 +1,314 @@ +Feature: Register and use custom oEmbed providers + + Background: + Given a WP install + And a filter-providers.php file: + """ + Date: Tue, 20 Jan 2026 12:25:21 +0100 Subject: [PATCH 2/3] Update features/add-oembed-provider.feature Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- features/add-oembed-provider.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/add-oembed-provider.feature b/features/add-oembed-provider.feature index 77b7ed8..3463637 100644 --- a/features/add-oembed-provider.feature +++ b/features/add-oembed-provider.feature @@ -276,7 +276,7 @@ Feature: Register and use custom oEmbed providers """ And STDOUT should contain: """ - audio.com/ + audio.com/ """ Scenario: Incompatible or wrong options From a3e03ff9c3c62557d5e03bb051e124da0cbf3005 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Tue, 20 Jan 2026 21:09:39 +0100 Subject: [PATCH 3/3] Fix `match` command too --- features/add-oembed-provider.feature | 9 ++++++++- src/Provider_Command.php | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/features/add-oembed-provider.feature b/features/add-oembed-provider.feature index 3463637..4ccfdde 100644 --- a/features/add-oembed-provider.feature +++ b/features/add-oembed-provider.feature @@ -276,7 +276,14 @@ Feature: Register and use custom oEmbed providers """ And STDOUT should contain: """ - audio.com/ + audio.com/ + """ + + Scenario: Match custom oEmbed provider after registration + When I run `wp embed provider match http://example.com/foo --require=filter-providers.php` + Then STDOUT should be: + """ + http://example.com/api/oembed.json """ Scenario: Incompatible or wrong options diff --git a/src/Provider_Command.php b/src/Provider_Command.php index 2a535d1..2a56151 100644 --- a/src/Provider_Command.php +++ b/src/Provider_Command.php @@ -147,7 +147,7 @@ public function list_providers( $args, $assoc_args ) { * @param array{discover?: bool, 'limit-response-size'?: string, 'link-type'?: 'json'|'xml', } $assoc_args Associative arguments. */ public function match_provider( $args, $assoc_args ) { - $oembed = new \WP_oEmbed(); + $oembed = _wp_oembed_get_object(); $url = $args[0]; $discover = Utils\get_flag_value( $assoc_args, 'discover', true );