Changeset 13893
- Timestamp:
- 06/02/2024 02:07:21 AM (4 months ago)
- Location:
- trunk/src/bp-core
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-functions.php
r13890 r13893 3185 3185 * @since 2.5.0 3186 3186 * 3187 * @param string $ value Email post type name.3187 * @param string $email_post_type Email post type name. 3188 3188 */ 3189 3189 return apply_filters( 'bp_get_email_post_type', buddypress()->email_post_type ); -
trunk/src/bp-core/classes/class-bp-core-user.php
r13890 r13893 131 131 * 132 132 * @param integer $user_id The ID for the user being queried. 133 * @param bool $populate_extras Whether to fetch extra information such as133 * @param bool $populate_extras Optional. Whether to fetch extra information such as 134 134 * group/friendship counts or not. Default: false. 135 135 */ 136 136 public function __construct( $user_id, $populate_extras = false ) { 137 if ( ! empty( $user_id ) ) {137 if ( ! empty( $user_id ) ) { 138 138 $this->id = $user_id; 139 139 $this->populate(); 140 140 141 if ( ! empty( $populate_extras ) ) {141 if ( ! empty( $populate_extras ) ) { 142 142 $this->populate_extras(); 143 143 } … … 150 150 public function populate() { 151 151 152 if ( bp_is_active( 'xprofile' ) ) 152 if ( bp_is_active( 'xprofile' ) ) { 153 153 $this->profile_data = $this->get_profile_data(); 154 155 if ( !empty( $this->profile_data ) ) { 154 } 155 156 if ( ! empty( $this->profile_data ) ) { 156 157 $full_name_field_name = bp_xprofile_fullname_field_name(); 157 158 158 159 $this->user_url = bp_members_get_user_url( $this->id ); 159 $this->fullname = esc_attr( $this->profile_data[ $full_name_field_name]['field_data'] );160 $this->fullname = esc_attr( $this->profile_data[ $full_name_field_name ]['field_data'] ); 160 161 $this->user_link = "<a href='{$this->user_url}'>{$this->fullname}</a>"; 161 162 $this->email = esc_attr( $this->profile_data['user_email'] ); … … 175 176 __( 'Profile photo of %s', 'buddypress' ), 176 177 $this->fullname 177 ) 178 ), 178 179 ) 179 180 ); … … 187 188 __( 'Profile photo of %s', 'buddypress' ), 188 189 $this->fullname 189 ) 190 ), 190 191 ) 191 192 ); … … 201 202 ), 202 203 'width' => 30, 203 'height' => 30 204 'height' => 30, 204 205 ) 205 206 ); … … 248 249 * 249 250 * @deprecated 1.7.0 Use {@link BP_User_Query}. 251 * 252 * @global wpdb $wpdb WordPress database object. 250 253 * 251 254 * @see BP_User_Query for a description of parameters, most of which … … 282 285 $sql = array(); 283 286 284 $sql['select_main'] = "SELECT DISTINCT u.ID as id, u.user_registered, u.user_nicename, u.user_login, u.display_name, u.user_email";285 286 if ( 'active' == $type || 'online' == $type || 'newest' == $type) {287 $sql['select_active'] = ", um.meta_value as last_activity";288 } 289 290 if ( 'popular' == $type ) {291 $sql['select_popular'] = ", um.meta_value as total_friend_count";292 } 293 294 if ( 'alphabetical' == $type ) {295 $sql['select_alpha'] = ", pd.value as fullname";287 $sql['select_main'] = 'SELECT DISTINCT u.ID as id, u.user_registered, u.user_nicename, u.user_login, u.display_name, u.user_email'; 288 289 if ( 'active' === $type || 'online' === $type || 'newest' === $type ) { 290 $sql['select_active'] = ', um.meta_value as last_activity'; 291 } 292 293 if ( 'popular' === $type ) { 294 $sql['select_popular'] = ', um.meta_value as total_friend_count'; 295 } 296 297 if ( 'alphabetical' === $type ) { 298 $sql['select_alpha'] = ', pd.value as fullname'; 296 299 } 297 300 298 301 if ( $meta_key ) { 299 $sql['select_meta'] = ", umm.meta_key";302 $sql['select_meta'] = ', umm.meta_key'; 300 303 301 304 if ( $meta_value ) { 302 $sql['select_meta'] .= ", umm.meta_value";305 $sql['select_meta'] .= ', umm.meta_value'; 303 306 } 304 307 } … … 312 315 313 316 // Alphabetical sorting is done by the xprofile Full Name field. 314 if ( 'alphabetical' == $type ) {317 if ( 'alphabetical' === $type ) { 315 318 $sql['join_profiledata_alpha'] = "LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id"; 316 319 } … … 322 325 $sql['where'] = 'WHERE ' . bp_core_get_status_sql( 'u.' ); 323 326 324 if ( 'active' == $type || 'online' == $type || 'newest'== $type ) {325 $sql['where_active'] = $wpdb->prepare( "AND um.meta_key = %s", bp_get_user_meta_key( 'last_activity' ) );326 } 327 328 if ( 'popular' == $type ) {329 $sql['where_popular'] = $wpdb->prepare( "AND um.meta_key = %s", bp_get_user_meta_key( 'total_friend_count' ) );330 } 331 332 if ( 'online' == $type ) {333 $sql['where_online'] = "AND DATE_ADD( um.meta_value, INTERVAL 5 MINUTE ) >= UTC_TIMESTAMP()";334 } 335 336 if ( 'alphabetical' == $type ) {337 $sql['where_alpha'] = "AND pd.field_id = 1";338 } 339 340 if ( ! empty( $exclude ) ) {327 if ( 'active' === $type || 'online' === $type || 'newest' === $type ) { 328 $sql['where_active'] = $wpdb->prepare( 'AND um.meta_key = %s', bp_get_user_meta_key( 'last_activity' ) ); 329 } 330 331 if ( 'popular' === $type ) { 332 $sql['where_popular'] = $wpdb->prepare( 'AND um.meta_key = %s', bp_get_user_meta_key( 'total_friend_count' ) ); 333 } 334 335 if ( 'online' === $type ) { 336 $sql['where_online'] = 'AND DATE_ADD( um.meta_value, INTERVAL 5 MINUTE ) >= UTC_TIMESTAMP()'; 337 } 338 339 if ( 'alphabetical' === $type ) { 340 $sql['where_alpha'] = 'AND pd.field_id = 1'; 341 } 342 343 if ( ! empty( $exclude ) ) { 341 344 $exclude = implode( ',', wp_parse_id_list( $exclude ) ); 342 345 $sql['where_exclude'] = "AND u.ID NOT IN ({$exclude})"; … … 346 349 // returned. The default value of false will hit the 'else' clause. 347 350 if ( 0 === $include || '0' === $include ) { 348 $sql['where_users'] = "AND 0 = 1"; 349 } else { 350 if ( !empty( $include ) ) { 351 $include = implode( ',', wp_parse_id_list( $include ) ); 351 $sql['where_users'] = 'AND 0 = 1'; 352 } elseif ( ! empty( $include ) ) { 353 $include = implode( ',', wp_parse_id_list( $include ) ); 352 354 $sql['where_users'] = "AND u.ID IN ({$include})"; 353 } elseif ( !empty( $user_id ) && bp_is_active( 'friends' ) ) {354 355 356 if ( !empty( $friend_ids ) ) {357 $friend_ids= implode( ',', wp_parse_id_list( $friend_ids ) );358 355 } elseif ( ! empty( $user_id ) && bp_is_active( 'friends' ) ) { 356 $friend_ids = friends_get_friend_user_ids( $user_id ); 357 358 if ( ! empty( $friend_ids ) ) { 359 $friend_ids = implode( ',', wp_parse_id_list( $friend_ids ) ); 360 $sql['where_friends'] = "AND u.ID IN ({$friend_ids})"; 359 361 360 362 // User has no friends, return false since there will be no users to fetch. 361 } else { 362 return false; 363 } 364 } 365 } 366 367 if ( !empty( $search_terms ) && bp_is_active( 'xprofile' ) ) { 363 } else { 364 return false; 365 } 366 } 367 368 if ( ! empty( $search_terms ) && bp_is_active( 'xprofile' ) ) { 368 369 $search_terms_like = '%' . bp_esc_like( $search_terms ) . '%'; 369 $sql['where_searchterms'] = $wpdb->prepare( "AND spd.value LIKE %s", $search_terms_like );370 } 371 372 if ( ! empty( $meta_key ) ) {373 $sql['where_meta'] = $wpdb->prepare( " AND umm.meta_key = %s", $meta_key );370 $sql['where_searchterms'] = $wpdb->prepare( 'AND spd.value LIKE %s', $search_terms_like ); 371 } 372 373 if ( ! empty( $meta_key ) ) { 374 $sql['where_meta'] = $wpdb->prepare( ' AND umm.meta_key = %s', $meta_key ); 374 375 375 376 // If a meta value is provided, match it. 376 377 if ( $meta_value ) { 377 $sql['where_meta'] .= $wpdb->prepare( " AND umm.meta_value = %s", $meta_value );378 $sql['where_meta'] .= $wpdb->prepare( ' AND umm.meta_value = %s', $meta_value ); 378 379 } 379 380 } 380 381 381 382 switch ( $type ) { 382 case 'active': case 'online': default: 383 $sql[] = "ORDER BY um.meta_value DESC"; 383 case 'active': 384 case 'online': 385 default: 386 $sql[] = 'ORDER BY um.meta_value DESC'; 384 387 break; 385 388 case 'newest': 386 $sql[] = "ORDER BY u.ID DESC";389 $sql[] = 'ORDER BY u.ID DESC'; 387 390 break; 388 391 case 'alphabetical': 389 $sql[] = "ORDER BY pd.value ASC";392 $sql[] = 'ORDER BY pd.value ASC'; 390 393 break; 391 394 case 'random': 392 $sql[] = "ORDER BY rand()";395 $sql[] = 'ORDER BY rand()'; 393 396 break; 394 397 case 'popular': 395 $sql[] = "ORDER BY CONVERT(um.meta_value, SIGNED) DESC";398 $sql[] = 'ORDER BY CONVERT(um.meta_value, SIGNED) DESC'; 396 399 break; 397 400 } 398 401 399 if ( ! empty( $limit ) && !empty( $page ) ) {400 $sql['pagination'] = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );402 if ( ! empty( $limit ) && ! empty( $page ) ) { 403 $sql['pagination'] = $wpdb->prepare( 'LIMIT %d, %d', intval( ( $page - 1 ) * $limit ), intval( $limit ) ); 401 404 } 402 405 … … 415 418 unset( $sql['select_main'] ); 416 419 417 if ( ! empty( $sql['select_active'] ) ) {420 if ( ! empty( $sql['select_active'] ) ) { 418 421 unset( $sql['select_active'] ); 419 422 } 420 423 421 if ( ! empty( $sql['select_popular'] ) ) {424 if ( ! empty( $sql['select_popular'] ) ) { 422 425 unset( $sql['select_popular'] ); 423 426 } 424 427 425 if ( ! empty( $sql['select_alpha'] ) ) {428 if ( ! empty( $sql['select_alpha'] ) ) { 426 429 unset( $sql['select_alpha'] ); 427 430 } 428 431 429 if ( ! empty( $sql['pagination'] ) ) {432 if ( ! empty( $sql['pagination'] ) ) { 430 433 unset( $sql['pagination'] ); 431 434 } 432 435 433 array_unshift( $sql, "SELECT COUNT(u.ID)");436 array_unshift( $sql, 'SELECT COUNT(u.ID)' ); 434 437 435 438 /** … … 448 451 * We can't add these to the main query above since only users who have this information will be returned (since the much of the data is in usermeta and won't support any type of directional join). 449 452 */ 450 if ( ! empty( $populate_extras ) ) {453 if ( ! empty( $populate_extras ) ) { 451 454 $user_ids = array(); 452 455 … … 456 459 457 460 // Add additional data to the returned results. 458 $paged_users = BP_Core_User::get_user_extras( $paged_users, $user_ids, $type ); 459 } 460 461 return array( 'users' => $paged_users, 'total' => $total_users ); 462 } 463 461 $paged_users = self::get_user_extras( $paged_users, $user_ids, $type ); 462 } 463 464 return array( 465 'users' => $paged_users, 466 'total' => $total_users, 467 ); 468 } 464 469 465 470 /** … … 482 487 $pag_sql = ''; 483 488 if ( $limit && $page ) { 484 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );489 $pag_sql = $wpdb->prepare( ' LIMIT %d, %d', intval( ( $page - 1 ) * $limit ), intval( $limit ) ); 485 490 } 486 491 487 492 // Multibyte compliance. 488 493 if ( function_exists( 'mb_strlen' ) ) { 489 if ( mb_strlen( $letter, 'UTF-8' ) > 1 || is_numeric( $letter ) || ! $letter ) {494 if ( mb_strlen( $letter, 'UTF-8' ) > 1 || is_numeric( $letter ) || ! $letter ) { 490 495 return false; 491 496 } 492 } else { 493 if ( strlen( $letter ) > 1 || is_numeric( $letter ) || !$letter ) { 494 return false; 495 } 497 } elseif ( strlen( $letter ) > 1 || is_numeric( $letter ) || ! $letter ) { 498 return false; 496 499 } 497 500 … … 501 504 $status_sql = bp_core_get_status_sql( 'u.' ); 502 505 503 if ( ! empty( $exclude ) ) {506 if ( ! empty( $exclude ) ) { 504 507 $exclude = implode( ',', wp_parse_id_list( $exclude ) ); 505 508 $exclude_sql = " AND u.id NOT IN ({$exclude})"; … … 524 527 * @param string $value SQL prepared statement for the user query. 525 528 */ 526 $paged_users_sql = apply_filters( 'bp_core_users_by_letter_sql', 529 $paged_users_sql = apply_filters( 'bp_core_users_by_letter_sql', $wpdb->prepare( "SELECT DISTINCT u.ID as id, u.user_registered, u.user_nicename, u.user_login, u.user_email FROM {$wpdb->users} u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id LEFT JOIN {$bp->profile->table_name_fields} pf ON pd.field_id = pf.id WHERE {$status_sql} AND pf.name = %s {$exclude_sql} AND pd.value LIKE %s ORDER BY pd.value ASC{$pag_sql}", bp_xprofile_fullname_field_name(), $letter_like ) ); 527 530 528 531 $total_users = $wpdb->get_var( $total_users_sql ); … … 537 540 */ 538 541 $user_ids = array(); 539 foreach ( (array) $paged_users as $user ) 542 foreach ( (array) $paged_users as $user ) { 540 543 $user_ids[] = (int) $user->id; 544 } 541 545 542 546 // Add additional data to the returned results. 543 547 if ( $populate_extras ) { 544 $paged_users = BP_Core_User::get_user_extras( $paged_users, $user_ids ); 545 } 546 547 return array( 'users' => $paged_users, 'total' => $total_users ); 548 $paged_users = self::get_user_extras( $paged_users, $user_ids ); 549 } 550 551 return array( 552 'users' => $paged_users, 553 'total' => $total_users, 554 ); 548 555 } 549 556 … … 566 573 567 574 $pag_sql = ''; 568 if ( $limit && $page ) 569 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 575 if ( $limit && $page ) { 576 $pag_sql = $wpdb->prepare( ' LIMIT %d, %d', intval( ( $page - 1 ) * $limit ), intval( $limit ) ); 577 } 570 578 571 579 $user_ids = implode( ',', wp_parse_id_list( $user_ids ) ); … … 638 646 639 647 // Add additional data to the returned results. 640 if ( !empty( $populate_extras ) ) { 641 $paged_users = BP_Core_User::get_user_extras( $paged_users, $user_ids ); 642 } 643 644 return array( 'users' => $paged_users, 'total' => $total_users ); 648 if ( ! empty( $populate_extras ) ) { 649 $paged_users = self::get_user_extras( $paged_users, $user_ids ); 650 } 651 652 return array( 653 'users' => $paged_users, 654 'total' => $total_users, 655 ); 645 656 } 646 657 … … 663 674 664 675 $user_ids = array(); 665 $pag_sql = $limit && $page ? $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * intval( $limit ) ), intval( $limit ) ) : '';676 $pag_sql = $limit && $page ? $wpdb->prepare( ' LIMIT %d, %d', intval( ( $page - 1 ) * intval( $limit ) ), intval( $limit ) ) : ''; 666 677 667 678 $search_terms_like = '%' . bp_esc_like( $search_terms ) . '%'; … … 684 695 * @param string $value SQL statement for the searched users query. 685 696 */ 686 $paged_users_sql = apply_filters( 'bp_core_search_users_sql', 697 $paged_users_sql = apply_filters( 'bp_core_search_users_sql', $wpdb->prepare( "SELECT DISTINCT u.ID as id, u.user_registered, u.user_nicename, u.user_login, u.user_email FROM {$wpdb->users} u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id WHERE {$status_sql} AND pd.value LIKE %s ORDER BY pd.value ASC{$pag_sql}", $search_terms_like ), $search_terms, $pag_sql ); 687 698 688 699 $total_users = $wpdb->get_var( $total_users_sql ); … … 693 704 * We can't add these to the main query above since only users who have this information will be returned (since the much of the data is in usermeta and won't support any type of directional join) 694 705 */ 695 foreach ( (array) $paged_users as $user ) 706 foreach ( (array) $paged_users as $user ) { 696 707 $user_ids[] = $user->id; 708 } 697 709 698 710 // Add additional data to the returned results. 699 if ( $populate_extras ) 700 $paged_users = BP_Core_User::get_user_extras( $paged_users, $user_ids ); 701 702 return array( 'users' => $paged_users, 'total' => $total_users ); 711 if ( $populate_extras ) { 712 $paged_users = self::get_user_extras( $paged_users, $user_ids ); 713 } 714 715 return array( 716 'users' => $paged_users, 717 'total' => $total_users, 718 ); 703 719 } 704 720 … … 720 736 $bp = buddypress(); 721 737 722 if ( empty( $user_ids ) ) 738 if ( empty( $user_ids ) ) { 723 739 return $paged_users; 740 } 724 741 725 742 // Sanitize user IDs. … … 727 744 728 745 // Fetch the user's full name. 729 if ( bp_is_active( 'xprofile' ) && 'alphabetical' != $type ) {746 if ( bp_is_active( 'xprofile' ) && 'alphabetical' !== $type ) { 730 747 $names = $wpdb->get_results( $wpdb->prepare( "SELECT pd.user_id as id, pd.value as fullname FROM {$bp->profile->table_name_fields} pf, {$bp->profile->table_name_data} pd WHERE pf.id = pd.field_id AND pf.name = %s AND pd.user_id IN ( {$user_ids} )", bp_xprofile_fullname_field_name() ) ); 731 748 for ( $i = 0, $count = count( $paged_users ); $i < $count; ++$i ) { 732 749 foreach ( (array) $names as $name ) { 733 if ( $name->id == $paged_users[$i]->id ) 734 $paged_users[$i]->fullname = $name->fullname; 750 if ( $name->id === $paged_users[ $i ]->id ) { 751 $paged_users[ $i ]->fullname = $name->fullname; 752 } 735 753 } 736 754 } … … 738 756 739 757 // Fetch the user's total friend count. 740 if ( 'popular' != $type ) {758 if ( 'popular' !== $type ) { 741 759 $friend_count = $wpdb->get_results( $wpdb->prepare( "SELECT user_id as id, meta_value as total_friend_count FROM {$wpdb->usermeta} WHERE meta_key = %s AND user_id IN ( {$user_ids} )", bp_get_user_meta_key( 'total_friend_count' ) ) ); 742 760 for ( $i = 0, $count = count( $paged_users ); $i < $count; ++$i ) { 743 761 foreach ( (array) $friend_count as $fcount ) { 744 if ( $fcount->id == $paged_users[$i]->id ) 745 $paged_users[$i]->total_friend_count = (int) $fcount->total_friend_count; 762 if ( $fcount->id === $paged_users[ $i ]->id ) { 763 $paged_users[ $i ]->total_friend_count = (int) $fcount->total_friend_count; 764 } 746 765 } 747 766 } … … 753 772 for ( $i = 0, $count = count( $paged_users ); $i < $count; ++$i ) { 754 773 foreach ( (array) $friend_status as $status ) { 755 if ( $status->initiator_user_id == $paged_users[$i]->id || $status->friend_user_id == $paged_users[$i]->id ) 756 $paged_users[$i]->is_friend = $status->is_confirmed; 774 if ( $status->initiator_user_id === $paged_users[ $i ]->id || $status->friend_user_id === $paged_users[ $i ]->id ) { 775 $paged_users[ $i ]->is_friend = $status->is_confirmed; 776 } 757 777 } 758 778 } … … 760 780 761 781 // Fetch the user's last_activity. 762 if ( 'active' != $type ) {782 if ( 'active' !== $type ) { 763 783 $user_activity = self::get_last_activity( $user_ids ); 764 784 for ( $i = 0, $count = count( $paged_users ); $i < $count; ++$i ) { 765 785 foreach ( (array) $user_activity as $activity ) { 766 if ( ! empty( $activity['user_id'] ) && (int) $activity['user_id'] === (int) $paged_users[ $i]->id ) {767 $paged_users[ $i]->last_activity = $activity['date_recorded'];786 if ( ! empty( $activity['user_id'] ) && (int) $activity['user_id'] === (int) $paged_users[ $i ]->id ) { 787 $paged_users[ $i ]->last_activity = $activity['date_recorded']; 768 788 } 769 789 } … … 775 795 for ( $i = 0, $count = count( $paged_users ); $i < $count; ++$i ) { 776 796 foreach ( (array) $user_update as $update ) { 777 if ( $update->id == $paged_users[$i]->id ) 778 $paged_users[$i]->latest_update = $update->latest_update; 797 if ( $update->id === $paged_users[ $i ]->id ) { 798 $paged_users[ $i ]->latest_update = $update->latest_update; 799 } 779 800 } 780 801 } … … 789 810 * 790 811 * @param int $user_id User ID. 791 * @return false|object WP_Userif successful, false on failure.812 * @return false|object User object if successful, false on failure. 792 813 */ 793 814 public static function get_core_userdata( $user_id ) { … … 797 818 /** 798 819 * Get last activity data for a user or set of users. 820 * 821 * @global wpdb $wpdb WordPress database object. 799 822 * 800 823 * @param int|array $user_id User IDs or multiple user IDs. … … 821 844 822 845 foreach ( $last_activities as $last_activity ) { 823 wp_cache_set( $last_activity->user_id, array( 824 'user_id' => $last_activity->user_id, 825 'date_recorded' => $last_activity->date_recorded, 826 'activity_id' => $last_activity->id, 827 ), 'bp_last_activity' ); 846 wp_cache_set( 847 $last_activity->user_id, 848 array( 849 'user_id' => $last_activity->user_id, 850 'date_recorded' => $last_activity->date_recorded, 851 'activity_id' => $last_activity->id, 852 ), 853 'bp_last_activity' 854 ); 828 855 } 829 856 } … … 835 862 836 863 if ( isset( $retval['user_id'] ) ) { 837 $retval[ $user_id ]['user_id'] 864 $retval[ $user_id ]['user_id'] = (int) $retval[ $user_id ]['user_id']; 838 865 } 839 866 if ( isset( $retval['activity_id'] ) ) { … … 852 879 * 853 880 * @since 2.0.0 881 * 882 * @global wpdb $wpdb WordPress database object. 854 883 * 855 884 * @param int $user_id ID of the user whose last_activity you are updating. … … 867 896 $updated = $wpdb->update( 868 897 $table_name, 869 870 898 // Data to update. 871 899 array( 872 900 'date_recorded' => $time, 873 901 ), 874 875 902 // WHERE. 876 903 array( 877 904 'id' => $activity[ $user_id ]['activity_id'], 878 905 ), 879 880 906 // Data sanitization format. 881 907 array( 882 908 '%s', 883 909 ), 884 885 910 // WHERE sanitization format. 886 911 array( … … 895 920 $updated = $wpdb->insert( 896 921 $table_name, 897 898 922 // Data. 899 923 array( … … 907 931 'date_recorded' => $time, 908 932 ), 909 910 933 // Data sanitization format. 911 934 array( … … 923 946 // Set up activity array for caching. 924 947 // View the foreach loop in the get_last_activity() method for format. 925 $activity = array();948 $activity = array(); 926 949 $activity[ $user_id ] = array( 927 950 'user_id' => $user_id, … … 952 975 * @since 2.0.0 953 976 * 977 * @global wpdb $wpdb WordPress database object. 978 * 954 979 * @param int $user_id ID of the user whose activity should be deleted. 955 980 * @return bool … … 966 991 $deleted = $wpdb->delete( 967 992 buddypress()->members->table_name_last_activity, 968 969 993 // WHERE. 970 994 array( 971 995 'id' => $existing[ $user_id ]['activity_id'], 972 996 ), 973 974 997 // WHERE sanitization format. 975 998 array( -
trunk/src/bp-core/classes/class-bp-core.php
r13878 r13893 25 25 * 26 26 * @since 1.5.0 27 *28 27 */ 29 28 public function __construct() { … … 44 43 * @since 7.0.0 45 44 * 46 * @param string $key 45 * @param string $key The object var to get. 47 46 * @return mixed 48 47 */ 49 48 public function __get( $key = '' ) { 50 49 51 // Backwards compatibility for the original Notifications table var 50 // Backwards compatibility for the original Notifications table var. 52 51 if ( 'table_name_notifications' === $key ) { 53 52 return bp_is_active( 'notifications' ) … … 56 55 } 57 56 58 // Return object var if set, else null 57 // Return object var if set, else null. 59 58 return isset( $this->{$key} ) 60 59 ? $this->{$key} … … 90 89 * @since 1.5.0 91 90 * 92 * @param array $ valueArray of included and optional components.91 * @param array $optional_components Array of included and optional components. 93 92 */ 94 93 $bp->optional_components = apply_filters( 'bp_optional_components', array( 'activity', 'blogs', 'friends', 'groups', 'messages', 'notifications', 'settings', 'xprofile' ) ); … … 104 103 105 104 // Get a list of activated components. 106 if ( $active_components = bp_get_option( 'bp-active-components' ) ) { 105 $active_components = bp_get_option( 'bp-active-components' ); 106 if ( $active_components ) { 107 107 108 108 /** This filter is documented in bp-core/admin/bp-core-admin-components.php */ 109 $bp->active_components 109 $bp->active_components = apply_filters( 'bp_active_components', $active_components ); 110 110 111 111 /** … … 118 118 $bp->deactivated_components = apply_filters( 'bp_deactivated_components', array_values( array_diff( array_values( array_merge( $bp->optional_components, $bp->required_components ) ), array_keys( $bp->active_components ) ) ) ); 119 119 120 // Pre 1.5 Backwards compatibility.120 // Pre 1.5 Backwards compatibility. 121 121 } elseif ( $deactivated_components = bp_get_option( 'bp-deactivated-components' ) ) { 122 122 … … 130 130 131 131 // Setup the active components. 132 $active_components 132 $active_components = array_fill_keys( array_diff( array_values( array_merge( $bp->optional_components, $bp->required_components ) ), array_values( $bp->deactivated_components ) ), '1' ); 133 133 134 134 /** This filter is documented in bp-core/admin/bp-core-admin-components.php */ 135 135 $bp->active_components = apply_filters( 'bp_active_components', $bp->active_components ); 136 136 137 // Default to all components active.137 // Default to all components active. 138 138 } else { 139 139 … … 142 142 143 143 // Setup the active components. 144 $active_components 144 $active_components = array_fill_keys( array_values( array_merge( $bp->optional_components, $bp->required_components ) ), '1' ); 145 145 146 146 /** This filter is documented in bp-core/admin/bp-core-admin-components.php */ … … 151 151 foreach ( $bp->optional_components as $component ) { 152 152 if ( bp_is_active( $component ) && file_exists( $bp->plugin_dir . '/bp-' . $component . '/bp-' . $component . '-loader.php' ) ) { 153 include ( $bp->plugin_dir . '/bp-' . $component . '/bp-' . $component . '-loader.php' );153 include $bp->plugin_dir . '/bp-' . $component . '/bp-' . $component . '-loader.php'; 154 154 } 155 155 } … … 158 158 foreach ( $bp->required_components as $component ) { 159 159 if ( file_exists( $bp->plugin_dir . '/bp-' . $component . '/bp-' . $component . '-loader.php' ) ) { 160 include ( $bp->plugin_dir . '/bp-' . $component . '/bp-' . $component . '-loader.php' );160 include $bp->plugin_dir . '/bp-' . $component . '/bp-' . $component . '-loader.php'; 161 161 } 162 162 } … … 189 189 190 190 $includes = array( 191 'admin' 191 'admin', 192 192 ); 193 193 … … 237 237 238 238 // Logged in user is the 'current_user'. 239 $current_user 239 $current_user = wp_get_current_user(); 240 240 241 241 // The user ID of the user who is currently logged in. 242 $bp->loggedin_user = new stdClass;243 $bp->loggedin_user->id 242 $bp->loggedin_user = new stdClass(); 243 $bp->loggedin_user->id = isset( $current_user->ID ) ? $current_user->ID : 0; 244 244 245 245 /** Avatars ********************************************************** … … 247 247 248 248 // Fetches the default Gravatar image to use if the user/group/blog has no avatar or gravatar. 249 $bp->grav_default = new stdClass;249 $bp->grav_default = new stdClass(); 250 250 251 251 /** … … 256 256 * @param string $value Default user Gravatar. 257 257 */ 258 $bp->grav_default->user = apply_filters( 'bp_user_gravatar_default',$bp->site_options['avatar_default'] );258 $bp->grav_default->user = apply_filters( 'bp_user_gravatar_default', $bp->site_options['avatar_default'] ); 259 259 260 260 /** … … 272 272 * @since 1.1.0 273 273 * 274 * @param string $ valueDefault blog Gravatar.275 */ 276 $bp->grav_default->blog = apply_filters( 'bp_blog_gravatar_default',$bp->grav_default->user );274 * @param string $gravatar_default Default blog Gravatar. 275 */ 276 $bp->grav_default->blog = apply_filters( 'bp_blog_gravatar_default', $bp->grav_default->user ); 277 277 278 278 // Only fully deprecate the legacy navigation globals if BP Classic is not active. … … 325 325 326 326 // Global groups. 327 wp_cache_add_global_groups( array( 328 'bp', 329 'bp_pages', 330 'bp_invitations', 331 ) ); 327 wp_cache_add_global_groups( 328 array( 329 'bp', 330 'bp_pages', 331 'bp_invitations', 332 ) 333 ); 332 334 333 335 parent::setup_cache_groups(); … … 371 373 register_post_type( 372 374 bp_get_email_post_type(), 373 apply_filters( 'bp_register_email_post_type', array( 374 'description' => _x( 'BuddyPress emails', 'email post type description', 'buddypress' ), 375 'capabilities' => array( 376 'edit_posts' => 'bp_moderate', 377 'edit_others_posts' => 'bp_moderate', 378 'publish_posts' => 'bp_moderate', 379 'read_private_posts' => 'bp_moderate', 380 'delete_posts' => 'bp_moderate', 381 'delete_others_posts' => 'bp_moderate', 382 ), 383 'map_meta_cap' => true, 384 'labels' => bp_get_email_post_type_labels(), 385 'menu_icon' => 'dashicons-email', 386 'public' => false, 387 'publicly_queryable' => bp_current_user_can( 'bp_moderate' ), 388 'query_var' => false, 389 'rewrite' => false, 390 'show_in_admin_bar' => false, 391 'show_ui' => bp_current_user_can( 'bp_moderate' ), 392 'supports' => bp_get_email_post_type_supports(), 393 ) ) 375 apply_filters( 376 'bp_register_email_post_type', 377 array( 378 'description' => _x( 'BuddyPress emails', 'email post type description', 'buddypress' ), 379 'capabilities' => array( 380 'edit_posts' => 'bp_moderate', 381 'edit_others_posts' => 'bp_moderate', 382 'publish_posts' => 'bp_moderate', 383 'read_private_posts' => 'bp_moderate', 384 'delete_posts' => 'bp_moderate', 385 'delete_others_posts' => 'bp_moderate', 386 ), 387 'map_meta_cap' => true, 388 'labels' => bp_get_email_post_type_labels(), 389 'menu_icon' => 'dashicons-email', 390 'public' => false, 391 'publicly_queryable' => bp_current_user_can( 'bp_moderate' ), 392 'query_var' => false, 393 'rewrite' => false, 394 'show_in_admin_bar' => false, 395 'show_ui' => bp_current_user_can( 'bp_moderate' ), 396 'supports' => bp_get_email_post_type_supports(), 397 ) 398 ) 394 399 ); 395 400 } -
trunk/src/bp-core/classes/class-bp-customizer-control-range.php
r10475 r13893 16 16 */ 17 17 class BP_Customizer_Control_Range extends WP_Customize_Control { 18 18 19 /** 20 * Control type. 21 * 19 22 * @var string 20 23 */ … … 47 50 <?php endif; ?> 48 51 49 <input type="range" id="<?php echo esc_attr( "{$id}-range" ); ?>" <?php $this->link(); $this->input_attrs(); ?> value="<?php echo esc_attr( $this->value() ); ?>" /> 52 <input type="range" id="<?php echo esc_attr( "{$id}-range" ); ?>" 53 <?php 54 $this->link(); 55 $this->input_attrs(); 56 ?> 57 value="<?php echo esc_attr( $this->value() ); ?>" /> 50 58 <output for="<?php echo esc_attr( "{$id}-range" ); ?>"><?php echo esc_html( $this->value() ); ?></output> 51 59 … … 53 61 <p><span class="description customize-control-description"><?php echo esc_html( $this->description ); ?></span></p> 54 62 <?php endif; ?> 55 </li><?php 63 </li> 64 <?php 56 65 } 57 66 } -
trunk/src/bp-core/classes/class-bp-date-query.php
r13184 r13893 11 11 defined( 'ABSPATH' ) || exit; 12 12 13 if ( class_exists( 'WP_Date_Query' ) ) : 13 if ( ! class_exists( 'WP_Date_Query' ) ) { 14 return; 15 } 14 16 15 17 /** … … 26 28 */ 27 29 class BP_Date_Query extends WP_Date_Query { 30 28 31 /** 29 32 * The column to query against. Can be changed via the query arguments. … … 46 49 * 47 50 * @since 2.1.0 48 * @since 10.0.0 Added $prepend_and argument. 51 * @since 10.0.0 Added `$prepend_and` argument. 52 * 53 * @see WP_Date_Query::__construct() 49 54 * 50 55 * @param array $date_query Date query arguments. 51 56 * @param string $column The DB column to query against. 52 57 * @param bool $prepend_and Whether to prepend the 'AND' operator to the WHERE SQL clause. 53 *54 * @see WP_Date_Query::__construct()55 58 */ 56 59 public function __construct( $date_query, $column = '', $prepend_and = false ) { … … 129 132 if ( ! empty( $date_query ) && is_array( $date_query ) && ! empty( $column ) ) { 130 133 $date_query = new self( $date_query, $column, $prepend_and ); 131 $sql = $date_query->get_sql();134 $sql = $date_query->get_sql(); 132 135 } 133 136 … … 135 138 } 136 139 } 137 endif; -
trunk/src/bp-core/classes/class-bp-media-extractor.php
r13793 r13893 6 6 * @subpackage Core 7 7 * @since 2.3.0 8 * 9 * @phpcs:disable Squiz.PHP.CommentedOutCode.Found 8 10 */ 9 11 … … 40 42 */ 41 43 class BP_Media_Extractor { 44 42 45 /** 43 46 * Media type. … … 54 57 const AUDIO = 32; 55 58 const VIDEOS = 64; 56 57 59 58 60 /** … … 132 134 $plaintext = $this->strip_markup( $richtext ); 133 135 134 135 136 // Extract links. 136 137 if ( self::LINKS & $what_to_extract ) { … … 181 182 return apply_filters( 'bp_media_extractor_extract', $media, $richtext, $what_to_extract, $extra_args, $plaintext ); 182 183 } 183 184 184 185 185 /** … … 209 209 */ 210 210 protected function extract_links( $richtext, $plaintext, $extra_args = array() ) { 211 $data = array( 'has' => array( 'links' => 0 ), 'links' => array() ); 211 $data = array( 212 'has' => array( 'links' => 0 ), 213 'links' => array(), 214 ); 212 215 213 216 // Matches: href="text" and href='text'. … … 269 272 */ 270 273 protected function extract_mentions( $richtext, $plaintext, $extra_args = array() ) { 271 $data = array( 'has' => array( 'mentions' => 0 ), 'mentions' => array() ); 274 $data = array( 275 'has' => array( 'mentions' => 0 ), 276 'mentions' => array(), 277 ); 272 278 $mentions = array(); 273 279 … … 279 285 } 280 286 281 // If the Activity component is disabled, instead do a basic parse. 282 } else { 283 if ( strpos( $plaintext, '@' ) !== false ) { 287 // If the Activity component is disabled, instead do a basic parse. 288 } elseif ( strpos( $plaintext, '@' ) !== false ) { 284 289 preg_match_all( '/[@]+([A-Za-z0-9-_\.@]+)\b/', $plaintext, $matches ); 285 290 286 if ( ! empty( $matches[1] ) ) { 287 $mentions = array_unique( array_map( 'strtolower', $matches[1] ) ); 288 } 291 if ( ! empty( $matches[1] ) ) { 292 $mentions = array_unique( array_map( 'strtolower', $matches[1] ) ); 289 293 } 290 294 } … … 343 347 */ 344 348 protected function extract_images( $richtext, $plaintext, $extra_args = array() ) { 345 $media = array( 'has' => array( 'images' => 0 ), 'images' => array() ); 349 $media = array( 350 'has' => array( 'images' => 0 ), 351 'images' => array(), 352 ); 346 353 347 354 $featured_image = $this->extract_images_from_featured_images( $richtext, $plaintext, $extra_args ); 348 355 $galleries = $this->extract_images_from_galleries( $richtext, $plaintext, $extra_args ); 349 350 356 351 357 // `<img src>` tags. … … 421 427 $media['has']['images'] = count( $media['images'] ); 422 428 423 424 429 /** 425 430 * Filters images extracted from text. … … 461 466 */ 462 467 protected function extract_shortcodes( $richtext, $plaintext, $extra_args = array() ) { 463 $data = array( 'has' => array( 'shortcodes' => 0 ), 'shortcodes' => array() ); 468 $data = array( 469 'has' => array( 'shortcodes' => 0 ), 470 'shortcodes' => array(), 471 ); 464 472 465 473 // Match any registered WordPress shortcodes. … … 519 527 */ 520 528 protected function extract_embeds( $richtext, $plaintext, $extra_args = array() ) { 521 $data = array( 'has' => array( 'embeds' => 0 ), 'embeds' => array() ); 529 $data = array( 530 'has' => array( 'embeds' => 0 ), 531 'embeds' => array(), 532 ); 522 533 523 534 if ( ! function_exists( '_wp_oembed_get_object' ) ) { 524 require( ABSPATH . WPINC . '/class-oembed.php' ); 525 } 526 535 require ABSPATH . WPINC . '/class-oembed.php'; 536 } 527 537 528 538 // Matches any links on their own lines. They may be oEmbeds. … … 599 609 */ 600 610 protected function extract_audio( $richtext, $plaintext, $extra_args = array() ) { 601 $data = array( 'has' => array( 'audio' => 0 ), 'audio' => array() ); 611 $data = array( 612 'has' => array( 'audio' => 0 ), 613 'audio' => array(), 614 ); 602 615 $audios = $this->extract_shortcodes( $richtext, $plaintext, $extra_args ); 603 616 $links = $this->extract_links( $richtext, $plaintext, $extra_args ); 604 617 605 618 $audio_types = wp_get_audio_extensions(); 606 607 619 608 620 // [audio] … … 695 707 */ 696 708 protected function extract_video( $richtext, $plaintext, $extra_args = array() ) { 697 $data = array( 'has' => array( 'videos' => 0 ), 'videos' => array() ); 709 $data = array( 710 'has' => array( 'videos' => 0 ), 711 'videos' => array(), 712 ); 698 713 $videos = $this->extract_shortcodes( $richtext, $plaintext, $extra_args ); 699 714 700 715 $video_types = wp_get_video_extensions(); 701 716 702 703 // [video] 717 // [video]. 704 718 $videos = wp_list_filter( $videos['shortcodes'], array( 'type' => 'video' ) ); 705 719 foreach ( $videos as $video ) { … … 787 801 $image_size = $extra_args['width']; // E.g. "thumb", "medium". 788 802 } 789 790 803 } else { 791 804 $image_size = 'full'; … … 807 820 $images = wp_parse_id_list( $gallery['ids'] ); 808 821 809 // Gallery post_parent variant.822 // Gallery post_parent variant. 810 823 } elseif ( isset( $extra_args['post'] ) ) { 811 824 $images = wp_parse_id_list( 812 get_children( array( 813 'fields' => 'ids', 814 'order' => 'ASC', 815 'orderby' => 'menu_order ID', 816 'post_mime_type' => 'image', 817 'post_parent' => $extra_args['post']->ID, 818 'post_status' => 'inherit', 819 'post_type' => 'attachment', 820 ) ) 825 get_children( 826 array( 827 'fields' => 'ids', 828 'order' => 'ASC', 829 'orderby' => 'menu_order ID', 830 'post_mime_type' => 'image', 831 'post_parent' => $extra_args['post']->ID, 832 'post_status' => 'inherit', 833 'post_type' => 'attachment', 834 ) 835 ) 821 836 ); 822 837 } … … 824 839 // Extract the data we need from each image in this gallery. 825 840 foreach ( $images as $image_id ) { 826 $image 841 $image = wp_get_attachment_image_src( $image_id, $image_size ); 827 842 828 843 $image_url = isset( $image[0] ) ? $image[0] : ''; … … 831 846 832 847 $data[] = array( 833 'url' => $image_url,834 'width' => $image_width,835 'height' => $image_height,848 'url' => $image_url, 849 'width' => $image_width, 850 'height' => $image_height, 836 851 837 852 'gallery_id' => 1 + $gallery_id, -
trunk/src/bp-core/classes/class-bp-theme-compat.php
r13890 r13893 104 104 */ 105 105 public function __set( $property, $value ) { 106 return $this->_data[ $property ] = $value; 106 $this->_data[ $property ] = $value; 107 108 return $this->_data[ $property ]; 107 109 } 108 110
Note: See TracChangeset
for help on using the changeset viewer.