Title: Error generating variable based on Youtube ID
Last modified: April 1, 2020

---

# Error generating variable based on Youtube ID

 *  Resolved [fabioaarito](https://wordpress.org/support/users/fabioaarito/)
 * (@fabioaarito)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/error-generating-variable-based-on-youtube-id/)
 * Hey guys,
 * First of all, thank you for your amazing work with this plugin.
 * I think I found a bug in the generator of the $selector variable you are using
   to generate an element id for the player.
    You are doing that based on the youtube
   video ID and you are assuming the ID is the last 4 characters of the youtube 
   video.
 * There are situations where the youtube video has special characters (even in 
   the last 4 characters). If that happens your shortcode will fail because you 
   have a JS variable that is the $selector and variables can’t have special characters.
 * Example:
    – Youtube ID: ybCsxtpp-Q – $id = ybCsxtpp-Q – $selector = pp-Q
 * In this case you will see a JS error:
 * > “Uncaught SyntaxError: Missing initializer in const declaration”
 * because the const name is “pp-Q”.
 * In my option it’s ok to have “-” in the selector variable but we can’t use it
   as a variable name.
    Other option is to use another approach to extract the $
   id where you can ensure the variable won’t have special characters.
 * Thank you again for your amazing contribution.

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Abu Hayat](https://wordpress.org/support/users/abuhayat/)
 * (@abuhayat)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/error-generating-variable-based-on-youtube-id/#post-12613455)
 * Hi
    Thanks for the feedback, I will fix it soon ! Have a nice day !
 *  Plugin Author [Abu Hayat](https://wordpress.org/support/users/abuhayat/)
 * (@abuhayat)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/error-generating-variable-based-on-youtube-id/#post-12617906)
 * [@fabioaarito](https://wordpress.org/support/users/fabioaarito/) I have updated
   my plugin few second ago and fixed the issue, Thanks for your collaboration. 
   I appreciate your rating / review.
    Have a nice day !
 *  Thread Starter [fabioaarito](https://wordpress.org/support/users/fabioaarito/)
 * (@fabioaarito)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/error-generating-variable-based-on-youtube-id/#post-12617920)
 * Thank you for the quick fix 🙂 I’ll update the plugin during the weekend.
    And
   I’ll certainly provide a rating for your amazing work 🙂

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Error generating variable based on Youtube ID’ is closed to new replies.

 * ![](https://ps.w.org/yt-player/assets/icon-128x128.png?rev=3050695)
 * [YT Player – Embed and Customize Video Players](https://wordpress.org/plugins/yt-player/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/yt-player/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/yt-player/)
 * [Active Topics](https://wordpress.org/support/plugin/yt-player/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/yt-player/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/yt-player/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [fabioaarito](https://wordpress.org/support/users/fabioaarito/)
 * Last activity: [6 years, 2 months ago](https://wordpress.org/support/topic/error-generating-variable-based-on-youtube-id/#post-12617920)
 * Status: resolved