| 1: | <?php |
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | if ( ! defined( 'ABSPATH' ) ) { |
| 14: | exit; |
| 15: | } |
| 16: | |
| 17: | |
| 18: | |
| 19: | |
| 20: | |
| 21: | |
| 22: | |
| 23: | |
| 24: | |
| 25: | |
| 26: | function epl_property_admin_contact( $contactmethods ) { |
| 27: | $contactmethods['mobile'] = __( 'Mobile', 'easy-property-listings' ); |
| 28: | $contactmethods['office_phone'] = __( 'Office Phone', 'easy-property-listings' ); |
| 29: | $contactmethods['skype'] = __( 'Skype', 'easy-property-listings' ); |
| 30: | $contactmethods['twitter'] = __( 'Twitter', 'easy-property-listings' ); |
| 31: | $contactmethods['facebook'] = __( 'Facebook', 'easy-property-listings' ); |
| 32: | $contactmethods['linkedin'] = __( 'LinkedIn', 'easy-property-listings' ); |
| 33: | $contactmethods['instagram'] = __( 'Instagram', 'easy-property-listings' ); |
| 34: | $contactmethods['pinterest'] = __( 'Pinterest', 'easy-property-listings' ); |
| 35: | $contactmethods['youtube'] = __( 'Youtube', 'easy-property-listings' ); |
| 36: | return $contactmethods; |
| 37: | } |
| 38: | add_filter( 'user_contactmethods', 'epl_property_admin_contact', 10, 1 ); |
| 39: | |
| 40: | |
| 41: | |
| 42: | |
| 43: | |
| 44: | |
| 45: | |
| 46: | function epl_get_custom_user_profile_fields() { |
| 47: | |
| 48: | return apply_filters( |
| 49: | 'epl_custom_user_profile_fields', |
| 50: | array( |
| 51: | array( |
| 52: | 'name' => 'position', |
| 53: | 'label' => __( 'Position', 'easy-property-listings' ), |
| 54: | 'description' => __( 'Please enter your title/position.', 'easy-property-listings' ), |
| 55: | 'class' => 'regular-text', |
| 56: | 'type' => 'text', |
| 57: | ), |
| 58: | array( |
| 59: | 'name' => 'slogan', |
| 60: | 'label' => __( 'Slogan', 'easy-property-listings' ), |
| 61: | 'description' => __( 'Please enter your slogan.', 'easy-property-listings' ), |
| 62: | 'class' => 'regular-text', |
| 63: | 'type' => 'text', |
| 64: | ), |
| 65: | array( |
| 66: | 'name' => 'video', |
| 67: | 'label' => __( 'Youtube Video Url', 'easy-property-listings' ), |
| 68: | 'description' => __( 'Please enter your YouTube Profile Video URL.', 'easy-property-listings' ), |
| 69: | 'class' => 'regular-text', |
| 70: | 'type' => 'text', |
| 71: | ), |
| 72: | array( |
| 73: | 'name' => 'contact-form', |
| 74: | 'label' => __( 'Contact Form short code', 'easy-property-listings' ), |
| 75: | 'description' => __( 'Please enter your form short code for author contact tab.', 'easy-property-listings' ), |
| 76: | 'class' => 'regular-text', |
| 77: | 'type' => 'text', |
| 78: | ), |
| 79: | ) |
| 80: | ); |
| 81: | } |
| 82: | |
| 83: | |
| 84: | |
| 85: | |
| 86: | |
| 87: | |
| 88: | |
| 89: | |
| 90: | function epl_add_custom_user_profile_fields( $user ) { |
| 91: | ?> |
| 92: | |
| 93: | <h3><?php esc_html_e( 'Easy Property Listings: Author Box Profile', 'easy-property-listings' ); ?></h3> |
| 94: | <p><?php esc_html_e( 'The following details will appear in your author box and widgets.', 'easy-property-listings' ); ?></p> |
| 95: | |
| 96: | <table class="form-table"> |
| 97: | <?php |
| 98: | $user_fields = epl_get_custom_user_profile_fields(); |
| 99: | |
| 100: | foreach ( $user_fields as $user_field ) { |
| 101: | ?> |
| 102: | <tr> |
| 103: | <th> |
| 104: | <label for="<?php echo esc_attr( $user_field['name'] ); ?>"> |
| 105: | <?php echo esc_html( $user_field['label'] ); ?> |
| 106: | </label> |
| 107: | </th> |
| 108: | <td> |
| 109: | <input |
| 110: | type="text" |
| 111: | name="<?php echo esc_attr( $user_field['name'] ); ?>" |
| 112: | id="<?php echo esc_attr( $user_field['name'] ); ?>" |
| 113: | value="<?php echo esc_attr( get_the_author_meta( $user_field['name'], $user->ID ) ); ?>" |
| 114: | class="regular-text" |
| 115: | /><br /> |
| 116: | <span class="description"> |
| 117: | <?php |
| 118: | echo isset( $user_field['description'] ) ? wp_kses_post( $user_field['description'] ) : ''; |
| 119: | ?> |
| 120: | </span> |
| 121: | </td> |
| 122: | </tr> |
| 123: | <?php |
| 124: | } |
| 125: | ?> |
| 126: | </table> |
| 127: | <?php |
| 128: | } |
| 129: | |
| 130: | |
| 131: | |
| 132: | |
| 133: | |
| 134: | |
| 135: | |
| 136: | |
| 137: | |
| 138: | function epl_save_custom_user_profile_fields( $user_id ) { |
| 139: | if ( ! current_user_can( 'edit_user', $user_id ) ) { |
| 140: | return false; |
| 141: | } |
| 142: | |
| 143: | $user_fields = epl_get_custom_user_profile_fields(); |
| 144: | |
| 145: | foreach ( $user_fields as $user_field ) { |
| 146: | |
| 147: | if ( isset( $_POST[ $user_field['name'] ] ) ) { |
| 148: | update_user_meta( $user_id, $user_field['name'], sanitize_text_field( wp_unslash( $_POST[ $user_field['name'] ] ) ) ); |
| 149: | } |
| 150: | } |
| 151: | } |
| 152: | |
| 153: | add_action( 'show_user_profile', 'epl_add_custom_user_profile_fields' ); |
| 154: | add_action( 'edit_user_profile', 'epl_add_custom_user_profile_fields' ); |
| 155: | |
| 156: | add_action( 'personal_options_update', 'epl_save_custom_user_profile_fields' ); |
| 157: | add_action( 'edit_user_profile_update', 'epl_save_custom_user_profile_fields' ); |
| 158: | |