-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsettings.php
executable file
·167 lines (139 loc) · 4.37 KB
/
settings.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<?php
/**
* Settings
*
* @copyright dornaweb.com
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class DWEmailVerifySettings{
/**
* List of all wordpress pages
*
* @var array
*/
private $wp_pages;
/**
* __construct
*/
public function __construct(){
$this->wp_pages = $this->get_pages_array();
add_action( 'admin_init', array( $this, 'settings' ) );
add_action( 'admin_menu', [ $this, 'menus' ] );
}
/**
* Settings fields
*/
public function settings(){
register_setting(
'dwvrf_options',
'dwvrf_options',
NULL
);
/*
register_setting(
'dwvrf_options',
'dw_email_verifications',
NULL
);*/
register_setting(
'dwvrf_options',
'dw_verify_authorize_page',
NULL
);
register_setting(
'dwvrf_options',
'dw_verify_autologin',
NULL
);
register_setting(
'dwvrf_options',
'dw_verify_redirect_page',
NULL
);
register_setting(
'dwvrf_options',
'dw_verify_max_resend_allowed',
NULL
);
}
/**
* Add menu pages
*/
public function menus(){
add_options_page(
__( 'Email verification settings', 'dwverify' ),
__( 'email verification', 'dwverify' ),
'manage_options',
'dw-email-verifications.php',
[ $this, 'settings_view' ]
);
}
/**
* Settings HTML output
*/
public function settings_view(){ ?>
<h1><?php echo esc_html__( 'Email verification settings', 'dwverify' ); ?></h1>
<form method="post" action="options.php">
<table class="form-table">
<tbody>
<tr>
<th scope="row"><label for="dw_verify_authorize_page"><?php echo esc_html__('Authorize page: ', 'dwverify'); ?></label></th>
<td>
<select name="dw_verify_authorize_page" id="dw_verify_authorize_page" class="regular-text">
<?php
$pages = $this->wp_pages;
foreach( $pages as $id => $page_name )
printf('<option value="%d" %s>%s</option>', $id, selected( get_option('dw_verify_authorize_page'), $id ) , $page_name ); ?>
</select>
</td>
</tr>
<tr>
<th scope="row"><?php echo esc_html__('Auto login' ,'dwverify'); ?></th>
<td> <fieldset><legend class="screen-reader-text"><span><?php echo esc_html__('Auto login: ' ,'dwverify'); ?></span></legend><label for="dw_verify_autologin">
<input name="dw_verify_autologin" value="1" id="dw_verify_autologin" <?php checked( get_option('dw_verify_autologin'), 1 ); ?> type="checkbox">
<?php echo esc_html__('Automatically sign-in after verification' ,'dwverify'); ?></label>
</fieldset></td>
</tr>
<tr>
<th scope="row"><label for="dw_verify_redirect_page"><?php echo esc_html__('Redirect page: ', 'dwverify'); ?></label></th>
<td>
<select name="dw_verify_redirect_page" id="dw_verify_redirect_page" class="regular-text">
<?php
$pages = $this->wp_pages;
foreach( $pages as $id => $page_name )
printf('<option value="%d" %s>%s</option>', $id, selected( get_option('dw_verify_redirect_page'), $id ) , $page_name ); ?>
</select>
</td>
</tr>
<tr>
<th scope="row"><label for="dw_verify_max_resend_allowed"><?php echo esc_html__('Max Re-send attempts: ', 'dwverify'); ?></label></th>
<td>
<input type="number" step="1" min="1" max="15" value="<?php echo esc_attr( get_option('dw_verify_max_resend_allowed') ); ?>" name="dw_verify_max_resend_allowed" id="dw_verify_max_resend_allowed" class="regular-text">
<span style="padding-top: 10px; display: block; color: 90%; font-style: italic; color: #787878;" class="note"><?php echo esc_html__('Max number of re-send requests a user can make, more than that, his account will be locked.', 'dwverify'); ?></span>
</td>
</tr>
</tbody>
</table>
<?php settings_fields( 'dwvrf_options' ); ?>
<?php submit_button(); ?>
</form>
<?php }
/**
* Get array of wordpress pages
*
* @return array
*/
private function get_pages_array() {
$pages = array();
$get_pages = get_pages('sort_column=post_parent,menu_order');
foreach ($get_pages as $page) {
$pages[$page->ID] = $page->post_title;
}
$none_selected = array("0" => esc_html__("-Select a page-", 'dwverify') );
$wp_pages = $none_selected + $pages;
return $wp_pages;
}
}
new DWEmailVerifySettings();