Carbon_Fields\Field\Relationship_Field::get_options PHP Method

get_options() public method

Generate the item options for the relationship field.
public get_options ( ) : array
return array $options The selectable options of the relationship field.
    public function get_options()
    {
        $options = array();
        /**
         * Filter the default query when fetching posts for a particular field.
         *
         * @param array $args The parameters, passed to get_posts().
         */
        foreach ($this->post_type as $post_type) {
            $filter_name = 'carbon_relationship_options_' . $this->get_name() . '_post_' . $post_type;
            $args = apply_filters($filter_name, array('post_type' => $post_type, 'posts_per_page' => -1, 'fields' => 'ids', 'suppress_filters' => false));
            // fetch and prepare posts as relationship items
            $new_options = get_posts($args);
            foreach ($new_options as &$p) {
                $p = array('id' => $p, 'title' => $this->get_title_by_type($p, 'post', $post_type), 'type' => 'post', 'subtype' => $post_type, 'label' => $this->get_item_label($p, 'post', $post_type), 'is_trashed' => get_post_status($p) == 'trash', 'edit_link' => get_edit_post_link($p));
            }
            $options = array_merge($options, $new_options);
        }
        /**
         * Filter the final list of options, available to a certain relationship field.
         *
         * @param array $options Unfiltered options items.
         * @param string $name Name of the relationship field.
         */
        $options = apply_filters('carbon_relationship_options', $options, $this->get_name());
        return $options;
    }