[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-messages/ -> bp-messages-template.php (source)

   1  <?php
   2  /**
   3   * BuddyPress Messages Template Tags.
   4   *
   5   * @package BuddyPress
   6   * @subpackage MessagesTemplate
   7   * @since 1.5.0
   8   */
   9  
  10  // Exit if accessed directly.
  11  defined( 'ABSPATH' ) || exit;
  12  
  13  /**
  14   * Retrieve private message threads for display in inbox/sentbox/notices.
  15   *
  16   * Similar to WordPress's have_posts() function, this function is responsible
  17   * for querying the database and retrieving private messages for display inside
  18   * the theme via individual template parts for a member's inbox/sentbox/notices.
  19   *
  20   * @since 1.0.0
  21   *
  22   * @global BP_Messages_Box_Template $messages_template
  23   *
  24   * @param array|string $args {
  25   *     Array of arguments. All are optional.
  26   *     @type int    $user_id      ID of the user whose threads are being loaded.
  27   *                                Default: ID of the logged-in user.
  28   *     @type string $box          Current "box" view. If not provided here, the current
  29   *                                view will be inferred from the URL.
  30   *     @type int    $per_page     Number of results to return per page. Default: 10.
  31   *     @type int    $max          Max results to return. Default: false.
  32   *     @type string $type         Type of messages to return. Values: 'all', 'read', 'unread'
  33   *                                Default: 'all'
  34   *     @type string $search_terms Terms to which to limit results. Default:
  35   *                                the value of $_REQUEST['s'].
  36   *     @type string $page_arg     URL argument used for the pagination param.
  37   *                                Default: 'mpage'.
  38   *     @type array  $meta_query   Meta query arguments. Only applicable if $box is
  39   *                                not 'notices'. See WP_Meta_Query more details.
  40   * }
  41   * @return bool True if there are threads to display, otherwise false.
  42   */
  43  function bp_has_message_threads( $args = array() ) {
  44      global $messages_template;
  45  
  46      // The default box the user is looking at.
  47      $current_action = bp_current_action();
  48      switch ( $current_action ) {
  49          case 'sentbox' :
  50          case 'notices' :
  51          case 'inbox'   :
  52              $default_box = $current_action;
  53              break;
  54          default :
  55              $default_box = 'inbox';
  56              break;
  57      }
  58  
  59      // User ID
  60      // @todo displayed user for moderators that get this far?
  61      $user_id = bp_displayed_user_id();
  62  
  63      // Search Terms.
  64      $search_terms = isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : '';
  65  
  66      // Parse the arguments.
  67      $r = bp_parse_args( $args, array(
  68          'user_id'      => $user_id,
  69          'box'          => $default_box,
  70          'per_page'     => 10,
  71          'max'          => false,
  72          'type'         => 'all',
  73          'search_terms' => $search_terms,
  74          'page_arg'     => 'mpage', // See https://buddypress.trac.wordpress.org/ticket/3679.
  75          'meta_query'   => array()
  76      ), 'has_message_threads' );
  77  
  78      // Load the messages loop global up with messages.
  79      $messages_template = new BP_Messages_Box_Template( $r );
  80  
  81      /**
  82       * Filters if there are any message threads to display in inbox/sentbox/notices.
  83       *
  84       * @since 1.1.0
  85       *
  86       * @param bool                     $value             Whether or not the message has threads.
  87       * @param BP_Messages_Box_Template $messages_template Current message box template object.
  88       * @param array                    $r                 Array of parsed arguments passed into function.
  89       */
  90      return apply_filters( 'bp_has_message_threads', $messages_template->has_threads(), $messages_template, $r );
  91  }
  92  
  93  /**
  94   * Check whether there are more threads to iterate over.
  95   *
  96   * @return bool
  97   */
  98  function bp_message_threads() {
  99      global $messages_template;
 100      return $messages_template->message_threads();
 101  }
 102  
 103  /**
 104   * Set up the current thread inside the loop.
 105   *
 106   * @return object
 107   */
 108  function bp_message_thread() {
 109      global $messages_template;
 110      return $messages_template->the_message_thread();
 111  }
 112  
 113  /**
 114   * Output the ID of the current thread in the loop.
 115   */
 116  function bp_message_thread_id() {
 117      echo bp_get_message_thread_id();
 118  }
 119      /**
 120       * Get the ID of the current thread in the loop.
 121       *
 122       * @return int
 123       */
 124  	function bp_get_message_thread_id() {
 125          global $messages_template;
 126  
 127          /**
 128           * Filters the ID of the current thread in the loop.
 129           *
 130           * @since 1.0.0
 131           *
 132           * @param int $thread_id ID of the current thread in the loop.
 133           */
 134          return apply_filters( 'bp_get_message_thread_id', $messages_template->thread->thread_id );
 135      }
 136  
 137  /**
 138   * Output the subject of the current thread in the loop.
 139   */
 140  function bp_message_thread_subject() {
 141      echo bp_get_message_thread_subject();
 142  }
 143      /**
 144       * Get the subject of the current thread in the loop.
 145       *
 146       * @return string
 147       */
 148  	function bp_get_message_thread_subject() {
 149          global $messages_template;
 150  
 151          /**
 152           * Filters the subject of the current thread in the loop.
 153           *
 154           * @since 1.1.0
 155           *
 156           * @param string $value Subject of the current thread in the loop.
 157           */
 158          return apply_filters( 'bp_get_message_thread_subject', $messages_template->thread->last_message_subject );
 159      }
 160  
 161  /**
 162   * Output an excerpt from the current message in the loop.
 163   */
 164  function bp_message_thread_excerpt() {
 165      echo bp_get_message_thread_excerpt();
 166  }
 167      /**
 168       * Generate an excerpt from the current message in the loop.
 169       *
 170       * @return string
 171       */
 172  	function bp_get_message_thread_excerpt() {
 173          global $messages_template;
 174  
 175          /**
 176           * Filters the excerpt of the current thread in the loop.
 177           *
 178           * @since 1.0.0
 179           *
 180           * @param string $value Excerpt of the current thread in the loop.
 181           */
 182          return apply_filters( 'bp_get_message_thread_excerpt', strip_tags( bp_create_excerpt( $messages_template->thread->last_message_content, 75 ) ) );
 183      }
 184  
 185  /**
 186   * Output the thread's last message content.
 187   *
 188   * When viewing your Inbox, the last message is the most recent message in
 189   * the thread of which you are *not* the author.
 190   *
 191   * When viewing your Sentbox, last message is the most recent message in
 192   * the thread of which you *are* the member.
 193   *
 194   * @since 2.0.0
 195   */
 196  function bp_message_thread_content() {
 197      echo bp_get_message_thread_content();
 198  }
 199      /**
 200       * Return the thread's last message content.
 201       *
 202       * When viewing your Inbox, the last message is the most recent message in
 203       * the thread of which you are *not* the author.
 204       *
 205       * When viewing your Sentbox, last message is the most recent message in
 206       * the thread of which you *are* the member.
 207       *
 208       * @since 2.0.0
 209       *
 210       * @return string The raw content of the last message in the thread.
 211       */
 212  	function bp_get_message_thread_content() {
 213          global $messages_template;
 214  
 215          /**
 216           * Filters the content of the last message in the thread.
 217           *
 218           * @since 2.0.0
 219           *
 220           * @param string $last_message_content Content of the last message in the thread.
 221           */
 222          return apply_filters( 'bp_get_message_thread_content', $messages_template->thread->last_message_content );
 223      }
 224  
 225  /**
 226   * Output a link to the page of the current thread's last author.
 227   */
 228  function bp_message_thread_from() {
 229      echo bp_get_message_thread_from();
 230  }
 231      /**
 232       * Get a link to the page of the current thread's last author.
 233       *
 234       * @return string
 235       */
 236  	function bp_get_message_thread_from() {
 237          global $messages_template;
 238  
 239          /**
 240           * Filters the link to the page of the current thread's last author.
 241           *
 242           * @since 1.0.0
 243           *
 244           * @param string $value Link to the page of the current thread's last author.
 245           */
 246          return apply_filters( 'bp_get_message_thread_from', bp_core_get_userlink( $messages_template->thread->last_sender_id ) );
 247      }
 248  
 249  /**
 250   * Output links to the pages of the current thread's recipients.
 251   */
 252  function bp_message_thread_to() {
 253      echo bp_get_message_thread_to();
 254  }
 255      /**
 256       * Generate HTML links to the pages of the current thread's recipients.
 257       *
 258       * @return string
 259       */
 260  	function bp_get_message_thread_to() {
 261          global $messages_template;
 262  
 263          /**
 264           * Filters the HTML links to the pages of the current thread's recipients.
 265           *
 266           * @since 1.0.0
 267           *
 268           * @param string $value HTML links to the pages of the current thread's recipients.
 269           */
 270          return apply_filters( 'bp_message_thread_to', BP_Messages_Thread::get_recipient_links($messages_template->thread->recipients ) );
 271      }
 272  
 273  /**
 274   * Output the permalink for a particular thread.
 275   *
 276   * @since 2.9.0 Introduced `$user_id` parameter.
 277   *
 278   * @param int $thread_id Optional. ID of the thread. Default: current thread
 279   *                       being iterated on in the loop.
 280   * @param int $user_id   Optional. ID of the user relative to whom the link
 281   *                       should be generated. Default: ID of logged-in user.
 282   */
 283  function bp_message_thread_view_link( $thread_id = 0, $user_id = null ) {
 284      echo bp_get_message_thread_view_link( $thread_id, $user_id );
 285  }
 286      /**
 287       * Get the permalink of a particular thread.
 288       *
 289       * @since 2.9.0 Introduced `$user_id` parameter.
 290       *
 291       * @param int $thread_id Optional. ID of the thread. Default: current
 292       *                       thread being iterated on in the loop.
 293       * @param int $user_id   Optional. ID of the user relative to whom the link
 294       *                       should be generated. Default: ID of logged-in user.
 295       * @return string
 296       */
 297  	function bp_get_message_thread_view_link( $thread_id = 0, $user_id = null ) {
 298          global $messages_template;
 299  
 300          if ( empty( $messages_template ) && (int) $thread_id > 0 ) {
 301              $thread_id = (int) $thread_id;
 302          } elseif ( ! empty( $messages_template->thread->thread_id ) ) {
 303              $thread_id = $messages_template->thread->thread_id;
 304          }
 305  
 306          if ( null === $user_id ) {
 307              $user_id = bp_loggedin_user_id();
 308          }
 309  
 310          $domain = bp_core_get_user_domain( $user_id );
 311  
 312          /**
 313           * Filters the permalink of a particular thread.
 314           *
 315           * @since 1.0.0
 316           * @since 2.6.0 Added the `$thread_id` parameter.
 317           * @since 2.9.0 Added the `$user_id` parameter.
 318           *
 319           * @param string $value     Permalink of a particular thread.
 320           * @param int    $thread_id ID of the thread.
 321           * @param int    $user_id   ID of the user.
 322           */
 323          return apply_filters( 'bp_get_message_thread_view_link', trailingslashit( $domain . bp_get_messages_slug() . '/view/' . $thread_id ), $thread_id, $user_id );
 324      }
 325  
 326  /**
 327   * Output the URL for deleting the current thread.
 328   *
 329   * @since 2.9.0 Introduced `$user_id` parameter.
 330   *
 331   * @param int $user_id Optional. ID of the user relative to whom the link
 332   *                     should be generated. Default: ID of logged-in user.
 333   */
 334  function bp_message_thread_delete_link( $user_id = null ) {
 335      echo esc_url( bp_get_message_thread_delete_link( $user_id ) );
 336  }
 337      /**
 338       * Generate the URL for deleting the current thread.
 339       *
 340       * @since 2.9.0 Introduced `$user_id` parameter.
 341       *
 342       * @param int $user_id Optional. ID of the user relative to whom the link
 343       *                     should be generated. Default: ID of logged-in user.
 344       * @return string
 345       */
 346  	function bp_get_message_thread_delete_link( $user_id = null ) {
 347          global $messages_template;
 348  
 349          if ( null === $user_id ) {
 350              $user_id = bp_loggedin_user_id();
 351          }
 352  
 353          $domain = bp_core_get_user_domain( $user_id );
 354  
 355          /**
 356           * Filters the URL for deleting the current thread.
 357           *
 358           * @since 1.0.0
 359           *
 360           * @param string $value   URL for deleting the current thread.
 361           * @param int    $user_id ID of the user relative to whom the link should be generated.
 362           */
 363          return apply_filters( 'bp_get_message_thread_delete_link', wp_nonce_url( trailingslashit( $domain . bp_get_messages_slug() . '/' . bp_current_action() . '/delete/' . $messages_template->thread->thread_id ), 'messages_delete_thread' ), $user_id );
 364      }
 365  
 366  /**
 367   * Output the URL used for marking a single message thread as unread.
 368   *
 369   * Since this function directly outputs a URL, it is escaped.
 370   *
 371   * @since 2.2.0
 372   * @since 2.9.0 Introduced `$user_id` parameter.
 373   *
 374   * @param int $user_id Optional. ID of the user relative to whom the link
 375   *                     should be generated. Default: ID of logged-in user.
 376   */
 377  function bp_the_message_thread_mark_unread_url( $user_id = null ) {
 378      echo esc_url( bp_get_the_message_thread_mark_unread_url( $user_id ) );
 379  }
 380      /**
 381       * Return the URL used for marking a single message thread as unread.
 382       *
 383       * @since 2.2.0
 384       * @since 2.9.0 Introduced `$user_id` parameter.
 385       *
 386       * @param int $user_id Optional. ID of the user relative to whom the link
 387       *                     should be generated. Default: ID of logged-in user.
 388       * @return string
 389       */
 390  	function bp_get_the_message_thread_mark_unread_url( $user_id = null ) {
 391  
 392          // Get the message ID.
 393          $id = bp_get_message_thread_id();
 394  
 395          // Get the args to add to the URL.
 396          $args = array(
 397              'action'     => 'unread',
 398              'message_id' => $id
 399          );
 400  
 401          if ( null === $user_id ) {
 402              $user_id = bp_loggedin_user_id();
 403          }
 404  
 405          $domain = bp_core_get_user_domain( $user_id );
 406  
 407          // Base unread URL.
 408          $url = trailingslashit( $domain . bp_get_messages_slug() . '/' . bp_current_action() . '/unread' );
 409  
 410          // Add the args to the URL.
 411          $url = add_query_arg( $args, $url );
 412  
 413          // Add the nonce.
 414          $url = wp_nonce_url( $url, 'bp_message_thread_mark_unread_' . $id );
 415  
 416          /**
 417           * Filters the URL used for marking a single message thread as unread.
 418           *
 419           * @since 2.2.0
 420           * @since 2.9.0 Added `$user_id` parameter.
 421           *
 422           * @param string $url     URL used for marking a single message thread as unread.
 423           * @param int    $user_id ID of the user relative to whom the link should be generated.
 424           */
 425          return apply_filters( 'bp_get_the_message_thread_mark_unread_url', $url, $user_id );
 426      }
 427  
 428  /**
 429   * Output the URL used for marking a single message thread as read.
 430   *
 431   * Since this function directly outputs a URL, it is escaped.
 432   *
 433   * @since 2.2.0
 434   * @since 2.9.0 Introduced `$user_id` parameter.
 435   *
 436   * @param int $user_id Optional. ID of the user relative to whom the link
 437   *                     should be generated. Default: ID of logged-in user.
 438   */
 439  function bp_the_message_thread_mark_read_url( $user_id = null ) {
 440      echo esc_url( bp_get_the_message_thread_mark_read_url( $user_id ) );
 441  }
 442      /**
 443       * Return the URL used for marking a single message thread as read.
 444       *
 445       * @since 2.2.0
 446       * @since 2.9.0 Introduced `$user_id` parameter.
 447       *
 448       * @param int $user_id Optional. ID of the user relative to whom the link
 449       *                     should be generated. Default: ID of logged-in user.
 450       * @return string
 451       */
 452  	function bp_get_the_message_thread_mark_read_url( $user_id = null ) {
 453  
 454          // Get the message ID.
 455          $id = bp_get_message_thread_id();
 456  
 457          // Get the args to add to the URL.
 458          $args = array(
 459              'action'     => 'read',
 460              'message_id' => $id
 461          );
 462  
 463          if ( null === $user_id ) {
 464              $user_id = bp_loggedin_user_id();
 465          }
 466  
 467          $domain = bp_core_get_user_domain( $user_id );
 468  
 469          // Base read URL.
 470          $url = trailingslashit( $domain . bp_get_messages_slug() . '/' . bp_current_action() . '/read' );
 471  
 472          // Add the args to the URL.
 473          $url = add_query_arg( $args, $url );
 474  
 475          // Add the nonce.
 476          $url = wp_nonce_url( $url, 'bp_message_thread_mark_read_' . $id );
 477  
 478          /**
 479           * Filters the URL used for marking a single message thread as read.
 480           *
 481           * @since 2.2.0
 482           *
 483           * @param string $url     URL used for marking a single message thread as read.
 484           * @param int    $user_id ID of the user relative to whom the link should be generated.
 485           */
 486          return apply_filters( 'bp_get_the_message_thread_mark_read_url', $url );
 487      }
 488  
 489  /**
 490   * Output the CSS class for the current thread.
 491   */
 492  function bp_message_css_class() {
 493      echo esc_attr( bp_get_message_css_class() );
 494  }
 495      /**
 496       * Generate the CSS class for the current thread.
 497       *
 498       * @return string
 499       */
 500  	function bp_get_message_css_class() {
 501          global $messages_template;
 502  
 503          $class = false;
 504  
 505          if ( $messages_template->current_thread % 2 == 1 ) {
 506              $class .= 'alt';
 507          }
 508  
 509          /**
 510           * Filters the CSS class for the current thread.
 511           *
 512           * @since 1.2.10
 513           *
 514           * @param string $class Class string to be added to the list of classes.
 515           */
 516          return apply_filters( 'bp_get_message_css_class', trim( $class ) );
 517      }
 518  
 519  /**
 520   * Check whether the current thread has unread items.
 521   *
 522   * @return bool True if there are unread items, otherwise false.
 523   */
 524  function bp_message_thread_has_unread() {
 525      global $messages_template;
 526  
 527      $retval = ! empty( $messages_template->thread->unread_count )
 528          ? true
 529          : false;
 530  
 531      /**
 532       * Filters whether or not a message thread has unread items.
 533       *
 534       * @since 2.1.0
 535       *
 536       * @param bool $retval Whether or not a message thread has unread items.
 537       */
 538      return apply_filters( 'bp_message_thread_has_unread', $retval );
 539  }
 540  
 541  /**
 542   * Output the current thread's unread count.
 543   */
 544  function bp_message_thread_unread_count() {
 545      echo esc_html( bp_get_message_thread_unread_count() );
 546  }
 547      /**
 548       * Get the current thread's unread count.
 549       *
 550       * @return int
 551       */
 552  	function bp_get_message_thread_unread_count() {
 553          global $messages_template;
 554  
 555          $count = ! empty( $messages_template->thread->unread_count )
 556              ? (int) $messages_template->thread->unread_count
 557              : false;
 558  
 559          /**
 560           * Filters the current thread's unread count.
 561           *
 562           * @since 1.0.0
 563           *
 564           * @param int $count Current thread unread count.
 565           */
 566          return apply_filters( 'bp_get_message_thread_unread_count', $count );
 567      }
 568  
 569  /**
 570   * Output a thread's total message count.
 571   *
 572   * @since 2.2.0
 573   *
 574   * @param int|bool $thread_id Optional. ID of the thread. Defaults to current thread ID.
 575   */
 576  function bp_message_thread_total_count( $thread_id = false ) {
 577      echo bp_get_message_thread_total_count( $thread_id );
 578  }
 579      /**
 580       * Get the current thread's total message count.
 581       *
 582       * @since 2.2.0
 583       *
 584       * @param int|bool $thread_id Optional. ID of the thread.
 585       *                            Defaults to current thread ID.
 586       * @return int
 587       */
 588  	function bp_get_message_thread_total_count( $thread_id = false ) {
 589          if ( false === $thread_id ) {
 590              $thread_id = bp_get_message_thread_id();
 591          }
 592  
 593          $thread_template = new BP_Messages_Thread_Template( $thread_id, 'ASC', array(
 594              'update_meta_cache' => false
 595          ) );
 596  
 597          $count = 0;
 598          if ( ! empty( $thread_template->message_count ) ) {
 599              $count = intval( $thread_template->message_count );
 600          }
 601  
 602          /**
 603           * Filters the current thread's total message count.
 604           *
 605           * @since 2.2.0
 606           * @since 2.6.0 Added the `$thread_id` parameter.
 607           *
 608           * @param int $count     Current thread total message count.
 609           * @param int $thread_id ID of the queried thread.
 610           */
 611          return apply_filters( 'bp_get_message_thread_total_count', $count, $thread_id );
 612      }
 613  
 614  /**
 615   * Output markup for the current thread's total and unread count.
 616   *
 617   * @since 2.2.0
 618   *
 619   * @param int|bool $thread_id Optional. ID of the thread. Default: current thread ID.
 620   */
 621  function bp_message_thread_total_and_unread_count( $thread_id = false ) {
 622      echo bp_get_message_thread_total_and_unread_count( $thread_id );
 623  }
 624      /**
 625       * Get markup for the current thread's total and unread count.
 626       *
 627       * @param int|bool $thread_id Optional. ID of the thread. Default: current thread ID.
 628       * @return string Markup displaying the total and unread count for the thread.
 629       */
 630  	function bp_get_message_thread_total_and_unread_count( $thread_id = false ) {
 631          if ( false === $thread_id ) {
 632              $thread_id = bp_get_message_thread_id();
 633          }
 634  
 635          $total  = bp_get_message_thread_total_count( $thread_id );
 636          $unread = bp_get_message_thread_unread_count( $thread_id );
 637  
 638          return sprintf(
 639              /* translators: 1: total number, 2: accessibility text: number of unread messages */
 640              '<span class="thread-count">(%1$s)</span> <span class="bp-screen-reader-text">%2$s</span>',
 641              number_format_i18n( $total ),
 642              sprintf( _n( '%d unread', '%d unread', $unread, 'buddypress' ), number_format_i18n( $unread ) )
 643          );
 644      }
 645  
 646  /**
 647   * Output the unformatted date of the last post in the current thread.
 648   */
 649  function bp_message_thread_last_post_date_raw() {
 650      echo bp_get_message_thread_last_post_date_raw();
 651  }
 652      /**
 653       * Get the unformatted date of the last post in the current thread.
 654       *
 655       * @return string
 656       */
 657  	function bp_get_message_thread_last_post_date_raw() {
 658          global $messages_template;
 659  
 660          /**
 661           * Filters the unformatted date of the last post in the current thread.
 662           *
 663           * @since 2.1.0
 664           *
 665           * @param string $last_message_date Unformatted date of the last post in the current thread.
 666           */
 667          return apply_filters( 'bp_get_message_thread_last_message_date', $messages_template->thread->last_message_date );
 668      }
 669  
 670  /**
 671   * Output the nicely formatted date of the last post in the current thread.
 672   */
 673  function bp_message_thread_last_post_date() {
 674      echo bp_get_message_thread_last_post_date();
 675  }
 676      /**
 677       * Get the nicely formatted date of the last post in the current thread.
 678       *
 679       * @return string
 680       */
 681  	function bp_get_message_thread_last_post_date() {
 682  
 683          /**
 684           * Filters the nicely formatted date of the last post in the current thread.
 685           *
 686           * @since 2.1.0
 687           *
 688           * @param string $value Formatted date of the last post in the current thread.
 689           */
 690          return apply_filters( 'bp_get_message_thread_last_post_date', bp_format_time( strtotime( bp_get_message_thread_last_post_date_raw() ) ) );
 691      }
 692  
 693  /**
 694   * Output the avatar for the last sender in the current message thread.
 695   *
 696   * @see bp_get_message_thread_avatar() for a description of arguments.
 697   *
 698   * @param array|string $args See {@link bp_get_message_thread_avatar()}.
 699   */
 700  function bp_message_thread_avatar( $args = '' ) {
 701      echo bp_get_message_thread_avatar( $args );
 702  }
 703      /**
 704       * Return the avatar for the last sender in the current message thread.
 705       *
 706       * @see bp_core_fetch_avatar() For a description of arguments and
 707       *      return values.
 708       *
 709       * @param array|string $args {
 710       *     Arguments are listed here with an explanation of their defaults.
 711       *     For more information about the arguments, see
 712       *     {@link bp_core_fetch_avatar()}.
 713       *     @type string      $type   Default: 'thumb'.
 714       *     @type int|bool    $width  Default: false.
 715       *     @type int|bool    $height Default: false.
 716       *     @type string      $class  Default: 'avatar'.
 717       *     @type string|bool $id     Default: false.
 718       *     @type string      $alt    Default: 'Profile picture of [display name]'.
 719       * }
 720       * @return string User avatar string.
 721       */
 722  	function bp_get_message_thread_avatar( $args = '' ) {
 723          global $messages_template;
 724  
 725          $fullname = bp_core_get_user_displayname( $messages_template->thread->last_sender_id );
 726          $alt      = sprintf( __( 'Profile picture of %s', 'buddypress' ), $fullname );
 727  
 728          $r = bp_parse_args( $args, array(
 729              'type'   => 'thumb',
 730              'width'  => false,
 731              'height' => false,
 732              'class'  => 'avatar',
 733              'id'     => false,
 734              'alt'    => $alt
 735          ) );
 736  
 737          /**
 738           * Filters the avatar for the last sender in the current message thread.
 739           *
 740           * @since 1.0.0
 741           * @since 2.6.0 Added the `$r` parameter.
 742           *
 743           * @param string $value User avatar string.
 744           * @param array  $r     Array of parsed arguments.
 745           */
 746          return apply_filters( 'bp_get_message_thread_avatar', bp_core_fetch_avatar( array(
 747              'item_id' => $messages_template->thread->last_sender_id,
 748              'type'    => $r['type'],
 749              'alt'     => $r['alt'],
 750              'css_id'  => $r['id'],
 751              'class'   => $r['class'],
 752              'width'   => $r['width'],
 753              'height'  => $r['height'],
 754          ) ), $r );
 755      }
 756  
 757  /**
 758   * Output the unread messages count for the current inbox.
 759   *
 760   * @since 2.6.x Added $user_id argument.
 761   *
 762   * @param int $user_id The user ID.
 763   *
 764   * @return int $unread_count Total inbox unread count for user.
 765   */
 766  function bp_total_unread_messages_count( $user_id = 0 ) {
 767      echo bp_get_total_unread_messages_count( $user_id );
 768  }
 769      /**
 770       * Get the unread messages count for the current inbox.
 771       *
 772       * @since 2.6.x Added $user_id argument.
 773       *
 774       * @param int $user_id The user ID.
 775       *
 776       * @return int $unread_count Total inbox unread count for user.
 777       */
 778  	function bp_get_total_unread_messages_count( $user_id = 0 ) {
 779  
 780          /**
 781           * Filters the unread messages count for the current inbox.
 782           *
 783           * @since 1.0.0
 784           *
 785           * @param int $value Unread messages count for the current inbox.
 786           */
 787          return apply_filters( 'bp_get_total_unread_messages_count', BP_Messages_Thread::get_inbox_count( $user_id ) );
 788      }
 789  
 790  /**
 791   * Output the pagination HTML for the current thread loop.
 792   */
 793  function bp_messages_pagination() {
 794      echo bp_get_messages_pagination();
 795  }
 796      /**
 797       * Get the pagination HTML for the current thread loop.
 798       *
 799       * @return string
 800       */
 801  	function bp_get_messages_pagination() {
 802          global $messages_template;
 803  
 804          /**
 805           * Filters the pagination HTML for the current thread loop.
 806           *
 807           * @since 1.0.0
 808           *
 809           * @param int $pag_links Pagination HTML for the current thread loop.
 810           */
 811          return apply_filters( 'bp_get_messages_pagination', $messages_template->pag_links );
 812      }
 813  
 814  /**
 815   * Generate the "Viewing message x to y (of z messages)" string for a loop.
 816   */
 817  function bp_messages_pagination_count() {
 818      global $messages_template;
 819  
 820      $start_num = intval( ( $messages_template->pag_page - 1 ) * $messages_template->pag_num ) + 1;
 821      $from_num  = bp_core_number_format( $start_num );
 822      $to_num    = bp_core_number_format( ( $start_num + ( $messages_template->pag_num - 1 ) > $messages_template->total_thread_count ) ? $messages_template->total_thread_count : $start_num + ( $messages_template->pag_num - 1 ) );
 823      $total     = bp_core_number_format( $messages_template->total_thread_count );
 824  
 825      if ( 1 == $messages_template->total_thread_count ) {
 826          $message = __( 'Viewing 1 message', 'buddypress' );
 827      } else {
 828          $message = sprintf( _n( 'Viewing %1$s - %2$s of %3$s message', 'Viewing %1$s - %2$s of %3$s messages', $messages_template->total_thread_count, 'buddypress' ), $from_num, $to_num, $total );
 829      }
 830  
 831      echo esc_html( $message );
 832  }
 833  
 834  /**
 835   * Output the Private Message search form.
 836   *
 837   * @todo  Move markup to template part in: /members/single/messages/search.php
 838   * @since 1.6.0
 839   */
 840  function bp_message_search_form() {
 841  
 842      // Get the default search text.
 843      $default_search_value = bp_get_search_default_text( 'messages' );
 844  
 845      // Setup a few values based on what's being searched for.
 846      $search_submitted     = ! empty( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : $default_search_value;
 847      $search_placeholder   = ( $search_submitted === $default_search_value ) ? ' placeholder="' .  esc_attr( $search_submitted ) . '"' : '';
 848      $search_value         = ( $search_submitted !== $default_search_value ) ? ' value="'       .  esc_attr( $search_submitted ) . '"' : '';
 849  
 850      // Start the output buffer, so form can be filtered.
 851      ob_start(); ?>
 852  
 853      <form action="" method="get" id="search-message-form">
 854          <label for="messages_search" class="bp-screen-reader-text"><?php
 855              /* translators: accessibility text */
 856              esc_html_e( 'Search Messages', 'buddypress' );
 857          ?></label>
 858          <input type="text" name="s" id="messages_search"<?php echo $search_placeholder . $search_value; ?> />
 859          <input type="submit" class="button" id="messages_search_submit" name="messages_search_submit" value="<?php esc_html_e( 'Search', 'buddypress' ); ?>" />
 860      </form>
 861  
 862      <?php
 863  
 864      // Get the search form from the above output buffer.
 865      $search_form_html = ob_get_clean();
 866  
 867      /**
 868       * Filters the private message component search form.
 869       *
 870       * @since 2.2.0
 871       *
 872       * @param string $search_form_html HTML markup for the message search form.
 873       */
 874      echo apply_filters( 'bp_message_search_form', $search_form_html );
 875  }
 876  
 877  /**
 878   * Echo the form action for Messages HTML forms.
 879   */
 880  function bp_messages_form_action() {
 881      echo esc_url( bp_get_messages_form_action() );
 882  }
 883      /**
 884       * Return the form action for Messages HTML forms.
 885       *
 886       * @return string The form action.
 887       */
 888  	function bp_get_messages_form_action() {
 889  
 890          /**
 891           * Filters the form action for Messages HTML forms.
 892           *
 893           * @since 1.0.0
 894           *
 895           * @param string $value The form action.
 896           */
 897          return apply_filters( 'bp_get_messages_form_action', trailingslashit( bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() . '/' . bp_action_variable( 0 ) ) );
 898      }
 899  
 900  /**
 901   * Output the default username for the recipient box.
 902   */
 903  function bp_messages_username_value() {
 904      echo esc_attr( bp_get_messages_username_value() );
 905  }
 906      /**
 907       * Get the default username for the recipient box.
 908       *
 909       * @return string
 910       */
 911  	function bp_get_messages_username_value() {
 912          if ( isset( $_COOKIE['bp_messages_send_to'] ) ) {
 913  
 914              /**
 915               * Filters the default username for the recipient box.
 916               *
 917               * Value passed into filter is dependent on if the 'bp_messages_send_to'
 918               * cookie or 'r' $_GET parameter is set.
 919               *
 920               * @since 1.0.0
 921               *
 922               * @param string $value Default user name.
 923               */
 924              return apply_filters( 'bp_get_messages_username_value', $_COOKIE['bp_messages_send_to'] );
 925          } elseif ( isset( $_GET['r'] ) && !isset( $_COOKIE['bp_messages_send_to'] ) ) {
 926              /** This filter is documented in bp-messages-template.php */
 927              return apply_filters( 'bp_get_messages_username_value', $_GET['r'] );
 928          }
 929      }
 930  
 931  /**
 932   * Output the default value for the Subject field.
 933   */
 934  function bp_messages_subject_value() {
 935      echo esc_attr( bp_get_messages_subject_value() );
 936  }
 937      /**
 938       * Get the default value for the Subject field.
 939       *
 940       * Will get a value out of $_POST['subject'] if available (ie after a
 941       * failed submission).
 942       *
 943       * @return string
 944       */
 945  	function bp_get_messages_subject_value() {
 946  
 947          // Sanitized in bp-messages-filters.php.
 948          $subject = ! empty( $_POST['subject'] )
 949              ? $_POST['subject']
 950              : '';
 951  
 952          /**
 953           * Filters the default value for the subject field.
 954           *
 955           * @since 1.0.0
 956           *
 957           * @param string $subject The default value for the subject field.
 958           */
 959          return apply_filters( 'bp_get_messages_subject_value', $subject );
 960      }
 961  
 962  /**
 963   * Output the default value for the Compose content field.
 964   */
 965  function bp_messages_content_value() {
 966      echo esc_textarea( bp_get_messages_content_value() );
 967  }
 968      /**
 969       * Get the default value fo the Compose content field.
 970       *
 971       * Will get a value out of $_POST['content'] if available (ie after a
 972       * failed submission).
 973       *
 974       * @return string
 975       */
 976  	function bp_get_messages_content_value() {
 977  
 978          // Sanitized in bp-messages-filters.php.
 979          $content = ! empty( $_POST['content'] )
 980              ? $_POST['content']
 981              : '';
 982  
 983          /**
 984           * Filters the default value for the content field.
 985           *
 986           * @since 1.0.0
 987           *
 988           * @param string $content The default value for the content field.
 989           */
 990          return apply_filters( 'bp_get_messages_content_value', $content );
 991      }
 992  
 993  /**
 994   * Output the markup for the message type dropdown.
 995   */
 996  function bp_messages_options() {
 997  ?>
 998  
 999      <label for="message-type-select" class="bp-screen-reader-text"><?php
1000          /* translators: accessibility text */
1001          _e( 'Select:', 'buddypress' );
1002      ?></label>
1003      <select name="message-type-select" id="message-type-select">
1004          <option value=""><?php _e( 'Select', 'buddypress' ); ?></option>
1005          <option value="read"><?php _ex('Read', 'Message dropdown filter', 'buddypress') ?></option>
1006          <option value="unread"><?php _ex('Unread', 'Message dropdown filter', 'buddypress') ?></option>
1007          <option value="all"><?php _ex('All', 'Message dropdown filter', 'buddypress') ?></option>
1008      </select> &nbsp;
1009  
1010      <?php if ( ! bp_is_current_action( 'sentbox' ) && ! bp_is_current_action( 'notices' ) ) : ?>
1011  
1012          <a href="#" id="mark_as_read"><?php _ex('Mark as Read', 'Message management markup', 'buddypress') ?></a> &nbsp;
1013          <a href="#" id="mark_as_unread"><?php _ex('Mark as Unread', 'Message management markup', 'buddypress') ?></a> &nbsp;
1014  
1015          <?php wp_nonce_field( 'bp_messages_mark_messages_read', 'mark-messages-read-nonce', false ); ?>
1016          <?php wp_nonce_field( 'bp_messages_mark_messages_unread', 'mark-messages-unread-nonce', false ); ?>
1017  
1018      <?php endif; ?>
1019  
1020      <a href="#" id="delete_<?php echo bp_current_action(); ?>_messages"><?php _e( 'Delete Selected', 'buddypress' ); ?></a> &nbsp;
1021      <?php wp_nonce_field( 'bp_messages_delete_selected', 'delete-selected-nonce', false ); ?>
1022  <?php
1023  }
1024  
1025  /**
1026   * Output the dropdown for bulk management of messages.
1027   *
1028   * @since 2.2.0
1029   */
1030  function bp_messages_bulk_management_dropdown() {
1031      ?>
1032      <label class="bp-screen-reader-text" for="messages-select"><?php
1033          _e( 'Select Bulk Action', 'buddypress' );
1034      ?></label>
1035      <select name="messages_bulk_action" id="messages-select">
1036          <option value="" selected="selected"><?php _e( 'Bulk Actions', 'buddypress' ); ?></option>
1037          <option value="read"><?php _e( 'Mark read', 'buddypress' ); ?></option>
1038          <option value="unread"><?php _e( 'Mark unread', 'buddypress' ); ?></option>
1039          <option value="delete"><?php _e( 'Delete', 'buddypress' ); ?></option>
1040          <?php
1041              /**
1042               * Action to add additional options to the messages bulk management dropdown.
1043               *
1044               * @since 2.3.0
1045               */
1046              do_action( 'bp_messages_bulk_management_dropdown' );
1047          ?>
1048      </select>
1049      <input type="submit" id="messages-bulk-manage" class="button action" value="<?php esc_attr_e( 'Apply', 'buddypress' ); ?>">
1050      <?php
1051  }
1052  
1053  /**
1054   * Return whether or not the notice is currently active.
1055   *
1056   * @since 1.6.0
1057   *
1058   * @return bool
1059   */
1060  function bp_messages_is_active_notice() {
1061      global $messages_template;
1062  
1063      $retval = ! empty( $messages_template->thread->is_active )
1064          ? true
1065          : false;
1066  
1067      /**
1068       * Filters whether or not the notice is currently active.
1069       *
1070       * @since 2.1.0
1071       *
1072       * @param bool $retval Whether or not the notice is currently active.
1073       */
1074      return apply_filters( 'bp_messages_is_active_notice', $retval );
1075  }
1076  
1077  /**
1078   * Output a string for the active notice.
1079   *
1080   * Since 1.6 this function has been deprecated in favor of text in the theme.
1081   *
1082   * @since 1.0.0
1083   * @deprecated 1.6.0
1084   * @return bool
1085   */
1086  function bp_message_is_active_notice() {
1087      echo bp_get_message_is_active_notice();
1088  }
1089      /**
1090       * Returns a string for the active notice.
1091       *
1092       * Since 1.6 this function has been deprecated in favor of text in the
1093       * theme.
1094       *
1095       * @since 1.0.0
1096       * @deprecated 1.6.0
1097       * @return string
1098       */
1099  	function bp_get_message_is_active_notice() {
1100  
1101          $string = bp_messages_is_active_notice()
1102              ? __( 'Currently Active', 'buddypress' )
1103              : '';
1104  
1105          return apply_filters( 'bp_get_message_is_active_notice', $string );
1106      }
1107  
1108  /**
1109   * Output the ID of the current notice in the loop.
1110   */
1111  function bp_message_notice_id() {
1112      echo (int) bp_get_message_notice_id();
1113  }
1114      /**
1115       * Get the ID of the current notice in the loop.
1116       *
1117       * @return int
1118       */
1119  	function bp_get_message_notice_id() {
1120          global $messages_template;
1121  
1122          /**
1123           * Filters the ID of the current notice in the loop.
1124           *
1125           * @since 1.5.0
1126           *
1127           * @param int $id ID of the current notice in the loop.
1128           */
1129          return apply_filters( 'bp_get_message_notice_id', $messages_template->thread->id );
1130      }
1131  
1132  /**
1133   * Output the post date of the current notice in the loop.
1134   */
1135  function bp_message_notice_post_date() {
1136      echo bp_get_message_notice_post_date();
1137  }
1138      /**
1139       * Get the post date of the current notice in the loop.
1140       *
1141       * @return string
1142       */
1143  	function bp_get_message_notice_post_date() {
1144          global $messages_template;
1145  
1146          /**
1147           * Filters the post date of the current notice in the loop.
1148           *
1149           * @since 1.0.0
1150           *
1151           * @param string $value Formatted post date of the current notice in the loop.
1152           */
1153          return apply_filters( 'bp_get_message_notice_post_date', bp_format_time( strtotime( $messages_template->thread->date_sent ) ) );
1154      }
1155  
1156  /**
1157   * Output the subject of the current notice in the loop.
1158   *
1159   * @since 5.0.0 The $notice parameter has been added.
1160   *
1161   * @param BP_Messages_Notice $notice The notice object.
1162   */
1163  function bp_message_notice_subject( $notice = null ) {
1164      echo bp_get_message_notice_subject( $notice );
1165  }
1166      /**
1167       * Get the subject of the current notice in the loop.
1168       *
1169       * @since 5.0.0 The $notice parameter has been added.
1170       *
1171       * @param BP_Messages_Notice $notice The notice object.
1172       * @return string
1173       */
1174  	function bp_get_message_notice_subject( $notice = null ) {
1175          global $messages_template;
1176  
1177          if ( ! isset( $notice->subject ) ) {
1178              $notice =& $messages_template->thread;
1179          }
1180  
1181          /**
1182           * Filters the subject of the current notice in the loop.
1183           *
1184           * @since 1.0.0
1185           *
1186           * @param string $subject Subject of the current notice in the loop.
1187           */
1188          return apply_filters( 'bp_get_message_notice_subject', $notice->subject );
1189      }
1190  
1191  /**
1192   * Output the text of the current notice in the loop.
1193   *
1194   * @since 5.0.0 The $notice parameter has been added.
1195   *
1196   * @param BP_Messages_Notice $notice The notice object.
1197   */
1198  function bp_message_notice_text( $notice = null ) {
1199      echo bp_get_message_notice_text( $notice );
1200  }
1201      /**
1202       * Get the text of the current notice in the loop.
1203       *
1204       * @since 5.0.0 The $notice parameter has been added.
1205       *
1206       * @param BP_Messages_Notice $notice The notice object.
1207       * @return string
1208       */
1209  	function bp_get_message_notice_text( $notice = null ) {
1210          global $messages_template;
1211  
1212          if ( ! isset( $notice->subject ) ) {
1213              $notice =& $messages_template->thread;
1214          }
1215  
1216          /**
1217           * Filters the text of the current notice in the loop.
1218           *
1219           * @since 1.0.0
1220           *
1221           * @param string $message Text for the current notice in the loop.
1222           */
1223          return apply_filters( 'bp_get_message_notice_text', $notice->message );
1224      }
1225  
1226  /**
1227   * Output the URL for deleting the current notice.
1228   */
1229  function bp_message_notice_delete_link() {
1230      echo esc_url( bp_get_message_notice_delete_link() );
1231  }
1232      /**
1233       * Get the URL for deleting the current notice.
1234       *
1235       * @return string Delete URL.
1236       */
1237  	function bp_get_message_notice_delete_link() {
1238          global $messages_template;
1239  
1240          /**
1241           * Filters the URL for deleting the current notice.
1242           *
1243           * @since 1.0.0
1244           *
1245           * @param string $value URL for deleting the current notice.
1246           * @param string $value Text indicating action being executed.
1247           */
1248          return apply_filters( 'bp_get_message_notice_delete_link', wp_nonce_url( trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() . '/notices/delete/' . $messages_template->thread->id ), 'messages_delete_notice' ) );
1249      }
1250  
1251  /**
1252   * Output the URL for deactivating the current notice.
1253   */
1254  function bp_message_activate_deactivate_link() {
1255      echo esc_url( bp_get_message_activate_deactivate_link() );
1256  }
1257      /**
1258       * Get the URL for deactivating the current notice.
1259       *
1260       * @return string
1261       */
1262  	function bp_get_message_activate_deactivate_link() {
1263          global $messages_template;
1264  
1265          if ( 1 === (int) $messages_template->thread->is_active ) {
1266              $link = wp_nonce_url( trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() . '/notices/deactivate/' . $messages_template->thread->id ), 'messages_deactivate_notice' );
1267          } else {
1268              $link = wp_nonce_url( trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() . '/notices/activate/' . $messages_template->thread->id ), 'messages_activate_notice' );
1269          }
1270  
1271          /**
1272           * Filters the URL for deactivating the current notice.
1273           *
1274           * @since 1.0.0
1275           *
1276           * @param string $link URL for deactivating the current notice.
1277           */
1278          return apply_filters( 'bp_get_message_activate_deactivate_link', $link );
1279      }
1280  
1281  /**
1282   * Output the Deactivate/Activate text for the notice action link.
1283   */
1284  function bp_message_activate_deactivate_text() {
1285      echo esc_html( bp_get_message_activate_deactivate_text() );
1286  }
1287      /**
1288       * Generate the text ('Deactivate' or 'Activate') for the notice action link.
1289       *
1290       * @return string
1291       */
1292  	function bp_get_message_activate_deactivate_text() {
1293          global $messages_template;
1294  
1295          if ( 1 === (int) $messages_template->thread->is_active  ) {
1296              $text = __('Deactivate', 'buddypress');
1297          } else {
1298              $text = __('Activate', 'buddypress');
1299          }
1300  
1301          /**
1302           * Filters the "Deactivate" or "Activate" text for notice action links.
1303           *
1304           * @since 1.0.0
1305           *
1306           * @param string $text Text used for notice action links.
1307           */
1308          return apply_filters( 'bp_message_activate_deactivate_text', $text );
1309      }
1310  
1311  /**
1312   * Output the messages component slug.
1313   *
1314   * @since 1.5.0
1315   *
1316   */
1317  function bp_messages_slug() {
1318      echo bp_get_messages_slug();
1319  }
1320      /**
1321       * Return the messages component slug.
1322       *
1323       * @since 1.5.0
1324       *
1325       * @return string
1326       */
1327  	function bp_get_messages_slug() {
1328  
1329          /**
1330           * Filters the messages component slug.
1331           *
1332           * @since 1.5.0
1333           *
1334           * @param string $slug Messages component slug.
1335           */
1336          return apply_filters( 'bp_get_messages_slug', buddypress()->messages->slug );
1337      }
1338  
1339  /**
1340   * Generate markup for currently active notices.
1341   */
1342  function bp_message_get_notices() {
1343      $notice = BP_Messages_Notice::get_active();
1344  
1345      if ( empty( $notice ) ) {
1346          return false;
1347      }
1348  
1349      $closed_notices = bp_get_user_meta( bp_loggedin_user_id(), 'closed_notices', true );
1350  
1351      if ( empty( $closed_notices ) ) {
1352          $closed_notices = array();
1353      }
1354  
1355      if ( is_array( $closed_notices ) ) {
1356          if ( !in_array( $notice->id, $closed_notices ) && $notice->id ) {
1357              ?>
1358              <div id="message" class="info notice" rel="n-<?php echo esc_attr( $notice->id ); ?>">
1359                  <strong><?php bp_message_notice_subject( $notice ); ?></strong>
1360                  <button type="button" id="close-notice" class="bp-tooltip" data-bp-tooltip="<?php esc_attr_e( 'Dismiss this notice', 'buddypress' ) ?>"><span class="bp-screen-reader-text"><?php _e( 'Dismiss this notice', 'buddypress' ) ?></span> <span aria-hidden="true">&Chi;</span></button>
1361                  <?php bp_message_notice_text( $notice ); ?>
1362                  <?php wp_nonce_field( 'bp_messages_close_notice', 'close-notice-nonce' ); ?>
1363              </div>
1364              <?php
1365          }
1366      }
1367  }
1368  
1369  /**
1370   * Output the URL for the Private Message link in member profile headers.
1371   */
1372  function bp_send_private_message_link() {
1373      echo esc_url( bp_get_send_private_message_link() );
1374  }
1375      /**
1376       * Generate the URL for the Private Message link in member profile headers.
1377       *
1378       * @return bool|string False on failure, otherwise the URL.
1379       */
1380  	function bp_get_send_private_message_link() {
1381  
1382          if ( bp_is_my_profile() || ! is_user_logged_in() ) {
1383              return false;
1384          }
1385  
1386          /**
1387           * Filters the URL for the Private Message link in member profile headers.
1388           *
1389           * @since 1.2.10
1390           *
1391           * @param string $value URL for the Private Message link in member profile headers.
1392           */
1393          return apply_filters( 'bp_get_send_private_message_link', wp_nonce_url( bp_loggedin_user_domain() . bp_get_messages_slug() . '/compose/?r=' . bp_core_get_username( bp_displayed_user_id() ) ) );
1394      }
1395  
1396  /**
1397   * Output the 'Private Message' button for member profile headers.
1398   *
1399   * Explicitly named function to avoid confusion with public messages.
1400   *
1401   * @since 1.2.6
1402   *
1403   */
1404  function bp_send_private_message_button() {
1405      echo bp_get_send_message_button();
1406  }
1407  
1408  /**
1409   * Output the 'Private Message' button for member profile headers.
1410   *
1411   * @since 1.2.0
1412   * @since 3.0.0 Added `$args` parameter.
1413   *
1414   * @param array|string $args See {@link bp_get_send_message_button()}.
1415   */
1416  function bp_send_message_button( $args = '' ) {
1417      echo bp_get_send_message_button( $args );
1418  }
1419      /**
1420       * Generate the 'Private Message' button for member profile headers.
1421       *
1422       * @since 1.2.0
1423       * @since 3.0.0 Added `$args` parameter.
1424       *
1425       * @param array|string $args {
1426       *     All arguments are optional. See {@link BP_Button} for complete
1427       *     descriptions.
1428       *     @type string $id                Default: 'private_message'.
1429       *     @type string $component         Default: 'messages'.
1430       *     @type bool   $must_be_logged_in Default: true.
1431       *     @type bool   $block_self        Default: true.
1432       *     @type string $wrapper_id        Default: 'send-private-message'.
1433       *     @type string $link_href         Default: the private message link for
1434       *                                     the current member in the loop.
1435       *     @type string $link_text         Default: 'Private Message'.
1436       *     @type string $link_class        Default: 'send-message'.
1437       * }
1438       * @return string
1439       */
1440  	function bp_get_send_message_button( $args = '' ) {
1441  
1442          $r = bp_parse_args( $args, array(
1443              'id'                => 'private_message',
1444              'component'         => 'messages',
1445              'must_be_logged_in' => true,
1446              'block_self'        => true,
1447              'wrapper_id'        => 'send-private-message',
1448              'link_href'         => bp_get_send_private_message_link(),
1449              'link_text'         => __( 'Private Message', 'buddypress' ),
1450              'link_class'        => 'send-message',
1451          ) );
1452  
1453  
1454          // Note: 'bp_get_send_message_button' is a legacy filter. Use
1455          // 'bp_get_send_message_button_args' instead. See #4536.
1456          return apply_filters( 'bp_get_send_message_button',
1457  
1458              /**
1459               * Filters the "Private Message" button for member profile headers.
1460               *
1461               * @since 1.8.0
1462               *
1463               * @param array $value See {@link BP_Button}.
1464               */
1465              bp_get_button( apply_filters( 'bp_get_send_message_button_args', $r ) )
1466          );
1467      }
1468  
1469  /**
1470   * Output the URL of the Messages AJAX loader gif.
1471   */
1472  function bp_message_loading_image_src() {
1473      echo esc_url( bp_get_message_loading_image_src() );
1474  }
1475      /**
1476       * Get the URL of the Messages AJAX loader gif.
1477       *
1478       * @return string
1479       */
1480  	function bp_get_message_loading_image_src() {
1481  
1482          /**
1483           * Filters the URL of the Messages AJAX loader gif.
1484           *
1485           * @since 1.0.0
1486           *
1487           * @param string $value URL of the Messages AJAX loader gif.
1488           */
1489          return apply_filters( 'bp_get_message_loading_image_src', buddypress()->messages->image_base . '/ajax-loader.gif' );
1490      }
1491  
1492  /**
1493   * Output the markup for the message recipient tabs.
1494   */
1495  function bp_message_get_recipient_tabs() {
1496      $recipients = explode( ' ', bp_get_message_get_recipient_usernames() );
1497  
1498      foreach ( $recipients as $recipient ) {
1499  
1500          $user_id = bp_is_username_compatibility_mode()
1501              ? bp_core_get_userid( $recipient )
1502              : bp_core_get_userid_from_nicename( $recipient );
1503  
1504          if ( ! empty( $user_id ) ) : ?>
1505  
1506              <li id="un-<?php echo esc_attr( $recipient ); ?>" class="friend-tab">
1507                  <span><?php
1508                      echo bp_core_fetch_avatar( array( 'item_id' => $user_id, 'type' => 'thumb', 'width' => 15, 'height' => 15 ) );
1509                      echo bp_core_get_userlink( $user_id );
1510                  ?></span>
1511              </li>
1512  
1513          <?php endif;
1514      }
1515  }
1516  
1517  /**
1518   * Output recipient usernames for prefilling the 'To' field on the Compose screen.
1519   */
1520  function bp_message_get_recipient_usernames() {
1521      echo esc_attr( bp_get_message_get_recipient_usernames() );
1522  }
1523      /**
1524       * Get the recipient usernames for prefilling the 'To' field on the Compose screen.
1525       *
1526       * @return string
1527       */
1528  	function bp_get_message_get_recipient_usernames() {
1529  
1530          // Sanitized in bp-messages-filters.php.
1531          $recipients = isset( $_GET['r'] )
1532              ? $_GET['r']
1533              : '';
1534  
1535          /**
1536           * Filters the recipients usernames for prefilling the 'To' field on the Compose screen.
1537           *
1538           * @since 1.0.0
1539           *
1540           * @param string $recipients Recipients usernames for 'To' field prefilling.
1541           */
1542          return apply_filters( 'bp_get_message_get_recipient_usernames', $recipients );
1543      }
1544  
1545  /**
1546   * Initialize the messages template loop for a specific thread.
1547   *
1548   * @param array|string $args {
1549   *     Array of arguments. All are optional.
1550   *     @type int    $thread_id         ID of the thread whose messages you are displaying.
1551   *                                     Default: if viewing a thread, the thread ID will be parsed from
1552   *                                     the URL (bp_action_variable( 0 )).
1553   *     @type string $order             'ASC' or 'DESC'. Default: 'ASC'.
1554   *     @type bool   $update_meta_cache Whether to pre-fetch metadata for
1555   *                                     queried message items. Default: true.
1556   * }
1557   * @return bool True if there are messages to display, otherwise false.
1558   */
1559  function bp_thread_has_messages( $args = '' ) {
1560      global $thread_template;
1561  
1562      $r = bp_parse_args( $args, array(
1563          'thread_id'         => false,
1564          'order'             => 'ASC',
1565          'update_meta_cache' => true,
1566      ), 'thread_has_messages' );
1567  
1568      if ( empty( $r['thread_id'] ) && bp_is_messages_component() && bp_is_current_action( 'view' ) ) {
1569          $r['thread_id'] = (int) bp_action_variable( 0 );
1570      }
1571  
1572      // Set up extra args.
1573      $extra_args = $r;
1574      unset( $extra_args['thread_id'], $extra_args['order'] );
1575  
1576      $thread_template = new BP_Messages_Thread_Template( $r['thread_id'], $r['order'], $extra_args );
1577  
1578      return $thread_template->has_messages();
1579  }
1580  
1581  /**
1582   * Output the 'ASC' or 'DESC' messages order string for this loop.
1583   */
1584  function bp_thread_messages_order() {
1585      echo esc_attr( bp_get_thread_messages_order() );
1586  }
1587      /**
1588       * Get the 'ASC' or 'DESC' messages order string for this loop.
1589       *
1590       * @return string
1591       */
1592  	function bp_get_thread_messages_order() {
1593          global $thread_template;
1594          return $thread_template->thread->messages_order;
1595      }
1596  
1597  /**
1598   * Check whether there are more messages to iterate over.
1599   *
1600   * @return bool
1601   */
1602  function bp_thread_messages() {
1603      global $thread_template;
1604  
1605      return $thread_template->messages();
1606  }
1607  
1608  /**
1609   * Set up the current thread inside the loop.
1610   *
1611   * @return object
1612   */
1613  function bp_thread_the_message() {
1614      global $thread_template;
1615  
1616      return $thread_template->the_message();
1617  }
1618  
1619  /**
1620   * Output the ID of the thread that the current loop belongs to.
1621   */
1622  function bp_the_thread_id() {
1623      echo (int) bp_get_the_thread_id();
1624  }
1625      /**
1626       * Get the ID of the thread that the current loop belongs to.
1627       *
1628       * @return int
1629       */
1630  	function bp_get_the_thread_id() {
1631          global $thread_template;
1632  
1633          /**
1634           * Filters the ID of the thread that the current loop belongs to.
1635           *
1636           * @since 1.1.0
1637           *
1638           * @param int $thread_id ID of the thread.
1639           */
1640          return apply_filters( 'bp_get_the_thread_id', $thread_template->thread->thread_id );
1641      }
1642  
1643  /**
1644   * Output the subject of the thread currently being iterated over.
1645   */
1646  function bp_the_thread_subject() {
1647      echo bp_get_the_thread_subject();
1648  }
1649      /**
1650       * Get the subject of the thread currently being iterated over.
1651       *
1652       * @return string
1653       */
1654  	function bp_get_the_thread_subject() {
1655          global $thread_template;
1656  
1657          /**
1658           * Filters the subject of the thread currently being iterated over.
1659           *
1660           * @since 1.1.0
1661           *
1662           * @return string $last_message_subject Subject of the thread currently being iterated over.
1663           */
1664          return apply_filters( 'bp_get_the_thread_subject', $thread_template->thread->last_message_subject );
1665      }
1666  
1667  /**
1668   * Get a list of thread recipients or a "x recipients" string.
1669   *
1670   * In BuddyPress 2.2.0, this parts of this functionality were moved into the
1671   * members/single/messages/single.php template. This function is no longer used
1672   * by BuddyPress.
1673   *
1674   * @return string
1675   */
1676  function bp_get_the_thread_recipients() {
1677      if ( 5 <= bp_get_thread_recipients_count() ) {
1678          $recipients = sprintf( __( '%s recipients', 'buddypress' ), number_format_i18n( bp_get_thread_recipients_count() ) );
1679      } else {
1680          $recipients = bp_get_thread_recipients_list();
1681      }
1682  
1683      return apply_filters( 'bp_get_the_thread_recipients', $recipients );
1684  }
1685  
1686  /**
1687   * Get the number of recipients in the current thread.
1688   *
1689   * @since 2.2.0
1690   *
1691   * @return int
1692   */
1693  function bp_get_thread_recipients_count() {
1694      global $thread_template;
1695      /**
1696       * Filters the total number of recipients in a thread.
1697       *
1698       * @since 2.8.0
1699       *
1700       * @param int $count Total recipients number.
1701       */
1702      return (int) apply_filters( 'bp_get_thread_recipients_count', count( $thread_template->thread->recipients ) );
1703  }
1704  
1705  /**
1706   * Get the max number of recipients to list in the 'Conversation between...' gloss.
1707   *
1708   * @since 2.3.0
1709   *
1710   * @return int
1711   */
1712  function bp_get_max_thread_recipients_to_list() {
1713      /**
1714       * Filters the max number of recipients to list in the 'Conversation between...' gloss.
1715       *
1716       * @since 2.3.0
1717       *
1718       * @param int $count Recipient count. Default: 5.
1719       */
1720      return (int) apply_filters( 'bp_get_max_thread_recipients_to_list', 5 );
1721  }
1722  
1723  /**
1724   * Output HTML links to recipients in the current thread.
1725   *
1726   * @since 2.2.0
1727   */
1728  function bp_the_thread_recipients_list() {
1729      echo bp_get_thread_recipients_list();
1730  }
1731      /**
1732       * Generate HTML links to the profiles of recipients in the current thread.
1733       *
1734       * @since 2.2.0
1735       *
1736       * @return string
1737       */
1738  	function bp_get_thread_recipients_list() {
1739          global $thread_template;
1740  
1741          $recipient_links = array();
1742  
1743          foreach( (array) $thread_template->thread->recipients as $recipient ) {
1744              if ( (int) $recipient->user_id !== bp_loggedin_user_id() ) {
1745                  $recipient_link = bp_core_get_userlink( $recipient->user_id );
1746  
1747                  if ( empty( $recipient_link ) ) {
1748                      $recipient_link = __( 'Deleted User', 'buddypress' );
1749                  }
1750  
1751                  $recipient_links[] = $recipient_link;
1752              } else {
1753                  $recipient_links[] = __( 'you', 'buddypress' );
1754              }
1755          }
1756  
1757          // Concatenate to natural language string.
1758          $recipient_links = wp_sprintf_l( '%l', $recipient_links );
1759  
1760          /**
1761           * Filters the HTML links to the profiles of recipients in the current thread.
1762           *
1763           * @since 2.2.0
1764           *
1765           * @param string $value Comma-separated list of recipient HTML links for current thread.
1766           */
1767          return apply_filters( 'bp_get_the_thread_recipients_list', $recipient_links );
1768      }
1769  
1770  /**
1771   * Echo the ID of the current message in the thread.
1772   *
1773   * @since 1.9.0
1774   */
1775  function bp_the_thread_message_id() {
1776      echo (int) bp_get_the_thread_message_id();
1777  }
1778      /**
1779       * Get the ID of the current message in the thread.
1780       *
1781       * @since 1.9.0
1782       *
1783       * @return int
1784       */
1785  	function bp_get_the_thread_message_id() {
1786          global $thread_template;
1787  
1788          $thread_message_id = isset( $thread_template->message->id )
1789              ? (int) $thread_template->message->id
1790              : null;
1791  
1792          /**
1793           * Filters the ID of the current message in the thread.
1794           *
1795           * @since 1.9.0
1796           *
1797           * @param int $thread_message_id ID of the current message in the thread.
1798           */
1799          return apply_filters( 'bp_get_the_thread_message_id', $thread_message_id );
1800      }
1801  
1802  /**
1803   * Output the CSS classes for messages within a single thread.
1804   *
1805   * @since 2.1.0
1806   */
1807  function bp_the_thread_message_css_class() {
1808      echo esc_attr( bp_get_the_thread_message_css_class() );
1809  }
1810      /**
1811       * Generate the CSS classes for messages within a single thread.
1812       *
1813       * @since 2.1.0
1814       *
1815       * @return string
1816       */
1817  	function bp_get_the_thread_message_css_class() {
1818          global $thread_template;
1819  
1820          $classes = array();
1821  
1822          // Zebra-striping.
1823          $classes[] = bp_get_the_thread_message_alt_class();
1824  
1825          // ID of the sender.
1826          $classes[] = 'sent-by-' . intval( $thread_template->message->sender_id );
1827  
1828          // Whether the sender is the same as the logged-in user.
1829          if ( bp_loggedin_user_id() == $thread_template->message->sender_id ) {
1830              $classes[] = 'sent-by-me';
1831          }
1832  
1833          /**
1834           * Filters the CSS classes for messages within a single thread.
1835           *
1836           * @since 2.1.0
1837           *
1838           * @param array $classes Array of classes to add to the HTML class attribute.
1839           */
1840          $classes = apply_filters( 'bp_get_the_thread_message_css_class', $classes );
1841  
1842          return implode( ' ', $classes );
1843      }
1844  
1845  /**
1846   * Output the CSS class used for message zebra striping.
1847   */
1848  function bp_the_thread_message_alt_class() {
1849      echo esc_attr( bp_get_the_thread_message_alt_class() );
1850  }
1851      /**
1852       * Get the CSS class used for message zebra striping.
1853       *
1854       * @return string
1855       */
1856  	function bp_get_the_thread_message_alt_class() {
1857          global $thread_template;
1858  
1859          if ( $thread_template->current_message % 2 == 1 ) {
1860              $class = 'even alt';
1861          } else {
1862              $class = 'odd';
1863          }
1864  
1865          /**
1866           * Filters the CSS class used for message zebra striping.
1867           *
1868           * @since 1.1.0
1869           *
1870           * @param string $class Class determined to be next for zebra striping effect.
1871           */
1872          return apply_filters( 'bp_get_the_thread_message_alt_class', $class );
1873      }
1874  
1875  /**
1876   * Output the ID for message sender within a single thread.
1877   *
1878   * @since 2.1.0
1879   */
1880  function bp_the_thread_message_sender_id() {
1881      echo (int) bp_get_the_thread_message_sender_id();
1882  }
1883      /**
1884       * Return the ID for message sender within a single thread.
1885       *
1886       * @since 2.1.0
1887       *
1888       * @return int
1889       */
1890  	function bp_get_the_thread_message_sender_id() {
1891          global $thread_template;
1892  
1893          $user_id = ! empty( $thread_template->message->sender_id )
1894              ? $thread_template->message->sender_id
1895              : 0;
1896  
1897          /**
1898           * Filters the ID for message sender within a single thread.
1899           *
1900           * @since 2.1.0
1901           *
1902           * @param int $user_id ID of the message sender.
1903           */
1904          return (int) apply_filters( 'bp_get_the_thread_message_sender_id', (int) $user_id );
1905      }
1906  
1907  /**
1908   * Output the avatar for the current message sender.
1909   *
1910   * @param array|string $args See {@link bp_get_the_thread_message_sender_avatar_thumb()}
1911   *                           for a description.
1912   */
1913  function bp_the_thread_message_sender_avatar( $args = '' ) {
1914      echo bp_get_the_thread_message_sender_avatar_thumb( $args );
1915  }
1916      /**
1917       * Get the avatar for the current message sender.
1918       *
1919       * @param array|string $args {
1920       *     Array of arguments. See {@link bp_core_fetch_avatar()} for more
1921       *     complete details. All arguments are optional.
1922       *     @type string $type   Avatar type. Default: 'thumb'.
1923       *     @type int    $width  Avatar width. Default: default for your $type.
1924       *     @type int    $height Avatar height. Default: default for your $type.
1925       * }
1926       * @return string <img> tag containing the avatar.
1927       */
1928  	function bp_get_the_thread_message_sender_avatar_thumb( $args = '' ) {
1929          global $thread_template;
1930  
1931          $r = bp_parse_args( $args, array(
1932              'type'   => 'thumb',
1933              'width'  => false,
1934              'height' => false,
1935          ) );
1936  
1937          /**
1938           * Filters the avatar for the current message sender.
1939           *
1940           * @since 1.1.0
1941           * @since 2.6.0 Added the `$r` parameter.
1942           *
1943           * @param string $value <img> tag containing the avatar value.
1944           * @param array  $r     Array of parsed arguments.
1945           */
1946          return apply_filters( 'bp_get_the_thread_message_sender_avatar_thumb', bp_core_fetch_avatar( array(
1947              'item_id' => $thread_template->message->sender_id,
1948              'type'    => $r['type'],
1949              'width'   => $r['width'],
1950              'height'  => $r['height'],
1951              'alt'     => bp_core_get_user_displayname( $thread_template->message->sender_id )
1952          ) ), $r );
1953      }
1954  
1955  /**
1956   * Output a link to the sender of the current message.
1957   *
1958   * @since 1.1.0
1959   */
1960  function bp_the_thread_message_sender_link() {
1961      echo esc_url( bp_get_the_thread_message_sender_link() );
1962  }
1963      /**
1964       * Get a link to the sender of the current message.
1965       *
1966       * @since 1.1.0
1967       *
1968       * @return string
1969       */
1970  	function bp_get_the_thread_message_sender_link() {
1971          global $thread_template;
1972  
1973          /**
1974           * Filters the link to the sender of the current message.
1975           *
1976           * @since 1.1.0
1977           *
1978           * @param string $value Link to the sender of the current message.
1979           */
1980          return apply_filters( 'bp_get_the_thread_message_sender_link', bp_core_get_userlink( $thread_template->message->sender_id, false, true ) );
1981      }
1982  
1983  /**
1984   * Output the display name of the sender of the current message.
1985   *
1986   * @since 1.1.0
1987   */
1988  function bp_the_thread_message_sender_name() {
1989      echo esc_html( bp_get_the_thread_message_sender_name() );
1990  }
1991      /**
1992       * Get the display name of the sender of the current message.
1993       *
1994       * @since 1.1.0
1995       *
1996       * @return string
1997       */
1998  	function bp_get_the_thread_message_sender_name() {
1999          global $thread_template;
2000  
2001          $display_name = bp_core_get_user_displayname( $thread_template->message->sender_id );
2002  
2003          if ( empty( $display_name ) ) {
2004              $display_name = __( 'Deleted User', 'buddypress' );
2005          }
2006  
2007          /**
2008           * Filters the display name of the sender of the current message.
2009           *
2010           * @since 1.1.0
2011           *
2012           * @param string $display_name Display name of the sender of the current message.
2013           */
2014          return apply_filters( 'bp_get_the_thread_message_sender_name', $display_name );
2015      }
2016  
2017  /**
2018   * Output the URL for deleting the current thread.
2019   *
2020   * @since 1.5.0
2021   */
2022  function bp_the_thread_delete_link() {
2023      echo esc_url( bp_get_the_thread_delete_link() );
2024  }
2025      /**
2026       * Get the URL for deleting the current thread.
2027       *
2028       * @since 1.5.0
2029       *
2030       * @return string URL
2031       */
2032  	function bp_get_the_thread_delete_link() {
2033  
2034          /**
2035           * Filters the URL for deleting the current thread.
2036           *
2037           * @since 1.0.0
2038           *
2039           * @param string $value URL for deleting the current thread.
2040           * @param string $value Text indicating action being executed.
2041           */
2042          return apply_filters( 'bp_get_message_thread_delete_link', wp_nonce_url( bp_displayed_user_domain() . bp_get_messages_slug() . '/inbox/delete/' . bp_get_the_thread_id(), 'messages_delete_thread' ) );
2043      }
2044  
2045  /**
2046   * Output the 'Sent x hours ago' string for the current message.
2047   *
2048   * @since 1.1.0
2049   */
2050  function bp_the_thread_message_time_since() {
2051      echo bp_get_the_thread_message_time_since();
2052  }
2053      /**
2054       * Generate the 'Sent x hours ago' string for the current message.
2055       *
2056       * @since 1.1.0
2057       *
2058       * @return string
2059       */
2060  	function bp_get_the_thread_message_time_since() {
2061  
2062          /**
2063           * Filters the 'Sent x hours ago' string for the current message.
2064           *
2065           * @since 1.1.0
2066           *
2067           * @param string $value Default text of 'Sent x hours ago'.
2068           */
2069          return apply_filters( 'bp_get_the_thread_message_time_since', sprintf( __( 'Sent %s', 'buddypress' ), bp_core_time_since( bp_get_the_thread_message_date_sent() ) ) );
2070      }
2071  
2072  /**
2073   * Output the timestamp for the current message.
2074   *
2075   * @since 2.1.0
2076   */
2077  function bp_the_thread_message_date_sent() {
2078      echo bp_get_the_thread_message_date_sent();
2079  }
2080      /**
2081       * Generate the 'Sent x hours ago' string for the current message.
2082       *
2083       * @since 2.1.0
2084       *
2085       *
2086       * @return int
2087       */
2088  	function bp_get_the_thread_message_date_sent() {
2089          global $thread_template;
2090  
2091          /**
2092           * Filters the date sent value for the current message as a timestamp.
2093           *
2094           * @since 2.1.0
2095           *
2096           * @param string $value Timestamp of the date sent value for the current message.
2097           */
2098          return apply_filters( 'bp_get_the_thread_message_date_sent', strtotime( $thread_template->message->date_sent ) );
2099      }
2100  
2101  /**
2102   * Output the content of the current message in the loop.
2103   *
2104   * @since 1.1.0
2105   */
2106  function bp_the_thread_message_content() {
2107      echo bp_get_the_thread_message_content();
2108  }
2109      /**
2110       * Get the content of the current message in the loop.
2111       *
2112       * @since 1.1.0
2113       *
2114       * @return string
2115       */
2116  	function bp_get_the_thread_message_content() {
2117          global $thread_template;
2118  
2119          $content = $thread_template->message->message;
2120  
2121          // If user was deleted, mark content as deleted.
2122          if ( false === bp_core_get_core_userdata( bp_get_the_thread_message_sender_id() ) ) {
2123              $content = esc_html__( '[deleted]', 'buddypress' );
2124          }
2125  
2126          /**
2127           * Filters the content of the current message in the loop.
2128           *
2129           * @since 1.1.0
2130           *
2131           * @param string $message The content of the current message in the loop.
2132           */
2133          return apply_filters( 'bp_get_the_thread_message_content', $content );
2134      }
2135  
2136  /** Embeds *******************************************************************/
2137  
2138  /**
2139   * Enable oEmbed support for Messages.
2140   *
2141   * @since 1.5.0
2142   *
2143   * @see BP_Embed
2144   */
2145  function bp_messages_embed() {
2146      add_filter( 'embed_post_id',         'bp_get_the_thread_message_id' );
2147      add_filter( 'bp_embed_get_cache',    'bp_embed_message_cache',      10, 3 );
2148      add_action( 'bp_embed_update_cache', 'bp_embed_message_save_cache', 10, 3 );
2149  }
2150  add_action( 'thread_loop_start', 'bp_messages_embed' );
2151  
2152  /**
2153   * Fetch a private message item's cached embeds.
2154   *
2155   * Used during {@link BP_Embed::parse_oembed()} via {@link bp_messages_embed()}.
2156   *
2157   * @since 2.2.0
2158   *
2159   * @param string $cache    An empty string passed by BP_Embed::parse_oembed() for
2160   *                         functions like this one to filter.
2161   * @param int    $id       The ID of the message item.
2162   * @param string $cachekey The cache key generated in BP_Embed::parse_oembed().
2163   * @return mixed The cached embeds for this message item.
2164   */
2165  function bp_embed_message_cache( $cache, $id, $cachekey ) {
2166      return bp_messages_get_meta( $id, $cachekey );
2167  }
2168  
2169  /**
2170   * Set a private message item's embed cache.
2171   *
2172   * Used during {@link BP_Embed::parse_oembed()} via {@link bp_messages_embed()}.
2173   *
2174   * @since 2.2.0
2175   *
2176   * @param string $cache    An empty string passed by BP_Embed::parse_oembed() for
2177   *                         functions like this one to filter.
2178   * @param string $cachekey The cache key generated in BP_Embed::parse_oembed().
2179   * @param int    $id       The ID of the message item.
2180   */
2181  function bp_embed_message_save_cache( $cache, $cachekey, $id ) {
2182      bp_messages_update_meta( $id, $cachekey, $cache );
2183  }


Generated: Thu Sep 19 01:01:39 2019 Cross-referenced by PHPXref 0.7.1