Coder Social home page Coder Social logo

Comments (13)

futtta avatar futtta commented on August 29, 2024 1

released just now :)

thanks for reporting & insisting! :-)

from wp-youtube-lyte.

futtta avatar futtta commented on August 29, 2024

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 );
    }
);

from wp-youtube-lyte.

alessandrocarrera avatar alessandrocarrera commented on August 29, 2024

@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

from wp-youtube-lyte.

futtta avatar futtta commented on August 29, 2024

strange ... how exactly did you add the short to a page/ post?

from wp-youtube-lyte.

alessandrocarrera avatar alessandrocarrera commented on August 29, 2024

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! 😊

from wp-youtube-lyte.

futtta avatar futtta commented on August 29, 2024

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?

from wp-youtube-lyte.

alessandrocarrera avatar alessandrocarrera commented on August 29, 2024

@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!

from wp-youtube-lyte.

alessandrocarrera avatar alessandrocarrera commented on August 29, 2024

@futtta sorry for my delay. I tested the bug into a Wordpress clean installation with this details:

  • WordPress 6.0.2
  • Theme Twenty Twenty-Two 1.2
  • Plugin Classic Editor 1.6.2
  • Plugin WP YouTube Lyte 1.7.19

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:


1


I have this setting on WP YouTube Lyte:


2


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:


3


Can you check it please and (if this is correct for you), can you release an update of your plugin? Thank you so much! 😊

from wp-youtube-lyte.

futtta avatar futtta commented on August 29, 2024

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? :-/

from wp-youtube-lyte.

alessandrocarrera avatar alessandrocarrera commented on August 29, 2024

@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:

diff

from wp-youtube-lyte.

futtta avatar futtta commented on August 29, 2024

from wp-youtube-lyte.

alessandrocarrera avatar alessandrocarrera commented on August 29, 2024

@futtta Perfect! So I await the update! Thank you so much for your kindness 😄

from wp-youtube-lyte.

alessandrocarrera avatar alessandrocarrera commented on August 29, 2024

released just now :)
thanks for reporting & insisting! :-)

Good! I am happy to have made my contribution! Thank you, too! 😄

from wp-youtube-lyte.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.