Skip to content
Cristi Burcă edited this page Jun 5, 2013 · 3 revisions

The scbWidget class is useful if you want to use scbForms inside widgets.

Example usage:

<?php

class MyWidget extends scbWidget {

	protected $defaults = array(
		'title' => '',
		'description' => 'example'
	);

	function __construct() {
		parent::__construct( 'my-widget', __( 'My Widget', 'my-textdomain' ), array(
			'description' => __( 'An example widget', 'my-textdomain' )
		) );
	}

	function form( $instance ) {
		echo html( 'p', $this->input( array(
			'type' => 'text',
			'name' => 'title',
			'desc' => __( 'Title:', 'my-textdomain' )
		), $instance ) );

		echo html( 'p', $this->input( array(
			'type' => 'textarea',
			'name' => 'description',
			'desc' => __( 'Description:', 'my-textdomain' )
		), $instance ) );
	}

	function content( $instance ) {
		echo wpautop( $instance['description'] );
	}
}

scbWidget::init( 'MyWidget' );
Clone this wiki locally