-
Notifications
You must be signed in to change notification settings - Fork 800
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
Shortcode: Get rid of custom shortcodes for YouTube and Vimeo in favor of Core #39096
Conversation
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available. Follow this PR Review Process:
Still unsure? Reach out in #jetpack-developers for guidance! Jetpack plugin: The Jetpack plugin has different release cadences depending on the platform:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
72d4cea
to
0c9ff78
Compare
* For bare URLs on their own line of the form. | ||
* | ||
* Accepted formats: | ||
* https://vimeo.com/289091934/cd1f466bcc |
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.
It would be worth making sure that Core handles this format as well. Those are private videos, iirc. See this issue for more information:
Automattic/wp-calypso#57257
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.
Will check! I thought it's not supported by Vimeo now 😂
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.
An example of a live video would be https://vimeo.com/635643256/b6a59a4d1e
An example of a video to purchase would be https://vimeo.com/555942796/e712a2e45d
I tested the video that needs to purchase, and it works well. However, the above live video is outdated so I cannot check whether the live video with the above format works or not. But I tested another live video, https://vimeo.com/1003283038, and it works!
In short, I assume Core supports the vimeo video with the above format, e.g.: https://vimeo.com/555942796/e712a2e45d
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.
I think it supports all format as the Core uses http://vimeo.com/api/oembed.json
endpoint to ask the information about the url, e.g. http://vimeo.com/api/oembed.json?url=http://vimeo.com/76979871
73d2b30
to
7f8c6bc
Compare
The failing |
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.
This is looking good. I have some minor remarks on actually releasing this, below.
Type: bugfix | ||
|
||
Shortcode: Get rid of custom shortcodes for Youtube and Vimeo in favor of Core |
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.
I would recommend updating this a bit:
Type: bugfix | |
Shortcode: Get rid of custom shortcodes for Youtube and Vimeo in favor of Core | |
Type: compat | |
Embeds: prioritize YouTube and Vimeo embeds provided by WordPress itself, over Jetpack's embedding solution. |
* | ||
* @return string Return output of Vimeo shortcode with the proper markup. | ||
*/ | ||
function wpcom_vimeo_embed_url( $matches, $attr, $url ) { |
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.
Instead of just removing the function, I would recommend marking it as deprecated first, and only remove it in a few releases. Since Vimeo embeds have been around for a long time, it's possible that third-parties currently do something with those functions.
Same for other functions in this PR.
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.
Updated!
@@ -186,7 +186,7 @@ public function test_replace_url_with_iframe_in_the_content( $url, $video_id ) { | |||
|
|||
global $post; | |||
|
|||
$post = self::factory()->post->create_and_get( array( 'post_content' => $url ) ); | |||
$post = self::factory()->post->create_and_get( array( 'post_content' => "[vimeo $url]" ) ); |
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.
Since the content goes from just a URL to a shortcode with a URL, should the function name be updated accordingly?
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.
Renamed to test_shortcodes_vimeo_replace_url_with_iframe_in_the_content
942b555
to
12433e4
Compare
@@ -250,6 +259,7 @@ class_exists( 'Jetpack_AMP_Support' ) | |||
* Callback to modify output of embedded Vimeo video using Jetpack's shortcode. | |||
* | |||
* @since 3.9 | |||
* @deprecated since x.x.x |
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.
You can use the $$next-version$$
placeholder; it will be automatically replaced on release.
jetpack/projects/packages/README.md
Lines 116 to 123 in d3f5823
When needing to add a package version number inside a DocBlock, please use `$$next-version$$` as such: | |
- `@since $$next-version$$` | |
- `@deprecated $$next-version$$` | |
- `@deprecated since $$next-version$$` | |
- `_deprecated_function( __METHOD__, 'package-$$next-version$$' );` (other WordPress deprecation functions also work, but note it must be all on one line). | |
The `$$next-version$$` specifier will be automatically replaced with the correct package version number the next time a new version of that package is released. |
* @deprecated since x.x.x | |
* @deprecated since $$next-version$$ |
@@ -278,21 +288,14 @@ function wpcom_vimeo_embed_url( $matches, $attr, $url ) { | |||
* http://player.vimeo.com/video/18427511 | |||
* | |||
* @since 3.9 | |||
* @deprecated since x.x.x |
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.
* @deprecated since x.x.x | |
* @deprecated since $$next-version$$ |
*/ | ||
function wpcom_youtube_embed_crazy_url( $matches, $attr, $url ) { | ||
return youtube_id( $url ); | ||
} | ||
|
||
/** | ||
* Add a new handler to automatically transform custom Youtube URLs (like playlists) into embeds. | ||
* | ||
* @deprecated since x.x.x |
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.
* @deprecated since x.x.x | |
* @deprecated since $$next-version$$ |
@@ -250,6 +259,7 @@ class_exists( 'Jetpack_AMP_Support' ) | |||
* Callback to modify output of embedded Vimeo video using Jetpack's shortcode. | |||
* | |||
* @since 3.9 | |||
* @deprecated since x.x.x |
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.
On top of that deprecation warning, I think you could add a warning to developers via _deprecated_function
:
https://developer.wordpress.org/reference/functions/_deprecated_function/
jetpack/docs/coding-guidelines.md
Lines 54 to 55 in f0fa2c8
- Deprecate classes, [functions](https://developer.wordpress.org/reference/functions/_deprecated_function/), and methods in the same way, while still returning its replacement if there is one. | |
- Deprecated code should remain in Jetpack for 6 months, so third-parties have time to find out about the deprecations and update their codebase. |
8676719-zen seems to report issues when trying to embed a private YouTube video. @arthur791004 Do you think you could take a look at that? |
I tested a scheduled video, and
Now the current experience on both editor and frontend is the same, it would be better to propose changes to Gutenberg to support it in the editor. Does it make sense?
BTW referring to https://wordpress.org/documentation/article/embeds/, it seems the “private” video is not supported by Core, and the scheduled video is a private video before the scheduled time. |
Yes, that would be a nice improvement. |
But the problem seems that the current YouTube oembed endpoint won't return the information of the private video 🥲 Here is the endpoint: |
…r of Core (#39096) * Shortcode: Get rid of custom shortcodes for Youtube and Vimeo in favor of Core * changelog * Fix tests * Fix lint * Fix tests * Extend regex * Don't need to mock http response * Add youtube test back * Update phan * Deprecate functions instead of removal * Update changelog * Rename tests * Fix lint * Use 54910next-version54910
Fixes Automattic/wp-calypso#91098
Fixes #7370
Proposed changes:
Other information:
Jetpack product discussion
Does this pull request change what data or activity we track or use?
Testing instructions: