Skip to content

feat: can now embed youtube videos and shorts #1109

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

Merged
merged 3 commits into from
Aug 7, 2025

Conversation

RaduCristianPopescu
Copy link
Contributor

@RaduCristianPopescu RaduCristianPopescu commented Jul 29, 2025

Summary

Will affect visual aspect of the product

YES

Screenshots

CleanShot 2025-07-29 at 15 41 00@2x

Test instructions

Check before Pull Request is ready:

Closes https://github.com/Codeinwp/feedzy-rss-feeds-pro/issues/841

@RaduCristianPopescu RaduCristianPopescu self-assigned this Jul 29, 2025
@RaduCristianPopescu RaduCristianPopescu added the pr-checklist-skip Allow this Pull Request to skip checklist. label Jul 29, 2025
@pirate-bot pirate-bot added the pr-checklist-complete The Pull Request checklist is complete. (automatic label) label Jul 29, 2025
@pirate-bot
Copy link
Contributor

pirate-bot commented Jul 29, 2025

Plugin build for 6ea271a is ready 🛎️!

Note

You can preview the changes in the Playground

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for embedding YouTube videos and shorts in RSS feed imports for free users. The implementation extracts YouTube video descriptions from RSS feeds and automatically embeds the videos using WordPress shortcodes.

  • Adds a new method to handle YouTube-specific content processing
  • Extracts video descriptions from YouTube RSS feeds using media RSS namespace
  • Automatically appends embed shortcodes for YouTube URLs

Comment on lines 234 to 236
// remove all dots in the hostname so that shortforms such as youtu.be can also be resolved.
$host = str_replace( array( '.', 'www' ), '', $host );
Copy link
Preview

Copilot AI Jul 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The string replacement logic is flawed. Removing 'www' as a substring will affect other parts of the hostname (e.g., 'wwwexample.com' becomes 'example.com'). Use a more precise approach like preg_replace('/^www\./', '', $host) after removing dots.

Suggested change
// remove all dots in the hostname so that shortforms such as youtu.be can also be resolved.
$host = str_replace( array( '.', 'www' ), '', $host );
// Remove the 'www.' prefix from the hostname if it exists.
$host = preg_replace( '/^www\./', '', $host );
// Remove all dots in the hostname so that shortforms such as youtu.be can also be resolved.
$host = str_replace( '.', '', $host );

Copilot uses AI. Check for mistakes.

Comment on lines 234 to 238
// remove all dots in the hostname so that shortforms such as youtu.be can also be resolved.
$host = str_replace( array( '.', 'www' ), '', $host );

// youtube.
if ( in_array( $host, array( 'youtubecom', 'youtube' ), true ) ) {
Copy link
Preview

Copilot AI Jul 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hostname check is incomplete. After removing dots, 'youtu.be' becomes 'youtube', but 'youtube.com' becomes 'youtubecom'. You should also include 'youtube' (for youtu.be) in the array or use a different approach to handle both domains properly.

Suggested change
// remove all dots in the hostname so that shortforms such as youtu.be can also be resolved.
$host = str_replace( array( '.', 'www' ), '', $host );
// youtube.
if ( in_array( $host, array( 'youtubecom', 'youtube' ), true ) ) {
// Normalize the hostname by removing 'www.' if present.
$host = preg_replace( '/^www\./', '', $host );
// Check if the hostname matches any valid YouTube domains.
if ( in_array( $host, array( 'youtube.com', 'youtu.be' ), true ) ) {

Copilot uses AI. Check for mistakes.

$item_array['item_content'] = $desc;
}
if ( ( empty( $sc ) || 'yes' === $sc['summary'] ) && empty( $item_array['item_description'] ) ) {
if ( is_numeric( $sc['summarylength'] ) && strlen( $desc ) > $sc['summarylength'] ) {
Copy link
Preview

Copilot AI Jul 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code assumes $sc['summarylength'] exists when $sc is not empty, but there's no validation that this key exists in the array. This could cause a PHP notice or error if the key is missing.

Suggested change
if ( is_numeric( $sc['summarylength'] ) && strlen( $desc ) > $sc['summarylength'] ) {
if ( isset( $sc['summarylength'] ) && is_numeric( $sc['summarylength'] ) && strlen( $desc ) > $sc['summarylength'] ) {

Copilot uses AI. Check for mistakes.

Comment on lines 259 to 260
if ( str_contains( $item_array['item_content'], 'Post Content' ) ) {
$item_array['item_content'] = '[embed]' . $url . '[/embed]' ;
Copy link
Preview

Copilot AI Jul 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The magic string 'Post Content' appears to be a hardcoded check for some default content. This should be defined as a constant or documented to explain what this specific string represents and why it's being checked.

Suggested change
if ( str_contains( $item_array['item_content'], 'Post Content' ) ) {
$item_array['item_content'] = '[embed]' . $url . '[/embed]' ;
if ( str_contains( $item_array['item_content'], self::DEFAULT_ITEM_CONTENT ) ) {
$item_array['item_content'] = '[embed]' . $url . '[/embed]';

Copilot uses AI. Check for mistakes.

}
}
if ( str_contains( $item_array['item_content'], 'Post Content' ) ) {
$item_array['item_content'] = '[embed]' . $url . '[/embed]' ;
Copy link
Preview

Copilot AI Jul 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra space before the semicolon. Should be [/embed]'; instead of [/embed]' ;

Suggested change
$item_array['item_content'] = '[embed]' . $url . '[/embed]' ;
$item_array['item_content'] = '[embed]' . $url . '[/embed]';

Copilot uses AI. Check for mistakes.

@Soare-Robert-Daniel Soare-Robert-Daniel merged commit 5835fea into development Aug 7, 2025
9 checks passed
@Soare-Robert-Daniel Soare-Robert-Daniel deleted the fix/embed_youtube branch August 7, 2025 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-checklist-complete The Pull Request checklist is complete. (automatic label) pr-checklist-skip Allow this Pull Request to skip checklist.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants