0
我想用一些複選框來構建一個小部件,但是我不知道如何保存值。 有沒有一種方法來保存它們,我差不多在完成我的小部件的最後,謝謝。 這部分我的代碼:在wordpress中構建一個帶有複選框選項的插件
function update($new_instance, $old_instance){
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']); // new_instance es el titulo que ingresa el usuario
$urlsprite = strip_tags($new_instance['urlsprite']);
$urlfacebook = strip_tags($new_instance['urlfacebook']);
$urltwitter = strip_tags($new_instance['urltwitter']);
$urlpicassa = strip_tags($new_instance['urlpicassa']);
$urlyoutube = strip_tags($new_instance['urlyoutube']);
$urlrss = strip_tags($new_instance['urlrss']);
$chkfacebook = $new_instance['chkfacebook'];
$chktwitter = $new_instance['chktwitter'];
$chkpicassa = $new_instance['chkpicassa'];
$chkyoutube = $new_instance['chkyoutube'];
$chkrss = $new_instance['chkrss'];
return $instance;
}
function widget($args, $instance){
extract($args);
<a id="facebook" target="_blank" href="<?php echo $instance['urlfacebook'] ?>"></a>
<a id="twitter" target="_blank" href="<?php echo $instance['urltwitter'] ?>"></a>
<a id="picassa" target="_blank" href="<?php echo $instance['urlpicassa'] ?>"></a>
<a id="youtube" target="_blank" href="<?php echo $instance['urlyoutube'] ?>"></a>
<a id="rss" target="_blank" href="<?php echo $instance['urlrss'] ?>"></a>
<?php
}