Closed alessandrocarrera closed 2 years ago
probably :-)
can you try this code snippet;
add_filter( 'lyte_content_preparse',
function( $in ) {
return str_replace( 'https://www.youtube.com/shorts/', 'https://www.youtube.com/watch?v=', $in );
}
);
@futtta thank you for your reply. I'm sorry but it not works. I find this link into the output on frontend:
httpv://www.youtube.com/watch?v=shorts/RN29WKHeMDs
strange ... how exactly did you add the short to a page/ post?
I pasted this link https://www.youtube.com/shorts/RN29WKHeMDs into the editor of a post. After updating it I still see this httpv://www.youtube.com/watch?v=shorts/RN29WKHeMDs
on the final output. I always see this strange output, before and after adding your custom filter into the Wordpress theme functions. Thank you again for your reply and please tell me if I can provide you more information! 😊
still strange, as I did the same thing (add the link in the editor) and it worked out of the box (even without the code snippet) ... Are you using a pagebuilder (Elementor/ Beaver Builder/ ...) or WordPress blocks (Gutenberg) or the classic editor?
@futtta I use classic editor. I try again in a Wordpress clean installation and I'll get back to you with more information. Thank you!
@futtta sorry for my delay. I tested the bug into a Wordpress clean installation with this details:
Everything updated at the last version. I'm still reproducing the problem. I create a new post, paste a lorem ipsum text, after a "shorts" YouTube video link like this and after a lorem ipsum text again. This is the frontend result:
I have this setting on WP YouTube Lyte:
I tried to fix using a similar solution like your filter into this reply and I resolved the problem with this snippet:
add_filter( 'lyte_content_preparse',
function( $in ) {
return str_replace( 'httpv://www.youtube.com/watch?v=shorts/', 'httpv://www.youtube.com/watch?v=', $in );
}
);
So, I think that into your code flow something do a pre-parse and it breaks the URL. With this filter (using a correct search parameter), I solve the problem and now I have this result:
Can you check it please and (if this is correct for you), can you release an update of your plugin? Thank you so much! 😊
I'm officially confused now; I set up a new site, same setup (theme & plugins including classic editor) and the short appears immediately, no code snippet needed.
With some additional echo'ing I saw that WordPress' oEmbed logic automatically changes the URL from https://www.youtube.com/shorts/RN29WKHeMDs
into https://youtu.be/RN29WKHeMDs?feature=oembed
which LYTE knows and acts upon, which explains why (for me at least) it worked out of the box ..
So I thought you must have disabled oEmbed, so I disable oEmbed (using code snippet from https://wordpress.stackexchange.com/a/267150) to test, but then I see the original https://www.youtube.com/shorts/RN29WKHeMDs
as URL, which LYTE does not handle by default. At that point the following code snippet (almost the same as the original one) makes things work;
add_filter( 'lyte_content_preparse',
function( $in ) {
return str_replace( 'https://www.youtube.com/shorts/', 'httpv://www.youtube.com/watch?v=', $in );
}
);
But I have not been able to get httpv://www.youtube.com/watch?v=shorts/RN29WKHeMDs
I'm afraid and looking at the code I don't understand how that would happen? :-/
@futtta I finally understood the problem! I test your code with a PHP live debugger and I found the exact point where your code generate the URL httpv://www.youtube.com/watch?v=shorts/RN29WKHeMDs
. So I searched into your github source the same point for showing it to you but when I compare the 2 functions I find some differences! Your 1.7.19
on Github (for the file wp-youtube-lyte.php
) is different from the 1.7.19
installed from Wordpress marketplace. This is the final DIFF:
https://www.diffchecker.com/aukzFyZM
Finally I did a "crazy monkey test" and I copy the source of the Github wp-youtube-lyte.php
into my local source of the clean installation of Wordpress and.... magic! It works and I have the same behavior of yours! So please can you synch your Github version with Wordpress marketplace and release it please? It is very important for me. Thank you so much! 😃
PS. I attach a screenshot of the interested part of the diff, too:
argh!! I briefly thought of that but forgot to compare myself. So simple! I'll push LYTE 1.7.20 out today :-)
On Fri, Oct 14, 2022 at 9:30 AM Alessandro Carrera @.***> wrote:
@futtta https://github.com/futtta I finally understood the problem! I test your code with a PHP live debugger and I found the exact point where your code generate the URL httpv:// www.youtube.com/watch?v=shorts/RN29WKHeMDs. So I searched into your github source the same point for showing it to you but when I compare the 2 functions I find some differences! Your 1.7.19 on Github (for the file wp-youtube-lyte.php) is different from the 1.7.19 installed from Wordpress marketplace. This is the final DIFF:
https://www.diffchecker.com/aukzFyZM
Finally I did a "crazy monkey test" and I copy the source of the Github wp-youtube-lyte.php into my local source of the clean installation of Wordpress and.... magic! It works and I have the same behavior of yours! So please can you synch your Github version with Wordpress marketplace and release it please? It is very important for me. Thank you so much! 😃
PS. I attach a screenshot of the interested part of the diff, too:
[image: diff] https://user-images.githubusercontent.com/74904794/195788212-9f656412-5bb4-4e0f-b485-977c445a5794.png
— Reply to this email directly, view it on GitHub https://github.com/futtta/wp-youtube-lyte/issues/32#issuecomment-1278601619, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABMIMOC5MRMJQXBQIVA4ALWDEDYHANCNFSM6AAAAAARBLTFTQ . You are receiving this because you were mentioned.Message ID: @.***>
@futtta Perfect! So I await the update! Thank you so much for your kindness 😄
released just now :)
thanks for reporting & insisting! :-)
released just now :) thanks for reporting & insisting! :-)
Good! I am happy to have made my contribution! Thank you, too! 😄
Currently the plugin not supports the YouTube "shorts" video format. You can see an example of this video format here:
https://www.youtube.com/shorts/RN29WKHeMDs
I think that implementing the support for this video format is simple because you still have the video ID into the URL. Thank you!