| 1 |
<?php |
| 2 |
/** |
| 3 |
* Returns the General > Regsiter tab setting fields |
| 4 |
* |
| 5 |
* @since 1.0.0 |
| 6 |
* @package userswp |
| 7 |
* |
| 8 |
* @return array Setting fields |
| 9 |
*/ |
| 10 |
function uwp_settings_general_register_fields() { |
| 11 |
$fields = array( |
| 12 |
'uwp_registration_action' => array( |
| 13 |
'id' => 'uwp_registration_action', |
| 14 |
'name' => __('Registration Action', 'userswp'), |
| 15 |
'desc' => __('Select how registration should be handled.', 'userswp'), |
| 16 |
'type' => 'select', |
| 17 |
'global' => false, |
| 18 |
'options' => uwp_registration_status_options(), |
| 19 |
'chosen' => true, |
| 20 |
'placeholder' => __( 'Select Option', 'userswp' ), |
| 21 |
'class' => 'uwp_label_block', |
| 22 |
), |
| 23 |
'register_redirect_to' => array( |
| 24 |
'id' => 'register_redirect_to', |
| 25 |
'name' => __( 'Register Redirect Page', 'userswp' ), |
| 26 |
'desc' => __( 'Set the page to redirect the user to after signing up. If no page has been set WordPress default will be used.', 'userswp' ), |
| 27 |
'type' => 'select', |
| 28 |
'options' => uwp_get_pages(), |
| 29 |
'chosen' => true, |
| 30 |
'placeholder' => __( 'Select a page', 'userswp' ), |
| 31 |
'class' => 'uwp_label_block', |
| 32 |
), |
| 33 |
'register_terms_page' => array( |
| 34 |
'id' => 'register_terms_page', |
| 35 |
'name' => __( 'Register TOS Page', 'userswp' ), |
| 36 |
'desc' => __( 'Terms of Service page. When set "Accept terms and Conditions" checkbox will appear on the register form.', 'userswp' ), |
| 37 |
'type' => 'select', |
| 38 |
'options' => uwp_get_pages(), |
| 39 |
'chosen' => true, |
| 40 |
'placeholder' => __( 'Select a page', 'userswp' ), |
| 41 |
'class' => 'uwp_label_block', |
| 42 |
), |
| 43 |
'register_admin_notify' => array( |
| 44 |
'id' => 'register_admin_notify', |
| 45 |
'name' => __( 'Enable admin email notification?', 'userswp' ), |
| 46 |
'desc' => 'When enabled an email will be sent to the admin for every user registration.', |
| 47 |
'type' => 'checkbox', |
| 48 |
'std' => '0', |
| 49 |
'class' => 'uwp_label_inline', |
| 50 |
), |
| 51 |
); |
| 52 |
return $fields; |
| 53 |
} |
| 54 |
|
| 55 |
/** |
| 56 |
* Returns the General > Login tab setting fields |
| 57 |
* |
| 58 |
* @since 1.0.0 |
| 59 |
* @package userswp |
| 60 |
* |
| 61 |
* @return array Setting fields |
| 62 |
*/ |
| 63 |
function uwp_settings_general_login_fields() { |
| 64 |
$pages = get_pages(); |
| 65 |
$pages_options = array( '-1' => __( 'Last User Page', 'userswp' ) ); |
| 66 |
if ( $pages ) { |
| 67 |
foreach ( $pages as $page ) { |
| 68 |
$pages_options[ $page->ID ] = $page->post_title; |
| 69 |
} |
| 70 |
} |
| 71 |
$fields = array( |
| 72 |
'login_redirect_to' => array( |
| 73 |
'id' => 'login_redirect_to', |
| 74 |
'name' => __( 'Login Redirect Page', 'userswp' ), |
| 75 |
'desc' => __( 'Set the page to redirect the user to after logging in. If no page has been set WordPress default will be used.', 'userswp' ), |
| 76 |
'type' => 'select', |
| 77 |
'options' => $pages_options, |
| 78 |
'chosen' => true, |
| 79 |
'placeholder' => __( 'Select a page', 'userswp' ), |
| 80 |
'class' => 'uwp_label_block', |
| 81 |
), |
| 82 |
); |
| 83 |
return $fields; |
| 84 |
} |
| 85 |
|
| 86 |
/** |
| 87 |
* Returns the General > Login tab setting fields |
| 88 |
* |
| 89 |
* @since 1.0.0 |
| 90 |
* @package userswp |
| 91 |
* |
| 92 |
* @return array Setting fields |
| 93 |
*/ |
| 94 |
function uwp_settings_general_wp_login_fields() { |
| 95 |
$fields = array( |
| 96 |
'block_wp_login' => array( |
| 97 |
'id' => 'block_wp_login', |
| 98 |
'name' => __( 'Redirect wp-login.php?', 'userswp' ), |
| 99 |
'desc' => 'When enabled /wp-login.php page will be redirected to UsersWP login page.', |
| 100 |
'type' => 'checkbox', |
| 101 |
'std' => '0', |
| 102 |
'class' => 'uwp_label_inline', |
| 103 |
), |
| 104 |
); |
| 105 |
return $fields; |
| 106 |
} |
| 107 |
|
| 108 |
/** |
| 109 |
* Returns the General > Logout tab setting fields |
| 110 |
* |
| 111 |
* @since 1.0.0 |
| 112 |
* @package userswp |
| 113 |
* |
| 114 |
* @return array Setting fields |
| 115 |
*/ |
| 116 |
function uwp_settings_general_logout_fields() { |
| 117 |
$fields = array( |
| 118 |
'logout_redirect_to' => array( |
| 119 |
'id' => 'logout_redirect_to', |
| 120 |
'name' => __( 'Logout Redirect Page', 'userswp' ), |
| 121 |
'desc' => __( 'Set the page to redirect the user to after logging out. If no page has been set WordPress default will be used.', 'userswp' ), |
| 122 |
'type' => 'select', |
| 123 |
'options' => uwp_get_pages(), |
| 124 |
'chosen' => true, |
| 125 |
'placeholder' => __( 'Select a page', 'userswp' ), |
| 126 |
'class' => 'uwp_label_block', |
| 127 |
), |
| 128 |
); |
| 129 |
return $fields; |
| 130 |
} |
| 131 |
|
| 132 |
/** |
| 133 |
* Returns the General > Delete tab setting fields |
| 134 |
* |
| 135 |
* @since 1.0.0 |
| 136 |
* @package userswp |
| 137 |
* |
| 138 |
* @return array Setting fields |
| 139 |
*/ |
| 140 |
function uwp_settings_general_delete_fields() { |
| 141 |
$fields = array( |
| 142 |
'delete_redirect_to' => array( |
| 143 |
'id' => 'delete_redirect_to', |
| 144 |
'name' => __( 'Delete Redirect Page', 'userswp' ), |
| 145 |
'desc' => __( 'Set the page to redirect the user to after after they delete account. If no page has been set WordPress default will be used.', 'userswp' ), |
| 146 |
'type' => 'select', |
| 147 |
'options' => uwp_get_pages(), |
| 148 |
'chosen' => true, |
| 149 |
'placeholder' => __( 'Select a page', 'userswp' ), |
| 150 |
'class' => 'uwp_label_block', |
| 151 |
), |
| 152 |
); |
| 153 |
return $fields; |
| 154 |
} |
| 155 |
|
| 156 |
/** |
| 157 |
* Returns merged login and logout tab setting fields |
| 158 |
* |
| 159 |
* @since 1.0.0 |
| 160 |
* @package userswp |
| 161 |
* |
| 162 |
* @return array Setting fields |
| 163 |
*/ |
| 164 |
function uwp_settings_general_loginout_fields() { |
| 165 |
$login = uwp_settings_general_login_fields(); |
| 166 |
$wp_login = uwp_settings_general_wp_login_fields(); |
| 167 |
$logout = uwp_settings_general_logout_fields(); |
| 168 |
|
| 169 |
$fields = array_merge($login, $wp_login, $logout); |
| 170 |
return $fields; |
| 171 |
} |
| 172 |
|
| 173 |
/** |
| 174 |
* Get the field icon. |
| 175 |
* |
| 176 |
* @since 1.0.12 |
| 177 |
* @package userswp |
| 178 |
* |
| 179 |
* @param string Field icon value. |
| 180 |
* @return array Field icon element. |
| 181 |
*/ |
| 182 |
function uwp_get_field_icon( $value ) { |
| 183 |
$field_icon = $value; |
| 184 |
|
| 185 |
if ( ! empty( $value ) ) { |
| 186 |
if ( strpos( $value, 'http' ) === 0 ) { |
| 187 |
$field_icon = '<span class="uwp_field_icon" style="background: url(' . $value . ') no-repeat left center;padding-left:14px;background-size:100% auto;margin-right:5px"></span>'; |
| 188 |
} else if ( strpos($value, 'fa fa-') !== false ) { |
| 189 |
$field_icon = '<i class="uwp_field_icon ' . $value . '"></i>'; |
| 190 |
} |
| 191 |
} |
| 192 |
|
| 193 |
return apply_filters( 'uwp_get_field_icon', $field_icon, $value ); |
| 194 |
} |