| 1 |
<?php |
| 2 |
add_action('widgets_init', 'uwp_init_register_widget'); |
| 3 |
function uwp_init_register_widget() { |
| 4 |
register_widget("UWP_Register_Widget"); |
| 5 |
} |
| 6 |
class UWP_Register_Widget extends WP_Widget |
| 7 |
{ |
| 8 |
|
| 9 |
/** |
| 10 |
* Class constructor. |
| 11 |
*/ |
| 12 |
function __construct() |
| 13 |
{ |
| 14 |
$widget_ops = array( |
| 15 |
'description' => __('Displays Register Form', 'userswp'), |
| 16 |
'classname' => 'uwp_progress_users', |
| 17 |
); |
| 18 |
parent::__construct(false, $name = _x('UWP > Register', 'widget name', 'userswp'), $widget_ops); |
| 19 |
|
| 20 |
} |
| 21 |
|
| 22 |
/** |
| 23 |
* Display the widget. |
| 24 |
* |
| 25 |
* @param array $args Widget arguments. |
| 26 |
* @param array $instance The widget settings, as saved by the user. |
| 27 |
*/ |
| 28 |
function widget($args, $instance) |
| 29 |
{ |
| 30 |
if (is_user_logged_in()) { |
| 31 |
return; |
| 32 |
} |
| 33 |
extract($args, EXTR_SKIP); |
| 34 |
$title = empty($instance['title']) ? __('Register', 'userswp') : apply_filters('uwp_register_widget_title', $instance['title']); |
| 35 |
|
| 36 |
echo '<div class="uwp_widgets">'; |
| 37 |
echo $before_widget; |
| 38 |
if ($title) { |
| 39 |
echo $before_title . $title . $after_title; |
| 40 |
} |
| 41 |
echo do_shortcode('[uwp_register]'); |
| 42 |
echo $after_widget; |
| 43 |
echo '</div>'; |
| 44 |
} |
| 45 |
|
| 46 |
function update($new_instance, $old_instance) |
| 47 |
{ |
| 48 |
//save the widget |
| 49 |
$instance = $old_instance; |
| 50 |
$instance['title'] = strip_tags($new_instance['title']); |
| 51 |
return $instance; |
| 52 |
} |
| 53 |
|
| 54 |
function form($instance) |
| 55 |
{ |
| 56 |
//widgetform in backend |
| 57 |
$instance = wp_parse_args((array)$instance, array( |
| 58 |
'title' => __('Register', 'userswp'), |
| 59 |
)); |
| 60 |
$title = strip_tags($instance['title']); |
| 61 |
?> |
| 62 |
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php echo __("Widget Title:", 'userswp'); ?> <input class="widefat" |
| 63 |
id="<?php echo $this->get_field_id('title'); ?>" |
| 64 |
name="<?php echo $this->get_field_name('title'); ?>" |
| 65 |
type="text" |
| 66 |
value="<?php echo esc_attr($title); ?>"/></label> |
| 67 |
</p> |
| 68 |
<?php |
| 69 |
} |
| 70 |
|
| 71 |
} |