| 61 | * Outputs opengraph tags for user profiles. |
| 62 | */ |
| 63 | function profiles_output_opengraph() { |
| 64 | if ( !bp_is_user_profile() || !bp_is_current_action( 'public' ) ) { |
| 65 | return; |
| 66 | } |
| 67 | $bio = bp_get_profile_field_data( array( 'field' => 'About Me' ) ); |
| 68 | $url = bp_displayed_user_domain(); |
| 69 | $image_url = get_avatar_url( bp_displayed_user_id(), array( 'size' => 1024 ) ); |
| 70 | $full_name = bp_get_displayed_user_fullname(); |
| 71 | $username = bp_get_displayed_user_username(); |
| 72 | |
| 73 | ?> |
| 74 | <meta property="og:type" content="profile" /> |
| 75 | <meta property="og:title" content="<?php echo esc_attr( $full_name ); ?> - WordPress user profile" /> |
| 76 | <meta property="og:description" content="<?php echo esc_attr( wp_trim_words( $bio, 25, '…' ) ); ?>" /> |
| 77 | <meta property="og:url" content="<?php echo esc_attr( $url ); ?>" /> |
| 78 | <meta property="og:site_name" content="WordPress" /> |
| 79 | <meta property="og:image" content="<?php echo esc_attr( $image_url ); ?>" /> |
| 80 | <meta property="profile:username" content="<?php echo esc_attr( $username ); ?>" /> |
| 81 | <? |
| 82 | } |
| 83 | add_action( 'wp_head', 'profiles_output_opengraph' ); |
| 84 | |
| 85 | /** |