Changeset 13647
- Timestamp:
- 11/20/2023 05:35:28 AM (11 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-members/bp-members-template.php
r13503 r13647 1111 1111 global $members_template; 1112 1112 1113 $defaults = array( 1114 'length' => 225, 1115 'view_link' => true, 1116 ); 1113 if ( ! bp_is_active( 'activity' ) ) { 1114 return ''; 1115 } 1117 1116 1118 1117 $r = bp_parse_args( 1119 1118 $args, 1120 $defaults 1119 array( 1120 'length' => 225, 1121 'view_link' => true, 1122 ), 1123 'member_latest_update' 1121 1124 ); 1122 1125 1123 extract( $r ); 1124 1125 if ( !bp_is_active( 'activity' ) || empty( $members_template->member->latest_update ) || !$update = maybe_unserialize( $members_template->member->latest_update ) ) 1126 return false; 1126 $length = (int) $r['length']; 1127 $view_link = (bool) $r['view_link']; 1128 1129 // Init default update. 1130 $update_content = ''; 1131 $update = array( 1132 'id' => 0, 1133 'content' => '', 1134 'excerpt' => '', 1135 'permalink' => '', 1136 ); 1137 1138 if ( ! empty( $members_template->member->latest_update ) ) { 1139 $update = maybe_unserialize( $members_template->member->latest_update ); 1140 } 1141 1142 if ( ! empty( $update['content'] ) ) { 1143 $excerpt = trim( strip_tags( bp_create_excerpt( $update['content'], $length ) ) ); 1144 $update['content'] = trim( strip_tags( $update['content'] ) ); 1145 $update['excerpt'] = $excerpt; 1146 } else { 1147 $excerpt = ''; 1148 } 1149 1150 if ( isset( $update['id'] ) ) { 1151 $activity_id = (int) $update['id']; 1152 $update['permalink'] = bp_activity_get_permalink( $activity_id ); 1153 } 1127 1154 1128 1155 /** … … 1132 1159 * @since 2.6.0 Added the `$r` parameter. 1133 1160 * 1134 * @param string $value Excerpt of the latest update for current member in the loop. 1135 * @param array $r Array of parsed arguments. 1136 */ 1137 $update_content = apply_filters( 'bp_get_activity_latest_update_excerpt', trim( strip_tags( bp_create_excerpt( $update['content'], $length ) ) ), $r ); 1138 1139 /* translators: %s: the member latest activity update */ 1140 $update_content = sprintf( _x( '- "%s"', 'member latest update in member directory', 'buddypress' ), $update_content ); 1141 1142 // If $view_link is true and the text returned by bp_create_excerpt() is different from the original text (ie it's 1143 // been truncated), add the "View" link. 1144 if ( $view_link && ( $update_content != $update['content'] ) ) { 1145 $view = __( 'View', 'buddypress' ); 1146 1147 $update_content .= '<span class="activity-read-more"><a href="' . bp_activity_get_permalink( $update['id'] ) . '" rel="nofollow">' . $view . '</a></span>'; 1161 * @param string $excerpt Excerpt of the latest update for current member in the loop. 1162 * @param array $r Array of parsed arguments. 1163 */ 1164 $excerpt = apply_filters( 'bp_get_activity_latest_update_excerpt', $excerpt, $r ); 1165 1166 // If we have an excerpt, set its output and eventually add a link to view the full activity. 1167 if ( $excerpt ) { 1168 /* translators: %s: the member latest activity update */ 1169 $update_content = sprintf( _x( '- "%s"', 'member latest update in member directory', 'buddypress' ), $excerpt ); 1170 1171 /* 1172 * If `$view_link` is true and the text returned by `bp_create_excerpt()` is different 1173 * from the original text (ie it's been truncated), add the "View" link. 1174 */ 1175 if ( $view_link && $update['permalink'] && ( strlen( $excerpt ) < strlen( $update['content'] ) ) ) { 1176 $update_content = sprintf( 1177 '%1$s<span class="activity-read-more"><a href="%2$s" rel="nofollow">%3$s</a></span>', 1178 $update_content . "\n", 1179 esc_url( $update['permalink'] ), 1180 esc_html__( 'View', 'buddypress' ) 1181 ); 1182 } 1148 1183 } 1149 1184 … … 1153 1188 * @since 1.2.0 1154 1189 * @since 2.6.0 Added the `$r` parameter. 1190 * @since 12.0.0 Added the `$update` parameter. 1155 1191 * 1156 1192 * @param string $update_content Formatted latest update for current member. 1157 1193 * @param array $r Array of parsed arguments. 1158 */ 1159 return apply_filters( 'bp_get_member_latest_update', $update_content, $r ); 1194 * @param array $update Array of the latest activity data. 1195 */ 1196 return apply_filters( 'bp_get_member_latest_update', $update_content, $r, $update ); 1160 1197 } 1161 1198
Note: See TracChangeset
for help on using the changeset viewer.