bp_get_the_message_star_action_link (数组args美元数组()

返回链接或原始URL,用于标记或取消标记消息。

描述

参数

args美元

数组(可选)数组的参数。

  • “user_id”
    (int)用户ID。默认为登录的用户ID。
  • “thread_id”
    (int)消息线程ID。默认值:0。如果不为零,则优先于$message_id。
  • “message_id”
    (int)单独的消息ID。如果在单个线程页面上,则默认为消息循环中的当前消息ID。
  • “url_only”
    (保龄球)是否只返回URL。如果为false,返回带有标记的链接。默认值:false。
  • “text_unstar”
    (字符串)“unstar”动作的链接文本。仅当$url_only为false时适用。
  • “text_star”
    (字符串)'star'动作的链接文本。仅当$url_only为false时适用。
  • “title_unstar”
    (字符串)“unstar”动作的链接标题。仅当$url_only为false时适用。
  • “title_star”
    (字符串)'star'动作的链接标题。仅当$url_only为false时适用。
  • “title_unstar_thread”
    (字符串)在线程循环中显示的“unstar”动作的链接标题。仅当设置了$message_id且$url_only为false时适用。
  • “title_star_thread”
    (字符串)在线程循环中显示的'star'动作的链接标题。仅当设置了$message_id且$url_only为false时适用。

默认值:数组()

返回

(字符串)

文件:bp-messages / bp-messages-star.php

函数bp_get_the_message_star_action_link($ args = array()){//默认用户标识。$ user_id = bp_displayed_user_id()?bp_displayed_user_id():bp_loggedin_user_id();$ r = bp_parse_args($ args,数组('user_id'=>(int)$ user_id,'thread_id'=> 0,'message_id'=>(int)bp_get_the_thread_message_id(),'url_only'=> false,'text_unstar'=> __('budteboss'),'text_star'=> __('star','buddyboss'),'title_unstar'=> __('starred','buddyboss'),'title_star'=>__('没有主演','buddyboss'),'title_unstar_thread'=> __('删除这个线程中的所有出售的消息','buddyboss'),'title_star_thread'=> __('star the thread中的第一个消息','buddyboss'),),'messages_star_action_link');//检查用户ID并确定基本用户URL。交换机($ r ['user_id']){//当前用户。case bp_loggedin_user_id():$ user_domain = bp_loggedin_user_domain();休息; // Displayed user. case bp_displayed_user_id() : $user_domain = bp_displayed_user_domain(); break; // Empty or other. default : $user_domain = bp_core_get_user_domain( $r['user_id'] ); break; } // Bail if no user domain was calculated. if ( empty( $user_domain ) ) { return ''; } // Define local variables. $retval = $bulk_attr = ''; // Thread ID. if ( (int) $r['thread_id'] > 0 ) { // See if we're in the loop. if ( bp_get_message_thread_id() == $r['thread_id'] ) { // Grab all message ids. $mids = wp_list_pluck( $GLOBALS['messages_template']->thread->messages, 'id' ); // Make sure order is ASC. // Order is DESC when used in the thread loop by default. $mids = array_reverse( $mids ); // Pull up the thread. } else { $thread = new BP_Messages_Thread( $r['thread_id'] ); $mids = wp_list_pluck( $thread->messages, 'id' ); } $is_starred = false; $message_id = 0; foreach ( $mids as $mid ) { // Try to find the first msg that is starred in a thread. if ( true === bp_messages_is_message_starred( $mid ) ) { $is_starred = true; $message_id = $mid; break; } } // No star, so default to first message in thread. if ( empty( $message_id ) ) { $message_id = $mids[0]; } $message_id = (int) $message_id; // Nonce. $nonce = wp_create_nonce( "bp-messages-star-{$message_id}" ); if ( true === $is_starred ) { $action = 'unstar'; $bulk_attr = ' data-star-bulk="1"'; $retval = $user_domain . bp_get_messages_slug() . '/unstar/' . $message_id . '/' . $nonce . '/all/'; } else { $action = 'star'; $retval = $user_domain . bp_get_messages_slug() . '/star/' . $message_id . '/' . $nonce . '/'; } $title = $r["title_{$action}_thread"]; // Message ID. } else { $message_id = (int) $r['message_id']; $is_starred = bp_messages_is_message_starred( $message_id ); $nonce = wp_create_nonce( "bp-messages-star-{$message_id}" ); if ( true === $is_starred ) { $action = 'unstar'; $retval = $user_domain . bp_get_messages_slug() . '/unstar/' . $message_id . '/' . $nonce . '/'; } else { $action = 'star'; $retval = $user_domain . bp_get_messages_slug() . '/star/' . $message_id . '/' . $nonce . '/'; } $title = $r["title_{$action}"]; } /** * Filters the star action URL for starring / unstarring a message. * * @since BuddyPress 2.3.0 * * @param string $retval URL for starring / unstarring a message. * @param array $r Parsed link arguments. See $args in bp_get_the_message_star_action_link(). */ $retval = esc_url( apply_filters( 'bp_get_the_message_star_action_urlonly', $retval, $r ) ); if ( true === (bool) $r['url_only'] ) { return $retval; } /** * Filters the star action link, including markup. * * @since BuddyPress 2.3.0 * * @param string $retval Link for starring / unstarring a message, including markup. * @param array $r Parsed link arguments. See $args in bp_get_the_message_star_action_link(). */ return apply_filters( 'bp_get_the_message_star_action_link', ' ' . $r['text_' . $action] . '', $r ); }

更新日志

更新日志
版本 描述
BuddyPress tripwire 介绍了。

问题吗?

我们总是很乐意帮助您解决代码或其他问题!搜索我们的开发人员文档联络支持,或与我们联系销售团队