PluginProbe
LoginPress | wp-login Custom Login Page Customizer / 1.6.0
LoginPress | wp-login Custom Login Page Customizer v1.6.0
6.2.5 6.2.4 6.2.3 6.2.2 6.2.1 trunk 1.0.0 1.0.1 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.2 1.0.20 1.0.21 1.0.22 1.0.23 1.0.3 1.0.4 All 118 releases
loginpress / classes / class-loginpress-setup.php

class-loginpress-setup.php in LoginPress | wp-login Custom Login Page Customizer 1.6.0, at classes/class-loginpress-setup.php

416 lines 16.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * LoginPress Settings
4 *
5 * @since 1.0.9
6 * @version 1.1.23
7 */
8 if ( ! class_exists( 'LoginPress_Settings' ) ):
9
10 class LoginPress_Settings {
11
12 private $settings_api;
13
14 function __construct() {
15
16 include_once( LOGINPRESS_ROOT_PATH . '/classes/class-loginpress-settings-api.php' );
17 $this->settings_api = new LoginPress_Settings_API;
18
19 add_action( 'admin_init', array( $this, 'loginpress_setting_init' ) );
20 add_action( 'admin_menu', array( $this, 'loginpress_setting_menu' ) );
21 }
22
23 function loginpress_setting_init() {
24
25 //set the settings.
26 $this->settings_api->set_sections( $this->get_settings_sections() );
27 $this->settings_api->set_fields( $this->get_settings_fields() );
28
29 //initialize settings.
30 $this->settings_api->admin_init();
31
32 //reset settings.
33 $this->load_default_settings();
34 }
35
36 function load_default_settings() {
37
38 $_loginpress_Setting = get_option( 'loginpress_setting' );
39 if ( isset( $_loginpress_Setting['reset_settings'] ) && 'on' == $_loginpress_Setting['reset_settings'] ) {
40
41 $loginpress_last_reset = array( 'last_reset_on' => date('Y-m-d') );
42 update_option( 'loginpress_customization', $loginpress_last_reset );
43 update_option( 'customize_presets_settings', 'default1' );
44 $_loginpress_Setting['reset_settings'] = 'off';
45 update_option( 'loginpress_setting', $_loginpress_Setting );
46 add_action( 'admin_notices', array( $this, 'settings_reset_message' ) );
47 }
48 }
49
50 function settings_reset_message() {
51
52 $class = 'notice notice-success';
53 $message = __( 'Default Settings Restored', 'loginpress' );
54
55 printf( '<div class="%1$s"><p>%2$s</p></div>', $class, $message );
56 }
57
58 // Code for add loginpress icon
59 function loginpress_setting_menu() {
60 add_action('admin_head', 'loginpressicon'); // admin_head is a hook loginpressicon is a function we are adding it to the hook
61
62
63 function loginpressicon() {
64 $ttf = plugins_url( '../loginpressfonts/loginpress.ttf?gb7unf', __FILE__ );
65 $woff = plugins_url( '../loginpressfonts/loginpress.woff?gb7unf', __FILE__ );
66 $svg = plugins_url( '../loginpressfonts/loginpress.svg?gb7unf', __FILE__ );
67 $eotie = plugins_url( '../loginpressfonts/loginpress.eot?gb7unf#iefix', __FILE__ );
68 $eot = plugins_url( '../loginpressfonts/loginpress.eot?gb7unf', __FILE__ );
69 echo "<style>
70 @font-face {
71 font-family: 'loginpress';
72 src: url('".$eot."');
73 src: url('".$eotie."') format('embedded-opentype'),
74 url('".$ttf."') format('truetype'),
75 url('".$woff."') format('woff'),
76 url('".$svg."') format('svg');
77 font-weight: normal;
78 font-style: normal;
79 }
80
81 .icon-loginpress-dashicon:before {
82 content: '\\e560';
83 color: #fff;
84 }
85
86 #adminmenu li#toplevel_page_loginpress-settings>a>div.wp-menu-image:before{
87 content: '\\e560';
88 font-family: 'loginpress' !important;
89 speak: none;
90 font-style: normal;
91 font-weight: normal;
92 font-variant: normal;
93 text-transform: none;
94 line-height: 1;
95
96 /* Better Font Rendering =========== */
97 -webkit-font-smoothing: antialiased;
98 -moz-osx-font-smoothing: grayscale;
99 }
100 </style>";
101 }
102 add_menu_page( __( 'LoginPress', 'loginpress' ), __( 'LoginPress', 'loginpress' ), 'manage_options', "loginpress-settings", array( $this, 'plugin_page' ), false, 50 );
103
104 add_submenu_page( 'loginpress-settings', __( 'Settings', 'loginpress' ), __( 'Settings', 'loginpress' ), 'manage_options', "loginpress-settings", array( $this, 'plugin_page' ) );
105
106 add_submenu_page( 'loginpress-settings', __( 'Customizer', 'loginpress' ), __( 'Customizer', 'loginpress' ), 'manage_options', "loginpress", '__return_null' );
107
108 add_submenu_page( 'loginpress-settings', __( 'Help', 'loginpress' ), __( 'Help', 'loginpress' ), 'manage_options', "loginpress-help", array( $this, 'loginpress_help_page' ) );
109
110 add_submenu_page( 'loginpress-settings', __( 'Import/Export LoginPress Settings', 'loginpress' ), __( 'Import / Export', 'loginpress' ), 'manage_options', "loginpress-import-export", array( $this, 'loginpress_import_export_page' ) );
111
112 add_submenu_page( 'loginpress-settings', __( 'Add-Ons', 'loginpress' ), __( 'Add-Ons', 'loginpress' ), 'manage_options', "loginpress-addons", array( $this, 'loginpress_addons_page' ) );
113
114 }
115
116 function get_settings_sections() {
117
118 $loginpress_general_tab = array(
119 array(
120 'id' => 'loginpress_setting',
121 'title' => __( 'Settings', 'loginpress' ),
122 'desc' => sprintf( __( 'Everything else is customizable through %1$sWordPress Customizer%2$s.', 'loginpress' ), '<a href="' . admin_url( 'admin.php?page=loginpress' ) . '">', '</a>' ),
123 ),
124 );
125
126 /**
127 * Add Promotion tabs in settings page.
128 * @since 1.1.22
129 * @version 1.1.24
130 */
131 if ( ! has_action( 'loginpress_pro_add_template' ) ) {
132 include LOGINPRESS_DIR_PATH . 'classes/class-loginpress-promotion.php';
133 }
134
135 $sections = apply_filters( 'loginpress_settings_tab', $loginpress_general_tab );
136
137 return $sections;
138 }
139
140 /**
141 * Returns all the settings fields
142 *
143 * @return array settings fields
144 */
145 function get_settings_fields() {
146
147 /**
148 * [$_free_fields array of free fields]
149 * @var array
150 */
151 $_free_fields = array(
152 array(
153 'name' => 'session_expiration',
154 'label' => __( 'Session Expire', 'loginpress' ),
155 'desc' => __( 'Set the session expiration time in minutes. e.g: 10', 'loginpress' ), //<br /> When you set the time, here you need to set the expiration cookies. for this, you just need to logout at least one time. After login again, it should be working fine.<br />For removing the session expiration just pass empty value in “Expiration” field and save it. Now clear the expiration cookies by logout at least one time.
156 'placeholder' => __( '10', 'loginpress' ),
157 'min' => 0,
158 // 'max' => 100,
159 'step' => '1',
160 'type' => 'number',
161 'default' => 'Title',
162 'sanitize_callback' => 'absint'
163 ),
164 // array(
165 // 'name' => 'enable_privacy_policy',
166 // 'label' => __( 'Enable Privacy Policy', 'loginpress' ),
167 // 'desc' => __( 'Enable Privacy Policy checkbox on registration page.', 'loginpress' ),
168 // 'type' => 'checkbox'
169 // ),
170 // array(
171 // 'name' => 'privacy_policy',
172 // 'label' => __( 'Privacy & Policy', 'loginpress' ),
173 // 'desc' => __( 'Right down the privacy and policy description.', 'loginpress' ),
174 // 'type' => 'wysiwyg',
175 // 'default' => __( sprintf( __( '%1$sPrivacy Policy%2$s.', 'loginpress' ), '<a href="' . admin_url( 'admin.php?page=loginpress-settings' ) . '">', '</a>' ) )
176 // ),
177 array(
178 'name' => 'auto_remember_me',
179 'label' => __( 'Auto Remember Me', 'loginpress' ),
180 'desc' => __( 'Keep remember me option always checked on login page', 'loginpress' ),
181 'type' => 'checkbox'
182 ),
183 array(
184 'name' => 'enable_reg_pass_field',
185 'label' => __( 'Custom Password Fields', 'loginpress' ),
186 'desc' => __( 'Enable custom password fields on registration form.', 'loginpress' ),
187 'type' => 'checkbox'
188 ),
189 array(
190 'name' => 'login_order',
191 'label' => __( 'Login Order', 'loginpress' ),
192 'desc' => __( 'Enable users to login using their username and/or email address.', 'loginpress' ),
193 'type' => 'radio',
194 'default' => 'default',
195 'options' => array(
196 'default' => __( 'Both Username Or Email Address', 'loginpress' ),
197 'username' => __( 'Only Username', 'loginpress' ),
198 'email' => __( 'Only Email Address', 'loginpress' )
199 )
200 ),
201 // array(
202 // 'name' => 'login_with_email',
203 // 'label' => __( 'Login with Email', 'loginpress' ),
204 // 'desc' => __( 'Force user to login with Email Only Instead Username.', 'loginpress' ),
205 // 'type' => 'checkbox'
206 // ),
207 array(
208 'name' => 'reset_settings',
209 'label' => __( 'Reset Default Settings', 'loginpress' ),
210 'desc' => __( 'Remove my custom settings.', 'loginpress' ),
211 'type' => 'checkbox'
212 ),
213 );
214
215 // Hide Advertisement in version 1.1.3
216 // if ( ! has_action( 'loginpress_pro_add_template' ) ) {
217 // array_unshift( $_free_fields , array(
218 // 'name' => 'enable_repatcha_promo',
219 // 'label' => __( 'Enable reCAPTCHA', 'loginpress' ),
220 // 'desc' => __( 'Enable LoginPress reCaptcha', 'loginpress' ),
221 // 'type' => 'checkbox'
222 // ) );
223 // }
224
225 /**
226 * Add option to remove language switcher option
227 *
228 * @since 1.5.11
229 */
230 if ( version_compare( $GLOBALS['wp_version'], '5.9', '>=' ) && ! empty( get_available_languages() ) ) {
231 $_free_fields = $this->loginpress_language_switcher( $_free_fields );
232 }
233
234 // Add WooCommerce lostpassword_url field in version 1.1.7
235 if ( class_exists( 'WooCommerce' ) ) {
236 $_free_fields = $this->loginpress_woocommerce_lostpasword_url( $_free_fields );
237 }
238
239 // Add loginpress_uninstall field in version 1.1.9
240 $_free_fields = $this->loginpress_uninstallation_tool( $_free_fields );
241
242 $_settings_fields = apply_filters( 'loginpress_pro_settings', $_free_fields );
243
244 $settings_fields = array( 'loginpress_setting' => $_settings_fields );
245
246 $tab = apply_filters( 'loginpress_settings_fields', $settings_fields );
247
248 return $tab;
249 }
250
251 function plugin_page() {
252
253 echo '<div class="wrap loginpress-admin-setting">';
254 echo '<h2 style="margin: 20px 0 20px 0;">';
255 esc_html_e( 'LoginPress - Rebranding your boring WordPress Login pages', 'loginpress' );
256 echo '</h2>';
257
258 $this->settings_api->show_navigation();
259 $this->settings_api->show_forms();
260
261 echo '</div>';
262 }
263
264 /**
265 * [loginpress_help_page callback function for sub-page Help]
266 * @since 1.0.19
267 */
268 function loginpress_help_page(){
269
270 include LOGINPRESS_DIR_PATH . 'classes/class-loginpress-log.php';
271
272 $html = '<div class="loginpress-help-page">';
273 $html .= '<h2>Help & Troubleshooting</h2>';
274 $html .= sprintf( __( 'Free plugin support is available on the %1$s plugin support forums%2$s.', 'loginpress' ), '<a href="https://wordpress.org/support/plugin/loginpress" target="_blank">', '</a>' );
275 $html .="<br /><br />";
276
277 if( ! class_exists('LoginPress_Pro')){
278 $html .= sprintf( __( 'For premium features, add-ons and priority email support, %1$s upgrade to pro%2$s.', 'loginpress' ), '<a href="https://wpbrigade.com/wordpress/plugins/loginpress-pro/?utm_source=loginpress-lite&utm_medium=help-page&utm_campaign=pro-upgrade" target="_blank">', '</a>' );
279 }else{
280 $html .= 'For premium features, add-ons and priority email support, Please submit a question <a href="https://loginpress.pro/contact/" target="_blank">here</a>!';
281 }
282
283 $html .="<br /><br />";
284 $html .= 'Found a bug or have a feature request? Please submit an issue <a href="https://loginpress.pro/contact/" target="_blank">here</a>!';
285 $html .= '<pre><textarea rows="25" cols="75" readonly="readonly">';
286 $html .= LoginPress_Log_Info::get_sysinfo();
287 $html .= '</textarea></pre>';
288 $html .= '<input type="button" class="button loginpress-log-file" value="' . __( 'Download Log File', 'loginpress' ) . '"/>';
289 $html .= '<span class="log-file-sniper"><img src="'. admin_url( 'images/wpspin_light.gif' ) .'" /></span>';
290 $html .= '<span class="log-file-text">LoginPress Log File Downloaded Successfully!</span>';
291 $html .= '</div>';
292 echo $html;
293 }
294
295 /**
296 * [loginpress_import_export_page callback function for sub-page Import / Export]
297 * @since 1.0.19
298 */
299 function loginpress_import_export_page(){
300
301 include LOGINPRESS_DIR_PATH . 'include/loginpress-import-export.php';
302 }
303
304 /**
305 * [loginpress_addons_page callback function for sub-page Add-ons]
306 * @since 1.0.19
307 */
308 function loginpress_addons_page() {
309
310 include LOGINPRESS_DIR_PATH . 'classes/class-loginpress-addons.php';
311 $obj_loginpress_addons = new LoginPress_Addons();
312 $obj_loginpress_addons->_addon_html();
313 }
314
315 /**
316 * Get all the pages
317 *
318 * @return array page names with key value pairs
319 */
320 function get_pages() {
321 $pages = get_pages();
322 $pages_options = array();
323 if ( $pages ) {
324 foreach ($pages as $page) {
325 $pages_options[$page->ID] = $page->post_title;
326 }
327 }
328
329 return $pages_options;
330 }
331
332 /**
333 * loginpress_woocommerce_lostpasword_url [merge a woocommerce lostpassword url field with the last element of array.]
334 * @param array $fields_list The free fields of LoginPress.
335 * @since 1.1.7
336 * @return array the total fields including the added field of WooCommerce lost password field.
337 */
338 function loginpress_woocommerce_lostpasword_url( $fields_list ) {
339
340 $array_elements = array_slice( $fields_list, 0, -1 ); //slice a last element of array.
341 $last_element = end( $fields_list ); // last element of array.
342 $lostpassword_url = array(
343 'name' => 'lostpassword_url',
344 'label' => __( 'Lost Password URL', 'loginpress' ),
345 'desc' => __( 'Use WordPress default lost password URL instead of WooCommerce custom lost password URL.', 'loginpress' ),
346 'type' => 'checkbox'
347 );
348 $last_two_elements = array_merge( array( $lostpassword_url, $last_element ) ); // merge last 2 elements of array.
349 return array_merge( $array_elements, $last_two_elements ); // merge an array and return.
350 }
351
352 /**
353 * loginpress_language_switcher [merge a language switcher in the settings element of array.]
354 *
355 * @param array $fields_list The free fields of LoginPress.
356 * @since 1.5.11
357 * @return array the total fields including the added field of language switcher
358 */
359 function loginpress_language_switcher( $fields_list ) {
360
361 $array_elements = array_slice( $fields_list, 0, -1 ); //slice a last element of array.
362 $last_element = end( $fields_list ); // last element of array.
363 $switcher_option = array(
364 'name' => 'enable_language_switcher',
365 'label' => __( 'Language Switcher', 'loginpress' ),
366 'desc' => __( 'Remove Language Switcher Dropdown On Login Page. ', 'loginpress' ),
367 'type' => 'checkbox'
368 );
369 $lang_switch_element = array_merge( array( $switcher_option , $last_element ) ); // merge last 2 elements of array.
370 return array_merge( $array_elements, $lang_switch_element ); // merge an array and return.
371 }
372
373 /**
374 * loginpress_uninstallation_filed [merge a uninstall loginpress field with array of element.]
375 * @param array $fields_list The free fields of LoginPress.
376 * @since 1.1.9
377 * @return array the total fields which are to be removed on uninstall.
378 */
379 function loginpress_uninstallation_filed( $fields_list ) {
380
381 $loginpress_page_check = '';
382 if ( is_multisite() ) {
383 $loginpress_page_check = __( 'and LoginPress page', 'loginpress' );
384 }
385
386 $loginpress_db_check = array( array(
387 'name' => 'loginpress_uninstall',
388 'label' => __( 'Remove Settings on Uninstall', 'loginpress' ),
389 'desc' => sprintf( esc_html__( 'This tool will remove all LoginPress settings %1$s upon uninstall.', 'loginpress' ), $loginpress_page_check ),
390 'type' => 'checkbox'
391 ) );
392 return array_merge( $fields_list, $loginpress_db_check ); // merge an array and return.
393 }
394
395 /**
396 * loginpress_uninstallation_tool [Pass return true in loginpress_multisite_uninstallation_tool filter's callback for enable uninsatalltion control on each site.]
397 * @param array $_free_fields
398 * @since 1.1.9
399 * @return array
400 */
401 function loginpress_uninstallation_tool( $_free_fields ) {
402
403 if ( is_multisite() && ! apply_filters( 'loginpress_multisite_uninstallation_tool', false ) ) {
404 if ( get_current_blog_id() == '1' ) {
405 $_free_fields = $this->loginpress_uninstallation_filed( $_free_fields );
406 }
407 } else {
408 $_free_fields = $this->loginpress_uninstallation_filed( $_free_fields );
409 }
410
411 return $_free_fields;
412 }
413
414 }
415 endif;
416