| 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( 'DRK_LITE_Field_icon' ) ) { |
| 11 |
class DRK_LITE_Field_icon extends DRK_LITE_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', 'darkify' ), |
| 23 |
'remove_title' => esc_html__( 'Remove Icon', 'darkify' ), |
| 24 |
) |
| 25 |
); |
| 26 |
|
| 27 |
echo wp_kses_post( $this->field_before() ); |
| 28 |
|
| 29 |
$nonce = wp_create_nonce( 'drk_lite_icon_nonce' ); |
| 30 |
$hidden = ( empty( $this->value ) ) ? ' hidden' : ''; |
| 31 |
|
| 32 |
echo '<div class="drk_lite-icon-select">'; |
| 33 |
echo '<span class="drk_lite-icon-preview' . esc_attr( $hidden ) . '"><i class="' . esc_attr( $this->value ) . '"></i></span>'; |
| 34 |
echo '<a href="#" class="button button-primary drk_lite-icon-add" data-nonce="' . esc_attr( $nonce ) . '">' . esc_html( $args['button_title'] ) . '</a>'; |
| 35 |
echo '<a href="#" class="button drk_lite-warning-primary drk_lite-icon-remove' . esc_attr( $hidden ) . '">' . esc_html( $args['remove_title'] ) . '</a>'; |
| 36 |
echo '<input type="hidden" name="' . esc_attr( $this->field_name() ) . '" value="' . esc_attr( $this->value ) . '" class="drk_lite-icon-value"' . wp_kses_post( $this->field_attributes() ) . ' />'; |
| 37 |
echo '</div>'; |
| 38 |
|
| 39 |
echo wp_kses_post( $this->field_after() ); |
| 40 |
} |
| 41 |
|
| 42 |
public function enqueue() { |
| 43 |
add_action( 'admin_footer', array( 'DRK_LITE_Field_icon', 'add_footer_modal_icon' ) ); |
| 44 |
add_action( 'customize_controls_print_footer_scripts', array( 'DRK_LITE_Field_icon', 'add_footer_modal_icon' ) ); |
| 45 |
} |
| 46 |
|
| 47 |
public static function add_footer_modal_icon() { |
| 48 |
?> |
| 49 |
<div id="drk_lite-modal-icon" class="drk_lite-modal drk_lite-modal-icon hidden"> |
| 50 |
<div class="drk_lite-modal-table"> |
| 51 |
<div class="drk_lite-modal-table-cell"> |
| 52 |
<div class="drk_lite-modal-overlay"></div> |
| 53 |
<div class="drk_lite-modal-inner"> |
| 54 |
<div class="drk_lite-modal-title"> |
| 55 |
<?php esc_html_e( 'Add Icon', 'darkify' ); ?> |
| 56 |
<div class="drk_lite-modal-close drk_lite-icon-close"></div> |
| 57 |
</div> |
| 58 |
<div class="drk_lite-modal-header"> |
| 59 |
<input type="text" placeholder="<?php esc_html_e( 'Search...', 'darkify' ); ?>" class="drk_lite-icon-search" /> |
| 60 |
</div> |
| 61 |
<div class="drk_lite-modal-content"> |
| 62 |
<div class="drk_lite-modal-loading"><div class="drk_lite-loading"></div></div> |
| 63 |
<div class="drk_lite-modal-load"></div> |
| 64 |
</div> |
| 65 |
</div> |
| 66 |
</div> |
| 67 |
</div> |
| 68 |
</div> |
| 69 |
<?php |
| 70 |
} |
| 71 |
} |
| 72 |
} |
| 73 |
|