2011-09-26 90 views
1

什么是我的功能:自定义WordPress的选项功能

$var = get_option('to_twitter_feed'); 

array("name" => "Twitter Username", 
    "desc" => "Enter your Twitter username for the Twitter feed", 
    "id" => $shortname."_twitter_feed", 
    "type" => "text", 
    "std" => ""), 

在我的WordPress的选择我有一个自定义Twitter的部件。我希望用户能够简单地在输入中键入他们的名字,并将其插入到小部件代码中。大部分代码都是完整的:基本上,我只需要知道如何将第一个代码中调用的内容放到第二个代码中。

我怎么称呼它:

<?php echo get_option('to_twitter_feed'); ?> 

我需要把它变成代码(在那里说THEUSERNAME):

<script type='text/javascript'> 
    jQuery(function($){ 
     $(".tweet").tweet({ 
      username: "THEUSERNAME", 
      join_text: "auto", 
      avatar_size: 32, 
      count: 3, 
      auto_join_text_default: "said,", 
      auto_join_text_ed: "we", 
      auto_join_text_ing: "we were", 
      auto_join_text_reply: "replied to", 
      auto_join_text_url: "was checking out", 
      loading_text: "loading tweets..." 
     }); 
    }); 
</script> 
+0

是什么,当你写的print_r($ VAR)的输出; ? –

回答

7

如果获得

<?php echo get_option('to_twitter_feed'); ?> 
Twitter用户名

then

您可以在Java脚本设置的Twitter用户名这样

<script type='text/javascript'> 
    jQuery(function($){ 
     $(".tweet").tweet({ 
      username: "<?php echo get_option('to_twitter_feed'); ?>", 
      join_text: "auto", 
      avatar_size: 32, 
      count: 3, 
      auto_join_text_default: "said,", 
      auto_join_text_ed: "we", 
      auto_join_text_ing: "we were", 
      auto_join_text_reply: "replied to", 
      auto_join_text_url: "was checking out", 
      loading_text: "loading tweets..." 
     }); 
    }); 
</script>