2011-09-26 146 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>