我爲Wordpress創建了一個自定義Flickr小部件,併成功地爲用戶輸入了他們的Flickr信息設置了一個選項表單,但是我無法獲取表單中的複選框以保存是否被選中。任何幫助將不勝感激!這裏是我的部件(),窗體()和更新()的功能:保存wordpress小部件問題中的複選框值
function widget($args, $instance) {
extract($args);
$title = apply_filters('widget_title', $instance['title']);
$displaynum = $instance['displaynum'];
$flickrid = $instance['flickrname'];
$num = 6;
$feed = new SimplePie($instance['feed']);
$feed->handle_content_type();
$photostream = $instance['show_photostream'];
function update($new_instance, $old_instance) {
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
$instance['displaynum'] = strip_tags($new_instance['displaynum']);
$instance['feed'] = $new_instance['feed'];
$instance['flickrname'] = $new_instance['flickrname'];
$instance['show_photostream'] = (bool) $new_instance['show_photostream'];
return $instance;
}
function form($instance) {
$defaults = array (
'title' => 'My Recent Flickr Uploads',
'displaynum' => 6,
'feed' => 'http://api.flickr.com/services/feeds/[email protected]&lang=en-us&format=rss_200',
'flickrname' => 'rastajellyfish',
'show_photostream' => isset($instance['show_photostream']) ? (bool) $instance['show_photostream'] : false
);
$instance = wp_parse_args((array) $instance, $defaults); ?>
任何幫助將不勝感激!
你給了複選框一個名字?我知道未選中的複選框不會作爲_POST/_GET中的變量傳遞。 – Steven 2010-09-03 20:16:16
它確實分配了一個名稱。 – 2010-09-05 18:52:31