Pods::process_magic_tags PHP Method

process_magic_tags() private method

Replace magic tags with their values
Since: 2.0.2
private process_magic_tags ( string $tag ) : string
$tag string The magic tag to process
return string Code with Magic Tags evaluated
    private function process_magic_tags($tag)
    {
        if (is_array($tag)) {
            if (!isset($tag[2]) && strlen(trim($tag[2])) < 1) {
                return '';
            }
            $tag = $tag[2];
        }
        $tag = trim($tag, ' {@}');
        $tag = explode(',', $tag);
        if (empty($tag) || !isset($tag[0]) || strlen(trim($tag[0])) < 1) {
            return '';
        }
        foreach ($tag as $k => $v) {
            $tag[$k] = trim($v);
        }
        $field_name = $tag[0];
        $helper_name = $before = $after = '';
        if (isset($tag[1]) && !empty($tag[1])) {
            $value = $this->field($field_name);
            $helper_name = $tag[1];
            $value = $this->helper($helper_name, $value, $field_name);
        } else {
            $value = $this->display($field_name);
        }
        if (isset($tag[2]) && !empty($tag[2])) {
            $before = $tag[2];
        }
        if (isset($tag[3]) && !empty($tag[3])) {
            $after = $tag[3];
        }
        $value = apply_filters('pods_do_magic_tags', $value, $field_name, $helper_name, $before, $after);
        if (is_array($value)) {
            $value = pods_serial_comma($value, array('field' => $field_name, 'fields' => $this->fields));
        }
        if (null !== $value && false !== $value) {
            return $before . $value . $after;
        }
        return '';
    }