Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(E_ALL);
- /*
- Plugin Name: Custom Widget
- Plugin URI: http://wpguru.in
- Description: Custom Widget..
- Author: Rakesh Raja
- Version: 1.6
- Author URI: http://wpguru.in
- */
- /*main widget class starts here*/
- class wpg_textwidget extends WP_Widget {
- /*construct widget /display it */
- function __construct()
- {
- $params = array(
- 'description' => 'Simple Text Widget',
- 'name' => 'WPG Text Widget'
- );
- parent:: __construct('wpg_textwidget', '', $params);
- } /* construct of widget ends here */
- /*widget form starts here*/
- public function form($instance)
- {
- extract($instance);
- ?>
- <p>
- <label for="<?php echo $this->get_field_id( 'title' ); ?>"> Title: </label>
- <input type="text" class="widefat"
- id="<?php echo $this->get_field_id( 'title' ); ?>"
- name="<?php echo $this->get_field_name( 'title' ); ?>"
- value="<?php if( isset($title) ) echo esc_attr($title); ?>" />
- <label for="<?php echo $this->get_field_id( 'info' ); ?>"> Info: </label>
- <textarea class="widefat"
- id="<?php echo $this->get_field_id( 'info' ); ?>"
- name="<?php echo $this->get_field_name( 'info' ); ?>" ><?php if( isset($info) ) echo esc_attr($info); ?>
- </textarea>
- <?php
- } /* widget form ends here */
- /* this print widget on theme page */
- public function widget($args, $instance)
- {
- extract($args);
- extract($instance);
- echo $before_widget;
- echo $before_title . $title . $after_title;
- echo $info;
- echo $after_widget;
- }/* print widget ends here */
- } /*end if main widget class*/
- add_action('widgets_init', 'wpg_register_wpgtextwidget');
- function wpg_register_wpgtextwidget()
- {
- register_widget('wpg_textwidget');
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement