-
Notifications
You must be signed in to change notification settings - Fork 0
/
cfs-font-awesome-field.php
59 lines (52 loc) · 1.72 KB
/
cfs-font-awesome-field.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
function cfsfa_assets() {
wp_enqueue_style('cfsfa_font_awesome','https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css');
wp_enqueue_style('cfsfa_fa_iconpicker', plugins_url('assets/css/fontawesome-iconpicker.min.css',__FILE__ ));
wp_enqueue_script( 'cfsfa_fa_iconpicker', plugins_url('assets/js/fontawesome-iconpicker.min.js',__FILE__ ));
}
add_action( 'admin_init','cfsfa_assets');
class cfs_font_awesome_field extends cfs_field {
function __construct() {
$this->name = 'font_awesome_field';
$this->label = __( 'Font Awesome', 'cfsfa' );
}
function html( $field ) { $icon = $field->value; if($icon == '') { $icon = "fa-anchor"; } ?>
<div class="cfsfa_wrap"><span id="fa_icon" class="input-group-addon"></span><input class="icp icp-auto" name="<?php esc_attr_e( $field->input_name ); ?>" value="<?php echo $icon; ?>" type="text" /></div>
<script type="text/javascript">
jQuery(function($) {
$('.icp-auto').iconpicker();
$('.iconpicker-item').on('click', function(e) {
$(".popover").hide();
});
$('.icp').on('click', function(e) {
$(this).next().show();
});
});
</script>
<style type="text/css">
.cfsfa_wrap{
position: relative;
padding-left: 50px;
min-height: 50px;
}
.cfsfa_wrap .icp{
margin-top: 15px;
}
span#fa_icon{
background-color: #363B3F;
color: #fff;
font-size: 24px;
line-height: 40px;
width: 40px;
height: 40px;
display: inline-block;
text-align: center;
border-radius: 3px;
margin: 7px 0;
position: absolute;
left: 0;
}
</style>
<?php
}
}