jahid786
12/4/2017 - 2:19 AM

Costom Wizget

<?php 
function footer_sidebar(){
	
	register_sidebar(array(
	
		'name'=>'Footer Sidebar',
		'id'=>'footer_widget',
		'description'=>'This is our footer sidebar',
		'before_widget'=>'<div class="col-md-4"><div class="widget">',
		'after_widget'=>'</div></div>',
		'before_title'=>'<h3 class="widget-title">',
		'after_title'=>'</h3>',
	
	));
}
add_action( 'widgets_init', 'footer_sidebar' );

class footer_widget extends WP_Widget {

	function __construct() {
		// Instantiate the parent object
		parent::__construct( 
			'contact',
			'Contact_us'
		);
	}

	function widget( $args, $instance ) {
		// Widget output
		echo $args['before_widget'];
		if ( ! empty( $instance['title'] ) )
		?>
		<div class="widget-title">
		<h3><?php echo $instance['title'];?></h3>
		</div>
		<!-- /.widget-title -->
		<div class="address">
			<p>
				<span class="icon"><i class="fa fa-map-marker"></i></span>
				<span class="txt"> New Elephant Road, Suvastu Arcade, Level 10,Room 9C-1, Dhaka 1205 Dhaka, Bangladesh</span>
			</p>
			<p>
				<span class="icon"><i class="fa fa-phone"></i></span>
				<span class="txt"> +01535855519, 01775429594</span>
			</p>
			<p>
				<span class="icon"><i class="fa fa-envelope"></i></span>
				<span class="txt"> helloacademy777@gmail.com</span>
			</p>
		</div>
	<!-- /.address -->
	<?php
		echo $args['after_widget'];
	}

	function update( $new_instance, $old_instance ) {
		// Save widget options
		$instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';

		return $instance;
	}

	function form( $instance ) {
		// Output admin widget options form
		$title = ! empty( $instance['title'] ) ? $instance['title'] : __( 'Title Name Type' );
	?>
			<p>
			<lable>Contact Title</lable>
			<input type="text" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" value="<?php echo $title ?>">
		</p>
		<?php
	}
}

	function footer_widgets() {
	register_widget( 'footer_widget' );
}

add_action( 'widgets_init', 'footer_widgets' );