Changeset 5684 for trunk/bp-activity/bp-activity-functions.php
- Timestamp:
- 02/09/2012 10:10:47 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity/bp-activity-functions.php
r5612 r5684 240 240 * @param int $user_id 241 241 * 242 * @global object $bp BuddyPress global settings243 242 * @uses bp_get_user_meta() 244 243 * @uses apply_filters() To call the 'bp_activity_get_user_favorites' hook … … 247 246 */ 248 247 function bp_activity_get_user_favorites( $user_id = 0 ) { 249 global $bp;250 248 251 249 // Fallback to logged in user if no user_id is passed … … 267 265 * @param int $user_id 268 266 * 269 * @global object $bp BuddyPress global settings270 267 * @uses is_user_logged_in() 271 268 * @uses bp_get_user_meta() … … 279 276 */ 280 277 function bp_activity_add_user_favorite( $activity_id, $user_id = 0 ) { 281 global $bp;282 278 283 279 // Favorite activity stream items are for logged in users only … … 326 322 * @param int $user_id 327 323 * 328 * @global object $bp BuddyPress global settings329 324 * @uses is_user_logged_in() 330 325 * @uses bp_get_user_meta() … … 337 332 */ 338 333 function bp_activity_remove_user_favorite( $activity_id, $user_id = 0 ) { 339 global $bp;340 334 341 335 // Favorite activity stream items are for logged in users only … … 421 415 * @param int $user_id 422 416 * 423 * @global object $bp BuddyPress global settings424 417 * @uses BP_Activity_Activity::total_favorite_count() {@link BP_Activity_Activity} 425 418 * … … 427 420 */ 428 421 function bp_activity_total_favorites_for_user( $user_id = 0 ) { 429 global $bp;430 422 431 423 // Fallback on displayed user, and then logged in user … … 879 871 * @param array $args See docs for $defaults for details 880 872 * 881 * @global object $bp BuddyPress global settings882 873 * @uses wp_parse_args() 883 874 * @uses BP_Activity_Activity::save() {@link BP_Activity_Activity} … … 889 880 */ 890 881 function bp_activity_add( $args = '' ) { 891 global $bp;892 882 893 883 $defaults = array( … … 1038 1028 extract( $params, EXTR_SKIP ); 1039 1029 1040 if ( empty( $content) || empty($user_id) || empty($activity_id) )1041 return false; 1042 1043 if ( empty( $parent_id) )1030 if ( empty( $content ) || empty( $user_id ) || empty( $activity_id ) ) 1031 return false; 1032 1033 if ( empty( $parent_id ) ) 1044 1034 $parent_id = $activity_id; 1045 1035 … … 1050 1040 // Insert the activity comment 1051 1041 $comment_id = bp_activity_add( array( 1052 'id' => $id,1053 'action' => apply_filters( 'bp_activity_comment_action', sprintf( __( '%s posted a new activity comment', 'buddypress' ), bp_core_get_userlink( $user_id ) ) ),1054 'content' => apply_filters( 'bp_activity_comment_content', $content ),1055 'component' => $bp->activity->id,1056 'type' => 'activity_comment',1057 'user_id' => $user_id,1058 'item_id' => $activity_id,1042 'id' => $id, 1043 'action' => apply_filters( 'bp_activity_comment_action', sprintf( __( '%s posted a new activity comment', 'buddypress' ), bp_core_get_userlink( $user_id ) ) ), 1044 'content' => apply_filters( 'bp_activity_comment_content', $content ), 1045 'component' => $bp->activity->id, 1046 'type' => 'activity_comment', 1047 'user_id' => $user_id, 1048 'item_id' => $activity_id, 1059 1049 'secondary_item_id' => $parent_id, 1060 'hide_sitewide' => $is_hidden1050 'hide_sitewide' => $is_hidden 1061 1051 ) ); 1062 1052 … … 1120 1110 * @param array $args See docs for $defaults for details 1121 1111 * 1122 * @global object $bp BuddyPress global settings1123 1112 * @uses wp_parse_args() 1124 1113 * @uses bp_activity_adjust_mention_count() … … 1134 1123 */ 1135 1124 function bp_activity_delete( $args = '' ) { 1136 global $bp;1137 1125 1138 1126 // Pass one or more the of following variables to delete by those variables … … 1169 1157 $latest_update = bp_get_user_meta( $user_id, 'bp_latest_update', true ); 1170 1158 if ( !empty( $latest_update ) ) { 1171 if ( in_array( (int)$latest_update['id'], (array)$activity_ids_deleted ) ) 1159 if ( in_array( (int)$latest_update['id'], (array)$activity_ids_deleted ) ) { 1172 1160 bp_delete_user_meta( $user_id, 'bp_latest_update' ); 1161 } 1173 1162 } 1174 1163 … … 1191 1180 * @param array $args See docs for $defaults for details 1192 1181 * 1193 * @global object $bp BuddyPress global settings1194 1182 * @uses wp_parse_args() 1195 1183 * @uses bp_activity_delete() … … 1198 1186 */ 1199 1187 function bp_activity_delete_by_item_id( $args = '' ) { 1200 global $bp; 1201 1202 $defaults = array( 'item_id' => false, 'component' => false, 'type' => false, 'user_id' => false, 'secondary_item_id' => false ); 1188 1189 $defaults = array( 1190 'item_id' => false, 1191 'component' => false, 1192 'type' => false, 1193 'user_id' => false, 1194 'secondary_item_id' => false 1195 ); 1203 1196 $r = wp_parse_args( $args, $defaults ); 1204 1197 extract( $r, EXTR_SKIP ); … … 1337 1330 * @param object $activity_obj (optional) The activity object 1338 1331 * 1339 * @global object $bp BuddyPress global settings1340 1332 * @uses bp_get_root_domain() 1341 1333 * @uses bp_get_activity_root_slug() … … 1345 1337 */ 1346 1338 function bp_activity_get_permalink( $activity_id, $activity_obj = false ) { 1347 global $bp; 1348 1349 if ( !$activity_obj ) 1339 1340 if ( empty( $activity_obj ) ) 1350 1341 $activity_obj = new BP_Activity_Activity( $activity_id ); 1351 1342 … … 1354 1345 } 1355 1346 1356 if ( 'new_blog_post' == $activity_obj->type || 'new_blog_comment' == $activity_obj->type || 'new_forum_topic' == $activity_obj->type || 'new_forum_post' == $activity_obj->type ) 1347 if ( 'new_blog_post' == $activity_obj->type || 'new_blog_comment' == $activity_obj->type || 'new_forum_topic' == $activity_obj->type || 'new_forum_post' == $activity_obj->type ) { 1357 1348 $link = $activity_obj->primary_link; 1358 else {1359 if ( 'activity_comment' == $activity_obj->type ) 1349 } else { 1350 if ( 'activity_comment' == $activity_obj->type ) { 1360 1351 $link = bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/p/' . $activity_obj->item_id . '/'; 1361 else1352 } else { 1362 1353 $link = bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/p/' . $activity_obj->id . '/'; 1354 } 1363 1355 } 1364 1356 … … 1395 1387 */ 1396 1388 function bp_activity_thumbnail_content_images( $content, $link = false ) { 1397 global $post;1398 1389 1399 1390 preg_match_all( '/<img[^>]*>/Ui', $content, $matches ); … … 1406 1397 // Get the width and height 1407 1398 preg_match( '/<img.*?(height\=[\'|"]{0,1}.*?[\'|"]{0,1})[\s|>]{1}/i', $matches[0][0], $height ); 1408 preg_match( '/<img.*?(width\=[\'|"]{0,1}.*?[\'|"]{0,1})[\s|>]{1}/i', $matches[0][0], $width);1399 preg_match( '/<img.*?(width\=[\'|"]{0,1}.*?[\'|"]{0,1})[\s|>]{1}/i', $matches[0][0], $width ); 1409 1400 1410 1401 if ( !empty( $src ) ) { 1411 $src = substr( substr( str_replace( 'src=', '', $src[1] ), 0, -1 ), 1 );1402 $src = substr( substr( str_replace( 'src=', '', $src[1] ), 0, -1 ), 1 ); 1412 1403 $height = substr( substr( str_replace( 'height=', '', $height[1] ), 0, -1 ), 1 ); 1413 $width = substr( substr( str_replace( 'width=', '', $width[1] ), 0, -1 ), 1 );1404 $width = substr( substr( str_replace( 'width=', '', $width[1] ), 0, -1 ), 1 ); 1414 1405 1415 1406 if ( empty( $width ) || empty( $height ) ) { 1416 $width = 100;1407 $width = 100; 1417 1408 $height = 100; 1418 1409 } 1419 1410 1420 $ratio = (int)$width / (int)$height;1411 $ratio = (int)$width / (int)$height; 1421 1412 $new_height = (int)$height >= 100 ? 100 : $height; 1422 $new_width = $new_height * $ratio;1413 $new_width = $new_height * $ratio; 1423 1414 1424 1415 $image = '<img src="' . esc_attr( $src ) . '" width="' . $new_width . '" height="' . $new_height . '" alt="' . __( 'Thumbnail', 'buddypress' ) . '" class="align-left thumbnail" />'; … … 1438 1429 * Convenience function to control whether the current user is allowed to mark activity items as spam 1439 1430 * 1440 * @global object $bp BuddyPress global settings1441 1431 * @return bool True if user is allowed to mark activity items as spam 1442 1432 * @since 1.6 … … 1444 1434 */ 1445 1435 function bp_activity_user_can_mark_spam() { 1446 global $bp;1447 1436 return apply_filters( 'bp_activity_user_can_mark_spam', bp_current_user_can( 'bp_moderate' ) ); 1448 1437 }
Note: See TracChangeset
for help on using the changeset viewer.