<?php
namespace ThemeAtelier\EventfulForElementor\Admin\Widgets\Options;

class EventfulForElementorUtlitiesFunctions
{
    public static function include_only_post()
    {


        $args = array(
            'post_type' => 'tribe_events',
            'posts_per_page' => -1,
        );
        $posts = get_posts($args);
        $options = array();
        foreach ($posts as $post) {
            $options[$post->ID] = $post->post_title;
        }
        return $options;
    }

    public static function get_post_type_taxonomies($post_type)
    {
        $taxonomies = get_object_taxonomies($post_type, 'objects');
        $taxonomy_names = array();
        foreach ($taxonomies as $taxonomy) {
            $taxonomy_names[$taxonomy->name] = $taxonomy->name;
        }
        return $taxonomy_names;
    }

    public static function ppfe_get_all_post_categories($post_type)
    {
        $options = array();
        $taxonomy = 'category';
        if (!empty($taxonomy)) {
            // Get categories for post type.
            $terms = get_terms(
                array(
                    'taxonomy'   => $taxonomy,
                    'hide_empty' => false,
                )
            );
            if (!empty($terms)) {
                foreach ($terms as $term) {
                    if (isset($term)) {
                        if (isset($term->slug) && isset($term->name)) {
                            $options[$term->slug] = $term->name;
                        }
                    }
                }
            }
        }
        return $options;
    }

    public static function get_post_type_author()
    {
        $authors = get_users();
        $author_names = [];
        foreach ($authors as $author) {
            $author_names[$author->ID] = $author->display_name;
        }
        return $author_names;
    }
    public static function get_post_statuses()
    {
        $statuses = get_post_stati(null, 'objects');
        $options = array();
        foreach ($statuses as $status => $object) {
            $options[$status] = ucfirst($object->label);
        }
        return $options;
    }
}
