<?php

    namespace Pixebuilder\Element;
    
    // prevent direct file access
	if( !defined( 'ABSPATH' ) ) exit;

    class Post_ID extends Item{

        static function get_type(){
            return 'post';
        }

        static function get_name(){
            return 'post-id';
        }

        static function get_title(){
            return esc_html__('Post ID', 'pixebuilder');
        }

        static function get_icon(){
            return 'content';
        }
        
        static function render_content($settings){
            
            // get variables
            $tag = empty($settings['text-tag'])? 'div': $settings['text-tag'];

            $atts = array();
            if( !empty($settings['text-typo']['preset']) ){
                $atts['typo-preset'] = $settings['text-typo']['preset'];
            }

            // print
            $ret = '';
            $post_id = get_the_ID();

            if( !empty($post_id) ){
                $ret .= '<' . $tag . ' class="pixe-text" ';
                $ret .= pixe_get_data_atts($atts);
                $ret .= '>' . $post_id . '</' . $tag . '>';
            }

            return $ret;
        }

    }

    \Pixe_Builder::register_element('Pixebuilder\Element\Post_ID');
    