ravinderk /
Give
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Profile Editor |
||
| 4 | * |
||
| 5 | * This template is used to display the profile editor with [give_profile_editor] |
||
| 6 | * |
||
| 7 | * @copyright Copyright (c) 2016, WordImpress |
||
| 8 | * @license https://opensource.org/licenses/gpl-license GNU Public License |
||
| 9 | */ |
||
| 10 | $current_user = wp_get_current_user(); |
||
| 11 | |||
| 12 | if ( is_user_logged_in() ): |
||
| 13 | $user_id = get_current_user_id(); |
||
| 14 | $first_name = get_user_meta( $user_id, 'first_name', true ); |
||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 15 | $last_name = get_user_meta( $user_id, 'last_name', true ); |
||
|
0 ignored issues
–
show
|
|||
| 16 | $display_name = $current_user->display_name; |
||
| 17 | $address = give_get_donor_address( $user_id ); |
||
| 18 | |||
| 19 | if ( isset( $_GET['updated'] ) && $_GET['updated'] == true && ! give_get_errors() ): ?> |
||
|
0 ignored issues
–
show
|
|||
| 20 | <p class="give_success"> |
||
| 21 | <strong><?php esc_html_e( 'Success:', 'give' ); ?></strong> <?php esc_html_e( 'Your profile has been updated.', 'give' ); ?> |
||
| 22 | </p> |
||
| 23 | <?php endif; ?> |
||
| 24 | |||
| 25 | <?php Give()->notices->render_frontend_notices( 0 ); ?> |
||
| 26 | |||
| 27 | <?php |
||
| 28 | /** |
||
| 29 | * Fires in the profile editor shortcode, before the form. |
||
| 30 | * |
||
| 31 | * Allows you to add new elements before the form. |
||
| 32 | * |
||
| 33 | * @since 1.0 |
||
| 34 | */ |
||
| 35 | do_action( 'give_profile_editor_before' ); |
||
| 36 | ?> |
||
| 37 | |||
| 38 | <form id="give_profile_editor_form" class="give-form" action="<?php echo give_get_current_page_url(); ?>" method="post"> |
||
|
0 ignored issues
–
show
|
|||
| 39 | |||
| 40 | <fieldset> |
||
| 41 | |||
| 42 | <legend id="give_profile_name_label"><?php esc_html_e( 'Change your Name', 'give' ); ?></legend> |
||
| 43 | |||
| 44 | <p id="give_profile_first_name_wrap" class="form-row form-row-first form-row-responsive"> |
||
| 45 | <label for="give_first_name"><?php esc_html_e( 'First Name', 'give' ); ?></label> |
||
| 46 | <input name="give_first_name" id="give_first_name" class="text give-input" type="text" value="<?php echo esc_attr( $first_name ); ?>"/> |
||
| 47 | </p> |
||
| 48 | |||
| 49 | <p id="give_profile_last_name_wrap" class="form-row form-row-last form-row-responsive"> |
||
| 50 | <label for="give_last_name"><?php esc_html_e( 'Last Name', 'give' ); ?></label> |
||
| 51 | <input name="give_last_name" id="give_last_name" class="text give-input" type="text" value="<?php echo esc_attr( $last_name ); ?>"/> |
||
| 52 | </p> |
||
| 53 | |||
| 54 | <p id="give_profile_display_name_wrap" class="form-row form-row-first form-row-responsive"> |
||
| 55 | <label for="give_display_name"><?php esc_html_e( 'Display Name', 'give' ); ?></label> |
||
| 56 | <select name="give_display_name" id="give_display_name" class="select give-select"> |
||
| 57 | View Code Duplication | <?php if ( ! empty( $current_user->first_name ) ): ?> |
|
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 58 | <option <?php selected( $display_name, $current_user->first_name ); ?> value="<?php echo esc_attr( $current_user->first_name ); ?>"><?php echo esc_html( $current_user->first_name ); ?></option> |
||
| 59 | <?php endif; ?> |
||
| 60 | <option <?php selected( $display_name, $current_user->user_nicename ); ?> value="<?php echo esc_attr( $current_user->user_nicename ); ?>"><?php echo esc_html( $current_user->user_nicename ); ?></option> |
||
| 61 | View Code Duplication | <?php if ( ! empty( $current_user->last_name ) ): ?> |
|
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 62 | <option <?php selected( $display_name, $current_user->last_name ); ?> value="<?php echo esc_attr( $current_user->last_name ); ?>"><?php echo esc_html( $current_user->last_name ); ?></option> |
||
| 63 | <?php endif; ?> |
||
| 64 | <?php if ( ! empty( $current_user->first_name ) && ! empty( $current_user->last_name ) ): ?> |
||
| 65 | <option <?php selected( $display_name, $current_user->first_name . ' ' . $current_user->last_name ); ?> value="<?php echo esc_attr( $current_user->first_name . ' ' . $current_user->last_name ); ?>"><?php echo esc_html( $current_user->first_name . ' ' . $current_user->last_name ); ?></option> |
||
| 66 | <option <?php selected( $display_name, $current_user->last_name . ' ' . $current_user->first_name ); ?> value="<?php echo esc_attr( $current_user->last_name . ' ' . $current_user->first_name ); ?>"><?php echo esc_html( $current_user->last_name . ' ' . $current_user->first_name ); ?></option> |
||
| 67 | <?php endif; ?> |
||
| 68 | </select> |
||
| 69 | <?php |
||
| 70 | /** |
||
| 71 | * Fires in the profile editor shortcode, to the name section. |
||
| 72 | * |
||
| 73 | * Allows you to add new elements to the name section. |
||
| 74 | * |
||
| 75 | * @since 1.0 |
||
| 76 | */ |
||
| 77 | do_action( 'give_profile_editor_name' ); |
||
| 78 | ?> |
||
| 79 | </p> |
||
| 80 | |||
| 81 | <?php |
||
| 82 | /** |
||
| 83 | * Fires in the profile editor shortcode, after the name field. |
||
| 84 | * |
||
| 85 | * Allows you to add new fields after the name field. |
||
| 86 | * |
||
| 87 | * @since 1.0 |
||
| 88 | */ |
||
| 89 | do_action( 'give_profile_editor_after_name' ); |
||
| 90 | ?> |
||
| 91 | |||
| 92 | <p class="form-row form-row-last form-row-responsive"> |
||
| 93 | <label for="give_email"><?php esc_html_e( 'Email Address', 'give' ); ?></label> |
||
| 94 | <input name="give_email" id="give_email" class="text give-input required" type="email" value="<?php echo esc_attr( $current_user->user_email ); ?>" required aria-required="true"/> |
||
| 95 | <?php |
||
| 96 | /** |
||
| 97 | * Fires in the profile editor shortcode, to the email section. |
||
| 98 | * |
||
| 99 | * Allows you to add new elements to the email section. |
||
| 100 | * |
||
| 101 | * @since 1.0 |
||
| 102 | */ |
||
| 103 | do_action( 'give_profile_editor_email' ); |
||
| 104 | ?> |
||
| 105 | </p> |
||
| 106 | |||
| 107 | <?php |
||
| 108 | /** |
||
| 109 | * Fires in the profile editor shortcode, after the email field. |
||
| 110 | * |
||
| 111 | * Allows you to add new fields after the email field. |
||
| 112 | * |
||
| 113 | * @since 1.0 |
||
| 114 | */ |
||
| 115 | do_action( 'give_profile_editor_after_email' ); |
||
| 116 | ?> |
||
| 117 | |||
| 118 | <legend id="give_profile_billing_address_label"><?php esc_html_e( 'Change your Billing Address', 'give' ); ?></legend> |
||
| 119 | |||
| 120 | <div id="give_profile_billing_address_wrap"> |
||
| 121 | |||
| 122 | <p id="give-card-address-wrap" class="form-row form-row-first form-row-responsive"> |
||
| 123 | <label for="give_address_line1"><?php esc_html_e( 'Address 1', 'give' ); ?></label> |
||
| 124 | <input name="give_address_line1" id="give_address_line1" class="text give-input" type="text" value="<?php echo esc_attr( $address['line1'] ); ?>"/> |
||
| 125 | </p> |
||
| 126 | |||
| 127 | <p id="give-card-address-2-wrap" class="form-row form-row-last form-row-responsive"> |
||
| 128 | <label for="give_address_line2"><?php esc_html_e( 'Address 2', 'give' ); ?></label> |
||
| 129 | <input name="give_address_line2" id="give_address_line2" class="text give-input" type="text" value="<?php echo esc_attr( $address['line2'] ); ?>"/> |
||
| 130 | </p> |
||
| 131 | |||
| 132 | <p id="give-card-city-wrap" class="form-row form-row-first form-row-responsive"> |
||
| 133 | <label for="give_address_city"><?php esc_html_e( 'City', 'give' ); ?></label> |
||
| 134 | <input name="give_address_city" id="give_address_city" class="text give-input" type="text" value="<?php echo esc_attr( $address['city'] ); ?>"/> |
||
| 135 | </p> |
||
| 136 | |||
| 137 | <p id="give-card-zip-wrap" class="form-row form-row-last form-row-responsive"> |
||
| 138 | <label for="give_address_zip"><?php esc_html_e( 'Zip / Postal Code', 'give' ); ?></label> |
||
| 139 | <input name="give_address_zip" id="give_address_zip" class="text give-input" type="text" value="<?php echo esc_attr( $address['zip'] ); ?>"/> |
||
| 140 | </p> |
||
| 141 | |||
| 142 | <p id="give-card-country-wrap" class="form-row form-row-first form-row-responsive"> |
||
| 143 | <label for="give_address_country"><?php esc_html_e( 'Country', 'give' ); ?></label> |
||
| 144 | <select name="give_address_country" id="give_address_country" class="select give-select"> |
||
| 145 | <?php foreach ( give_get_country_list() as $key => $country ) : ?> |
||
| 146 | <option value="<?php echo $key; ?>"<?php selected( $address['country'], $key ); ?>><?php echo esc_html( $country ); ?></option> |
||
|
0 ignored issues
–
show
|
|||
| 147 | <?php endforeach; ?> |
||
| 148 | </select> |
||
| 149 | </p> |
||
| 150 | |||
| 151 | <p id="give-card-state-wrap" class="form-row form-row-last form-row-responsive"> |
||
| 152 | <label for="give_address_state"><?php esc_html_e( 'State / Province / County', 'give' ); ?></label> |
||
| 153 | <input name="give_address_state" id="give_address_state" class="text give-input" type="text" value="<?php echo esc_attr( $address['state'] ); ?>"/> |
||
| 154 | </p> |
||
| 155 | |||
| 156 | <?php |
||
| 157 | /** |
||
| 158 | * Fires in the profile editor shortcode, to the address section. |
||
| 159 | * |
||
| 160 | * Allows you to add new elements to the address section. |
||
| 161 | * |
||
| 162 | * @since 1.0 |
||
| 163 | */ |
||
| 164 | do_action( 'give_profile_editor_address' ); |
||
| 165 | ?> |
||
| 166 | |||
| 167 | </div> |
||
| 168 | |||
| 169 | <?php |
||
| 170 | /** |
||
| 171 | * Fires in the profile editor shortcode, after the address field. |
||
| 172 | * |
||
| 173 | * Allows you to add new fields after the address field. |
||
| 174 | * |
||
| 175 | * @since 1.0 |
||
| 176 | */ |
||
| 177 | do_action( 'give_profile_editor_after_address' ); |
||
| 178 | ?> |
||
| 179 | |||
| 180 | <legend id="give_profile_password_label"><?php esc_html_e( 'Change your Password', 'give' ); ?></legend> |
||
| 181 | |||
| 182 | <div id="give_profile_password_wrap" class="give-clearfix"> |
||
| 183 | <p id="give_profile_password_wrap_1" class="form-row form-row-first form-row-responsive"> |
||
| 184 | <label for="give_new_user_pass1"><?php esc_html_e( 'New Password', 'give' ); ?></label> |
||
| 185 | <input name="give_new_user_pass1" id="give_new_user_pass1" class="password give-input" type="password"/> |
||
| 186 | </p> |
||
| 187 | |||
| 188 | <p id="give_profile_password_wrap_2" class="form-row form-row-last form-row-responsive"> |
||
| 189 | <label for="give_new_user_pass2"><?php esc_html_e( 'Re-enter Password', 'give' ); ?></label> |
||
| 190 | <input name="give_new_user_pass2" id="give_new_user_pass2" class="password give-input" type="password"/> |
||
| 191 | <?php |
||
| 192 | /** |
||
| 193 | * Fires in the profile editor shortcode, to the password section. |
||
| 194 | * |
||
| 195 | * Allows you to add new elements to the password section. |
||
| 196 | * |
||
| 197 | * @since 1.0 |
||
| 198 | */ |
||
| 199 | do_action( 'give_profile_editor_password' ); |
||
| 200 | ?> |
||
| 201 | </p> |
||
| 202 | </div> |
||
| 203 | |||
| 204 | <p class="give_password_change_notice"><?php esc_html_e( 'Please note after changing your password, you must log back in.', 'give' ); ?></p> |
||
| 205 | |||
| 206 | <?php |
||
| 207 | /** |
||
| 208 | * Fires in the profile editor shortcode, after the password field. |
||
| 209 | * |
||
| 210 | * Allows you to add new fields after the password field. |
||
| 211 | * |
||
| 212 | * @since 1.0 |
||
| 213 | */ |
||
| 214 | do_action( 'give_profile_editor_after_password' ); |
||
| 215 | ?> |
||
| 216 | |||
| 217 | <p id="give_profile_submit_wrap"> |
||
| 218 | <input type="hidden" name="give_profile_editor_nonce" value="<?php echo wp_create_nonce( 'give-profile-editor-nonce' ); ?>"/> |
||
|
0 ignored issues
–
show
|
|||
| 219 | <input type="hidden" name="give_action" value="edit_user_profile"/> |
||
| 220 | <input type="hidden" name="give_redirect" value="<?php echo esc_url( give_get_current_page_url() ); ?>"/> |
||
| 221 | <input name="give_profile_editor_submit" id="give_profile_editor_submit" type="submit" class="give_submit" value="<?php esc_attr_e( 'Save Changes', 'give' ); ?>"/> |
||
| 222 | </p> |
||
| 223 | |||
| 224 | </fieldset> |
||
| 225 | |||
| 226 | </form><!-- #give_profile_editor_form --> |
||
| 227 | |||
| 228 | <?php |
||
| 229 | /** |
||
| 230 | * Fires in the profile editor shortcode, after the form. |
||
| 231 | * |
||
| 232 | * Allows you to add new elements after the form. |
||
| 233 | * |
||
| 234 | * @since 1.0 |
||
| 235 | */ |
||
| 236 | do_action( 'give_profile_editor_after' ); |
||
| 237 | ?> |
||
| 238 | |||
| 239 | <?php |
||
| 240 | else: |
||
|
0 ignored issues
–
show
|
|||
| 241 | esc_html_e( 'You need to login to edit your profile.', 'give' ); |
||
| 242 | echo give_login_form(); |
||
|
0 ignored issues
–
show
|
|||
| 243 | endif; |
||
| 244 |