PluginProbe
Loginizer / trunk
Loginizer vtrunk
2.1.0 2.0.9 2.0.8 1.9.8 1.9.9 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 trunk 1.0 1.0.1 1.0.2 1.1.0 1.1.1 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 All 74 releases
loginizer / main / settings / passwordless.php

passwordless.php in Loginizer trunk, at main/settings/passwordless.php

231 lines 9.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if(!defined('ABSPATH')){
4 die('Hacking Attempt!');
5 }
6
7 // Loginizer - PasswordLess Page
8 function loginizer_page_passwordless(){
9
10 global $loginizer, $lz_error, $lz_env;
11
12 if(!current_user_can('manage_options')){
13 wp_die('Sorry, but you do not have permissions to change settings.');
14 }
15
16 if(!loginizer_is_premium() && count($_POST) > 0){
17 $lz_error['not_in_free'] = __('This feature is not available in the Free version.', 'loginizer').' <a href="'.LOGINIZER_PRICING_URL.'" target="_blank" style="text-decoration:none; color:green;"><b>'.esc_html__('Upgrade to Pro', 'loginizer').'</b></a>';
18 return loginizer_page_passwordless_T();
19 }
20
21 /* Make sure post was from this page */
22 if(count($_POST) > 0){
23 check_admin_referer('loginizer-options');
24 }
25
26 if(isset($_POST['save_lz'])){
27
28 // In the future there can be more settings
29 $option['email_pass_less'] = (int) lz_optpost('email_pass_less');
30 $option['passwordless_sub'] = @stripslashes($_POST['lz_passwordless_sub']);
31 $option['passwordless_msg'] = @stripslashes($_POST['lz_passwordless_msg']);
32 $option['passwordless_html'] = (int) lz_optpost('lz_passwordless_html');
33 $option['passwordless_redirect'] = esc_url_raw($_POST['lz_passwordless_redirect']);
34 $option['passwordless_redirect_for'] = !empty($_POST['lz_passwordless_redirect_for']) ? map_deep($_POST['lz_passwordless_redirect_for'], 'sanitize_text_field') : [];
35 $option['passwordless_disabled_for'] = !empty($_POST['lz_passwordless_disabled_for']) ? map_deep(wp_unslash($_POST['lz_passwordless_disabled_for']), 'sanitize_text_field') : [];
36 $option['epl_email_only'] = (int) lz_optpost('epl_email_only');
37
38 // Is there an error ?
39 if(!empty($lz_error)){
40 return loginizer_page_passwordless_T();
41 }
42
43 // Save the options
44 update_option('loginizer_epl', $option);
45
46 // Mark as saved
47 $GLOBALS['lz_saved'] = true;
48
49 }
50
51 // Call theme
52 loginizer_page_passwordless_T();
53 }
54
55 // Loginizer - PasswordLess Page Theme
56 function loginizer_page_passwordless_T(){
57
58 global $loginizer, $lz_error, $lz_env;
59
60 $lz_options = get_option('loginizer_epl');
61
62 // Universal header
63 loginizer_page_header('PasswordLess Settings');
64
65 loginizer_feature_available('PasswordLess Login');
66
67 // Saved ?
68 if(!empty($GLOBALS['lz_saved'])){
69 echo '<div id="message" class="updated"><p>'. __('The settings were saved successfully', 'loginizer'). '</p></div><br />';
70 }
71
72 // Any errors ?
73 if(!empty($lz_error)){
74 lz_report_error($lz_error);echo '<br />';
75 }
76
77 ?>
78
79 <style>
80 input[type="text"], textarea, select {
81 width: 90%;
82 }
83
84 .form-table label{
85 font-weight:bold;
86 }
87
88 .form-table td{
89 vertical-align:top;
90 }
91
92 .exp{
93 font-size:12px;
94 }
95 </style>
96
97 <div id="" class="postbox">
98
99 <div class="postbox-header">
100 <h2 class="hndle ui-sortable-handle">
101 <span><?php echo __('PasswordLess Settings', 'loginizer'); ?></span>
102 </h2>
103 </div>
104
105 <div class="inside">
106
107 <form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1">
108 <?php wp_nonce_field('loginizer-options'); ?>
109 <table class="form-table">
110 <tr>
111 <td scope="row" valign="top" style="width:350px !important"><label for="email_pass_less"><?php echo __('Enable PasswordLess Login', 'loginizer'); ?></label></td>
112 <td>
113 <input type="checkbox" value="1" name="email_pass_less" id="email_pass_less" <?php echo lz_POSTchecked('email_pass_less', (empty($loginizer['email_pass_less']) ? false : true)); echo (defined('SITEPAD') ? 'disabled="disabled"' : '') ?> />
114 </td>
115 </tr>
116 <tr>
117 <td scope="row" valign="top" style="width:350px !important">
118 <label for="epl_email_only"><?php echo __('Accept Email Only', 'loginizer'); ?> <span class="exp" style="font-weight:400;"><em><?php esc_html_e('Recommended', 'loginizer'); ?></em></span></label><br>
119 <span class="exp"><?php echo __('When enabled, users must log in with their email address; usernames will not be accepted.', 'loginizer');?></span><br>
120
121 </td>
122 <td>
123 <input type="checkbox" value="1" name="epl_email_only" id="epl_email_only" <?php echo lz_POSTchecked('epl_email_only', (empty($loginizer['epl_email_only']) ? false : true)); ?> />
124 <p class="description"><?php echo __('If a wrong username/email is given, the brute force checker will prevent any brute force attempt !', 'loginizer'); ?></p>
125 </td>
126 </tr>
127 <tr>
128 <td scope="row" valign="top">
129 <label for="lz_passwordless_sub"><?php echo __('Email Subject', 'loginizer'); ?></label><br>
130 <span class="exp"><?php echo __('Set blank to reset to the default subject', 'loginizer'); ?></span>
131 <br />Default : <?php echo (!empty($loginizer['pl_d_sub']) ? $loginizer['pl_d_sub'] : ''); ?>
132 </td>
133 <td valign="top">
134 <input type="text" size="40" value="<?php echo lz_htmlizer(!empty($_POST['lz_passwordless_sub']) ? stripslashes($_POST['lz_passwordless_sub']) : (empty($lz_options['passwordless_sub']) ? '' : $lz_options['passwordless_sub'])); ?>" name="lz_passwordless_sub" id="lz_passwordless_sub" />
135 </td>
136 </tr>
137 <tr>
138 <td scope="row" valign="top">
139 <label for="lz_passwordless_msg"><?php echo __('Email Body', 'loginizer'); ?></label><br>
140 <span class="exp"><?php echo __('Set blank to reset to the default message', 'loginizer'); ?></span>
141 <br />Default : <pre style="font-size:10px"><?php echo (!empty($loginizer['pl_d_msg']) ? $loginizer['pl_d_msg'] : '') ; ?></pre>
142 </td>
143 <td valign="top">
144 <textarea rows="10" name="lz_passwordless_msg" id="lz_passwordless_msg"><?php echo lz_htmlizer(!empty($_POST['lz_passwordless_msg']) ? stripslashes($_POST['lz_passwordless_msg']) : (empty($lz_options['passwordless_msg']) ? '' : $lz_options['passwordless_msg'])); ?></textarea>
145 <br />
146 Variables :
147 <br />$email - Users Email
148 <br />$site_name - The Site Name
149 <br />$site_url - The Site URL
150 <br />$login_url - The Login URL
151 </td>
152 </tr>
153 <tr>
154 <td scope="row" valign="top"><label for="lz_passwordless_html"><?php echo __('Send email as HTML', 'loginizer'); ?></label></td>
155 <td>
156 <input type="checkbox" value="1" name="lz_passwordless_html" id="lz_passwordless_html" <?php echo lz_POSTchecked('lz_passwordless_html', (empty($loginizer['passwordless_html']) ? false : true)); ?> />
157 </td>
158 </tr>
159 <tr>
160 <td scope="row" valign="top" style="width:350px !important">
161 <label for="lz_passwordless_redirect"><?php echo __('Custom redirect to', 'loginizer'); ?></label><br/>
162 <span class="exp"><?php echo __('Redirects user to a page of your website other than the admin panel', 'loginizer'); ?></span>
163 </td>
164 <td align="top">
165 <input type="text" size="40" value="<?php echo lz_htmlizer(!empty($_POST['lz_passwordless_redirect']) ? stripslashes($_POST['lz_passwordless_redirect']) : (empty($lz_options['passwordless_redirect']) ? '' : $lz_options['passwordless_redirect'])); ?>" name="lz_passwordless_redirect" id="lz_passwordless_redirect" />
166 </td>
167 </tr>
168
169 <tr>
170 <td scope="row" valign="top" style="width:350px !important">
171 <label for="lz_passwordless_redirect_for"><?php echo __('Custom redirect for', 'loginizer'); ?></label><br/>
172 <span class="exp"><?php echo __('Select the user roles for whom this custom redirect will be used', 'loginizer'); ?></span>
173 </td>
174 <td align="top">
175 <?php
176 $editable_roles = get_editable_roles();
177 echo '<div style="max-height:120px; overflow:auto;">';
178 $r = '';
179 foreach($editable_roles as $role => $details) {
180 $name = translate_user_role( $details['name'] );
181 // Preselect specified role.
182 if(!empty($lz_options['passwordless_redirect_for']) && in_array($role, $lz_options['passwordless_redirect_for'])) {
183 $r .= "\n\t<input type=\"checkbox\" checked name=\"lz_passwordless_redirect_for[]\" value='" . esc_attr($role) . "' style=\"margin-top:5px\">$name</option>";
184 } else {
185 $r .= "\n\t<input type=\"checkbox\" value='" . esc_attr($role) . "' name=\"lz_passwordless_redirect_for[]\">$name</option>";
186 }
187
188 $r .= '<br/>';
189 }
190 echo $r . '</div>';
191 ?>
192 </td>
193 </tr>
194
195 <tr>
196 <td scope="row" valign="top" style="width:350px !important">
197 <label for="lz_passwordless_disabled_for"><?php echo __('Disable for', 'loginizer'); ?></label><br/>
198 <span class="exp"><?php echo __('Which login form you want to disable passwordless login for', 'loginizer'); ?></span>
199 </td>
200 <td align="top">
201 <?php
202 $forms = ['admin', 'woocommerce'];
203 echo '<div>';
204 $r = '';
205 foreach($forms as $form) {
206 // Preselect specified form.
207 if(!empty($lz_options['passwordless_disabled_for']) && in_array($form, $lz_options['passwordless_disabled_for'])){
208 $r .= "\n\t<input type=\"checkbox\" checked name=\"lz_passwordless_disabled_for[]\" value='" . esc_attr($form) . "' style=\"margin-top:5px\">".esc_html(ucfirst($form))."</option>";
209 } else {
210 $r .= "\n\t<input type=\"checkbox\" value='" . esc_attr($form) . "' name=\"lz_passwordless_disabled_for[]\">".esc_html(ucfirst($form))."</option>";
211 }
212
213 $r .= '<br/>';
214 }
215 echo $r . '</div>';
216 ?>
217 </td>
218 </tr>
219
220 </table><br />
221 <center><input name="save_lz" class="button button-primary action" value="<?php echo __('Save Settings', 'loginizer'); ?>" type="submit" /></center>
222 </form>
223
224 </div>
225 </div>
226 <br />
227
228 <?php
229 loginizer_page_footer();
230
231 }