Shortcode – How to call the url in the code
-
Hello,
I created my first shortcode. It was difficult but after several errors and trying again and again, it finally works. Now I’d like to improve it.
How can I have the path of the 2 files you will see in my code without writing all the path? I tried all the afternoon but not succeed; I do not know enough php.
For the skin file, I tried:
'skin' => "'. plugins_url() .'/jwplayer/six.xml",
But it returns : Error loading skin : File not found.
It seems that it is a little bit more complicated to do… Thank you in advance for your help. Sorry for my bad English.
PS: I know that exists a WordPress plugin for JWPlayer but I do not want to use it.
Here is the code that works:
function jo_video_jw($atts){ extract(shortcode_atts(array( 'myElement' => "myElement", 'width' => "100%", 'aspectratio' => '', 'autostart' => "false", 'file' => '', 'skin' => "https://localhost/xxx/wp-content/plugins/jwplayer/six.xml", 'image' => "https://localhost/xxx/wp-content/uploads/videos/messe.jpg" ), $atts)); $return = '<div id="'.$myElement.'">Loading the player...</div> <script type="text/javascript"> { jwplayer("'.$myElement.'").setup({ autostart: "'.$autostart.'", image: "'.$image.'", width: "'.$width.'", aspectratio: "'.$aspectratio.'", skin: "'.$skin.'", file: "'.$file.'", }); } </script>'; return $return; } add_shortcode('video_jw','jo_video_jw');
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Shortcode – How to call the url in the code’ is closed to new replies.