Changeset 9926
- Timestamp:
- 06/11/2015 02:19:29 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.3/src/bp-messages/bp-messages-star.php
r9923 r9926 89 89 */ 90 90 function bp_get_the_message_star_action_link( $args = array() ) { 91 92 // Default user ID 93 $user_id = bp_displayed_user_id() 94 ? bp_displayed_user_id() 95 : bp_loggedin_user_id(); 96 91 97 $r = bp_parse_args( $args, array( 92 'user_id' => bp_loggedin_user_id(),93 'thread_id' => 0,94 'message_id' => (int) bp_get_the_thread_message_id(),95 'url_only' => false,96 'text_unstar' => __( 'Unstar','buddypress' ),97 'text_star' => __( 'Star','buddypress' ),98 'title_unstar' => __( 'Starred','buddypress' ),99 'title_star' => __( 'Not starred', 'buddypress' ),98 'user_id' => (int) $user_id, 99 'thread_id' => 0, 100 'message_id' => (int) bp_get_the_thread_message_id(), 101 'url_only' => false, 102 'text_unstar' => __( 'Unstar', 'buddypress' ), 103 'text_star' => __( 'Star', 'buddypress' ), 104 'title_unstar' => __( 'Starred', 'buddypress' ), 105 'title_star' => __( 'Not starred', 'buddypress' ), 100 106 'title_unstar_thread' => __( 'Remove all starred messages in this thread', 'buddypress' ), 101 'title_star_thread' => __( 'Star the first message in this thread', 'buddypress' ),107 'title_star_thread' => __( 'Star the first message in this thread', 'buddypress' ), 102 108 ), 'messages_star_action_link' ); 103 109 104 $retval = $bulk_attr = ''; 105 106 if ( 0 === $r['user_id'] ) { 107 return $retval; 110 // Check user ID and determine base user URL 111 switch ( $r['user_id'] ) { 112 113 // Current user 114 case bp_loggedin_user_id() : 115 $user_domain = bp_loggedin_user_domain(); 116 break; 117 118 // Displayed user 119 case bp_displayed_user_id() : 120 $user_domain = bp_displayed_user_domain(); 121 break; 122 123 // Empty or other 124 default : 125 $user_domain = bp_core_get_user_domain( $r['user_id'] ); 126 break; 108 127 } 109 128 110 // get user domain 111 if ( $r['user_id'] == bp_loggedin_user_id() ) { 112 $user_domain = bp_loggedin_user_domain(); 113 } elseif ( $r['user_id'] == bp_displayed_user_domain() ) { 114 $user_domain = bp_displayed_user_domain(); 115 } else { 116 $user_domain = bp_core_get_user_domain( $r['user_id'] ); 129 // Bail if no user domain was calculated 130 if ( empty( $user_domain ) ) { 131 return ''; 117 132 } 118 133 119 134 // thread ID 120 135 if ( (int) $r['thread_id'] > 0 ) { 136 121 137 // see if we're in the loop 122 138 if ( bp_get_message_thread_id() == $r['thread_id'] ) { 139 123 140 // grab all message ids 124 141 $mids = wp_list_pluck( $GLOBALS['messages_template']->thread->messages, 'id' ); … … 130 147 // pull up the thread 131 148 } else { 132 $thread = new BP_Messages_ thread( $r['thread_id'] );133 $mids = wp_list_pluck( $thread->messages, 'id' );149 $thread = new BP_Messages_Thread( $r['thread_id'] ); 150 $mids = wp_list_pluck( $thread->messages, 'id' ); 134 151 } 135 152 … … 137 154 $message_id = 0; 138 155 foreach ( $mids as $mid ) { 156 139 157 // try to find the first msg that is starred in a thread 140 158 if ( true === bp_messages_is_message_starred( $mid ) ) { … … 150 168 } 151 169 170 $message_id = (int) $message_id; 171 152 172 // nonce 153 173 $nonce = wp_create_nonce( "bp-messages-star-{$message_id}" ); 154 174 155 if ( $is_starred ) {156 $action = 'unstar';175 if ( true === $is_starred ) { 176 $action = 'unstar'; 157 177 $bulk_attr = ' data-star-bulk="1"'; 158 $retval = $user_domain . bp_get_messages_slug() . '/unstar/' . $message_id . '/' . $nonce . '/all/';178 $retval = $user_domain . bp_get_messages_slug() . '/unstar/' . $message_id . '/' . $nonce . '/all/'; 159 179 } else { 160 $action = 'star';161 $retval = $user_domain . bp_get_messages_slug() . '/star/' . $message_id . '/' . $nonce . '/';180 $action = 'star'; 181 $retval = $user_domain . bp_get_messages_slug() . '/star/' . $message_id . '/' . $nonce . '/'; 162 182 } 163 183 … … 170 190 $nonce = wp_create_nonce( "bp-messages-star-{$message_id}" ); 171 191 172 if ( $is_starred ) {192 if ( true === $is_starred ) { 173 193 $action = 'unstar'; 174 194 $retval = $user_domain . bp_get_messages_slug() . '/unstar/' . $message_id . '/' . $nonce . '/'; … … 202 222 * @param array $r Parsed link arguments. See $args in bp_get_the_message_star_action_link(). 203 223 */ 204 return apply_filters( 'bp_get_the_message_star_action_link', '<a title="' . esc_attr( $title ) . '" class="message-action-' . $action . '" data-star-status="' . $action .'" data-star-nonce="' . $nonce. '"' . $bulk_attr . ' data-message-id="' . esc_attr( (int) $message_id ) . '" href="' . $retval . '"><span class="icon"></span> <span class="bp-screen-reader-text">' . $r['text_' . $action] . '</span></a>', $r );224 return apply_filters( 'bp_get_the_message_star_action_link', '<a title="' . esc_attr( $title ) . '" class="message-action-' . esc_attr( $action ) . '" data-star-status="' . esc_attr( $action ) .'" data-star-nonce="' . esc_attr( $nonce ) . '"' . $bulk_attr . ' data-message-id="' . esc_attr( (int) $message_id ) . '" href="' . $retval . '"><span class="icon"></span> <span class="bp-screen-reader-text">' . $r['text_' . $action] . '</span></a>', $r ); 205 225 } 206 226
Note: See TracChangeset
for help on using the changeset viewer.