Carbon_Fields\Field\Association_Field::get_item_label PHP Метод

get_item_label() публичный Метод

Can be overriden or extended by the carbon_relationship_item_label filter.
public get_item_label ( integer $id, string $type, string $subtype = '' ) : string
$id integer The database ID of the item.
$type string Item type (post, term, user, comment, or a custom one).
$subtype string Subtype - "page", "post", "category", etc.
Результат string $label The label of the item.
    public function get_item_label($id, $type, $subtype = '')
    {
        $label = $subtype ? $subtype : $type;
        if ($type === 'post') {
            $post_type_object = get_post_type_object($subtype);
            $label = $post_type_object->labels->singular_name;
        } elseif ($type === 'term') {
            $taxonomy_object = get_taxonomy($subtype);
            $label = $taxonomy_object->labels->singular_name;
        }
        /**
         * Filter the label of the relationship item.
         *
         * @param string $label   The unfiltered item label.
         * @param string $name    Name of the relationship field.
         * @param int    $id      The database ID of the item.
         * @param string $type    Item type (post, term, user, comment, or a custom one).
         * @param string $subtype Subtype - "page", "post", "category", etc.
         */
        return apply_filters('carbon_relationship_item_label', $label, $this->get_name(), $id, $type, $subtype);
    }