<?php

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

if ( ! class_exists( 'EDITH_Field_pro_notice' ) ) {
	/**
	 * Extending Edith framework for adding new Pro Notice Field
	 */
	class EDITH_Field_pro_notice extends EDITH_Fields {

		/**
		 * Fields Render
		 *
		 * @return void
		 */
		public function render() {

			$args = wp_parse_args(
				$this->field,
				array(
					'heading'  => '',
					'content'  => '',
					'btn_text' => '',
					'btn_url'  => '',
				)
			);

			echo wp_kses_post( $this->field_before() );

			echo '<div class="edith-pro-notice-wrapper">';

			if ( isset( $this->field['heading'] ) ) {
				printf( '<h3>%s</h3>', esc_html( $this->field['heading'] ) );
			}

			if ( isset( $this->field['content'] ) ) {
				echo wp_kses_post( wpautop( $this->field['content'] ) );
			}

			if ( isset( $this->field['btn_text'] ) && isset( $this->field['btn_url'] ) ) {
				printf( '<a class="button button-primary" href="%s" target="_blank">%s</a>', esc_url( $this->field['btn_url'] ), esc_html( $this->field['btn_text'] ) );
			}

			echo '</div>';

			echo wp_kses_post( $this->field_after() );
		}
	}
}
