public function testGetPostTypesLabels() { $postTypesToIndex = Core\FieldsHelper::getPostTypesToIndex(); $postLabels = Core\FieldsHelper::getPostTypesLabels($postTypesToIndex); $type = 'post'; $postType = get_post_type_object($type); $this->assertEquals($postType->labels->name, $postLabels[$type]); $type = 'page'; $postType = get_post_type_object($type); $this->assertEquals($postType->labels->name, $postLabels[$type]); }
public function testGetTotalPublishedPosts() { $result = Settings::getTotalPublishedPosts(); $postsTypesToIndex = array_keys(Core\FieldsHelper::getPostTypesToIndex()); $totals = array(); foreach ($postsTypesToIndex as $type) { $countByType = wp_count_posts($type); $totals[$type] = 0; foreach ($countByType as $postStatus => $count) { if ('publish' === $postStatus) { $totals[$type] += $count; } } $this->assertEquals($result[$type], $totals[$type]); } }
public static function getTotalPublishedPosts() { $postsTypesToIndex = array_keys(Core\FieldsHelper::getPostTypesToIndex()); $totals = array(); foreach ($postsTypesToIndex as $type) { $countByType = wp_count_posts($type); $totals[$type] = 0; foreach ($countByType as $postStatus => $count) { if ('publish' === $postStatus) { $totals[$type] += $count; } } } return $totals; }