PluginProbe ʕ •ᴥ•ʔ
Paid Membership Plugin, Ecommerce, User Registration Form, Login Form, User Profile & Restrict Content – ProfilePress / trunk
Paid Membership Plugin, Ecommerce, User Registration Form, Login Form, User Profile & Restrict Content – ProfilePress vtrunk
4.16.18 4.16.17 4.16.16 trunk 1.0 1.0.1 1.0.2 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.5a 1.1.6 1.1.7 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.4 1.4.1 1.4.2 1.5 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.7 1.7.1 1.7.2 1.8 1.8.1 1.8.10 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9 1.9.1 1.9.10 1.9.11 1.9.12 1.9.13 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.1.9 2.2.10 2.2.11 2.2.12 2.2.13 2.2.14 2.2.15 2.2.16 2.2.2 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 3.0 3.1 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 3.1.19 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.10 3.2.11 3.2.12 3.2.13 3.2.14 3.2.15 3.2.16 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 4.0.0 4.0.1 4.0.2 4.0.3 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.10.0 4.10.1 4.10.2 4.10.3 4.11.0 4.12.0 4.13.0 4.13.1 4.13.2 4.13.3 4.13.4 4.14.0 4.14.1 4.14.2 4.14.3 4.14.4 4.15.0 4.15.1 4.15.10 4.15.11 4.15.12 4.15.13 4.15.14 4.15.15 4.15.16 4.15.17 4.15.18 4.15.19 4.15.2 4.15.20 4.15.20.1 4.15.21 4.15.22 4.15.23 4.15.24 4.15.25 4.15.3 4.15.4 4.15.5 4.15.6 4.15.7 4.15.8 4.15.9 4.16.0 4.16.1 4.16.10 4.16.11 4.16.12 4.16.13 4.16.14 4.16.15 4.16.2 4.16.3 4.16.4 4.16.5 4.16.6 4.16.7 4.16.8 4.16.9 4.2.0 4.3.0 4.3.1 4.3.2 4.4.0 4.4.1 4.5.0 4.5.1 4.5.2 4.5.3 4.5.4 4.5.5 4.6.0 4.7.0 4.8.0 4.9.0
wp-user-avatar / src / Widgets / Form.php
wp-user-avatar / src / Widgets Last commit date
Form.php 11 months ago Init.php 5 years ago TabbedWidget.php 4 years ago TabbedWidgetDependency.php 1 year ago UserPanel.php 2 years ago index.php 5 years ago
Form.php
156 lines
1 <?php
2
3 namespace ProfilePress\Core\Widgets;
4
5 use ProfilePress\Core\Classes\FormRepository as FR;
6 use WP_Widget;
7
8 class Form extends WP_Widget
9 {
10 public function __construct()
11 {
12 parent::__construct(
13 'pp_form',
14 esc_html__('ProfilePress Form', 'wp-user-avatar'),
15 array('description' => esc_html__('Easily add your ProfilePress forms to widget areas.', 'wp-user-avatar'))
16 );
17 }
18
19 public function widget($args, $instance)
20 {
21 $chosen_form = sanitize_text_field($instance['chosen_form'] ?? '');
22
23 $hide_widget = $instance['hide'] ?? '';
24
25 if ('yes' == $hide_widget && is_user_logged_in()) return;
26
27 echo $args['before_widget'];
28
29 if ( ! empty($instance['title'])) {
30 echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title'];
31 }
32
33 echo do_shortcode($chosen_form);
34
35 echo $args['after_widget'];
36 }
37
38 /**
39 * Back-end widget form.
40 *
41 * @param array $instance
42 *
43 * @return void
44 */
45 public function form($instance)
46 {
47 $title = ! empty($instance['title']) ? $instance['title'] : '';
48 $hide = ! empty($instance['hide']) ? $instance['hide'] : '';
49 $chosen_form = ! empty($instance['chosen_form']) ? $instance['chosen_form'] : '';
50
51 $login_form_ids = FR::get_form_ids(FR::LOGIN_TYPE);
52 $registration_form_ids = FR::get_form_ids(FR::REGISTRATION_TYPE);
53 $password_reset_ids = FR::get_form_ids(FR::PASSWORD_RESET_TYPE);
54 $edit_profile_form_ids = FR::get_form_ids(FR::EDIT_PROFILE_TYPE);
55 $melange_ids = FR::get_form_ids(FR::MELANGE_TYPE);
56
57 if (empty($login_form_ids) || empty($registration_form_ids) || empty($password_reset_ids) || empty($edit_profile_form_ids) || empty($melange_ids)) {
58 echo '<p>' . __(apply_filters('ppress_no_form_widget', 'No ProfilePress form is available.'), 'wp-user-avatar') . '</p>';
59
60 return;
61 }
62 ?>
63
64 <p>
65 <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'wp-user-avatar'); ?></label>
66 <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>">
67 </p>
68
69 <p>
70 <label for="<?php echo $this->get_field_id('chosen_form'); ?>"><?php _e('Select Form', 'wp-user-avatar'); ?></label><br/>
71 <select class="widefat" id="<?php echo $this->get_field_id('chosen_form'); ?>" name="<?php echo $this->get_field_name('chosen_form'); ?>">
72 <?php
73 if ( ! empty($login_form_ids)) {
74 printf('<optgroup label="%s">', esc_html__('Login Form', 'wp-user-avatar'));
75 foreach ($login_form_ids as $login_form_id) {
76 $key = sprintf("[profilepress-login id=%s]", $login_form_id);
77 printf('<option value="%s" %s>%s</option>',
78 $key,
79 selected($key, $chosen_form, false),
80 FR::get_name($login_form_id, FR::LOGIN_TYPE)
81 );
82 }
83 echo '</optgroup>';
84 }
85
86 if ( ! empty($registration_form_ids)) {
87 printf('<optgroup label="%s">', esc_html__('Registration Form', 'wp-user-avatar'));
88 foreach ($registration_form_ids as $registration_form_id) {
89 $key = sprintf("[profilepress-registration id=%s]", $registration_form_id);
90 printf('<option value="%s" %s>%s</option>',
91 $key,
92 selected($key, $chosen_form, false),
93 FR::get_name($registration_form_id, FR::REGISTRATION_TYPE)
94 );
95 }
96 echo '</optgroup>';
97 }
98
99 if ( ! empty($password_reset_ids)) {
100 printf('<optgroup label="%s">', esc_html__('Password Reset Form', 'wp-user-avatar'));
101 foreach ($password_reset_ids as $password_reset_id) {
102 $key = sprintf("[profilepress-password-reset id=%s]", $password_reset_id);
103 printf('<option value="%s" %s>%s</option>',
104 $key,
105 selected($key, $chosen_form, false),
106 FR::get_name($password_reset_id, FR::PASSWORD_RESET_TYPE)
107 );
108 }
109 echo '</optgroup>';
110 }
111
112 if ( ! empty($edit_profile_form_ids)) {
113 printf('<optgroup label="%s">', esc_html__('Edit Profile Form', 'wp-user-avatar'));
114 foreach ($edit_profile_form_ids as $edit_profile_form_id) {
115 $key = sprintf("[profilepress-edit-profile id=%s]", $edit_profile_form_id);
116 printf('<option value="%s" %s>%s</option>',
117 $key,
118 selected($key, $chosen_form, false),
119 FR::get_name($edit_profile_form_id, FR::EDIT_PROFILE_TYPE)
120 );
121 }
122 echo '</optgroup>';
123 }
124
125 if ( ! empty($melange_ids)) {
126 printf('<optgroup label="%s">', esc_html__('Melange Form', 'wp-user-avatar'));
127 foreach ($melange_ids as $melange_id) {
128 $key = sprintf("[profilepress-melange id=%s]", $melange_id);
129 printf('<option value="%s" %s>%s</option>',
130 $key,
131 selected($key, $chosen_form, false),
132 FR::get_name($melange_id, FR::MELANGE_TYPE)
133 );
134 }
135 echo '</optgroup>';
136 }
137 ?>
138 </select>
139 </p>
140 <p>
141 <label for="<?php echo $this->get_field_id('hide'); ?>"><?php _e('Hide when a user is logged in:', 'wp-user-avatar'); ?></label>
142 <input class="widefat" id="<?php echo $this->get_field_id('hide'); ?>" name="<?php echo $this->get_field_name('hide'); ?>" type="checkbox" value="yes" <?php checked($hide, 'yes'); ?>>
143 </p>
144 <?php
145 }
146
147 public function update($new_instance, $old_instance)
148 {
149 $instance = array();
150 $instance['title'] = ( ! empty($new_instance['title'])) ? sanitize_text_field($new_instance['title']) : '';
151 $instance['hide'] = ( ! empty($new_instance['hide'])) ? sanitize_text_field($new_instance['hide']) : '';
152 $instance['chosen_form'] = ( ! empty($new_instance['chosen_form'])) ? sanitize_text_field($new_instance['chosen_form']) : '';
153
154 return $instance;
155 }
156 }