| 762 | /** |
| 763 | * Provide backwards compatibility for the admin_user_info_links filter. |
| 764 | * |
| 765 | * I haz a sad. |
| 766 | * |
| 767 | * @access private |
| 768 | * @since 3.3.0 |
| 769 | */ |
| 770 | function _wp_admin_bar_profile_links_compat( $wp_admin_bar = null ) { |
| 771 | if ( 'in_admin_header' == current_filter() ) { |
| 772 | if ( has_filter( 'admin_user_info_links' ) ) |
| 773 | add_action( 'admin_bar_menu', '_wp_admin_bar_profile_links_compat' ); |
| 774 | return; |
| 775 | } |
| 776 | |
| 777 | $original_howdy = sprintf( __( 'Howdy, %1$s' ), $GLOBALS['user_identity'] ); |
| 778 | $links = array( |
| 779 | 5 => $original_howdy, |
| 780 | 8 => null, |
| 781 | 10 => null, |
| 782 | 15 => null, |
| 783 | ); |
| 784 | |
| 785 | $links = apply_filters( 'admin_user_info_links', $links, wp_get_current_user() ); |
| 786 | ksort( $links ); |
| 787 | |
| 788 | $filtered_howdy = array_shift( $links ); |
| 789 | |
| 790 | // Srsly? |
| 791 | if ( $filtered_howdy != $original_howdy ) |
| 792 | $wp_admin_bar->menu->{'my-account'}['title'] = $filtered_howdy . get_avatar( get_current_user_id(), 28 ); |
| 793 | |
| 794 | $links = array_filter( $links ); |
| 795 | |
| 796 | if ( empty( $links ) ) |
| 797 | return; |
| 798 | |
| 799 | // Trim whitespace and pipes from links. |
| 800 | $links = array_map( 'trim', $links, array_fill( 0, count( $links ), " |\n\t" ) ); |
| 801 | |
| 802 | foreach ( $links as $link ) { |
| 803 | if ( ! preg_match( '#<a\s[^>]*?href=[\'"](.+?)[\'"].*?>(.*?)</a>#is', $link, $matches ) ) |
| 804 | continue; |
| 805 | $wp_admin_bar->add_menu( array( |
| 806 | 'parent' => 'my-account', |
| 807 | 'title' => $matches[2], |
| 808 | 'href' => $matches[1], |
| 809 | ) ); |
| 810 | } |
| 811 | } |
| 812 | if ( is_admin() ) |
| 813 | add_action( 'in_admin_header', '_wp_admin_bar_profile_links_compat' ); |
| 814 | else |
| 815 | add_action( 'admin_bar_menu', '_wp_admin_bar_profile_links_compat' ); |
| 816 | |