| 1 |
<?php |
| 2 |
/** |
| 3 |
* UsersWP General Settings |
| 4 |
* |
| 5 |
* @author AyeCode |
| 6 |
* @category Admin |
| 7 |
* @package userswp/Admin |
| 8 |
* @version 1.0.24 |
| 9 |
*/ |
| 10 |
|
| 11 |
if ( ! defined( 'ABSPATH' ) ) { |
| 12 |
exit; // Exit if accessed directly |
| 13 |
} |
| 14 |
|
| 15 |
if ( ! class_exists( 'UsersWP_Settings_General', false ) ) : |
| 16 |
|
| 17 |
/** |
| 18 |
* UsersWP_Settings_General. |
| 19 |
*/ |
| 20 |
class UsersWP_Settings_General extends UsersWP_Settings_Page { |
| 21 |
|
| 22 |
/** |
| 23 |
* Constructor. |
| 24 |
*/ |
| 25 |
public function __construct() { |
| 26 |
|
| 27 |
$this->id = 'general'; |
| 28 |
$this->label = __( 'General', 'userswp' ); |
| 29 |
|
| 30 |
add_filter( 'uwp_settings_tabs_array', array( $this, 'add_settings_page' ), 20 ); |
| 31 |
add_action( 'uwp_settings_' . $this->id, array( $this, 'output' ) ); |
| 32 |
add_action( 'uwp_sections_' . $this->id, array( $this, 'output_toggle_advanced' ) ); |
| 33 |
add_action( 'uwp_settings_save_' . $this->id, array( $this, 'save' ) ); |
| 34 |
add_action( 'uwp_sections_' . $this->id, array( $this, 'output_sections' ) ); |
| 35 |
|
| 36 |
|
| 37 |
} |
| 38 |
|
| 39 |
/** |
| 40 |
* Output the settings. |
| 41 |
*/ |
| 42 |
public function output() { |
| 43 |
global $current_section; |
| 44 |
|
| 45 |
$settings = $this->get_settings( $current_section ); |
| 46 |
|
| 47 |
UsersWP_Admin_Settings::output_fields( $settings ); |
| 48 |
} |
| 49 |
|
| 50 |
|
| 51 |
/** |
| 52 |
* Save settings. |
| 53 |
*/ |
| 54 |
public function save() { |
| 55 |
global $current_section; |
| 56 |
|
| 57 |
$settings = $this->get_settings( $current_section ); |
| 58 |
UsersWP_Admin_Settings::save_fields( $settings ); |
| 59 |
} |
| 60 |
|
| 61 |
/** |
| 62 |
* Get sections. |
| 63 |
* |
| 64 |
* @return array |
| 65 |
*/ |
| 66 |
public function get_sections() { |
| 67 |
|
| 68 |
$sections = array( |
| 69 |
'' => __( 'Pages', 'userswp' ), |
| 70 |
'register' => __( 'Register', 'userswp' ), |
| 71 |
'login' => __( 'Login', 'userswp' ), |
| 72 |
'change-password' => __( 'Change Password', 'userswp' ), |
| 73 |
'profile' => __( 'Profile', 'userswp' ), |
| 74 |
'users' => __( 'Users', 'userswp' ), |
| 75 |
'account' => __( 'Account', 'userswp' ), |
| 76 |
'authorbox' => __( 'Author box', 'userswp' ), |
| 77 |
'developer' => __( 'Developer', 'userswp' ), |
| 78 |
); |
| 79 |
|
| 80 |
return apply_filters( 'uwp_get_sections_' . $this->id, $sections ); |
| 81 |
} |
| 82 |
|
| 83 |
/** |
| 84 |
* Get general settings array. |
| 85 |
* |
| 86 |
* @return array |
| 87 |
*/ |
| 88 |
public function get_settings( $current_section = '' ) { |
| 89 |
|
| 90 |
if ( 'register' == $current_section ) { |
| 91 |
/** |
| 92 |
* Filter registration settings array. |
| 93 |
* |
| 94 |
* @package userswp |
| 95 |
*/ |
| 96 |
|
| 97 |
$settings = apply_filters( 'uwp_register_options', array( |
| 98 |
array( |
| 99 |
'title' => __( 'Register Settings', 'userswp' ), |
| 100 |
'type' => 'title', |
| 101 |
'id' => 'register_options', |
| 102 |
), |
| 103 |
array( |
| 104 |
'id' => 'register_modal', |
| 105 |
'name' => __( 'Register Lightbox', 'userswp' ), |
| 106 |
'desc' => __( 'When enabled some register links will open in a lightbox instead of changing page.','userswp'), |
| 107 |
'type' => 'checkbox', |
| 108 |
'default' => '1', |
| 109 |
), |
| 110 |
array( |
| 111 |
'id' => 'register_modal_form', |
| 112 |
'name' => __( 'Register Form(s)', 'userswp' ), |
| 113 |
'desc' => __( 'Choose form(s) to display on registration pages. When multiple forms are selected, users can choose their user type. Applies to both lightbox and normal registration forms.','userswp'), |
| 114 |
'type' => 'multiselect', |
| 115 |
'options' => uwp_get_register_forms_dropdown_options(), |
| 116 |
'default' => '1', |
| 117 |
'desc_tip' => true, |
| 118 |
), |
| 119 |
array( |
| 120 |
'id' => 'register_form_display_style', |
| 121 |
'name' => __( 'User Type Selector Style', 'userswp' ), |
| 122 |
'desc' => __( 'Choose how to display the user type selector when multiple forms are available. Button groups work best for 2-5 user types, while select field is better for many types.','userswp'), |
| 123 |
'type' => 'select', |
| 124 |
'options' => array( |
| 125 |
'buttons' => __( 'Button Groups', 'userswp' ), |
| 126 |
'select' => __( 'Select Field (Dropdown)', 'userswp' ), |
| 127 |
), |
| 128 |
'default' => 'buttons', |
| 129 |
'desc_tip' => true, |
| 130 |
), |
| 131 |
array( |
| 132 |
'id' => 'register_form_button_title', |
| 133 |
'type' => 'text', |
| 134 |
'name' => __( 'Register Form Button Title', 'userswp' ), |
| 135 |
'desc' => __( 'Enter the register form button title.', 'userswp' ), |
| 136 |
'placeholder' => __( 'Create account', 'userswp' ), |
| 137 |
'default' => '', |
| 138 |
'desc_tip' => true, |
| 139 |
'advanced' => true |
| 140 |
), |
| 141 |
array( |
| 142 |
'id' => 'wp_register_redirect', |
| 143 |
'name' => __( 'Redirect Admin Default Register Page', 'userswp' ), |
| 144 |
'desc' => __( 'When enabled /wp-login.php?action=register page will be redirected to UsersWP register page.', 'userswp' ), |
| 145 |
'type' => 'checkbox', |
| 146 |
'default' => '1', |
| 147 |
), |
| 148 |
array( |
| 149 |
'id' => 'register_min_password_strength', |
| 150 |
'name' => __( 'Minimum password strength', 'userswp' ), |
| 151 |
'desc' => __( 'Forces users to use strong password on registration if set.', 'userswp' ), |
| 152 |
'type' => 'select', |
| 153 |
'options' => array(''=>'None','3'=>'Medium','4'=>'Strong'), |
| 154 |
'default' => '', |
| 155 |
'desc_tip' => true, |
| 156 |
), |
| 157 |
array( |
| 158 |
'id' => 'register_uwp_strong_pass_msg', |
| 159 |
'name' => __( 'Error message for entering strong password', 'userswp' ), |
| 160 |
'desc' => __( 'Enter the message to show when user enters weak password in registration form.', 'userswp' ), |
| 161 |
'type' => 'text', |
| 162 |
'default' => '', |
| 163 |
'placeholder' => __( 'Please enter valid strong password.', 'userswp' ), |
| 164 |
'desc_tip' => true, |
| 165 |
'advanced' => true, |
| 166 |
), |
| 167 |
array( |
| 168 |
'id' => 'register_username_length', |
| 169 |
'name' => __( 'Username Minimum Length', 'userswp' ), |
| 170 |
'desc' => __( 'Minimum username character limit required for registration.', 'userswp' ), |
| 171 |
'desc_tip' => true, |
| 172 |
'type' => 'number', |
| 173 |
'default' => '4', |
| 174 |
'advanced' => true, |
| 175 |
), |
| 176 |
array( |
| 177 |
'id' => 'register_username_length_max', |
| 178 |
'name' => __( 'Username Maximum Length', 'userswp' ), |
| 179 |
'desc' => __( 'Maximum username character limit required for registration.', 'userswp' ), |
| 180 |
'desc_tip' => true, |
| 181 |
'type' => 'number', |
| 182 |
'default' => '20', |
| 183 |
'advanced' => true, |
| 184 |
), |
| 185 |
array( |
| 186 |
'id' => 'register_password_min_length', |
| 187 |
'name' => __( 'Minimum Password Limit', 'userswp' ), |
| 188 |
'desc' => __( 'Minimum Password limit user should enter in the form.', 'userswp' ), |
| 189 |
'desc_tip' => true, |
| 190 |
'type' => 'number', |
| 191 |
'default' => '8', |
| 192 |
'advanced' => true, |
| 193 |
), |
| 194 |
array( |
| 195 |
'id' => 'register_password_max_length', |
| 196 |
'name' => __( 'Maximum Password Limit', 'userswp' ), |
| 197 |
'desc' => __( 'Maximum Password limit user should enter in the form.', 'userswp' ), |
| 198 |
'desc_tip' => true, |
| 199 |
'type' => 'number', |
| 200 |
'default' => '15', |
| 201 |
'advanced' => true, |
| 202 |
), |
| 203 |
|
| 204 |
array( 'type' => 'sectionend', 'id' => 'register_options' ), |
| 205 |
)); |
| 206 |
} else if ( 'login' == $current_section ) { |
| 207 |
/** |
| 208 |
* Filter login settings array. |
| 209 |
* |
| 210 |
* @package userswp |
| 211 |
*/ |
| 212 |
$pages = get_pages(); |
| 213 |
$pages_options = array( |
| 214 |
'-1' => __( 'Last User Page', 'userswp' ), |
| 215 |
'0' => __( 'Default Redirect', 'userswp'), |
| 216 |
'-2' => __( 'Custom Redirect', 'userswp'), |
| 217 |
); |
| 218 |
if ( $pages ) { |
| 219 |
foreach ( $pages as $page ) { |
| 220 |
$pages_options[ $page->ID ] = $page->post_title; |
| 221 |
} |
| 222 |
} |
| 223 |
|
| 224 |
$settings = apply_filters( 'uwp_login_options', array( |
| 225 |
array( |
| 226 |
'title' => __( 'Login Settings', 'userswp' ), |
| 227 |
'type' => 'title', |
| 228 |
'id' => 'login_options', |
| 229 |
), |
| 230 |
array( |
| 231 |
'id' => 'login_modal', |
| 232 |
'name' => __( 'Login Lightbox', 'userswp' ), |
| 233 |
'desc' => __( 'When enabled some login links will open in a lightbox instead of changing page. The page will be reloaded after successful login instead of a redirect.','userswp'), |
| 234 |
'type' => 'checkbox', |
| 235 |
'default' => '1', |
| 236 |
), |
| 237 |
array( |
| 238 |
'id' => 'login_modal_enable_redirect', |
| 239 |
'name' => __( 'Enable Login Lightbox Redirect', 'userswp' ), |
| 240 |
'desc' => __( 'When enabled the login in lightbox will follow login redirect settings.','userswp'), |
| 241 |
'type' => 'checkbox', |
| 242 |
'default' => '0', |
| 243 |
), |
| 244 |
array( |
| 245 |
'id' => 'login_redirect_to', |
| 246 |
'name' => __( 'Login Redirect Page', 'userswp' ), |
| 247 |
'desc' => __( 'Set the page to redirect the user to after logging in. If default redirect has been set then WordPress default will be used.', 'userswp' ), |
| 248 |
'type' => 'select', |
| 249 |
'options' => $pages_options, |
| 250 |
'default' => '-1', |
| 251 |
'desc_tip' => true, |
| 252 |
), |
| 253 |
array( |
| 254 |
'id' => 'login_redirect_custom_url', |
| 255 |
'name' => __( 'Redirect Custom URL', 'userswp' ), |
| 256 |
'desc' => __( 'Set the custom url to redirect the user to after logging in.', 'userswp' ), |
| 257 |
'type' => 'text', |
| 258 |
'default' => '', |
| 259 |
'desc_tip' => true, |
| 260 |
'class' => 'uwp-login-redirect-custom-url', |
| 261 |
), |
| 262 |
array( |
| 263 |
'id' => 'register_link_title', |
| 264 |
'name' => __( 'Register Link Title', 'userswp' ), |
| 265 |
'desc' => __( 'Enter the register link title.', 'userswp' ), |
| 266 |
'type' => 'text', |
| 267 |
'default' => '', |
| 268 |
'placeholder' => __( 'Create account', 'userswp' ), |
| 269 |
'desc_tip' => true, |
| 270 |
'advanced' => true, |
| 271 |
), |
| 272 |
array( |
| 273 |
'id' => 'forgot_link_title', |
| 274 |
'name' => __( 'Forgot Password Link Title', 'userswp' ), |
| 275 |
'desc' => __( 'Enter the forgot password title.', 'userswp' ), |
| 276 |
'type' => 'text', |
| 277 |
'default' => '', |
| 278 |
'placeholder' => __( 'Forgot password?', 'userswp' ), |
| 279 |
'desc_tip' => true, |
| 280 |
'advanced' => true, |
| 281 |
), |
| 282 |
array( |
| 283 |
'id' => 'block_wp_login', |
| 284 |
'name' => __( 'Redirect wp-login.php?', 'userswp' ), |
| 285 |
'desc' => __('When enabled /wp-login.php page will be redirected to UsersWP login page.','userswp' ), |
| 286 |
'type' => 'checkbox', |
| 287 |
'default' => '0', |
| 288 |
), |
| 289 |
array( |
| 290 |
'name' => __( 'Restrict wp-admin', 'userswp' ), |
| 291 |
'desc' => __( 'The user roles that should be restricted from accessing the wp-admin area.', 'userswp' ), |
| 292 |
'id' => 'admin_blocked_roles', |
| 293 |
'default' => array('subscriber'), |
| 294 |
'type' => 'multiselect', |
| 295 |
'class' => 'uwp-select', |
| 296 |
'options' => uwp_get_user_roles(array('administrator')), |
| 297 |
'desc_tip' => true, |
| 298 |
), |
| 299 |
array( |
| 300 |
'id' => 'logout_redirect_to', |
| 301 |
'name' => __( 'Logout Redirect Page', 'userswp' ), |
| 302 |
'desc' => __( 'Set the page to redirect the user to after logging out. If no page has been set WordPress default will be used.', 'userswp' ), |
| 303 |
'type' => 'single_select_page', |
| 304 |
'desc_tip' => true, |
| 305 |
), |
| 306 |
array( |
| 307 |
'id' => 'disable_wp_2fa', |
| 308 |
'name' => __( 'Disable WP-2FA', 'userswp' ), |
| 309 |
'desc' => __('This will disable integration with WP 2FA - Two-factor authentication for WordPress plugin.','userswp' ), |
| 310 |
'type' => 'checkbox', |
| 311 |
'default' => '0', |
| 312 |
), |
| 313 |
array( 'type' => 'sectionend', 'id' => 'login_options' ), |
| 314 |
)); |
| 315 |
} else if ( 'change-password' == $current_section ) { |
| 316 |
/** |
| 317 |
* Filter change password settings array. |
| 318 |
* |
| 319 |
* @package userswp |
| 320 |
*/ |
| 321 |
$settings = apply_filters( 'uwp_change_password_options', array( |
| 322 |
array( |
| 323 |
'title' => __( 'Change Password Settings', 'userswp' ), |
| 324 |
'type' => 'title', |
| 325 |
'id' => 'change_password_options', |
| 326 |
), |
| 327 |
array( |
| 328 |
'id' => 'forgot_modal', |
| 329 |
'name' => __( 'Forgot password lightbox', 'userswp' ), |
| 330 |
'desc' => __( 'When enabled some forgot password links will open in a lightbox instead of changing page.','userswp'), |
| 331 |
'type' => 'checkbox', |
| 332 |
'default' => '1', |
| 333 |
), |
| 334 |
array( |
| 335 |
'id' => 'login_link_title', |
| 336 |
'name' => __( 'Login Link Title', 'userswp' ), |
| 337 |
'desc' => __( 'Enter the login link title.', 'userswp' ), |
| 338 |
'type' => 'text', |
| 339 |
'default' => '', |
| 340 |
'placeholder' => __( 'Login', 'userswp' ), |
| 341 |
'desc_tip' => true, |
| 342 |
'advanced' => true, |
| 343 |
), |
| 344 |
array( |
| 345 |
'id' => 'profile_link_title', |
| 346 |
'name' => __( 'Profile Link Title', 'userswp' ), |
| 347 |
'desc' => __( 'Enter the profile link title.', 'userswp' ), |
| 348 |
'type' => 'text', |
| 349 |
'default' => '', |
| 350 |
'placeholder' => __( 'Profile', 'userswp' ), |
| 351 |
'desc_tip' => true, |
| 352 |
'advanced' => true, |
| 353 |
), |
| 354 |
array( |
| 355 |
'id' => 'account_link_title', |
| 356 |
'name' => __( 'Account Link Title', 'userswp' ), |
| 357 |
'desc' => __( 'Enter the account link title.', 'userswp' ), |
| 358 |
'type' => 'text', |
| 359 |
'default' => '', |
| 360 |
'placeholder' => __( 'Account', 'userswp' ), |
| 361 |
'desc_tip' => true, |
| 362 |
'advanced' => true, |
| 363 |
), |
| 364 |
array( |
| 365 |
'id' => 'change_enable_old_password', |
| 366 |
'name' => __( 'Enabled Old Password?', 'userswp' ), |
| 367 |
'desc' => __( 'Ask user to enter their old password before changing the password to add an extra layer of security.', 'userswp' ), |
| 368 |
'type' => 'checkbox', |
| 369 |
'default' => '1', |
| 370 |
), |
| 371 |
array( |
| 372 |
'id' => 'change_disable_password_nag', |
| 373 |
'name' => __( 'Disable system generated password notice.', 'userswp' ), |
| 374 |
'desc' => __( 'This option will disable system generated password notice if user has not changed default password after registration.', 'userswp' ), |
| 375 |
'type' => 'checkbox', |
| 376 |
'default' => '0', |
| 377 |
), |
| 378 |
|
| 379 |
array( 'type' => 'sectionend', 'id' => 'change_password_options' ), |
| 380 |
)); |
| 381 |
} else if ( 'profile' == $current_section ) { |
| 382 |
/** |
| 383 |
* Filter profile settings array. |
| 384 |
* |
| 385 |
* @package userswp |
| 386 |
*/ |
| 387 |
$file_obj = new UsersWP_Files(); |
| 388 |
|
| 389 |
$settings = apply_filters( 'uwp_profile_options', array( |
| 390 |
array( |
| 391 |
'title' => __( 'Profile Settings', 'userswp' ), |
| 392 |
'type' => 'title', |
| 393 |
'id' => 'profile_options', |
| 394 |
), |
| 395 |
array( |
| 396 |
'id' => 'profile_default_banner', |
| 397 |
'name' => __( 'Default banner image', 'userswp' ), |
| 398 |
'desc' => __( 'Recommended image size: 1000x300', 'userswp'), |
| 399 |
'type' => 'image', |
| 400 |
'default' => '', |
| 401 |
'desc_tip' => true, |
| 402 |
), |
| 403 |
array( |
| 404 |
'id' => 'profile_default_profile', |
| 405 |
'name' => __( 'Default profile image', 'userswp' ), |
| 406 |
'desc' => __( 'Recommended image size: 150x150', 'userswp'), |
| 407 |
'type' => 'image', |
| 408 |
'default' => '', |
| 409 |
'desc_tip' => true, |
| 410 |
), |
| 411 |
array( |
| 412 |
'id' => 'enable_profile_header', |
| 413 |
'name' => __( 'Display header in profile', 'userswp' ), |
| 414 |
'type' => 'checkbox', |
| 415 |
'default' => '1', |
| 416 |
'advanced' => true, |
| 417 |
), |
| 418 |
array( |
| 419 |
'id' => 'enable_profile_body', |
| 420 |
'name' => __( 'Display body in profile', 'userswp' ), |
| 421 |
'type' => 'checkbox', |
| 422 |
'default' => '1', |
| 423 |
'advanced' => true, |
| 424 |
), |
| 425 |
array( |
| 426 |
'id' => 'profile_avatar_size', |
| 427 |
'name' => __( 'Profile avatar max file size', 'userswp' ), |
| 428 |
'desc' => sprintf(__( 'Enter Profile Avatar max file size in Kb. e.g. 512 for 512 kb, 1024 for 1 Mb, 2048 for 2 Mb etc. If empty WordPress default (%s) will be used.', 'userswp' ), '<b>'.$file_obj->uwp_formatSizeinKb($file_obj->uwp_get_max_upload_size()).'</b>'), |
| 429 |
'type' => 'number', |
| 430 |
'default' => '', |
| 431 |
'desc_tip' => true, |
| 432 |
'advanced' => true, |
| 433 |
), |
| 434 |
array( |
| 435 |
'id' => 'profile_banner_size', |
| 436 |
'name' => __( 'Profile banner max file size', 'userswp' ), |
| 437 |
'desc' => sprintf(__( 'Enter Profile Banner max file size in Kb. e.g. 512 for 512 kb, 1024 for 1 Mb, 2048 for 2 Mb etc. If empty WordPress default (%s) will be used.', 'userswp' ), '<b>'.$file_obj->uwp_formatSizeinKb($file_obj->uwp_get_max_upload_size()).'</b>'), |
| 438 |
'type' => 'number', |
| 439 |
'default' => '', |
| 440 |
'desc_tip' => true, |
| 441 |
'advanced' => true, |
| 442 |
), |
| 443 |
array( |
| 444 |
'id' => 'profile_avatar_width', |
| 445 |
'name' => __( 'Profile avatar width', 'userswp' ), |
| 446 |
'type' => 'number', |
| 447 |
'default' => 150, |
| 448 |
'advanced' => true, |
| 449 |
), |
| 450 |
array( |
| 451 |
'id' => 'profile_avatar_height', |
| 452 |
'name' => __( 'Profile avatar height', 'userswp' ), |
| 453 |
'type' => 'number', |
| 454 |
'default' => 150, |
| 455 |
'advanced' => true, |
| 456 |
), |
| 457 |
array( |
| 458 |
'id' => 'profile_banner_width', |
| 459 |
'name' => __( 'Profile banner width', 'userswp' ), |
| 460 |
'type' => 'number', |
| 461 |
'default' => 1000, |
| 462 |
'advanced' => true, |
| 463 |
), |
| 464 |
array( |
| 465 |
'id' => 'profile_banner_height', |
| 466 |
'name' => __( 'Profile banner height', 'userswp' ), |
| 467 |
'type' => 'number', |
| 468 |
'default' => 300, |
| 469 |
'advanced' => true, |
| 470 |
), |
| 471 |
array( |
| 472 |
'id' => 'profile_no_of_items', |
| 473 |
'name' => __( 'Number of items', 'userswp' ), |
| 474 |
'type' => 'number', |
| 475 |
'default' => 10, |
| 476 |
'desc' => __( 'Enter number of items to display in profile tabs.', 'userswp' ), |
| 477 |
'desc_tip' => true, |
| 478 |
'advanced' => true, |
| 479 |
), |
| 480 |
array( |
| 481 |
'id' => 'uwp_disable_author_link', |
| 482 |
'name' => __( 'Disable author redirect to UsersWP profile page.', 'userswp' ), |
| 483 |
'type' => 'checkbox', |
| 484 |
'default' => '0', |
| 485 |
'advanced' => true, |
| 486 |
), |
| 487 |
array( |
| 488 |
'id' => 'user_post_counts_cpts', |
| 489 |
'name' => __( 'User Counts CPTs', 'userswp' ), |
| 490 |
'desc' => __( 'Choose post types to display user counts in profile page for all users.', 'userswp' ), |
| 491 |
'type' => 'multiselect', |
| 492 |
'sortable' => true, |
| 493 |
'options' => uwp_get_posttypes(), |
| 494 |
'desc_tip' => true, |
| 495 |
), |
| 496 |
array( |
| 497 |
'id' => 'login_user_post_counts_cpts', |
| 498 |
'name' => __( 'User Counts CPTs for profile owner', 'userswp' ), |
| 499 |
'desc' => __( 'Choose post types to display user counts in profile page for profile owners.', 'userswp' ), |
| 500 |
'type' => 'multiselect', |
| 501 |
'sortable' => true, |
| 502 |
'options' => uwp_get_posttypes(), |
| 503 |
'desc_tip' => true, |
| 504 |
), |
| 505 |
array( 'type' => 'sectionend', 'id' => 'profile_options' ), |
| 506 |
)); |
| 507 |
} else if ( 'users' == $current_section ) { |
| 508 |
/** |
| 509 |
* Filter general settings array. |
| 510 |
* |
| 511 |
* @package userswp |
| 512 |
*/ |
| 513 |
$settings = apply_filters( 'uwp_users_options', array( |
| 514 |
array( |
| 515 |
'title' => __( 'Users Settings', 'userswp' ), |
| 516 |
'type' => 'title', |
| 517 |
'id' => 'users_options', |
| 518 |
), |
| 519 |
|
| 520 |
array( |
| 521 |
'id' => 'users_default_layout', |
| 522 |
'name' => __( 'Users default layout', 'userswp' ), |
| 523 |
'desc' => __( 'Choose the default layout for users listing page.', 'userswp' ), |
| 524 |
'type' => 'select', |
| 525 |
'options' => $this->uwp_available_users_layout(), |
| 526 |
'desc_tip' => true, |
| 527 |
), |
| 528 |
array( |
| 529 |
'id' => 'users_no_of_items', |
| 530 |
'name' => __( 'Number of items', 'userswp' ), |
| 531 |
'type' => 'number', |
| 532 |
'default' => 10, |
| 533 |
'desc' => __( 'Enter number of items to display in users list page.', 'userswp' ), |
| 534 |
'desc_tip' => true, |
| 535 |
'advanced' => true, |
| 536 |
), |
| 537 |
array( |
| 538 |
'id' => 'users_excluded_from_list', |
| 539 |
'name' => __( 'Users to exclude', 'userswp' ), |
| 540 |
'desc' => __( 'Select users to exclude from the users listing.', 'userswp' ), |
| 541 |
'desc_tip' => true, |
| 542 |
'type' => 'multiselect', |
| 543 |
'size' => 'regular', |
| 544 |
'options' => $this->get_users(), |
| 545 |
), |
| 546 |
|
| 547 |
array( 'type' => 'sectionend', 'id' => 'users_options' ), |
| 548 |
)); |
| 549 |
}else if ( 'account' == $current_section ) { |
| 550 |
/** |
| 551 |
* Filter general settings array. |
| 552 |
* |
| 553 |
* @package userswp |
| 554 |
*/ |
| 555 |
$settings = apply_filters( 'uwp_users_options', array( |
| 556 |
array( |
| 557 |
'title' => __( 'User Account Settings', 'userswp' ), |
| 558 |
'type' => 'title', |
| 559 |
'id' => 'accounts_options', |
| 560 |
), |
| 561 |
|
| 562 |
array( |
| 563 |
'id' => 'disable_account_delete', |
| 564 |
'name' => __( 'Disable Account Delete', 'userswp' ), |
| 565 |
'desc' => __( 'Don\'t allow users to delete their own account. Default enabled.' , 'userswp' ), |
| 566 |
'type' => 'checkbox', |
| 567 |
'default' => 0, |
| 568 |
), |
| 569 |
|
| 570 |
array( 'type' => 'sectionend', 'id' => 'accounts_options' ), |
| 571 |
)); |
| 572 |
}else if ( 'authorbox' == $current_section ) { |
| 573 |
/** |
| 574 |
* Filter general settings array. |
| 575 |
* |
| 576 |
* @package userswp |
| 577 |
*/ |
| 578 |
$settings = apply_filters( 'uwp_authorbox_options', array( |
| 579 |
array( |
| 580 |
'title' => __( 'Author Box Settings', 'userswp' ), |
| 581 |
'type' => 'title', |
| 582 |
'id' => 'authorbox_options', |
| 583 |
), |
| 584 |
array( |
| 585 |
'id' => 'author_box_enable_disable', |
| 586 |
'name' => __( 'Enable Author Box', 'userswp' ), |
| 587 |
'desc' => __( 'Displays author box based on settings', 'userswp' ), |
| 588 |
'type' => 'checkbox', |
| 589 |
'default' => '1', |
| 590 |
), |
| 591 |
array( |
| 592 |
'id' => 'author_box_display_content', |
| 593 |
'name' => __('Where to display?', 'userswp'), |
| 594 |
'desc' => __('Displays the author box above or below post content.', 'userswp'), |
| 595 |
'type' => 'select', |
| 596 |
'options' => array( |
| 597 |
'above_content' => __('Above content', 'userswp'), |
| 598 |
'below_content' => __('Below content', 'userswp'), |
| 599 |
), |
| 600 |
'desc_tip' => true, |
| 601 |
'default' => 'below_content', |
| 602 |
), |
| 603 |
array( |
| 604 |
'id' => 'author_box_display_post_types', |
| 605 |
'name' => __( 'Post types', 'userswp' ), |
| 606 |
'desc' => __( 'Choose post types to display author box', 'userswp' ), |
| 607 |
'type' => 'multiselect', |
| 608 |
'sortable' => true, |
| 609 |
'options' => uwp_get_posttypes(), |
| 610 |
'desc_tip' => true, |
| 611 |
'default' => 'post', |
| 612 |
), |
| 613 |
array( |
| 614 |
'id' => 'author_box_bio_limit', |
| 615 |
'name' => __( 'Bio Length', 'userswp' ), |
| 616 |
'desc' => __( 'Author bio word limit in Author box.', 'userswp' ), |
| 617 |
'desc_tip' => true, |
| 618 |
'type' => 'number', |
| 619 |
'default' => '200', |
| 620 |
'advanced' => true, |
| 621 |
), |
| 622 |
array( |
| 623 |
'name' => __('Author box Content', 'userswp'), |
| 624 |
'desc' => __('The author box body, this can be text or HTML.', 'userswp'), |
| 625 |
'id' => 'author_box_content', |
| 626 |
'type' => 'textarea', |
| 627 |
'class' => 'code uwp-authorbox-body', |
| 628 |
'desc_tip' => true, |
| 629 |
'placeholder' => UsersWP_Defaults::author_box_content(), |
| 630 |
'custom_desc' => __('Available template tags:', 'userswp') . ' ' . uwp_authbox_tags(), |
| 631 |
'advanced' => true, |
| 632 |
), |
| 633 |
array( |
| 634 |
'name' => __('Author box Content (bootstrap)', 'userswp'), |
| 635 |
'desc' => __('The author box body, this can be text or HTML.', 'userswp'), |
| 636 |
'id' => 'author_box_content_bootstrap', |
| 637 |
'type' => 'textarea', |
| 638 |
'class' => 'code uwp-authorbox-body', |
| 639 |
'desc_tip' => true, |
| 640 |
'placeholder' => UsersWP_Defaults::author_box_content_bootstrap(), |
| 641 |
'custom_desc' => __('Available template tags:', 'userswp') . ' ' . uwp_authbox_tags(), |
| 642 |
'advanced' => true, |
| 643 |
), |
| 644 |
|
| 645 |
array( 'type' => 'sectionend', 'id' => 'authorbox_options' ), |
| 646 |
)); |
| 647 |
}else if ( 'developer' == $current_section ) { |
| 648 |
/** |
| 649 |
* Filter general settings array. |
| 650 |
* |
| 651 |
* @package userswp |
| 652 |
*/ |
| 653 |
$settings = apply_filters( 'uwp_developer_options', array( |
| 654 |
array( |
| 655 |
'title' => __( 'Developer Settings', 'userswp' ), |
| 656 |
'type' => 'title', |
| 657 |
'id' => 'developer_options', |
| 658 |
), |
| 659 |
|
| 660 |
array( |
| 661 |
'id' => 'disable_avatar_override', |
| 662 |
'name' => __( 'Disable Avatar Override?', 'userswp' ), |
| 663 |
'desc' => __( 'By default UsersWP will change the avatar to profile image. You can disable this using this option.', 'userswp' ), |
| 664 |
'type' => 'checkbox', |
| 665 |
), |
| 666 |
|
| 667 |
array( |
| 668 |
'name' => __( 'Advanced settings', 'userswp' ), |
| 669 |
'desc' => __( 'Disable advanced toggle, show advanced settings at all times (not recommended).', 'userswp' ), |
| 670 |
'id' => 'admin_disable_advanced', |
| 671 |
'type' => 'checkbox', |
| 672 |
), |
| 673 |
|
| 674 |
array( |
| 675 |
'id' => 'enable_uwp_error_log', |
| 676 |
'name' => __( 'Debugging', 'userswp' ), |
| 677 |
'desc' => __( 'Show debugging info in the error logs.', 'userswp' ), |
| 678 |
'type' => 'checkbox', |
| 679 |
), |
| 680 |
|
| 681 |
// @todo to be move to own design section |
| 682 |
array( |
| 683 |
'id' => 'design_style', |
| 684 |
'name' => __('Default Design Style', 'userswp'), |
| 685 |
'desc' => __('The default design style to use.', 'userswp'), |
| 686 |
'type' => 'select', |
| 687 |
'options' => array( |
| 688 |
'bootstrap' => __('Bootstrap', 'userswp'), |
| 689 |
'' => __('Legacy (non-bootstrap)', 'userswp'), |
| 690 |
), |
| 691 |
'desc_tip' => true, |
| 692 |
'default' => 'bootstrap', |
| 693 |
), |
| 694 |
|
| 695 |
array( 'type' => 'sectionend', 'id' => 'developer_options' ), |
| 696 |
)); |
| 697 |
} else { |
| 698 |
/** |
| 699 |
* Filter pages settings array. |
| 700 |
* |
| 701 |
* @package userswp |
| 702 |
*/ |
| 703 |
$settings = apply_filters( 'uwp_page_options', array( |
| 704 |
array( |
| 705 |
'title' => __( 'Page Settings', 'userswp' ), |
| 706 |
'type' => 'title', |
| 707 |
'desc' => 'These are essential pages used by UWP, you can set the pages here and edit the title/slug of the page via WP page settings.', |
| 708 |
'id' => 'page_options', |
| 709 |
'desc_tip' => true, |
| 710 |
), |
| 711 |
array( |
| 712 |
'name' => __( 'User Profile Page', 'userswp' ), |
| 713 |
'desc' => __( 'This is the front end user\'s profile page. This page automatically overrides the default WordPress author page.', 'userswp' ), |
| 714 |
'id' => 'profile_page', |
| 715 |
'type' => 'single_select_page', |
| 716 |
'desc_tip' => true, |
| 717 |
), |
| 718 |
array( |
| 719 |
'name' => __( 'Register Page', 'userswp' ), |
| 720 |
'desc' => __( 'This is the front end register page. This is where users create their account.', 'userswp' ), |
| 721 |
'id' => 'register_page', |
| 722 |
'type' => 'single_select_page', |
| 723 |
'desc_tip' => true, |
| 724 |
), |
| 725 |
array( |
| 726 |
'name' => __( 'Login Page', 'userswp' ), |
| 727 |
'desc' => __( 'This is the front end login page. This is where users will login after creating their account.', 'userswp' ), |
| 728 |
'id' => 'login_page', |
| 729 |
'type' => 'single_select_page', |
| 730 |
'desc_tip' => true, |
| 731 |
), |
| 732 |
array( |
| 733 |
'name' => __( 'Account Page', 'userswp' ), |
| 734 |
'desc' => __( 'This is the front end account page. This is where users can edit their account.', 'userswp' ), |
| 735 |
'id' => 'account_page', |
| 736 |
'type' => 'single_select_page', |
| 737 |
'desc_tip' => true, |
| 738 |
), |
| 739 |
array( |
| 740 |
'name' => __( 'Change Password Page', 'userswp' ), |
| 741 |
'desc' => __( 'This is the front end Change Password page.', 'userswp' ), |
| 742 |
'id' => 'change_page', |
| 743 |
'type' => 'single_select_page', |
| 744 |
'desc_tip' => true, |
| 745 |
), |
| 746 |
array( |
| 747 |
'name' => __( 'Forgot Password Page', 'userswp' ), |
| 748 |
'desc' => __( 'This is the front end Forgot Password page. This is the page where users are sent to reset their password when they lose it.', 'userswp' ), |
| 749 |
'id' => 'forgot_page', |
| 750 |
'type' => 'single_select_page', |
| 751 |
'desc_tip' => true, |
| 752 |
), |
| 753 |
array( |
| 754 |
'name' => __( 'Reset Password Page', 'userswp' ), |
| 755 |
'desc' => __( 'This is the front end Reset Password page. This is the page where users can reset their password when they lose it.', 'userswp' ), |
| 756 |
'id' => 'reset_page', |
| 757 |
'type' => 'single_select_page', |
| 758 |
'desc_tip' => true, |
| 759 |
), |
| 760 |
array( |
| 761 |
'name' => __( 'Users List Page', 'userswp' ), |
| 762 |
'desc' => __( 'This is the front end Users List page. This is the page where all registered users of the websites are listed.', 'userswp' ), |
| 763 |
'id' => 'users_page', |
| 764 |
'type' => 'single_select_page', |
| 765 |
'desc_tip' => true, |
| 766 |
), |
| 767 |
array( |
| 768 |
'name' => __( 'Users List Item Page', 'userswp' ), |
| 769 |
'desc' => __( 'This is the page/template for displaying user item in users list page. You can change the template as you want which will apply to each user item in users list page.', 'userswp' ), |
| 770 |
'id' => 'user_list_item_page', |
| 771 |
'type' => 'single_select_page', |
| 772 |
'desc_tip' => true, |
| 773 |
), |
| 774 |
array( 'type' => 'sectionend', 'id' => 'page_options' ), |
| 775 |
)); |
| 776 |
} |
| 777 |
|
| 778 |
|
| 779 |
return apply_filters( 'uwp_get_settings_' . $this->id, $settings ); |
| 780 |
} |
| 781 |
|
| 782 |
/** |
| 783 |
* Output a color picker input box. |
| 784 |
* |
| 785 |
* @param mixed $name |
| 786 |
* @param string $id |
| 787 |
* @param mixed $value |
| 788 |
* @param string $desc (default: '') |
| 789 |
*/ |
| 790 |
public function color_picker( $name, $id, $value, $desc = '' ) { |
| 791 |
echo '<div class="color_box">' . uwp_help_tip( $desc ) . '<input name="' . esc_attr( $id ) . '" id="' . esc_attr( $id ) . '" type="text" value="' . esc_attr( $value ) . '" class="colorpick" /> <div id="colorPickerDiv_' . esc_attr( $id ) . '" class="colorpickdiv"></div></div>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 792 |
} |
| 793 |
|
| 794 |
public function uwp_available_users_layout() { |
| 795 |
$tabs_arr = array( |
| 796 |
'list' => __( 'Grid View - 1 Column (List View)', 'userswp' ), |
| 797 |
'2col' => __( 'Grid View - 2 Column', 'userswp' ), |
| 798 |
'3col' => __( 'Grid View - 3 Column', 'userswp' ), |
| 799 |
'4col' => __( 'Grid View - 4 Column', 'userswp' ), |
| 800 |
'5col' => __( 'Grid View - 5 Column', 'userswp' ), |
| 801 |
); |
| 802 |
|
| 803 |
$tabs_arr = apply_filters('uwp_available_users_layout', $tabs_arr); |
| 804 |
|
| 805 |
return $tabs_arr; |
| 806 |
} |
| 807 |
|
| 808 |
/** |
| 809 |
* Get users lists. |
| 810 |
* |
| 811 |
* @return array $users |
| 812 |
*/ |
| 813 |
public function get_users() { |
| 814 |
$get_users = get_users(); |
| 815 |
|
| 816 |
$users = array(); |
| 817 |
if(!empty($get_users) ) { |
| 818 |
foreach ($get_users as $key => $user) { |
| 819 |
$users[$user->ID] = esc_attr( $user->display_name ); |
| 820 |
} |
| 821 |
} |
| 822 |
|
| 823 |
return $users; |
| 824 |
} |
| 825 |
} |
| 826 |
|
| 827 |
endif; |
| 828 |
|
| 829 |
return new UsersWP_Settings_General(); |