dashboard.php
5 months ago
download-history.php
5 months ago
edit-profile.php
5 months ago
profile.php
5 months ago
edit-profile.php
210 lines
| 1 | <?php |
| 2 | /** |
| 3 | * User Dashboard - Edit Profile |
| 4 | * Enterprise-grade design |
| 5 | */ |
| 6 | |
| 7 | if (!defined('ABSPATH')) die(); |
| 8 | |
| 9 | global $current_user, $wpdb; |
| 10 | $user = get_userdata($current_user->ID); |
| 11 | $public_profile = get_user_meta(get_current_user_id(), '__wpdm_public_profile', true); |
| 12 | $profile_pic = wpdm_valueof($public_profile, 'logo'); |
| 13 | ?> |
| 14 | |
| 15 | <div id="edit-profile-form"> |
| 16 | <form method="post" id="edit_profile" name="contact_form" action="" class="form"> |
| 17 | <?php wp_nonce_field(NONCE_KEY, '__wpdm_epnonce'); ?> |
| 18 | |
| 19 | <!-- Basic Profile Card --> |
| 20 | <div class="wpdm-card"> |
| 21 | <div class="wpdm-card-header"> |
| 22 | <h3> |
| 23 | <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path><circle cx="12" cy="7" r="4"></circle></svg> |
| 24 | <?php esc_html_e('Basic Profile', 'download-manager'); ?> |
| 25 | </h3> |
| 26 | </div> |
| 27 | <div class="wpdm-card-body"> |
| 28 | <div class="wpdm-form-grid"> |
| 29 | <div class="wpdm-form-group"> |
| 30 | <label for="fname"><?php esc_html_e('Display Name', 'download-manager'); ?> <span class="wpdm-required">*</span></label> |
| 31 | <input type="text" class="wpdm-input" required value="<?php echo esc_attr($user->display_name); ?>" name="wpdm_profile[display_name]" id="fname"> |
| 32 | </div> |
| 33 | <div class="wpdm-form-group"> |
| 34 | <label for="username"><?php esc_html_e('Username', 'download-manager'); ?></label> |
| 35 | <input type="text" class="wpdm-input wpdm-input--readonly" value="<?php echo esc_attr($user->user_login); ?>" id="username" readonly> |
| 36 | </div> |
| 37 | <div class="wpdm-form-group"> |
| 38 | <label for="title"><?php esc_html_e('Title', 'download-manager'); ?></label> |
| 39 | <input type="text" class="wpdm-input" name="wpdm_profile[title]" value="<?php echo esc_attr(get_user_meta($user->ID, '__wpdm_title', true)); ?>" id="title"> |
| 40 | </div> |
| 41 | <div class="wpdm-form-group"> |
| 42 | <label for="email"><?php esc_html_e('Email', 'download-manager'); ?> <span class="wpdm-required">*</span></label> |
| 43 | <input type="email" class="wpdm-input" required name="wpdm_profile[user_email]" value="<?php echo esc_attr($user->user_email); ?>" id="email"> |
| 44 | </div> |
| 45 | <div class="wpdm-form-group wpdm-form-group--full"> |
| 46 | <label for="description"><?php esc_html_e('About Me', 'download-manager'); ?></label> |
| 47 | <textarea class="wpdm-textarea" name="wpdm_profile[description]" id="description" rows="4"><?php echo esc_textarea(get_user_meta($user->ID, 'description', true)); ?></textarea> |
| 48 | </div> |
| 49 | </div> |
| 50 | <?php do_action('wpdm_update_profile_filed_html', $user); ?> |
| 51 | <?php do_action('wpdm_update_profile_field_html', $user); ?> |
| 52 | </div> |
| 53 | </div> |
| 54 | |
| 55 | <!-- Profile Picture Card --> |
| 56 | <div class="wpdm-card" style="margin-top: 1.5rem;"> |
| 57 | <div class="wpdm-card-header"> |
| 58 | <h3> |
| 59 | <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><circle cx="8.5" cy="8.5" r="1.5"></circle><polyline points="21 15 16 10 5 21"></polyline></svg> |
| 60 | <?php esc_html_e('Profile Picture', 'download-manager'); ?> |
| 61 | </h3> |
| 62 | </div> |
| 63 | <div class="wpdm-card-body"> |
| 64 | <div class="wpdm-avatar-upload"> |
| 65 | <div class="wpdm-avatar-preview" id="avatar-preview"> |
| 66 | <?php if ($profile_pic): ?> |
| 67 | <img src="<?php echo esc_url($profile_pic); ?>" alt=""> |
| 68 | <?php else: ?> |
| 69 | <svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path><circle cx="12" cy="7" r="4"></circle></svg> |
| 70 | <?php endif; ?> |
| 71 | </div> |
| 72 | <div class="wpdm-avatar-actions"> |
| 73 | <input type="hidden" name="__wpdm_profile_pic" id="store-logo" value="<?php echo esc_attr($profile_pic); ?>"> |
| 74 | <button type="button" class="wpdm-btn wpdm-btn--secondary wpdm-media-upload" rel="#store-logo"> |
| 75 | <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path><polyline points="17 8 12 3 7 8"></polyline><line x1="12" y1="3" x2="12" y2="15"></line></svg> |
| 76 | <?php esc_html_e('Upload Image', 'download-manager'); ?> |
| 77 | </button> |
| 78 | <button type="button" class="wpdm-btn wpdm-btn--danger wpdm-btn--sm" id="remove-avatar" style="<?php echo $profile_pic ? '' : 'display: none;'; ?>"> |
| 79 | <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"></polyline><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path></svg> |
| 80 | <?php esc_html_e('Remove', 'download-manager'); ?> |
| 81 | </button> |
| 82 | <p class="wpdm-help-text"><?php esc_html_e('Recommended: Square image, at least 256x256 pixels', 'download-manager'); ?></p> |
| 83 | </div> |
| 84 | </div> |
| 85 | </div> |
| 86 | </div> |
| 87 | |
| 88 | <!-- Password Card --> |
| 89 | <div class="wpdm-card" style="margin-top: 1.5rem;"> |
| 90 | <div class="wpdm-card-header"> |
| 91 | <h3> |
| 92 | <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect><path d="M7 11V7a5 5 0 0 1 10 0v4"></path></svg> |
| 93 | <?php esc_html_e('Update Password', 'download-manager'); ?> |
| 94 | </h3> |
| 95 | </div> |
| 96 | <div class="wpdm-card-body"> |
| 97 | <div class="wpdm-form-grid"> |
| 98 | <div class="wpdm-form-group"> |
| 99 | <label for="new_pass"><?php esc_html_e('New Password', 'download-manager'); ?></label> |
| 100 | <input autocomplete="new-password" type="password" class="wpdm-input" value="" name="password" id="new_pass" placeholder="<?php esc_attr_e('Enter new password', 'download-manager'); ?>"> |
| 101 | </div> |
| 102 | <div class="wpdm-form-group"> |
| 103 | <label for="re_new_pass"><?php esc_html_e('Confirm Password', 'download-manager'); ?></label> |
| 104 | <input autocomplete="new-password" type="password" class="wpdm-input" value="" name="cpassword" id="re_new_pass" placeholder="<?php esc_attr_e('Re-enter new password', 'download-manager'); ?>"> |
| 105 | </div> |
| 106 | </div> |
| 107 | <div class="wpdm-alert wpdm-alert--info" style="margin-top: 1rem;"> |
| 108 | <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="16" x2="12" y2="12"></line><line x1="12" y1="8" x2="12.01" y2="8"></line></svg> |
| 109 | <span><?php esc_html_e('Leave empty if you don\'t want to change your password', 'download-manager'); ?></span> |
| 110 | </div> |
| 111 | </div> |
| 112 | </div> |
| 113 | |
| 114 | <?php do_action("wpdm_edit_profile_form"); ?> |
| 115 | |
| 116 | <!-- Submit Button --> |
| 117 | <div class="wpdm-card wpdm-card--action" style="margin-top: 1.5rem;"> |
| 118 | <button type="submit" class="wpdm-btn wpdm-btn--primary wpdm-btn--lg" id="edit_profile_sbtn"> |
| 119 | <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"></path><polyline points="17 21 17 13 7 13 7 21"></polyline><polyline points="7 3 7 8 15 8"></polyline></svg> |
| 120 | <?php esc_html_e('Save Changes', 'download-manager'); ?> |
| 121 | </button> |
| 122 | </div> |
| 123 | |
| 124 | </form> |
| 125 | <div id="edit-profile-msg"></div> |
| 126 | </div> |
| 127 | <div id="wpdm-fixed-top-center"></div> |
| 128 | |
| 129 | <style> |
| 130 | .wpdm-avatar-upload { |
| 131 | display: flex; |
| 132 | align-items: flex-start; |
| 133 | gap: 1.5rem; |
| 134 | flex-wrap: wrap; |
| 135 | } |
| 136 | .wpdm-avatar-preview { |
| 137 | width: 120px; |
| 138 | height: 120px; |
| 139 | border-radius: 50%; |
| 140 | background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%); |
| 141 | display: flex; |
| 142 | align-items: center; |
| 143 | justify-content: center; |
| 144 | overflow: hidden; |
| 145 | border: 4px solid #fff; |
| 146 | box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12); |
| 147 | flex-shrink: 0; |
| 148 | } |
| 149 | .wpdm-avatar-preview img { |
| 150 | width: 100%; |
| 151 | height: 100%; |
| 152 | object-fit: cover; |
| 153 | } |
| 154 | .wpdm-avatar-preview svg { |
| 155 | color: #94a3b8; |
| 156 | } |
| 157 | .wpdm-avatar-actions { |
| 158 | display: flex; |
| 159 | flex-direction: column; |
| 160 | align-items: flex-start; |
| 161 | gap: 0.75rem; |
| 162 | } |
| 163 | .wpdm-avatar-actions .wpdm-help-text { |
| 164 | margin: 0; |
| 165 | } |
| 166 | </style> |
| 167 | |
| 168 | <script> |
| 169 | jQuery(function ($) { |
| 170 | // Form submission |
| 171 | $('#edit_profile').on('submit', function (e) { |
| 172 | e.preventDefault(); |
| 173 | var $btn = $('#edit_profile_sbtn'); |
| 174 | var originalHtml = $btn.html(); |
| 175 | $btn.html('<svg class="wpdm-spin" xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="2" x2="12" y2="6"></line><line x1="12" y1="18" x2="12" y2="22"></line><line x1="4.93" y1="4.93" x2="7.76" y2="7.76"></line><line x1="16.24" y1="16.24" x2="19.07" y2="19.07"></line><line x1="2" y1="12" x2="6" y2="12"></line><line x1="18" y1="12" x2="22" y2="12"></line><line x1="4.93" y1="19.07" x2="7.76" y2="16.24"></line><line x1="16.24" y1="7.76" x2="19.07" y2="4.93"></line></svg> <?php echo esc_js(__('Saving...', 'download-manager')); ?>').prop('disabled', true); |
| 176 | |
| 177 | $(this).ajaxSubmit({ |
| 178 | success: function (res) { |
| 179 | WPDM.notify(res.msg, res.type, '#wpdm-fixed-top-center', 10000); |
| 180 | $btn.html(originalHtml).prop('disabled', false); |
| 181 | }, |
| 182 | error: function() { |
| 183 | $btn.html(originalHtml).prop('disabled', false); |
| 184 | WPDM.notify('<?php echo esc_js(__('An error occurred. Please try again.', 'download-manager')); ?>', 'error', '#wpdm-fixed-top-center', 10000); |
| 185 | } |
| 186 | }); |
| 187 | }); |
| 188 | |
| 189 | // Avatar preview update |
| 190 | $('#store-logo').on('change', function() { |
| 191 | var url = $(this).val(); |
| 192 | var $preview = $('#avatar-preview'); |
| 193 | var $removeBtn = $('#remove-avatar'); |
| 194 | |
| 195 | if (url) { |
| 196 | $preview.html('<img src="' + url + '" alt="">'); |
| 197 | $removeBtn.show(); |
| 198 | } else { |
| 199 | $preview.html('<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path><circle cx="12" cy="7" r="4"></circle></svg>'); |
| 200 | $removeBtn.hide(); |
| 201 | } |
| 202 | }); |
| 203 | |
| 204 | // Remove avatar |
| 205 | $('#remove-avatar').on('click', function() { |
| 206 | $('#store-logo').val('').trigger('change'); |
| 207 | }); |
| 208 | }); |
| 209 | </script> |
| 210 |