| 375 | | if ( false === ( $is_multi_author = wp_cache_get('is_multi_author', 'posts') ) ) { |
| 376 | | $rows = (array) $wpdb->get_col("SELECT DISTINCT post_author FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' LIMIT 2"); |
| 377 | | $is_multi_author = 1 < count( $rows ) ? 1 : 0; |
| 378 | | wp_cache_set('is_multi_author', $is_multi_author, 'posts'); |
| | 375 | $args = wp_parse_args( $args, array( |
| | 376 | 'post_type' => 'post', |
| | 377 | 'post_status' => 'publish', |
| | 378 | )); |
| | 379 | |
| | 380 | if ( 'any' == strtolower( $args['post_type'] ) ) |
| | 381 | $args['post_type'] = false; |
| | 382 | |
| | 383 | if ( 'any' == strtolower( $args['post_status'] ) ) |
| | 384 | $args['post_status'] = false; |
| | 385 | |
| | 386 | $args = array_filter( $args ); |
| | 387 | |
| | 388 | // Get the cache key based on $args |
| | 389 | $key = md5( serialize( $args ) ); |
| | 390 | |
| | 391 | // Check for a cached check |
| | 392 | $is_multi_author = wp_cache_get( 'is_multi_author', 'posts' ); |
| | 393 | |
| | 394 | if ( ! is_array( $is_multi_author ) ) |
| | 395 | $is_multi_author = array(); |
| | 396 | |
| | 397 | // If there is no cached check, let's do it |
| | 398 | if ( ! isset( $is_multi_author[$key] ) ) { |
| | 399 | $where = ''; |
| | 400 | |
| | 401 | // If the $args not empty, Build the WHERE string |
| | 402 | if ( ! empty( $args ) ) { |
| | 403 | |
| | 404 | $where = array(); |
| | 405 | |
| | 406 | foreach ( array_keys( $args ) as $key ) |
| | 407 | $where[] = "{$key} = %s"; |
| | 408 | |
| | 409 | $where = $wpdb->prepare( 'WHERE ' . implode( $where, ' AND ' ), array_values( $args ) ); |
| | 410 | |
| | 411 | } // end if |
| | 412 | |
| | 413 | // Do the do |
| | 414 | $rows = (array) $wpdb->get_col( "SELECT DISTINCT post_author FROM $wpdb->posts {$where} LIMIT 2" ); |
| | 415 | $is_multi_author[$key] = ( 1 < count( $rows ) ) ? 1 : 0; |
| | 416 | |
| | 417 | // Cache the check result |
| | 418 | wp_cache_set( 'is_multi_author', $is_multi_author, 'posts' ); |