| @@ 28-50 (lines=23) @@ | ||
| 25 | * |
|
| 26 | * @return int The number of potential publishers. |
|
| 27 | */ |
|
| 28 | public function count() { |
|
| 29 | ||
| 30 | // Search for entities which are either a Person |
|
| 31 | // or Organization. |
|
| 32 | ||
| 33 | // Get only the ids as all we need is the count. |
|
| 34 | $entities = get_posts( array( |
|
| 35 | 'post_type' => Wordlift_Entity_Service::valid_entity_post_types(), |
|
| 36 | 'post_status' => 'publish', |
|
| 37 | 'posts_per_page' => - 1, |
|
| 38 | 'tax_query' => array( |
|
| 39 | array( |
|
| 40 | 'taxonomy' => Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, |
|
| 41 | 'field' => 'slug', |
|
| 42 | 'terms' => array( 'organization', 'person' ), |
|
| 43 | ), |
|
| 44 | ), |
|
| 45 | 'fields' => 'ids', |
|
| 46 | ) ); |
|
| 47 | ||
| 48 | // Finally return the count. |
|
| 49 | return count( $entities ); |
|
| 50 | } |
|
| 51 | ||
| 52 | /** |
|
| 53 | * Search SQL filter for matching against post title only. |
|
| @@ 436-464 (lines=29) @@ | ||
| 433 | * |
|
| 434 | * @return array The arguments for a `get_posts` call. |
|
| 435 | */ |
|
| 436 | public static function add_criterias( $args ) { |
|
| 437 | ||
| 438 | // Build an optimal tax-query. |
|
| 439 | $tax_query = array( |
|
| 440 | 'relation' => 'AND', |
|
| 441 | array( |
|
| 442 | 'taxonomy' => Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, |
|
| 443 | 'operator' => 'EXISTS', |
|
| 444 | ), |
|
| 445 | array( |
|
| 446 | 'taxonomy' => Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, |
|
| 447 | 'field' => 'slug', |
|
| 448 | 'terms' => 'article', |
|
| 449 | 'operator' => 'NOT IN', |
|
| 450 | ), |
|
| 451 | ); |
|
| 452 | ||
| 453 | return $args + array( |
|
| 454 | 'post_type' => Wordlift_Entity_Service::valid_entity_post_types(), |
|
| 455 | // Since 3.17.0: should this be faster? |
|
| 456 | 'tax_query' => $tax_query, |
|
| 457 | // 'tax_query' => array( |
|
| 458 | // array( |
|
| 459 | // 'taxonomy' => Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, |
|
| 460 | // 'terms' => self::get_entity_terms(), |
|
| 461 | // ), |
|
| 462 | // ), |
|
| 463 | ); |
|
| 464 | } |
|
| 465 | ||
| 466 | // /** |
|
| 467 | // * Get the entity terms IDs which represent an entity. |
|