# post-carousel/2.2.10/admin/views/sp-framework/fields/icon/icon.php

Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog &amp; News, version 2.2.10. 45 lines.

- Page: https://pluginprobe.com/plugins/post-carousel/2.2.10/code/admin/views/sp-framework/fields/icon/icon.php
- Raw: https://pluginprobe.com/plugins/post-carousel/2.2.10/raw/admin/views/sp-framework/fields/icon/icon.php
- Modified: 2021-06-04T12:58:50+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/post-carousel/2.2.10/code/admin/views/sp-framework/fields/icon/icon.php#L10-L20`.

```php
<?php if ( ! defined( 'ABSPATH' ) ) {
	die; } // Cannot access directly.
/**
 *
 * Field: icon
 *
 * @since 1.0.0
 * @version 1.0.0
 */
if ( ! class_exists( 'SP_PC_Field_icon' ) ) {
	class SP_PC_Field_icon extends SP_PC_Fields {

		public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
			parent::__construct( $field, $value, $unique, $where, $parent );
		}

		public function render() {

			$args = wp_parse_args(
				$this->field,
				array(
					'button_title' => esc_html__( 'Add Icon', 'smart-post-show' ),
					'remove_title' => esc_html__( 'Remove Icon', 'smart-post-show' ),
				)
			);

			echo $this->field_before();

			$nonce  = wp_create_nonce( 'spf_icon_nonce' );
			$hidden = ( empty( $this->value ) ) ? ' hidden' : '';

			echo '<div class="spf-icon-select">';
			echo '<span class="spf-icon-preview' . $hidden . '"><i class="' . $this->value . '"></i></span>';
			echo '<a href="#" class="button button-primary spf-icon-add" data-nonce="' . $nonce . '">' . $args['button_title'] . '</a>';
			echo '<a href="#" class="button spf-warning-primary spf-icon-remove' . $hidden . '">' . $args['remove_title'] . '</a>';
			echo '<input type="text" name="' . $this->field_name() . '" value="' . $this->value . '" class="spf-icon-value"' . $this->field_attributes() . ' />';
			echo '</div>';

			echo $this->field_after();

		}

	}
}

```
