| 1 |
<?php if ( ! defined( 'ABSPATH' ) ) { |
| 2 |
die; } // Cannot access directly. |
| 3 |
/** |
| 4 |
* |
| 5 |
* Field: icon |
| 6 |
* |
| 7 |
* @since 1.0.0 |
| 8 |
* @version 1.0.0 |
| 9 |
*/ |
| 10 |
if ( ! class_exists( 'SP_PC_Field_icon' ) ) { |
| 11 |
class SP_PC_Field_icon extends SP_PC_Fields { |
| 12 |
|
| 13 |
/** |
| 14 |
* The constructor mehtod. |
| 15 |
* |
| 16 |
* @param [type] $field |
| 17 |
* @param string $value |
| 18 |
* @param string $unique |
| 19 |
* @param string $where |
| 20 |
* @param string $parent |
| 21 |
*/ |
| 22 |
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) { |
| 23 |
parent::__construct( $field, $value, $unique, $where, $parent ); |
| 24 |
} |
| 25 |
|
| 26 |
/** |
| 27 |
* Render method. |
| 28 |
* |
| 29 |
* @return void |
| 30 |
*/ |
| 31 |
public function render() { |
| 32 |
|
| 33 |
$args = wp_parse_args( |
| 34 |
$this->field, |
| 35 |
array( |
| 36 |
'button_title' => esc_html__( 'Add Icon', 'smart-post-show' ), |
| 37 |
'remove_title' => esc_html__( 'Remove Icon', 'smart-post-show' ), |
| 38 |
) |
| 39 |
); |
| 40 |
|
| 41 |
echo wp_kses_post( $this->field_before() ); |
| 42 |
|
| 43 |
$nonce = wp_create_nonce( 'spf_icon_nonce' ); |
| 44 |
$hidden = ( empty( $this->value ) ) ? ' hidden' : ''; |
| 45 |
|
| 46 |
echo '<div class="spf-icon-select">'; |
| 47 |
echo '<span class="spf-icon-preview' . esc_attr( $hidden ) . '"><i class="' . esc_attr( $this->value ) . '"></i></span>'; |
| 48 |
echo '<a href="#" class="button button-primary spf-icon-add" data-nonce="' . esc_attr( $nonce ) . '">' . esc_html( $args['button_title'] ) . '</a>'; |
| 49 |
echo '<a href="#" class="button spf-warning-primary spf-icon-remove' . esc_attr( $hidden ) . '">' . esc_html( $args['remove_title'] ) . '</a>'; |
| 50 |
echo '<input type="text" name="' . esc_attr( $this->field_name() ) . '" value="' . esc_attr( $this->value ) . '" class="spf-icon-value"' . wp_kses_post( $this->field_attributes() ) . ' />'; |
| 51 |
echo '</div>'; |
| 52 |
|
| 53 |
echo wp_kses_post( $this->field_after() ); |
| 54 |
|
| 55 |
} |
| 56 |
|
| 57 |
} |
| 58 |
} |
| 59 |
|