Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,34 @@ Inspects oEmbed providers, clears embed cache, and more.
wp embed
~~~

**EXAMPLES**

# Get embed HTML for a given URL.
$ wp embed fetch https://www.youtube.com/watch?v=dQw4w9WgXcQ
<iframe width="525" height="295" src="https://www.youtube.com/embed/dQw4w9WgXcQ?feature=oembed" ...

# Find cache post ID for a given URL.
$ wp embed cache find https://www.youtube.com/watch?v=dQw4w9WgXcQ --width=500
123

# List format,endpoint fields of available providers.
$ wp embed provider list
+------------------------------+-----------------------------------------+
| format | endpoint |
+------------------------------+-----------------------------------------+
| #https?://youtu\.be/.*#i | https://www.youtube.com/oembed |
| #https?://flic\.kr/.*#i | https://www.flickr.com/services/oembed/ |
| #https?://wordpress\.tv/.*#i | https://wordpress.tv/oembed/ |

# List id,regex,priority fields of available handlers.
$ wp embed handler list --fields=priority,id
+----------+-------------------+
| priority | id |
+----------+-------------------+
| 10 | youtube_embed_url |
| 9999 | audio |
| 9999 | video |
+----------+-------------------+



Expand Down Expand Up @@ -96,7 +123,20 @@ Retrieves oEmbed providers.
wp embed provider
~~~

**EXAMPLES**

# List format,endpoint fields of available providers.
$ wp embed provider list
+------------------------------+-----------------------------------------+
| format | endpoint |
+------------------------------+-----------------------------------------+
| #https?://youtu\.be/.*#i | https://www.youtube.com/oembed |
| #https?://flic\.kr/.*#i | https://www.flickr.com/services/oembed/ |
| #https?://wordpress\.tv/.*#i | https://wordpress.tv/oembed/ |

# Get the matching provider for the URL.
$ wp embed provider match https://www.youtube.com/watch?v=dQw4w9WgXcQ
https://www.youtube.com/oembed



Expand Down Expand Up @@ -196,7 +236,16 @@ Retrieves embed handlers.
wp embed handler
~~~

**EXAMPLES**

# List id,regex,priority fields of available handlers.
$ wp embed handler list --fields=priority,id
+----------+-------------------+
| priority | id |
+----------+-------------------+
| 10 | youtube_embed_url |
| 9999 | audio |
| 9999 | video |



Expand Down Expand Up @@ -259,7 +308,19 @@ Finds, triggers, and deletes oEmbed caches.
wp embed cache
~~~

**EXAMPLES**

# Find cache post ID for a given URL.
$ wp embed cache find https://www.youtube.com/watch?v=dQw4w9WgXcQ --width=500
123

# Clear cache for a post.
$ wp embed cache clear 123
Success: Cleared oEmbed cache.

# Triggers cache for a post.
$ wp embed cache trigger 456
Success: Caching triggered!



Expand Down
16 changes: 16 additions & 0 deletions src/Cache_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,22 @@

/**
* Finds, triggers, and deletes oEmbed caches.
*
* ## EXAMPLES
*
* # Find cache post ID for a given URL.
* $ wp embed cache find https://www.youtube.com/watch?v=dQw4w9WgXcQ --width=500
* 123
*
* # Clear cache for a post.
* $ wp embed cache clear 123
* Success: Cleared oEmbed cache.
*
* # Triggers cache for a post.
* $ wp embed cache trigger 456
* Success: Caching triggered!
*
* @package wp-cli
*/
class Cache_Command extends WP_CLI_Command {

Expand Down
29 changes: 29 additions & 0 deletions src/Embeds_Namespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,35 @@
/**
* Inspects oEmbed providers, clears embed cache, and more.
*
* ## EXAMPLES
*
* # Get embed HTML for a given URL.
* $ wp embed fetch https://www.youtube.com/watch?v=dQw4w9WgXcQ
* <iframe width="525" height="295" src="https://www.youtube.com/embed/dQw4w9WgXcQ?feature=oembed" ...
*
* # Find cache post ID for a given URL.
* $ wp embed cache find https://www.youtube.com/watch?v=dQw4w9WgXcQ --width=500
* 123
*
* # List format,endpoint fields of available providers.
* $ wp embed provider list
* +------------------------------+-----------------------------------------+
* | format | endpoint |
* +------------------------------+-----------------------------------------+
* | #https?://youtu\.be/.*#i | https://www.youtube.com/oembed |
* | #https?://flic\.kr/.*#i | https://www.flickr.com/services/oembed/ |
* | #https?://wordpress\.tv/.*#i | https://wordpress.tv/oembed/ |
*
* # List id,regex,priority fields of available handlers.
* $ wp embed handler list --fields=priority,id
* +----------+-------------------+
* | priority | id |
* +----------+-------------------+
* | 10 | youtube_embed_url |
* | 9999 | audio |
* | 9999 | video |
* +----------+-------------------+
*
* @package wp-cli
*/
class Embeds_Namespace extends CommandNamespace {
Expand Down
2 changes: 1 addition & 1 deletion src/Fetch_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ function ( $args ) use ( $response_size_limit ) {
remove_all_filters( 'oembed_dataparse' ); // Save a few cycles.
add_filter(
'oembed_dataparse',
function ( $ret, $data, $url ) {
function ( $ret, $data, $url ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter
return $data;
},
PHP_INT_MAX,
Expand Down
13 changes: 13 additions & 0 deletions src/Handler_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@

/**
* Retrieves embed handlers.
*
* ## EXAMPLES
*
* # List id,regex,priority fields of available handlers.
* $ wp embed handler list --fields=priority,id
* +----------+-------------------+
* | priority | id |
* +----------+-------------------+
* | 10 | youtube_embed_url |
* | 9999 | audio |
* | 9999 | video |
*
* @package wp-cli
*/
class Handler_Command extends WP_CLI_Command {
protected $default_fields = array(
Expand Down
17 changes: 17 additions & 0 deletions src/Provider_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,23 @@

/**
* Retrieves oEmbed providers.
*
* ## EXAMPLES
*
* # List format,endpoint fields of available providers.
* $ wp embed provider list
* +------------------------------+-----------------------------------------+
* | format | endpoint |
* +------------------------------+-----------------------------------------+
* | #https?://youtu\.be/.*#i | https://www.youtube.com/oembed |
* | #https?://flic\.kr/.*#i | https://www.flickr.com/services/oembed/ |
* | #https?://wordpress\.tv/.*#i | https://wordpress.tv/oembed/ |
*
* # Get the matching provider for the URL.
* $ wp embed provider match https://www.youtube.com/watch?v=dQw4w9WgXcQ
* https://www.youtube.com/oembed
*
* @package wp-cli
*/
class Provider_Command extends WP_CLI_Command {
protected $default_fields = array(
Expand Down