__( '自定义广告代码', 'Bing' ) ) ); $this->default_instance = array( 'title' => __( '广告', 'Bing' ), 'code' => '' ); } //小工具内容 function widget( $args, $instance ){ if( empty( $instance ) ) $instance = $this->default_instance; $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ); echo $args['before_widget']; if( !empty( $title ) ) echo $args['before_title'] . $title . $args['after_title']; echo $instance['code']; echo $args['after_widget']; } //保存设置选项 function update( $new_instance, $old_instance ){ $instance = array(); //标题 $instance['title'] = strip_tags( $new_instance['title'] ); //广告代码 $instance['code'] = force_balance_tags( $new_instance['code'] ); $instance['code'] = do_shortcode( $instance['code'] ); return $instance; } //设置表单 function form( $instance ){ $instance = wp_parse_args( $instance, $this->default_instance ); ?>