【发布时间】:2015-05-04 14:37:40
【问题描述】:
我的 Wordpress 小部件中有这 2 个功能,但我无法使用表单功能来获取小部件选项的默认值或保存值。
private static function get_defaults() {
$defauls = array(
'title' => '' ,
'subtitle' => '' ,
'columns' => '4' ,
'ntax' => '' ,
'showposts' => '12' ,
'imagesize' => 'medium' ,
'posttype' => '' ,
'exclude' => '' ,
'terms' => '' ,
'border' => '' ,
'padding' => ''
);
return $defaults;
}
/**
* Generates the administration form for the widget.
*
* @param array instance The array of keys and values for the widget.
*/
public function form( $instance ) {
$instance = wp_parse_args(
(array)$instance,self::get_defaults()
);
【问题讨论】: