[plugins] textarea and javascript
-
Hi!
I’m new on wordpress… and I coded a new plugin. But I have a big problem.
I use Fancybox to show some youtube-videos with this plugin. And to set some settings for fancybox i have to write a script in <script>-tags. This works fine.But, when I want to make this settings customizable, I can’t.
I will do this in an <textarea>
The default-settings are set at activation of the plugin in a function with this code:
function jquery_defaults() { $fb_settings_def = esc_attr(" 'padding' : 6, // 'autoScale' : false, 'transitionIn' : 'elastic', 'transitionOut' : 'elastic', 'speedIn': 500, 'speedOut': 500, 'title' : this.title, 'titlePosition' : 'inside', 'easingIn' : 'easeOutBack', 'easingOut' : 'easeInOutElastic', 'href' : this.href.replace(new RegExp(\"watch\\\?v=\", \"i\"), 'v/')+ '&autoplay=1', 'type' : 'swf', 'swf' : { 'wmode' : 'transparent', 'allowfullscreen' : 'true' }"); add_option('fb_settings_def', $fb_settings_def);
I need the “esc_attr” for displaying this code correctly in my textarea:
<textarea wrap="physical" cols="120" rows="30" name="fb_settings" id="fb_settings" aria-describedby="newcontent-description"> <?php echo get_option('fb_settings_def'); ?> </textarea>
And i try to write this settings into the page in <script>-tags with:
<script type="text/javascript"> jQuery(function(){ //jQuery-fancybox jQuery("#youtube_fancybox_<?php echo $ytid . "-" . $rz; ?>").click(function() { jQuery.fancybox({ <?php echo esc_attr_e(get_option('fb_settings_def')); ?> 'width' : '<?php echo $video_x; ?>', 'height' : '<?php echo $video_y; ?>', }); return false; }); }) </script>
But the result is:
jQuery(function(){ //jQuery-fancybox jQuery("#youtube_fancybox_Lr184Ms5hlE-813").click(function() { jQuery.fancybox({ 'padding' : 6, // 'autoScale&' : false, 'transitionIn' : 'elastic', 'transitionOut' : 'elastic', 'speedIn': 500, 'speedOut': 500, 'title' : this.title, 'titlePosition' : 'inside', 'easingIn' : 'easeOutBack', 'easingOut' : 'easeInOutElastic', 'href' : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/')+ '&autoplay=1', 'type' : 'swf', 'swf' : { 'wmode' : 'transparent', 'allowfullscreen' : 'true' } 'width' : '800', 'height' : '600', }); return false; }); })
How can i do this right?
- The topic ‘[plugins] textarea and javascript’ is closed to new replies.