• 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({
    &#039;padding&#039;       : 6,
    //        &#039;autoScale&&#039;     : false,
            &#039;transitionIn&#039;  : &#039;elastic&#039;,
            &#039;transitionOut&#039; : &#039;elastic&#039;,
            &#039;speedIn&#039;: 500,
            &#039;speedOut&#039;: 500,
            &#039;title&#039;         : this.title,
            &#039;titlePosition&#039;   : 'inside',
            &#039;easingIn&#039;   : &#039;easeOutBack&#039;,
            &#039;easingOut&#039;   : &#039;easeInOutElastic&#039;,
            &#039;href&#039;          : this.href.replace(new RegExp(&quot;watch\\?v=&quot;, &quot;i&quot;), 'v/')+ &#039;&autoplay=1',
            &#039;type'          : 'swf',
            &#039;swf'           : {
                 &#039;wmode&#039;        : '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.