| 1 |
<?php |
| 2 |
/** |
| 3 |
* Function that creates the "General Settings" submenu page |
| 4 |
* |
| 5 |
* @since v.2.0 |
| 6 |
* |
| 7 |
* @return void |
| 8 |
*/ |
| 9 |
function wppb_register_general_settings_submenu_page() { |
| 10 |
add_submenu_page( 'profile-builder', __( 'General Settings', 'profilebuilder' ), __( 'General Settings', 'profilebuilder' ), 'manage_options', 'profile-builder-general-settings', 'wppb_general_settings_content' ); |
| 11 |
} |
| 12 |
add_action( 'admin_menu', 'wppb_register_general_settings_submenu_page', 3 ); |
| 13 |
|
| 14 |
|
| 15 |
function wppb_generate_default_settings_defaults(){ |
| 16 |
$wppb_general_settings = get_option( 'wppb_general_settings', 'not_found' ); |
| 17 |
|
| 18 |
if ( $wppb_general_settings == 'not_found' ) |
| 19 |
update_option( 'wppb_general_settings', array( 'extraFieldsLayout' => 'default', 'emailConfirmation' => 'no', 'activationLandingPage' => '', 'adminApproval' => 'no', 'loginWith' => 'username' ) ); |
| 20 |
} |
| 21 |
|
| 22 |
|
| 23 |
/** |
| 24 |
* Function that adds content to the "General Settings" submenu page |
| 25 |
* |
| 26 |
* @since v.2.0 |
| 27 |
* |
| 28 |
* @return string |
| 29 |
*/ |
| 30 |
function wppb_general_settings_content() { |
| 31 |
wppb_generate_default_settings_defaults(); |
| 32 |
?> |
| 33 |
<div class="wrap wppb-wrap"> |
| 34 |
<form method="post" action="options.php#general-settings"> |
| 35 |
<?php $wppb_generalSettings = get_option( 'wppb_general_settings' ); ?> |
| 36 |
<?php settings_fields( 'wppb_general_settings' ); ?> |
| 37 |
|
| 38 |
<h2><?php _e( 'General Settings', 'profilebuilder' ); ?></h2> |
| 39 |
<table class="form-table"> |
| 40 |
<tr> |
| 41 |
<th scope="row"> |
| 42 |
<?php _e( "Load Profile Builder's own CSS file in the front-end:", "profilebuilder" ); ?> |
| 43 |
</th> |
| 44 |
<td> |
| 45 |
<label><input type="checkbox" name="wppb_general_settings[extraFieldsLayout]"<?php echo ( ( isset( $wppb_generalSettings['extraFieldsLayout'] ) && ( $wppb_generalSettings['extraFieldsLayout'] == 'default' ) ) ? ' checked' : '' ); ?> value="default" class="wppb-select"><?php _e( 'Yes', 'profilebuilder' ); ?></label> |
| 46 |
<ul> |
| 47 |
<li class="description"><?php printf( __( 'You can find the default file here: %1$s', 'profilebuilder' ), '<a href="'.dirname( plugin_dir_url( __FILE__ ) ).'/assets/css/style-front-end.css" target="_blank">'.dirname( dirname( plugin_basename( __FILE__ ) ) ).'\assets\css\style-front-end.css</a>' ); ?></li> |
| 48 |
</ul> |
| 49 |
</td> |
| 50 |
</tr> |
| 51 |
<?php |
| 52 |
if ( !is_multisite() ){ |
| 53 |
?> |
| 54 |
<tr> |
| 55 |
<th scope="row"> |
| 56 |
<?php _e( '"Email Confirmation" Activated:', 'profilebuilder' );?> |
| 57 |
</th> |
| 58 |
<td> |
| 59 |
<select name="wppb_general_settings[emailConfirmation]" class="wppb-select" id="wppb_settings_email_confirmation" onchange="wppb_display_page_select(this.value)"> |
| 60 |
<option value="yes" <?php if ( $wppb_generalSettings['emailConfirmation'] == 'yes' ) echo 'selected'; ?>><?php _e( 'Yes', 'profilebuilder' ); ?></option> |
| 61 |
<option value="no" <?php if ( $wppb_generalSettings['emailConfirmation'] == 'no' ) echo 'selected'; ?>><?php _e( 'No', 'profilebuilder' ); ?></option> |
| 62 |
</select> |
| 63 |
<ul> |
| 64 |
<li class="description"><?php _e( 'On single-site installations this works with front-end forms only. Recommended to redirect WP default registration to a Profile Builder one using "Custom Redirects" addon.', 'profilebuilder' ); ?></li> |
| 65 |
<li class="description"><?php _e( 'The "Email Confirmation" feature is active (by default) on WPMU installations.', 'profilebuilder' ); ?></li> |
| 66 |
<?php if ( is_multisite() || ( $wppb_generalSettings['emailConfirmation'] == 'yes' ) ) ?> |
| 67 |
<li class="description dynamic1"><?php printf( __( 'You can find a list of unconfirmed email addresses %1$sUsers > All Users > Email Confirmation%2$s.', 'profilebuilder' ), '<a href="'.get_bloginfo( 'url' ).'/wp-admin/users.php?page=unconfirmed_emails">', '</a>' )?></li> |
| 68 |
</ul> |
| 69 |
</td> |
| 70 |
</tr> |
| 71 |
<?php |
| 72 |
}else{ |
| 73 |
echo '<input type="hidden" id="wppb_general_settings_hidden" value="multisite"/>'; |
| 74 |
} |
| 75 |
?> |
| 76 |
|
| 77 |
<tr id="wppb-settings-activation-page"> |
| 78 |
<th scope="row"> |
| 79 |
<?php _e( '"Email Confirmation" Landing Page:', 'profilebuilder' ); ?> |
| 80 |
</th> |
| 81 |
<td> |
| 82 |
<select name="wppb_general_settings[activationLandingPage]" class="wppb-select"> |
| 83 |
<option value="" <?php if ( empty( $wppb_generalSettings['emailConfirmation'] ) ) echo 'selected'; ?>></option> |
| 84 |
<optgroup label="<?php _e( 'Existing Pages', 'profilebuilder' ); ?>"> |
| 85 |
<?php |
| 86 |
$pages = get_pages( apply_filters( 'wppb_page_args_filter', array( 'sort_order' => 'ASC', 'sort_column' => 'post_title', 'post_type' => 'page', 'post_status' => array( 'publish' ) ) ) ); |
| 87 |
|
| 88 |
foreach ( $pages as $key => $value ){ |
| 89 |
echo '<option value="'.$value->ID.'"'; |
| 90 |
if ( $wppb_generalSettings['activationLandingPage'] == $value->ID ) |
| 91 |
echo ' selected'; |
| 92 |
|
| 93 |
echo '>' . $value->post_title . '</option>'; |
| 94 |
} |
| 95 |
?> |
| 96 |
</optgroup> |
| 97 |
</select> |
| 98 |
<p class="description"> |
| 99 |
<?php _e( 'Specify the page where the users will be directed when confirming the email account. This page can differ from the register page(s) and can be changed at any time. If none selected, a simple confirmation page will be displayed for the user.', 'profilebuilder' ); ?> |
| 100 |
</p> |
| 101 |
</td> |
| 102 |
</tr> |
| 103 |
|
| 104 |
|
| 105 |
<?php |
| 106 |
if ( file_exists( WPPB_PLUGIN_DIR.'/features/admin-approval/admin-approval.php' ) ){ |
| 107 |
?> |
| 108 |
<tr> |
| 109 |
<th scope="row"> |
| 110 |
<?php _e( '"Admin Approval" Activated:', 'profilebuilder' ); ?> |
| 111 |
</th> |
| 112 |
<td> |
| 113 |
<select id="adminApprovalSelect" name="wppb_general_settings[adminApproval]" class="wppb-select" onchange="wppb_display_page_select_aa(this.value)"> |
| 114 |
<option value="yes" <?php if ($wppb_generalSettings['adminApproval'] == 'yes') echo 'selected'; ?>><?php _e( 'Yes', 'profilebuilder' ); ?></option> |
| 115 |
<option value="no" <?php if ($wppb_generalSettings['adminApproval'] == 'no') echo 'selected'; ?>><?php _e( 'No', 'profilebuilder' ); ?></option> |
| 116 |
</select> |
| 117 |
<ul> |
| 118 |
<li class="description dynamic2"><?php printf( __( 'You can find a list of users at %1$sUsers > All Users > Admin Approval%2$s.', 'profilebuilder' ), '<a href="'.get_bloginfo( 'url' ).'/wp-admin/users.php?page=admin_approval&orderby=registered&order=desc">', '</a>' )?></li> |
| 119 |
<ul> |
| 120 |
</td> |
| 121 |
</tr> |
| 122 |
|
| 123 |
<?php } ?> |
| 124 |
|
| 125 |
<?php |
| 126 |
if ( PROFILE_BUILDER == 'Profile Builder Free' ) { |
| 127 |
?> |
| 128 |
<tr> |
| 129 |
<th scope="row"> |
| 130 |
<?php _e( '"Admin Approval" Feature:', 'profilebuilder' ); ?> |
| 131 |
</th> |
| 132 |
<td> |
| 133 |
<p><em> <?php printf( __( 'You decide who is a user on your website. Get notified via email or approve multiple users at once from the WordPress UI. Enable Admin Approval by upgrading to %1$sHobbyist or PRO versions%2$s.', 'profilebuilder' ),'<a href="http://www.cozmoslabs.com/wordpress-profile-builder/?utm_source=wpbackend&utm_medium=clientsite&utm_content=general-settings-link&utm_campaign=PBFree">', '</a>' )?></em></p> |
| 134 |
</td> |
| 135 |
</tr> |
| 136 |
<?php } ?> |
| 137 |
|
| 138 |
<tr> |
| 139 |
<th scope="row"> |
| 140 |
<?php _e( 'Allow Users to Log in With:', 'profilebuilder' ); ?> |
| 141 |
</th> |
| 142 |
<td> |
| 143 |
<select name="wppb_general_settings[loginWith]" class="wppb-select"> |
| 144 |
<option value="username" <?php if ( $wppb_generalSettings['loginWith'] == 'username' ) echo 'selected'; ?>><?php _e( 'Username', 'profilebuilder' ); ?></option> |
| 145 |
<option value="email" <?php if ( $wppb_generalSettings['loginWith'] == 'email' ) echo 'selected'; ?>><?php _e( 'Email', 'profilebuilder' ); ?></option> |
| 146 |
</select> |
| 147 |
</td> |
| 148 |
</tr> |
| 149 |
|
| 150 |
<tr> |
| 151 |
<th scope="row"> |
| 152 |
<?php _e( 'Minimum Password Length:', 'profilebuilder' ); ?> |
| 153 |
</th> |
| 154 |
<td> |
| 155 |
<input type="text" name="wppb_general_settings[minimum_password_length]" class="wppb-text" value="<?php if( !empty( $wppb_generalSettings['minimum_password_length'] ) ) echo $wppb_generalSettings['minimum_password_length']; ?>"/> |
| 156 |
<ul> |
| 157 |
<li class="description"><?php _e( 'Enter the minimum characters the password should have. Leave empty for no minimum limit', 'profilebuilder' ); ?> </li> |
| 158 |
</ul> |
| 159 |
</td> |
| 160 |
</tr> |
| 161 |
|
| 162 |
<tr> |
| 163 |
<th scope="row"> |
| 164 |
<?php _e( 'Minimum Password Strength:', 'profilebuilder' ); ?> |
| 165 |
</th> |
| 166 |
<td> |
| 167 |
<select name="wppb_general_settings[minimum_password_strength]" class="wppb-select"> |
| 168 |
<option value=""><?php _e( 'Disabled', 'profilebuilder' ); ?></option> |
| 169 |
<option value="short" <?php if ( !empty($wppb_generalSettings['minimum_password_strength']) && $wppb_generalSettings['minimum_password_strength'] == 'short' ) echo 'selected'; ?>><?php _e( 'Very weak', 'profilebuilder' ); ?></option> |
| 170 |
<option value="bad" <?php if ( !empty($wppb_generalSettings['minimum_password_strength']) && $wppb_generalSettings['minimum_password_strength'] == 'bad' ) echo 'selected'; ?>><?php _e( 'Weak', 'profilebuilder' ); ?></option> |
| 171 |
<option value="good" <?php if ( !empty($wppb_generalSettings['minimum_password_strength']) && $wppb_generalSettings['minimum_password_strength'] == 'good' ) echo 'selected'; ?>><?php _e( 'Medium', 'profilebuilder' ); ?></option> |
| 172 |
<option value="strong" <?php if ( !empty($wppb_generalSettings['minimum_password_strength']) && $wppb_generalSettings['minimum_password_strength'] == 'strong' ) echo 'selected'; ?>><?php _e( 'Strong', 'profilebuilder' ); ?></option> |
| 173 |
</select> |
| 174 |
</td> |
| 175 |
</tr> |
| 176 |
</table> |
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
<input type="hidden" name="action" value="update" /> |
| 181 |
<p class="submit"><input type="submit" class="button-primary" value="<?php _e( 'Save Changes' ); ?>" /></p> |
| 182 |
</form> |
| 183 |
</div> |
| 184 |
|
| 185 |
<?php |
| 186 |
} |