| @@ 506-534 (lines=29) @@ | ||
| 503 | * |
|
| 504 | * @return array The arguments for a `get_posts` call. |
|
| 505 | */ |
|
| 506 | public static function add_criterias( $args ) { |
|
| 507 | ||
| 508 | // Build an optimal tax-query. |
|
| 509 | $tax_query = array( |
|
| 510 | 'relation' => 'AND', |
|
| 511 | array( |
|
| 512 | 'taxonomy' => Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, |
|
| 513 | 'operator' => 'EXISTS', |
|
| 514 | ), |
|
| 515 | array( |
|
| 516 | 'taxonomy' => Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, |
|
| 517 | 'field' => 'slug', |
|
| 518 | 'terms' => 'article', |
|
| 519 | 'operator' => 'NOT IN', |
|
| 520 | ), |
|
| 521 | ); |
|
| 522 | ||
| 523 | return $args + array( |
|
| 524 | 'post_type' => Wordlift_Entity_Service::valid_entity_post_types(), |
|
| 525 | // Since 3.17.0: should this be faster? |
|
| 526 | 'tax_query' => $tax_query, |
|
| 527 | // 'tax_query' => array( |
|
| 528 | // array( |
|
| 529 | // 'taxonomy' => Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, |
|
| 530 | // 'terms' => self::get_entity_terms(), |
|
| 531 | // ), |
|
| 532 | // ), |
|
| 533 | ); |
|
| 534 | } |
|
| 535 | ||
| 536 | // /** |
|
| 537 | // * Get the entity terms IDs which represent an entity. |
|
| @@ 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. |
|