Changeset 14010 for trunk/src/bp-blogs/classes/class-bp-blogs-blog.php
- Timestamp:
- 08/26/2024 11:10:35 PM (3 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-blogs/classes/class-bp-blogs-blog.php
r13902 r14010 49 49 */ 50 50 public function __construct( $id = null ) { 51 if ( ! empty( $id ) ) {51 if ( ! empty( $id ) ) { 52 52 $this->id = (int) $id; 53 53 $this->populate(); … … 71 71 /** 72 72 * Save the BP blog data to the database. 73 * 74 * @global wpdb $wpdb WordPress database object. 73 75 * 74 76 * @return bool … … 109 111 110 112 // Don't try and save if there is no user ID or blog ID set. 111 if ( ! $this->user_id || !$this->blog_id )113 if ( ! $this->user_id || ! $this->blog_id ) { 112 114 return false; 115 } 113 116 114 117 // Don't save if this blog has already been recorded for the user. 115 if ( ! $this->id && $this->exists() )118 if ( ! $this->id && $this->exists() ) { 116 119 return false; 120 } 117 121 118 122 $bp = buddypress(); … … 126 130 } 127 131 128 if ( ! $wpdb->query($sql) )132 if ( ! $wpdb->query( $sql ) ) { 129 133 return false; 134 } 130 135 131 136 /** … … 140 145 do_action_ref_array( 'bp_blogs_blog_after_save', array( &$this ) ); 141 146 142 if ( $this->id ) 147 if ( $this->id ) { 143 148 return $this->id; 144 else 145 return $wpdb->insert_id; 149 } 150 151 return $wpdb->insert_id; 146 152 } 147 153 … … 149 155 * Check whether an association between this user and this blog exists. 150 156 * 151 * @return int $value The number of associations between the user and blog 152 * saved in the blog component tables. 157 * @global wpdb $wpdb WordPress database object. 158 * 159 * @return string|null The number of associations between the user and blog. 153 160 */ 154 161 public function exists() { … … 166 173 * 167 174 * @since 1.2.0 168 * @since 10.0.0 Converted to array as main function argument. Added `$date_query` parameter. 169 * 170 * @param array $data { 175 * @since 10.0.0 Converted to `array` as main function argument. Added `$date_query` parameter. 176 * 177 * @global wpdb $wpdb WordPress database object. 178 * 179 * @param array ...$args { 171 180 * Array of site data to query for. 181 * 172 182 * @type string $type The order in which results should be returned. 173 183 * 'active', 'alphabetical', 'newest', or 'random'. … … 184 194 * @type array|bool $include_blog_ids Optional. Array of blog IDs to include. 185 195 * @type array $date_query Optional. Filter results by site last activity date. See first 186 * param ter of {@link WP_Date_Query::__construct()} for syntax. Only187 * applicable if $typeis either 'newest' or 'active'.196 * parameter of {@link WP_Date_Query::__construct()} for syntax. Only 197 * applicable if `$type` is either 'newest' or 'active'. 188 198 * } 189 199 * @return array Multidimensional results array, structured as follows: … … 194 204 global $wpdb; 195 205 196 $bp = buddypress();197 198 206 // Backward compatibility with old method of passing arguments. 199 207 if ( ! is_array( $args[0] ) || count( $args ) > 1 ) { 200 _deprecated_argument( __METHOD__, '10.0.0', sprintf( esc_html__( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ), __METHOD__, __FILE__ ) ); 201 202 $old_args_keys = [ 203 0 => 'type', 204 1 => 'per_page', 205 2 => 'page', 206 3 => 'user_id', 207 4 => 'search_terms', 208 5 => 'update_meta_cache', 209 6 => 'include_blog_ids', 210 ]; 208 _deprecated_argument( 209 __METHOD__, 210 '10.0.0', 211 sprintf( 212 // translators: 1: the name of the method. 2: the name of the file. 213 esc_html__( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ), 214 __METHOD__, 215 __FILE__ 216 ) 217 ); 218 219 $old_args_keys = array( 220 0 => 'type', 221 1 => 'per_page', 222 2 => 'page', 223 3 => 'user_id', 224 4 => 'search_terms', 225 5 => 'update_meta_cache', 226 6 => 'include_blog_ids', 227 ); 211 228 212 229 $args = bp_core_parse_args_array( $old_args_keys, $args ); … … 215 232 } 216 233 217 $r = wp_parse_args( 234 $bp = buddypress(); 235 $r = wp_parse_args( 218 236 $args, 219 237 array( … … 230 248 231 249 if ( ! is_user_logged_in() || ( ! bp_current_user_can( 'bp_moderate' ) && ( $r['user_id'] != bp_loggedin_user_id() ) ) ) { 232 $hidden_sql = "AND wb.public = 1";250 $hidden_sql = 'AND wb.public = 1'; 233 251 } else { 234 252 $hidden_sql = ''; 235 253 } 236 254 237 $pag_sql = ( $r['per_page'] && $r['page'] ) ? $wpdb->prepare( " LIMIT %d, %d", intval( ( $r['page'] - 1 ) * $r['per_page']), intval( $r['per_page'] ) ) : '';238 239 $user_sql = ! empty( $r['user_id'] ) ? $wpdb->prepare( " AND b.user_id = %d", $r['user_id'] ) : '';255 $pag_sql = ( $r['per_page'] && $r['page'] ) ? $wpdb->prepare( ' LIMIT %d, %d', intval( ( $r['page'] - 1 ) * $r['per_page'] ), intval( $r['per_page'] ) ) : ''; 256 257 $user_sql = ! empty( $r['user_id'] ) ? $wpdb->prepare( ' AND b.user_id = %d', $r['user_id'] ) : ''; 240 258 241 259 $date_query_sql = ''; 242 260 243 261 switch ( $r['type'] ) { 244 case 'active': default: 262 case 'active': 263 default: 245 264 $date_query_sql = BP_Date_Query::get_where_sql( $r['date_query'], 'bm.meta_value', true ); 246 $order_sql = "ORDER BY bm.meta_value DESC";265 $order_sql = 'ORDER BY bm.meta_value DESC'; 247 266 break; 248 267 case 'alphabetical': 249 $order_sql = "ORDER BY bm_name.meta_value ASC";268 $order_sql = 'ORDER BY bm_name.meta_value ASC'; 250 269 break; 251 270 case 'newest': 252 271 $date_query_sql = BP_Date_Query::get_where_sql( $r['date_query'], 'wb.registered', true ); 253 $order_sql = "ORDER BY wb.registered DESC";272 $order_sql = 'ORDER BY wb.registered DESC'; 254 273 break; 255 274 case 'random': 256 $order_sql = "ORDER BY RAND()";275 $order_sql = 'ORDER BY RAND()'; 257 276 break; 258 277 } 259 278 260 $include_sql = '';279 $include_sql = ''; 261 280 $include_blog_ids = array_filter( wp_parse_id_list( $r['include_blog_ids'] ) ); 262 281 if ( ! empty( $include_blog_ids ) ) { … … 278 297 } 279 298 280 $paged_blogs = $wpdb->get_results( " 299 $paged_blogs = $wpdb->get_results( 300 " 281 301 SELECT b.blog_id, b.user_id as admin_user_id, u.user_email as admin_user_email, wb.domain, wb.path, bm.meta_value as last_activity, bm_name.meta_value as name 282 302 FROM … … 292 312 {$search_terms_sql} {$user_sql} {$include_sql} {$date_query_sql} 293 313 GROUP BY b.blog_id {$order_sql} {$pag_sql} 294 " ); 295 296 $total_blogs = $wpdb->get_var( " 314 " 315 ); 316 317 $total_blogs = $wpdb->get_var( 318 " 297 319 SELECT COUNT(DISTINCT b.blog_id) 298 320 FROM … … 306 328 AND bm.meta_key = 'last_activity' AND bm_name.meta_key = 'name' 307 329 {$search_terms_sql} {$user_sql} {$include_sql} {$date_query_sql} 308 " ); 330 " 331 ); 309 332 310 333 $blog_ids = array(); … … 313 336 } 314 337 315 $paged_blogs = BP_Blogs_Blog::get_blog_extras( $paged_blogs, $blog_ids, $r['type'] );338 $paged_blogs = self::get_blog_extras( $paged_blogs, $blog_ids, $r['type'] ); 316 339 317 340 // Integer casting. … … 325 348 } 326 349 327 return array( 'blogs' => $paged_blogs, 'total' => $total_blogs ); 350 return array( 351 'blogs' => $paged_blogs, 352 'total' => $total_blogs, 353 ); 328 354 } 329 355 330 356 /** 331 357 * Delete the record of a given blog for all users. 358 * 359 * @global wpdb $wpdb WordPress database object. 332 360 * 333 361 * @param int $blog_id The blog being removed from all users. … … 346 374 /** 347 375 * Delete the record of a given blog for a specific user. 376 * 377 * @global wpdb $wpdb WordPress database object. 348 378 * 349 379 * @param int $blog_id The blog being removed. … … 355 385 global $wpdb; 356 386 357 if ( ! $user_id )387 if ( ! $user_id ) { 358 388 $user_id = bp_loggedin_user_id(); 389 } 359 390 360 391 $bp = buddypress(); … … 365 396 /** 366 397 * Delete all of a user's blog associations in the BP tables. 398 * 399 * @global wpdb $wpdb WordPress database object. 367 400 * 368 401 * @param int|null $user_id Optional. The ID of the user whose blog associations … … 373 406 global $wpdb; 374 407 375 if ( ! $user_id )408 if ( ! $user_id ) { 376 409 $user_id = bp_loggedin_user_id(); 410 } 377 411 378 412 $bp = buddypress(); … … 388 422 * blogs that have been recorded by BuddyPress, while the WP function 389 423 * does a true query of a user's blog capabilities. 424 * 425 * @global wpdb $wpdb WordPress database object. 390 426 * 391 427 * @param int $user_id Optional. ID of the user whose blogs are being … … 402 438 $bp = buddypress(); 403 439 404 if ( ! $user_id )440 if ( ! $user_id ) { 405 441 $user_id = bp_displayed_user_id(); 442 } 406 443 407 444 // Show logged in users their hidden blogs. 408 if ( ! bp_is_my_profile() && !$show_hidden )445 if ( ! bp_is_my_profile() && ! $show_hidden ) { 409 446 $blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT b.blog_id, b.id, bm1.meta_value as name, wb.domain, wb.path FROM {$bp->blogs->table_name} b, {$wpdb->base_prefix}blogs wb, {$bp->blogs->table_name_blogmeta} bm1 WHERE b.blog_id = wb.blog_id AND b.blog_id = bm1.blog_id AND bm1.meta_key = 'name' AND wb.public = 1 AND wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND b.user_id = %d ORDER BY b.blog_id", $user_id ) ); 410 else447 } else { 411 448 $blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT b.blog_id, b.id, bm1.meta_value as name, wb.domain, wb.path FROM {$bp->blogs->table_name} b, {$wpdb->base_prefix}blogs wb, {$bp->blogs->table_name_blogmeta} bm1 WHERE b.blog_id = wb.blog_id AND b.blog_id = bm1.blog_id AND bm1.meta_key = 'name' AND wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND b.user_id = %d ORDER BY b.blog_id", $user_id ) ); 412 413 $total_blog_count = BP_Blogs_Blog::total_blog_count_for_user( $user_id ); 449 } 450 451 $total_blog_count = self::total_blog_count_for_user( $user_id ); 414 452 415 453 $user_blogs = array(); 416 454 foreach ( (array) $blogs as $blog ) { 417 $user_blogs[$blog->blog_id] = new stdClass; 418 $user_blogs[$blog->blog_id]->id = (int) $blog->id; 419 $user_blogs[$blog->blog_id]->blog_id = (int) $blog->blog_id; 420 $user_blogs[$blog->blog_id]->siteurl = ( is_ssl() ) ? 'https://' . $blog->domain . $blog->path : 'http://' . $blog->domain . $blog->path; 421 $user_blogs[$blog->blog_id]->name = $blog->name; 422 } 423 424 return array( 'blogs' => $user_blogs, 'count' => $total_blog_count ); 455 $user_blogs[ $blog->blog_id ] = new stdClass(); 456 $user_blogs[ $blog->blog_id ]->id = (int) $blog->id; 457 $user_blogs[ $blog->blog_id ]->blog_id = (int) $blog->blog_id; 458 $user_blogs[ $blog->blog_id ]->siteurl = ( is_ssl() ) ? 'https://' . $blog->domain . $blog->path : 'http://' . $blog->domain . $blog->path; 459 $user_blogs[ $blog->blog_id ]->name = $blog->name; 460 } 461 462 return array( 463 'blogs' => $user_blogs, 464 'count' => $total_blog_count, 465 ); 425 466 } 426 467 … … 429 470 * 430 471 * This method always includes hidden blogs. 472 * 473 * @global wpdb $wpdb WordPress database object. 431 474 * 432 475 * @param int $user_id Optional. ID of the user whose blogs are being 433 476 * queried. Defaults to logged-in user. 434 * @return int The number of blogs associated with the user.477 * @return int[] 435 478 */ 436 479 public static function get_blog_ids_for_user( $user_id = 0 ) { … … 439 482 $bp = buddypress(); 440 483 441 if ( ! $user_id )484 if ( ! $user_id ) { 442 485 $user_id = bp_displayed_user_id(); 443 444 return array_map( 'intval', $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM {$bp->blogs->table_name} WHERE user_id = %d", $user_id ) ) ); 486 } 487 488 $blog_ids = $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM {$bp->blogs->table_name} WHERE user_id = %d", $user_id ) ); 489 490 return wp_parse_id_list( $blog_ids ); 445 491 } 446 492 447 493 /** 448 494 * Check whether a blog has been recorded by BuddyPress. 495 * 496 * @global wpdb $wpdb WordPress database object. 449 497 * 450 498 * @param int $blog_id ID of the blog being queried. … … 469 517 * cap. 470 518 * 519 * @global wpdb $wpdb WordPress database object. 520 * 471 521 * @param int|null $user_id Optional. ID of the user whose blogs are being 472 522 * queried. Defaults to logged-in user. 473 * @return intBlog count for the user.523 * @return string|null Blog count for the user. 474 524 */ 475 525 public static function total_blog_count_for_user( $user_id = null ) { … … 478 528 $bp = buddypress(); 479 529 480 if ( ! $user_id )530 if ( ! $user_id ) { 481 531 $user_id = bp_displayed_user_id(); 532 } 482 533 483 534 // If the user is logged in return the blog count including their hidden blogs. 484 if ( ( is_user_logged_in() && $user_id == bp_loggedin_user_id() ) || bp_current_user_can( 'bp_moderate' ) ) {535 if ( ( is_user_logged_in() && $user_id === bp_loggedin_user_id() ) || bp_current_user_can( 'bp_moderate' ) ) { 485 536 return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT b.blog_id) FROM {$bp->blogs->table_name} b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND user_id = %d", $user_id ) ); 486 } else {487 return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT b.blog_id) FROM {$bp->blogs->table_name} b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.public = 1 AND wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND user_id = %d", $user_id ) ); 488 }537 } 538 539 return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT b.blog_id) FROM {$bp->blogs->table_name} b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.public = 1 AND wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND user_id = %d", $user_id ) ); 489 540 } 490 541 … … 494 545 * Matches against blog names and descriptions, as stored in the BP 495 546 * blogmeta table. 547 * 548 * @global wpdb $wpdb WordPress database object. 496 549 * 497 550 * @param string $filter The search term. … … 511 564 512 565 $hidden_sql = ''; 513 if ( !bp_current_user_can( 'bp_moderate' ) ) 514 $hidden_sql = "AND wb.public = 1"; 566 if ( ! bp_current_user_can( 'bp_moderate' ) ) { 567 $hidden_sql = 'AND wb.public = 1'; 568 } 515 569 516 570 $pag_sql = ''; 517 571 if ( $limit && $page ) { 518 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );572 $pag_sql = $wpdb->prepare( ' LIMIT %d, %d', intval( ( $page - 1 ) * $limit ), intval( $limit ) ); 519 573 } 520 574 … … 529 583 } 530 584 531 return array( 'blogs' => $paged_blogs, 'total' => (int) $total_blogs ); 585 return array( 586 'blogs' => $paged_blogs, 587 'total' => (int) $total_blogs, 588 ); 532 589 } 533 590 … … 537 594 * Query will include hidden blogs if the logged-in user has the 538 595 * 'bp_moderate' cap. 596 * 597 * @global wpdb $wpdb WordPress database object. 539 598 * 540 599 * @param int|null $limit Optional. The maximum number of items to return. … … 551 610 $bp = buddypress(); 552 611 553 $hidden_sql = ! bp_current_user_can( 'bp_moderate' ) ? "AND wb.public = 1": '';554 $pag_sql = ( $limit && $page ) ? $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ) : '';612 $hidden_sql = ! bp_current_user_can( 'bp_moderate' ) ? 'AND wb.public = 1' : ''; 613 $pag_sql = ( $limit && $page ) ? $wpdb->prepare( ' LIMIT %d, %d', intval( ( $page - 1 ) * $limit ), intval( $limit ) ) : ''; 555 614 556 615 $paged_blogs = $wpdb->get_results( "SELECT DISTINCT b.blog_id FROM {$bp->blogs->table_name} b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 {$hidden_sql} {$pag_sql}" ); … … 562 621 } 563 622 564 return array( 'blogs' => $paged_blogs, 'total' => (int) $total_blogs ); 623 return array( 624 'blogs' => $paged_blogs, 625 'total' => (int) $total_blogs, 626 ); 565 627 } 566 628 … … 570 632 * Query will include hidden blogs if the logged-in user has the 571 633 * 'bp_moderate' cap. 634 * 635 * @global wpdb $wpdb WordPress database object. 572 636 * 573 637 * @param string $letter The letter you're looking for. … … 589 653 590 654 $hidden_sql = ''; 591 if ( !bp_current_user_can( 'bp_moderate' ) ) 592 $hidden_sql = "AND wb.public = 1"; 655 if ( ! bp_current_user_can( 'bp_moderate' ) ) { 656 $hidden_sql = 'AND wb.public = 1'; 657 } 593 658 594 659 $pag_sql = ''; 595 if ( $limit && $page ) 596 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 660 if ( $limit && $page ) { 661 $pag_sql = $wpdb->prepare( ' LIMIT %d, %d', intval( ( $page - 1 ) * $limit ), intval( $limit ) ); 662 } 597 663 598 664 $paged_blogs = $wpdb->get_results( "SELECT DISTINCT bm.blog_id FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE bm.meta_key = 'name' AND {$letter_sql} {$hidden_sql} AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY bm.meta_value ASC{$pag_sql}" ); … … 604 670 } 605 671 606 return array( 'blogs' => $paged_blogs, 'total' => (int) $total_blogs ); 672 return array( 673 'blogs' => $paged_blogs, 674 'total' => (int) $total_blogs, 675 ); 607 676 } 608 677 … … 616 685 * - The blog description 617 686 * 687 * @global wpdb $wpdb WordPress database object. 688 * 618 689 * @param array $paged_blogs Array of results from the original query. 619 690 * @param array $blog_ids Array of IDs returned from the original query. … … 626 697 $bp = buddypress(); 627 698 628 if ( empty( $blog_ids ) ) 699 if ( empty( $blog_ids ) ) { 629 700 return $paged_blogs; 701 } 630 702 631 703 $blog_ids = implode( ',', wp_parse_id_list( $blog_ids ) ); 632 704 633 705 for ( $i = 0, $count = count( $paged_blogs ); $i < $count; ++$i ) { 634 $blog_prefix = $wpdb->get_blog_prefix( $paged_blogs[$i]->blog_id );635 $paged_blogs[ $i]->latest_post = $wpdb->get_row( "SELECT ID, post_content, post_title, post_excerpt, guid FROM {$blog_prefix}posts WHERE post_status = 'publish' AND post_type = 'post' AND id != 1 ORDER BY id DESC LIMIT 1" );706 $blog_prefix = $wpdb->get_blog_prefix( $paged_blogs[ $i ]->blog_id ); 707 $paged_blogs[ $i ]->latest_post = $wpdb->get_row( "SELECT ID, post_content, post_title, post_excerpt, guid FROM {$blog_prefix}posts WHERE post_status = 'publish' AND post_type = 'post' AND id != 1 ORDER BY id DESC LIMIT 1" ); 636 708 637 709 /** … … 649 721 650 722 // Add URLs to any Featured Image this post might have. 651 if ( ! empty( $paged_blogs[ $i]->latest_post ) && has_post_thumbnail( $paged_blogs[$i]->latest_post->ID ) ) {723 if ( ! empty( $paged_blogs[ $i ]->latest_post ) && has_post_thumbnail( $paged_blogs[ $i ]->latest_post->ID ) ) { 652 724 653 725 // Grab 4 sizes of the image. Thumbnail. 654 $image = wp_get_attachment_image_src( get_post_thumbnail_id( $paged_blogs[ $i]->latest_post->ID ), 'thumbnail', false );655 if ( ! empty( $image ) ) 726 $image = wp_get_attachment_image_src( get_post_thumbnail_id( $paged_blogs[ $i ]->latest_post->ID ), 'thumbnail', false ); 727 if ( ! empty( $image ) ) { 656 728 $images['thumbnail'] = $image[0]; 729 } 657 730 658 731 // Medium. 659 $image = wp_get_attachment_image_src( get_post_thumbnail_id( $paged_blogs[ $i]->latest_post->ID ), 'medium', false );660 if ( ! empty( $image ) ) 732 $image = wp_get_attachment_image_src( get_post_thumbnail_id( $paged_blogs[ $i ]->latest_post->ID ), 'medium', false ); 733 if ( ! empty( $image ) ) { 661 734 $images['medium'] = $image[0]; 735 } 662 736 663 737 // Large. 664 $image = wp_get_attachment_image_src( get_post_thumbnail_id( $paged_blogs[ $i]->latest_post->ID ), 'large', false );665 if ( ! empty( $image ) ) 738 $image = wp_get_attachment_image_src( get_post_thumbnail_id( $paged_blogs[ $i ]->latest_post->ID ), 'large', false ); 739 if ( ! empty( $image ) ) { 666 740 $images['large'] = $image[0]; 741 } 667 742 668 743 // Post thumbnail. 669 $image = wp_get_attachment_image_src( get_post_thumbnail_id( $paged_blogs[ $i]->latest_post->ID ), 'post-thumbnail', false );670 if ( ! empty( $image ) ) 744 $image = wp_get_attachment_image_src( get_post_thumbnail_id( $paged_blogs[ $i ]->latest_post->ID ), 'post-thumbnail', false ); 745 if ( ! empty( $image ) ) { 671 746 $images['post-thumbnail'] = $image[0]; 747 } 672 748 673 749 // Add the images to the latest_post object. 674 $paged_blogs[ $i]->latest_post->images = $images;750 $paged_blogs[ $i ]->latest_post->images = $images; 675 751 } 676 752 … … 684 760 for ( $i = 0, $count = count( $paged_blogs ); $i < $count; ++$i ) { 685 761 foreach ( (array) $blog_descs as $desc ) { 686 if ( $desc->blog_id == $paged_blogs[$i]->blog_id ) 687 $paged_blogs[$i]->description = $desc->description; 762 if ( $desc->blog_id === $paged_blogs[ $i ]->blog_id ) { 763 $paged_blogs[ $i ]->description = $desc->description; 764 } 688 765 } 689 766 } … … 696 773 * 697 774 * Checks the 'public' column in the wp_blogs table. 775 * 776 * @global wpdb $wpdb WordPress database object. 698 777 * 699 778 * @param int $blog_id The ID of the blog being checked. … … 703 782 global $wpdb; 704 783 705 if ( ! (int) $wpdb->get_var( $wpdb->prepare( "SELECT public FROM {$wpdb->base_prefix}blogs WHERE blog_id = %d", $blog_id ) ) ) {784 if ( ! (int) $wpdb->get_var( $wpdb->prepare( "SELECT public FROM {$wpdb->base_prefix}blogs WHERE blog_id = %d", $blog_id ) ) ) { 706 785 return true; 707 786 } … … 712 791 /** 713 792 * Get ID of user-blog link. 793 * 794 * @global wpdb $wpdb WordPress database object. 714 795 * 715 796 * @param int $user_id ID of user. … … 725 806 726 807 if ( empty( $user_blog ) ) { 727 $user_blog = false; 728 } else { 729 $user_blog = intval( $user_blog ); 730 } 731 732 return $user_blog; 808 return false; 809 } 810 811 return intval( $user_blog ); 733 812 } 734 813 }
Note: See TracChangeset
for help on using the changeset viewer.