PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.2.74
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.2.74
1.2.74 1.2.73 1.2.72 1.2.71 1.2.70 1.2.69 1.2.68 1.2.67 1.2.66 1.2.65 1.2.64 1.2.63 trunk 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.20 1.0.21 All 174 releases
← All changes | widgets/register.php +149 -61 1.0.121.2.74 View file →
@@ -1,71 +1,159 @@
1 1 <?php
2 -add_action('widgets_init', 'uwp_init_register_widget');
3 -function uwp_init_register_widget() {
4 - register_widget("UWP_Register_Widget");
2 +if ( ! defined( 'ABSPATH' ) ) {
3 + exit;
5 4 }
6 -class UWP_Register_Widget extends WP_Widget
7 -{
8 5
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);
6 +/**
7 + * UsersWP register widget.
8 + *
9 + * @since 1.0.0
10 + */
11 +class UWP_Register_Widget extends WP_Super_Duper {
19 12
20 - }
13 + /**
14 + * Register the registration widget with WordPress.
15 + *
16 + */
17 + public function __construct() {
21 18
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']);
19 + $options = array(
20 + 'textdomain' => 'userswp',
21 + 'block-icon' => 'admin-site',
22 + 'block-category' => 'widgets',
23 + 'block-keywords' => "['userswp','register']",
24 + 'class_name' => __CLASS__,
25 + 'base_id' => 'uwp_register',
26 + 'name' => __( 'UWP > Register', 'userswp' ),
27 + 'widget_ops' => array(
28 + 'classname' => 'uwp-register-class bsui',
29 + 'description' => esc_html__( 'Displays register form.', 'userswp' ),
30 + ),
31 + 'arguments' => array(
32 + 'id' => array(
33 + 'title' => __( 'Form', 'userswp' ),
34 + 'desc' => __( 'Select form.', 'userswp' ),
35 + 'type' => 'select',
36 + 'options' => uwp_get_register_forms_dropdown_options(),
37 + 'default' => 1,
38 + 'desc_tip' => true,
39 + 'advanced' => false
40 + ),
41 + 'limit' => array(
42 + 'title' => __( 'Display form having IDs', 'userswp' ),
43 + 'desc' => __( 'Enter comma separeted IDs to show limited forms', 'userswp' ),
44 + 'type' => 'text',
45 + 'desc_tip' => true,
46 + 'default' => '',
47 + 'advanced' => true
48 + ),
49 + 'title' => array(
50 + 'title' => __( 'Widget title', 'userswp' ),
51 + 'desc' => __( 'Enter widget title.', 'userswp' ),
52 + 'type' => 'text',
53 + 'desc_tip' => true,
54 + 'default' => '',
55 + 'advanced' => true
56 + ),
57 + 'form_title' => array(
58 + 'title' => __( 'Form Title', 'userswp' ),
59 + 'desc' => __( 'Enter the form title (or "0" for no title)', 'userswp' ),
60 + 'type' => 'text',
61 + 'desc_tip' => true,
62 + 'default' => '',
63 + 'placeholder' => __( 'Register', 'userswp' ),
64 + 'advanced' => true
65 + ),
66 + 'redirect_to' => array(
67 + 'type' => 'text',
68 + 'title' => __( 'Redirect to:', 'userswp' ),
69 + 'desc' => __( 'Enter the url you want to redirect after register.', 'userswp' ),
70 + 'placeholder' => '',
71 + 'default' => '',
72 + 'desc_tip' => true,
73 + 'advanced' => true
74 + ),
75 + 'design_style' => array(
76 + 'title' => __( 'Design Style', 'userswp' ),
77 + 'desc' => __( 'The design style to use.', 'userswp' ),
78 + 'type' => 'select',
79 + 'options' => array(
80 + "" => __( 'default', 'userswp' ),
81 + "bootstrap" => __( 'Style 1', 'userswp' ),
82 + ),
83 + 'default' => '',
84 + 'desc_tip' => true,
85 + 'advanced' => true
86 + ),
87 + 'css_class' => array(
88 + 'type' => 'text',
89 + 'title' => __( 'Extra class:', 'userswp' ),
90 + 'desc' => __( 'Give the wrapper an extra class so you can style things as you want.', 'userswp' ),
91 + 'placeholder' => '',
92 + 'default' => '',
93 + 'desc_tip' => true,
94 + 'advanced' => true,
95 + ),
96 + )
35 97
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 - }
98 + );
45 99
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 - }
100 + parent::__construct( $options );
101 + }
53 102
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 - }
103 + /**
104 + * The Super block output function.
105 + *
106 + * @param array $args
107 + * @param array $widget_args
108 + * @param string $content
109 + *
110 + * @return mixed|string|bool
111 + */
112 + public function output( $args = array(), $widget_args = array(), $content = '' ) {
70 113
114 + if ( is_user_logged_in() && ! is_admin() ) {
115 + return false;
116 + }
117 +
118 + $defaults = array(
119 + 'form_title' => __( 'Register', 'userswp' ),
120 + 'css_class' => 'border-0',
121 + 'redirect_to' => '',
122 + );
123 +
124 + /**
125 + * Parse incoming $args into an array and merge it with $defaults
126 + */
127 + $args = wp_parse_args( $args, $defaults );
128 +
129 + if(isset($_REQUEST['user_type']) && !empty($_REQUEST['user_type'])){
130 + $args['id'] = uwp_get_form_id_by_type(sanitize_text_field($_REQUEST['user_type']));
131 + }
132 +
133 + if(isset($_REQUEST['uwp_form_id']) && !empty($_REQUEST['uwp_form_id'])){
134 + $args['id'] = absint($_REQUEST['uwp_form_id']);
135 + }
136 +
137 + ob_start();
138 +
139 + echo '<div class="uwp_widgets uwp_widget_register">';
140 +
141 + $design_style = ! empty( $args['design_style'] ) ? esc_attr( $args['design_style'] ) : uwp_get_option( "design_style", 'bootstrap' );
142 + $template = $design_style ? $design_style . "/register.php" : "register.php";
143 +
144 + echo '<div class="uwp_page wpbs">';
145 +
146 + uwp_get_template( $template, $args );
147 +
148 + echo '</div>';
149 +
150 + echo '</div>';
151 +
152 + if(!wp_doing_ajax()){
153 + uwp_password_strength_inline_js();
154 + }
155 +
156 + return ob_get_clean();
157 +
158 + }
71 159 }