| @@ -6,14 +6,14 @@ | ||
| 6 | 6 | * @package userswp |
| 7 | 7 | * |
| 8 | 8 | * @since 1.0.0 |
| 9 | 9 | */ |
| 10 | -function get_register_form_fields( $form_id = 1 ) { | |
| 10 | +function get_register_form_fields($form_id = 1) { | |
| 11 | 11 | global $wpdb; |
| 12 | 12 | $table_name = uwp_get_table_prefix() . 'uwp_form_fields'; |
| 13 | 13 | $extras_table_name = uwp_get_table_prefix() . 'uwp_form_extras'; |
| 14 | - $fields = $wpdb->get_results( $wpdb->prepare( 'SELECT fields.* FROM ' . $table_name . ' fields JOIN ' . $extras_table_name . " extras ON extras.site_htmlvar_name = fields.htmlvar_name WHERE fields.form_type = %s AND fields.is_active = '1' AND fields.for_admin_use != '1' AND fields.is_register_field = '1' AND extras.form_type = 'register' AND extras.form_id=%d AND fields.form_id=%d ORDER BY extras.sort_order ASC", array( 'account', $form_id, $form_id ) ) ); | |
| 15 | - $fields = apply_filters( 'uwp_get_register_form_fields', $fields, $form_id ); | |
| 14 | + $fields = $wpdb->get_results($wpdb->prepare("SELECT fields.* FROM " . $table_name . " fields JOIN " . $extras_table_name . " extras ON extras.site_htmlvar_name = fields.htmlvar_name WHERE fields.form_type = %s AND fields.is_active = '1' AND fields.for_admin_use != '1' AND fields.is_register_field = '1' AND extras.form_type = 'register' AND extras.form_id=%d AND fields.form_id=%d ORDER BY extras.sort_order ASC", array('account', $form_id, $form_id))); | |
| 15 | + $fields = apply_filters('uwp_get_register_form_fields', $fields, $form_id); | |
| 16 | 16 | return $fields; |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | function check_register_form_field( $var ) { |
| @@ -25,9 +25,9 @@ | ||
| 25 | 25 | $extras_table_name = uwp_get_table_prefix() . 'uwp_form_extras'; |
| 26 | 26 | |
| 27 | 27 | $fields = $wpdb->get_results( |
| 28 | 28 | $wpdb->prepare( |
| 29 | - 'select * from ' . $extras_table_name . ' where form_type = %s AND site_htmlvar_name = %s order by sort_order asc', | |
| 29 | + "select * from " . $extras_table_name . " where form_type = %s AND site_htmlvar_name = %s order by sort_order asc", | |
| 30 | 30 | array( 'register', $var ) |
| 31 | 31 | ) |
| 32 | 32 | ); |
| 33 | 33 | |
| @@ -49,9 +49,9 @@ | ||
| 49 | 49 | function get_register_validate_form_fields( $form_id = 1 ) { |
| 50 | 50 | global $wpdb; |
| 51 | 51 | $table_name = uwp_get_table_prefix() . 'uwp_form_fields'; |
| 52 | 52 | $extras_table_name = uwp_get_table_prefix() . 'uwp_form_extras'; |
| 53 | - $fields = $wpdb->get_results( $wpdb->prepare( 'SELECT fields.* FROM ' . $table_name . ' fields JOIN ' . $extras_table_name . " extras ON extras.site_htmlvar_name = fields.htmlvar_name WHERE fields.form_type = %s AND extras.form_type = 'register' AND fields.field_type != 'fieldset' AND fields.field_type != 'file' AND fields.is_active = '1' AND fields.for_admin_use != '1' AND fields.is_register_field = '1' AND extras.form_id = %d AND fields.form_id = %s ORDER BY extras.sort_order ASC", array( 'account', $form_id, $form_id ) ) ); | |
| 53 | + $fields = $wpdb->get_results( $wpdb->prepare( "SELECT fields.* FROM " . $table_name . " fields JOIN " . $extras_table_name . " extras ON extras.site_htmlvar_name = fields.htmlvar_name WHERE fields.form_type = %s AND fields.field_type != 'fieldset' AND fields.field_type != 'file' AND fields.is_active = '1' AND fields.for_admin_use != '1' AND fields.is_register_field = '1' AND fields.form_id = %s ORDER BY extras.sort_order ASC", array( 'account', $form_id ) ) ); | |
| 54 | 54 | $fields = apply_filters( 'uwp_get_register_validate_form_fields', $fields, $form_id ); |
| 55 | 55 | |
| 56 | 56 | return $fields; |
| 57 | 57 | } |
| @@ -68,15 +68,15 @@ | ||
| 68 | 68 | global $wpdb; |
| 69 | 69 | $table_name = uwp_get_table_prefix() . 'uwp_form_fields'; |
| 70 | 70 | $enable_old_password = uwp_get_option( 'change_enable_old_password', false ); |
| 71 | 71 | $user_id = get_current_user_id(); |
| 72 | - if ( $user_id && 1 == get_user_meta( $user_id, 'is_uwp_social_login_no_password', true ) ) { | |
| 72 | + if($user_id && 1 == get_user_meta($user_id, 'is_uwp_social_login_no_password', true)){ | |
| 73 | 73 | $enable_old_password = 0; |
| 74 | 74 | } |
| 75 | 75 | if ( $enable_old_password == '1' ) { |
| 76 | - $fields = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM ' . $table_name . " WHERE form_type = %s AND field_type != 'fieldset' AND field_type != 'file' AND is_active = '1' AND for_admin_use != '1' ORDER BY sort_order ASC", array( 'change' ) ) ); | |
| 76 | + $fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . $table_name . " WHERE form_type = %s AND field_type != 'fieldset' AND field_type != 'file' AND is_active = '1' AND for_admin_use != '1' ORDER BY sort_order ASC", array( 'change' ) ) ); | |
| 77 | 77 | } else { |
| 78 | - $fields = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM ' . $table_name . " WHERE form_type = %s AND field_type != 'fieldset' AND field_type != 'file' AND is_active = '1' AND for_admin_use != '1' AND htmlvar_name != 'old_password' ORDER BY sort_order ASC", array( 'change' ) ) ); | |
| 78 | + $fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . $table_name . " WHERE form_type = %s AND field_type != 'fieldset' AND field_type != 'file' AND is_active = '1' AND for_admin_use != '1' AND htmlvar_name != 'old_password' ORDER BY sort_order ASC", array( 'change' ) ) ); | |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | return $fields; |
| 82 | 82 | } |
| @@ -97,11 +97,11 @@ | ||
| 97 | 97 | $form_id = uwp_get_register_form_id( get_current_user_id() ); |
| 98 | 98 | $table_name = uwp_get_table_prefix() . 'uwp_form_fields'; |
| 99 | 99 | $include_admin_use = apply_filters( 'uwp_account_include_admin_use_only_fields', false ); |
| 100 | 100 | if ( $include_admin_use ) { |
| 101 | - $fields = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM ' . $table_name . " WHERE form_type = %s AND is_active = '1' AND is_register_only_field = '0' AND htmlvar_name != 'password' AND form_id = %s" . $extra_where . ' ORDER BY sort_order ASC', array( 'account', $form_id ) ) ); | |
| 101 | + $fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . $table_name . " WHERE form_type = %s AND is_active = '1' AND is_register_only_field = '0' AND htmlvar_name != 'password' AND form_id = %s" . $extra_where . " ORDER BY sort_order ASC", array( 'account', $form_id ) ) ); | |
| 102 | 102 | } else { |
| 103 | - $fields = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM ' . $table_name . " WHERE form_type = %s AND is_active = '1' AND for_admin_use != '1' AND is_register_only_field = '0' AND htmlvar_name != 'password' AND form_id = %s" . $extra_where . ' ORDER BY sort_order ASC', array( 'account', $form_id ) ) ); | |
| 103 | + $fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . $table_name . " WHERE form_type = %s AND is_active = '1' AND for_admin_use != '1' AND is_register_only_field = '0' AND htmlvar_name != 'password' AND form_id = %s" . $extra_where . " ORDER BY sort_order ASC", array( 'account', $form_id ) ) ); | |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | return $fields; |
| 107 | 107 | } |
| @@ -118,15 +118,15 @@ | ||
| 118 | 118 | global $wpdb; |
| 119 | 119 | $table_name = uwp_get_table_prefix() . 'uwp_form_fields'; |
| 120 | 120 | $enable_old_password = uwp_get_option( 'change_enable_old_password', false ); |
| 121 | 121 | $user_id = get_current_user_id(); |
| 122 | - if ( $user_id && 1 == get_user_meta( $user_id, 'is_uwp_social_login_no_password', true ) ) { | |
| 122 | + if($user_id && 1 == get_user_meta($user_id, 'is_uwp_social_login_no_password', true)){ | |
| 123 | 123 | $enable_old_password = 0; |
| 124 | 124 | } |
| 125 | 125 | if ( $enable_old_password == '1' ) { |
| 126 | - $fields = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM ' . $table_name . " WHERE form_type = %s AND is_active = '1' AND for_admin_use != '1' ORDER BY sort_order ASC", array( 'change' ) ) ); | |
| 126 | + $fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . $table_name . " WHERE form_type = %s AND is_active = '1' AND for_admin_use != '1' ORDER BY sort_order ASC", array( 'change' ) ) ); | |
| 127 | 127 | } else { |
| 128 | - $fields = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM ' . $table_name . " WHERE form_type = %s AND is_active = '1' AND for_admin_use != '1' AND htmlvar_name != 'old_password' ORDER BY sort_order ASC", array( 'change' ) ) ); | |
| 128 | + $fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . $table_name . " WHERE form_type = %s AND is_active = '1' AND for_admin_use != '1' AND htmlvar_name != 'old_password' ORDER BY sort_order ASC", array( 'change' ) ) ); | |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | return $fields; |
| 132 | 132 | } |
| @@ -136,9 +136,8 @@ | ||
| 136 | 136 | * |
| 137 | 137 | * @param array $data Submitted form data |
| 138 | 138 | * @param string $type Form type. |
| 139 | 139 | * @param array|bool $fields Fields applicable for validation. |
| 140 | - * @param string $extra_where Extra where query. | |
| 141 | 140 | * |
| 142 | 141 | * @return array|mixed|WP_Error Validated form data. |
| 143 | 142 | * @since 1.0.0 |
| 144 | 143 | * @package userswp |
| @@ -143,12 +142,12 @@ | ||
| 143 | 142 | * @since 1.0.0 |
| 144 | 143 | * @package userswp |
| 145 | 144 | * |
| 146 | 145 | */ |
| 147 | -function uwp_validate_fields( $data, $type, $fields = false, $extra_where = '' ) { | |
| 146 | +function uwp_validate_fields( $data, $type, $fields = false ) { | |
| 148 | 147 | $validation = new UsersWP_Validation(); |
| 149 | 148 | |
| 150 | - return $validation->validate_fields( $data, $type, $fields, $extra_where ); | |
| 149 | + return $validation->validate_fields( $data, $type, $fields ); | |
| 151 | 150 | } |
| 152 | 151 | |
| 153 | 152 | /** |
| 154 | 153 | * Returns form field label. If empty returns the field title. |
| @@ -184,12 +183,14 @@ | ||
| 184 | 183 | $placeholder = __( $field->placeholder_value, 'userswp' ); |
| 185 | 184 | } else { |
| 186 | 185 | $placeholder = wp_sprintf( __( 'Choose %s…', 'userswp' ), uwp_get_form_label( $field ) ); |
| 187 | 186 | } |
| 188 | - } elseif ( isset( $field->placeholder_value ) && ! empty( $field->placeholder_value ) ) { | |
| 187 | + } else { | |
| 188 | + if ( isset( $field->placeholder_value ) && ! empty( $field->placeholder_value ) ) { | |
| 189 | 189 | $placeholder = __( $field->placeholder_value, 'userswp' ); |
| 190 | 190 | } else { |
| 191 | - $placeholder = uwp_get_form_label( $field ); | |
| 191 | + $placeholder = uwp_get_form_label( $field ); | |
| 192 | + } | |
| 192 | 193 | } |
| 193 | 194 | |
| 194 | 195 | if ( isset( $field->is_required ) && ! empty( $field->is_required ) ) { |
| 195 | 196 | $placeholder .= ' *'; |
| @@ -238,28 +239,23 @@ | ||
| 238 | 239 | return $custom_field_info[ $cache_key ]; |
| 239 | 240 | } |
| 240 | 241 | |
| 241 | 242 | if ( $form_type ) { |
| 242 | - $field = $wpdb->get_row( | |
| 243 | - $wpdb->prepare( | |
| 244 | - 'SELECT * FROM ' . $table_name . ' WHERE htmlvar_name = %s AND form_type = %s', | |
| 245 | - array( | |
| 246 | - $htmlvar_name, | |
| 247 | - $form_type, | |
| 248 | - ) | |
| 249 | - ) | |
| 250 | - ); | |
| 243 | + $field = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM " . $table_name . " WHERE htmlvar_name = %s AND form_type = %s", array( | |
| 244 | + $htmlvar_name, | |
| 245 | + $form_type | |
| 246 | + ) ) ); | |
| 251 | 247 | } else { |
| 252 | - $field = $wpdb->get_row( $wpdb->prepare( 'SELECT * FROM ' . $table_name . ' WHERE htmlvar_name = %s', array( $htmlvar_name ) ) ); | |
| 248 | + $field = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM " . $table_name . " WHERE htmlvar_name = %s", array( $htmlvar_name ) ) ); | |
| 253 | 249 | } |
| 254 | - | |
| 250 | + | |
| 255 | 251 | // Cache the field data. |
| 256 | 252 | $custom_field_info[ $cache_key ] = $field; |
| 257 | - | |
| 253 | + | |
| 258 | 254 | return $field; |
| 259 | 255 | } |
| 260 | 256 | |
| 261 | -function uwp_resend_activation_mail( $user_id ) { | |
| 257 | +function uwp_resend_activation_mail($user_id) { | |
| 262 | 258 | |
| 263 | 259 | if ( ! $user_id ) { |
| 264 | 260 | return false; |
| 265 | 261 | } |
| @@ -272,9 +268,9 @@ | ||
| 272 | 268 | if ( $activation_link ) { |
| 273 | 269 | |
| 274 | 270 | $message = __( 'To activate your account, visit the following address:', 'userswp' ) . "\r\n\r\n"; |
| 275 | 271 | |
| 276 | - $message .= "<a href='" . esc_url( $activation_link ) . "' target='_blank'>" . esc_url( $activation_link ) . '</a>' . "\r\n"; | |
| 272 | + $message .= "<a href='" . esc_url( $activation_link ) . "' target='_blank'>" . esc_url( $activation_link ) . "</a>" . "\r\n"; | |
| 277 | 273 | |
| 278 | 274 | $activate_message = '<p><b>' . __( 'Please activate your account :', 'userswp' ) . '</b></p><p>' . $message . '</p>'; |
| 279 | 275 | |
| 280 | 276 | $activate_message = apply_filters( 'uwp_activation_mail_message', $activate_message, $user_id ); |
| @@ -307,9 +303,9 @@ | ||
| 307 | 303 | if ( strpos( $fa_icon, 'fa fa-' ) === 0 || strpos( $fa_icon, 'fas fa-' ) === 0 || strpos( $fa_icon, 'far fa-' ) === 0 || strpos( $fa_icon, 'fab fa-' ) === 0 || strpos( $fa_icon, 'fa-' ) === 0 ) { |
| 308 | 304 | $return = true; |
| 309 | 305 | } |
| 310 | 306 | } |
| 311 | - return apply_filters( 'uwp_is_fa_icon', $return, $icon ); | |
| 307 | + return apply_filters( 'uwp_is_fa_icon', $return, $icon ); | |
| 312 | 308 | } |
| 313 | 309 | |
| 314 | 310 | /** |
| 315 | 311 | * Check icon url. |
| @@ -324,9 +320,9 @@ | ||
| 324 | 320 | if ( strpos( $icon, 'http://' ) === 0 || strpos( $icon, 'https://' ) === 0 ) { |
| 325 | 321 | $return = true; |
| 326 | 322 | } |
| 327 | 323 | } |
| 328 | - return apply_filters( 'uwp_is_icon_url', $return, $icon ); | |
| 324 | + return apply_filters( 'uwp_is_icon_url', $return, $icon ); | |
| 329 | 325 | } |
| 330 | 326 | |
| 331 | 327 | /** |
| 332 | 328 | * Get the field icon. |
| @@ -340,9 +336,9 @@ | ||
| 340 | 336 | function uwp_get_field_icon( $value ) { |
| 341 | 337 | $field_icon = $value; |
| 342 | 338 | |
| 343 | 339 | if ( ! empty( $value ) ) { |
| 344 | - if ( strpos( $value, 'http' ) === 0 ) { | |
| 340 | + if (strpos($value, 'http') === 0) { | |
| 345 | 341 | $field_icon = '<span class="uwp_field_icon" style="background: url(' . esc_url( $value ) . ') no-repeat left center;padding-left:14px;background-size:100% auto;margin-right:5px"></span>'; |
| 346 | 342 | } else { |
| 347 | 343 | $field_icon = '<i class="uwp_field_icon ' . esc_attr( $value ) . '"></i>'; |
| 348 | 344 | } |
| @@ -350,19 +346,19 @@ | ||
| 350 | 346 | |
| 351 | 347 | return apply_filters( 'uwp_get_field_icon', $field_icon, $value ); |
| 352 | 348 | } |
| 353 | 349 | |
| 354 | -function uwp_get_registration_form_actions() { | |
| 350 | +function uwp_get_registration_form_actions(){ | |
| 355 | 351 | $registration_options = array( |
| 356 | - 'auto_approve' => __( 'Auto Approve', 'userswp' ), | |
| 357 | - 'auto_approve_login' => __( 'Auto Approve + Auto Login', 'userswp' ), | |
| 358 | - 'require_email_activation' => __( 'Require Email Activation', 'userswp' ), | |
| 352 | + 'auto_approve' => __('Auto Approve', 'userswp'), | |
| 353 | + 'auto_approve_login' => __('Auto Approve + Auto Login', 'userswp'), | |
| 354 | + 'require_email_activation' => __('Require Email Activation', 'userswp'), | |
| 359 | 355 | ); |
| 360 | 356 | |
| 361 | - return apply_filters( 'uwp_registration_status_options', $registration_options ); | |
| 357 | + return apply_filters('uwp_registration_status_options', $registration_options); | |
| 362 | 358 | } |
| 363 | 359 | |
| 364 | -function uwp_get_register_forms_dropdown_options( $include_forms = array() ) { | |
| 360 | +function uwp_get_register_forms_dropdown_options($include_forms = array()) { | |
| 365 | 361 | |
| 366 | 362 | $get_register_form = uwp_get_option( 'multiple_registration_forms' ); |
| 367 | 363 | |
| 368 | 364 | $register_forms = array(); |
| @@ -375,12 +371,12 @@ | ||
| 375 | 371 | } |
| 376 | 372 | } |
| 377 | 373 | } |
| 378 | 374 | |
| 379 | - if ( ! empty( $register_forms ) && isset( $include_forms ) && count( $include_forms ) > 0 ) { | |
| 380 | - foreach ( $register_forms as $form_id => $title ) { | |
| 381 | - if ( ! in_array( $form_id, $include_forms ) ) { | |
| 382 | - unset( $register_forms[ $form_id ] ); | |
| 375 | + if(!empty($register_forms) && isset($include_forms) && count($include_forms) > 0){ | |
| 376 | + foreach($register_forms as $form_id => $title){ | |
| 377 | + if(!in_array($form_id, $include_forms)){ | |
| 378 | + unset($register_forms[$form_id]); | |
| 383 | 379 | } |
| 384 | 380 | } |
| 385 | 381 | } |
| 386 | 382 | |
| @@ -398,9 +394,9 @@ | ||
| 398 | 394 | foreach ( $get_register_form as $key => $register_form ) { |
| 399 | 395 | |
| 400 | 396 | if ( ! empty( $register_form['id'] ) && $register_form['id'] == $form_id ) { |
| 401 | 397 | |
| 402 | - $form_title = ! empty( $register_form[ $type ] ) ? $register_form[ $type ] : ''; | |
| 398 | + $form_title = ! empty( $register_form[$type] ) ? $register_form[$type] : ''; | |
| 403 | 399 | } |
| 404 | 400 | } |
| 405 | 401 | } |
| 406 | 402 | } |
| @@ -407,11 +403,11 @@ | ||
| 407 | 403 | |
| 408 | 404 | return $form_title; |
| 409 | 405 | } |
| 410 | 406 | |
| 411 | -function uwp_get_form_id_by_type( $form_type ) { | |
| 407 | +function uwp_get_form_id_by_type($form_type){ | |
| 412 | 408 | $form_id = 1; |
| 413 | - if ( isset( $form_type ) && ! empty( $form_type ) ) { | |
| 409 | + if ( isset($form_type) && ! empty( $form_type ) ) { | |
| 414 | 410 | $get_register_form = uwp_get_option( 'multiple_registration_forms' ); |
| 415 | 411 | |
| 416 | 412 | if ( ! empty( $get_register_form ) && is_array( $get_register_form ) ) { |
| 417 | 413 | |
| @@ -416,9 +412,9 @@ | ||
| 416 | 412 | if ( ! empty( $get_register_form ) && is_array( $get_register_form ) ) { |
| 417 | 413 | |
| 418 | 414 | foreach ( $get_register_form as $key => $register_form ) { |
| 419 | 415 | |
| 420 | - if ( ! empty( $register_form['title'] ) && $form_type == sanitize_title_with_dashes( $register_form['title'] ) ) { | |
| 416 | + if ( ! empty( $register_form['title'] ) && $form_type == sanitize_title_with_dashes($register_form['title']) ) { | |
| 421 | 417 | |
| 422 | 418 | $form_id = $register_form['id']; |
| 423 | 419 | } |
| 424 | 420 | } |
| @@ -464,26 +460,8 @@ | ||
| 464 | 460 | |
| 465 | 461 | return ! empty( $form_id ) ? (int) $form_id : 1; |
| 466 | 462 | } |
| 467 | 463 | |
| 468 | -/** | |
| 469 | - * Get user regsitration form by form ID. | |
| 470 | - * | |
| 471 | - * @param int $form_id The ID of the registration form. | |
| 472 | - * @return array|false The user type array if found, false otherwise. | |
| 473 | - */ | |
| 474 | -function uwp_get_user_register_form( int $form_id ) { | |
| 475 | - $register_forms = (array) UsersWP_User_Types::get_register_forms(); | |
| 476 | - | |
| 477 | - foreach ( $register_forms as $register_form ) { | |
| 478 | - if ( isset( $register_form['id'] ) && (int) $register_form['id'] === (int) $form_id ) { | |
| 479 | - return $register_form; | |
| 480 | - } | |
| 481 | - } | |
| 482 | - | |
| 483 | - return false; | |
| 484 | -} | |
| 485 | - | |
| 486 | 464 | function uwp_get_register_fields_htmlvar( $form_id = 1 ) { |
| 487 | 465 | |
| 488 | 466 | $fields = get_register_form_fields( $form_id ); |
| 489 | 467 | |
| @@ -502,10 +480,10 @@ | ||
| 502 | 480 | |
| 503 | 481 | return $html_var; |
| 504 | 482 | } |
| 505 | 483 | |
| 506 | -function uwp_get_unique_custom_fields( $fields, $key = 'htmlvar_name' ) { | |
| 507 | - if ( empty( $fields ) ) { | |
| 484 | +function uwp_get_unique_custom_fields($fields, $key = 'htmlvar_name'){ | |
| 485 | + if(empty($fields)){ | |
| 508 | 486 | return array(); |
| 509 | 487 | } |
| 510 | 488 | |
| 511 | 489 | $temp_array = array(); |
| @@ -511,34 +489,34 @@ | ||
| 511 | 489 | $temp_array = array(); |
| 512 | 490 | $i = 0; |
| 513 | 491 | $key_array = array(); |
| 514 | 492 | |
| 515 | - foreach ( $fields as $field ) { | |
| 516 | - if ( is_object( $field ) ) { | |
| 493 | + foreach($fields as $field) { | |
| 494 | + if(is_object($field)){ | |
| 517 | 495 | $val = $field->$key; |
| 518 | 496 | } else { |
| 519 | - $val = $field[ $key ]; | |
| 497 | + $val = $field[$key]; | |
| 520 | 498 | } |
| 521 | 499 | |
| 522 | - if ( ! in_array( $val, $key_array ) ) { | |
| 523 | - $key_array[ $i ] = $val; | |
| 524 | - $temp_array[ $val ] = $field; | |
| 500 | + if (!in_array($val, $key_array)) { | |
| 501 | + $key_array[$i] = $val; | |
| 502 | + $temp_array[$val] = $field; | |
| 525 | 503 | } |
| 526 | - ++$i; | |
| 504 | + $i++; | |
| 527 | 505 | } |
| 528 | 506 | |
| 529 | 507 | return $temp_array; |
| 530 | 508 | } |
| 531 | 509 | |
| 532 | -function uwp_get_default_form_data() { | |
| 510 | +function uwp_get_default_form_data(){ | |
| 533 | 511 | $fields = array();$i = 1; |
| 534 | - $user_role = get_option( 'default_role' ); | |
| 512 | + $user_role = get_option('default_role'); | |
| 535 | 513 | |
| 536 | 514 | $account_fields = UsersWP_Activator::uwp_default_custom_fields_account(); |
| 537 | - if ( ! empty( $account_fields ) ) { | |
| 538 | - foreach ( $account_fields as $account_field ) { | |
| 539 | - $fields[ $account_field['htmlvar_name'] ] = $i; | |
| 540 | - ++$i; | |
| 515 | + if(!empty($account_fields)){ | |
| 516 | + foreach ($account_fields as $account_field){ | |
| 517 | + $fields[$account_field['htmlvar_name']] = $i; | |
| 518 | + $i++; | |
| 541 | 519 | } |
| 542 | 520 | } |
| 543 | 521 | |
| 544 | 522 | $reg_fields = get_register_form_fields(); |
| @@ -554,41 +532,41 @@ | ||
| 554 | 532 | } |
| 555 | 533 | |
| 556 | 534 | $data = array( |
| 557 | 535 | array( |
| 558 | - 'id' => 1, | |
| 559 | - 'title' => __( 'Default', 'userswp' ), | |
| 560 | - 'user_role' => $user_role, | |
| 561 | - 'reg_action' => uwp_get_option( 'uwp_registration_action', 'auto_approve' ), | |
| 536 | + 'id' => 1, | |
| 537 | + 'title' => __('Default','userswp'), | |
| 538 | + 'user_role' => $user_role, | |
| 539 | + 'reg_action' => uwp_get_option( 'uwp_registration_action', 'auto_approve' ), | |
| 562 | 540 | 'redirect_to' => (int) uwp_get_option( 'register_redirect_to', - 1 ), |
| 563 | - 'custom_url' => uwp_get_option( 'register_redirect_custom_url', home_url() ), | |
| 564 | - 'gdpr_page' => (int) uwp_get_option( 'register_gdpr_page', false ), | |
| 565 | - 'tos_page' => (int) uwp_get_option( 'register_terms_page', false ), | |
| 566 | - 'fields' => $fields, | |
| 567 | - ), | |
| 541 | + 'custom_url' => uwp_get_option( 'register_redirect_custom_url', home_url() ), | |
| 542 | + 'gdpr_page' => (int) uwp_get_option('register_gdpr_page', false), | |
| 543 | + 'tos_page' => (int) uwp_get_option('register_terms_page', false), | |
| 544 | + 'fields' => $fields | |
| 545 | + ) | |
| 568 | 546 | ); |
| 569 | 547 | |
| 570 | 548 | return $data; |
| 571 | 549 | } |
| 572 | 550 | |
| 573 | -function uwp_get_upload_image_size( $type = 'avatar' ) { | |
| 551 | +function uwp_get_upload_image_size($type = "avatar"){ | |
| 574 | 552 | |
| 575 | 553 | if ( $type == 'avatar' ) { |
| 576 | 554 | $width = uwp_get_option( 'profile_avatar_width', 150 ); |
| 577 | - $width = empty( $width ) ? 150 : $width; | |
| 555 | + $width = empty($width) ? 150 : $width; | |
| 578 | 556 | $value['width'] = apply_filters( 'uwp_avatar_image_width', $width ); |
| 579 | 557 | |
| 580 | 558 | $height = uwp_get_option( 'profile_avatar_height', 150 ); |
| 581 | - $height = empty( $height ) ? 150 : $height; | |
| 559 | + $height = empty($height) ? 150 : $height; | |
| 582 | 560 | $value['height'] = apply_filters( 'uwp_avatar_image_height', $height ); |
| 583 | 561 | } else { |
| 584 | 562 | $width = uwp_get_option( 'profile_banner_width', 1000 ); |
| 585 | - $width = empty( $width ) ? 1000 : $width; | |
| 563 | + $width = empty($width) ? 1000 : $width; | |
| 586 | 564 | $value['width'] = apply_filters( 'uwp_banner_image_width', $width ); |
| 587 | 565 | |
| 588 | 566 | $height = uwp_get_option( 'profile_banner_height', 300 ); |
| 589 | - $height = empty( $height ) ? 300 : $height; | |
| 567 | + $height = empty($height) ? 300 : $height; | |
| 590 | 568 | $value['height'] = apply_filters( 'uwp_banner_image_height', $height ); |
| 591 | 569 | } |
| 592 | 570 | |
| 593 | 571 | return $value; |
| 594 | -} | |
| 572 | +} | |