| 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 |
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) { |
| 14 |
parent::__construct( $field, $value, $unique, $where, $parent ); |
| 15 |
} |
| 16 |
|
| 17 |
public function render() { |
| 18 |
|
| 19 |
$args = wp_parse_args( |
| 20 |
$this->field, |
| 21 |
array( |
| 22 |
'button_title' => esc_html__( 'Add Icon', 'smart-post-show' ), |
| 23 |
'remove_title' => esc_html__( 'Remove Icon', 'smart-post-show' ), |
| 24 |
) |
| 25 |
); |
| 26 |
|
| 27 |
echo $this->field_before(); |
| 28 |
|
| 29 |
$nonce = wp_create_nonce( 'spf_icon_nonce' ); |
| 30 |
$hidden = ( empty( $this->value ) ) ? ' hidden' : ''; |
| 31 |
|
| 32 |
echo '<div class="spf-icon-select">'; |
| 33 |
echo '<span class="spf-icon-preview' . $hidden . '"><i class="' . $this->value . '"></i></span>'; |
| 34 |
echo '<a href="#" class="button button-primary spf-icon-add" data-nonce="' . $nonce . '">' . $args['button_title'] . '</a>'; |
| 35 |
echo '<a href="#" class="button spf-warning-primary spf-icon-remove' . $hidden . '">' . $args['remove_title'] . '</a>'; |
| 36 |
echo '<input type="text" name="' . $this->field_name() . '" value="' . $this->value . '" class="spf-icon-value"' . $this->field_attributes() . ' />'; |
| 37 |
echo '</div>'; |
| 38 |
|
| 39 |
echo $this->field_after(); |
| 40 |
|
| 41 |
} |
| 42 |
|
| 43 |
} |
| 44 |
} |
| 45 |
|