| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package Awesome Support/Admin/Functions/User Profile |
| 4 |
* @author AwesomeSupport <contact@getawesomesupport.com> |
| 5 |
* @license GPL-2.0+ |
| 6 |
* @link https://getawesomesupport.com |
| 7 |
* @copyright 2015-2017 AwesomeSupport |
| 8 |
*/ |
| 9 |
|
| 10 |
// If this file is called directly, abort. |
| 11 |
if ( ! defined( 'WPINC' ) ) { |
| 12 |
die; |
| 13 |
} |
| 14 |
|
| 15 |
/** |
| 16 |
* Get the list of user profile data to display in the user profile metabox |
| 17 |
* |
| 18 |
* @since 3.3 |
| 19 |
* |
| 20 |
* @param int $ticket_id Current ticket iD |
| 21 |
* |
| 22 |
* @return array |
| 23 |
*/ |
| 24 |
function wpas_user_profile_get_contact_info( $ticket_id ) { |
| 25 |
|
| 26 |
$data = array( |
| 27 |
'name', |
| 28 |
'role', |
| 29 |
'email', |
| 30 |
); |
| 31 |
|
| 32 |
return apply_filters( 'wpas_user_profile_contact_info', $data, $ticket_id ); |
| 33 |
|
| 34 |
} |
| 35 |
|
| 36 |
/** |
| 37 |
* Get the content of a user profile data field |
| 38 |
* |
| 39 |
* User profile data fields are declared in wpas_user_profile_get_contact_info() |
| 40 |
* |
| 41 |
* @since 3.3 |
| 42 |
* |
| 43 |
* @param string $info ID of the information field being displayed |
| 44 |
* @param WP_User $user The current user object (the creator of the ticket) |
| 45 |
* @param int $ticket_id ID of the current ticket |
| 46 |
* |
| 47 |
* @return void |
| 48 |
*/ |
| 49 |
function wpas_user_profile_contact_info_contents( $info, $user, $ticket_id ) { |
| 50 |
|
| 51 |
if ( !$user ) { |
| 52 |
return; |
| 53 |
} |
| 54 |
|
| 55 |
switch ( $info ) { |
| 56 |
|
| 57 |
case 'name': |
| 58 |
echo wp_kses_post(apply_filters( 'wpas_user_profile_contact_name', $user->data->display_name, $user, $ticket_id )); |
| 59 |
break; |
| 60 |
|
| 61 |
case 'role': |
| 62 |
// translators: %s is the date. |
| 63 |
$x_content = __( 'Support User since %s', 'awesome-support' ); |
| 64 |
echo wp_kses_post( sprintf( $x_content, '<strong>' . gmdate( get_option( 'date_format' ), strtotime( $user->data->user_registered ) ) . '</strong>' ) ); |
| 65 |
break; |
| 66 |
|
| 67 |
case 'email': |
| 68 |
printf( '<a href="mailto:%1$s">%1$s</a>', esc_attr( $user->data->user_email ) ); |
| 69 |
break; |
| 70 |
|
| 71 |
default: |
| 72 |
do_action( 'wpas_user_profile_info_' . $info, $user, $ticket_id ); |
| 73 |
break; |
| 74 |
|
| 75 |
} |
| 76 |
|
| 77 |
} |
| 78 |
|