不久前,我学会了如何在WordPress上创建插件。然而,WordPress改变了周围的一切,我正在尝试使用新的WordPress格式创建同样的插件。我已经阅读了一些东西,但试图直接通过修改WordPress文本字段插件(我重做插件的目标之一是让它多次可用)。我知道代码真的很粗糙,但我被卡住了。我试着添加了两个新的字段,只是为了看看事情的进展,当我去编辑小部件时,一旦你点击标题上的保存,第一个文本区数据被保存,其他两个字段就消失了。
我有一种感觉,我遗漏了一些明显的东西,但我似乎就是弄不明白。代码如下:
'widget_text','description‘=> __(’文本或超文本标记语言‘);$control_ops = => (’width‘widget 400,’=>‘=> 350);$this->WP_ widget( 'text',__(’多摘录‘),$widget_ops,$control_ops);}函数widget( $args,$instance ){ extract($args);$title = apply_filters( 'widget_title',空( $instance‘title’)?'‘:$instance'title',$instance );$text = apply_filters( 'widget_text',$instance'text',$instance );$texta = apply_filters( 'widget_text',$instance’$texta‘,$instance );$posts =$instance’‘posts’;echo $before_widget;if ( !empty( $title )){ echo $before_title。$title。$after_title;} ?> '','text‘=> '','posts’=> '','texta‘=> '’) );$title =strip_tags($instance‘=>’);$text = format_to_edit($instance'text');$texta =format_to_edit($instance‘$texta’);$posts =$instance‘’posts‘;?>
get_field_id('title');?>"> get_field_id('title');?>“name="get_field_name('title');?>”type="text“value="”/>
get\_field\_id('text'); ?>" name="get\_field\_name('text'); ?>"> get\_field\_id('texta'); ?>" name="get\_field\_name('texta'); ?>"> get_field_id('posts');?>“>帖子: get_field_id('posts');?>”name="get_field_name('posts');?>“type="text”value="“/>
提前谢谢。
发布于 2009-10-06 00:30:20
编辑:我发现我最初的答案有点正确。以下是解决问题所需的详细信息。
将WP_Widget_Excerpt函数更改为:
function WP_Widget_Excerpt() {
$widget_ops = array('classname' => 'WP_Widget_Excerpt', 'description' => __('Text or HTML'));
$control_ops = array('width' => 400, 'height' => 350);
$this->WP_Widget('WP_Widget_Excerpt', __('Multi Excerpt'), $widget_ops, $control_ops);
}发布于 2009-11-19 21:12:32
如果您的小部件正在做一些简单的事情,您可以使用Widgetifyr.com为您创建您的小部件。我创建了旧样式的小部件以及新的基于2.8+类的小部件。这样你的小部件就可以在更多版本的Wordpress上运行。
https://stackoverflow.com/questions/1520224
复制相似问题