| 1 |
<?php |
| 2 |
add_action('widgets_init', 'uwp_init_register_widget'); |
| 3 |
|
| 4 |
function uwp_init_register_widget() { |
| 5 |
|
| 6 |
register_widget("UWP_Register_Widget"); |
| 7 |
|
| 8 |
} |
| 9 |
|
| 10 |
class UWP_Register_Widget extends WP_Super_Duper { |
| 11 |
|
| 12 |
public function __construct() { |
| 13 |
|
| 14 |
$options = array( |
| 15 |
'textdomain' => 'userswp', |
| 16 |
'block-icon' => 'admin-site', |
| 17 |
'block-category'=> 'widgets', |
| 18 |
'block-keywords'=> "['userswp','register']", |
| 19 |
'class_name' => __CLASS__, |
| 20 |
'base_id' => 'uwp_register', |
| 21 |
'name' => __('UWP > Register','userswp'), |
| 22 |
'widget_ops' => array( |
| 23 |
'classname' => 'uwp-register-class', |
| 24 |
'description' => esc_html__('Displays register form.','userswp'), |
| 25 |
), |
| 26 |
'arguments' => array( |
| 27 |
'title' => array( |
| 28 |
'title' => __( 'Register widget title', 'userswp' ), |
| 29 |
'desc' => __( 'Enter register widget title.', 'userswp' ), |
| 30 |
'type' => 'text', |
| 31 |
'desc_tip' => true, |
| 32 |
'default' => '', |
| 33 |
'advanced' => false |
| 34 |
), |
| 35 |
) |
| 36 |
|
| 37 |
); |
| 38 |
|
| 39 |
parent::__construct( $options ); |
| 40 |
} |
| 41 |
|
| 42 |
public function output( $args = array(), $widget_args = array(), $content = '' ) { |
| 43 |
|
| 44 |
if (is_user_logged_in()) { |
| 45 |
return; |
| 46 |
} |
| 47 |
|
| 48 |
ob_start(); |
| 49 |
|
| 50 |
echo '<div class="uwp_widgets uwp_widget_register">'; |
| 51 |
|
| 52 |
$temp_obj = new UsersWP_Templates(); |
| 53 |
|
| 54 |
$template = $temp_obj->uwp_locate_template('register'); |
| 55 |
|
| 56 |
echo '<div class="uwp_page">'; |
| 57 |
|
| 58 |
if ($template) { |
| 59 |
include($template); |
| 60 |
} |
| 61 |
|
| 62 |
echo '</div>'; |
| 63 |
|
| 64 |
echo '</div>'; |
| 65 |
|
| 66 |
$output = ob_get_contents(); |
| 67 |
|
| 68 |
ob_end_clean(); |
| 69 |
|
| 70 |
return trim($output); |
| 71 |
|
| 72 |
} |
| 73 |
} |