Version Description
- Refactored JS to simplify codebase and fix bugs where Chosen or Select2 fields would not initialize in a variety of field/sub-field configurations and display options.
Download this release
Release Info
Developer | mattkeys |
Plugin | Advanced Custom Fields: Font Awesome Field |
Version | 2.0.6 |
Comparing to | |
See all releases |
Code changes from version 2.0.5 to 2.0.6
- acf-font-awesome.php +2 -2
- assets/js/input-v4.js +44 -34
- assets/js/input-v5.js +28 -39
- readme.txt +6 -0
acf-font-awesome.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
Plugin Name: Advanced Custom Fields: Font Awesome
|
5 |
Plugin URI: https://wordpress.org/plugins/advanced-custom-fields-font-awesome/
|
6 |
Description: Adds a new 'Font Awesome Icon' field to the popular Advanced Custom Fields plugin.
|
7 |
-
Version: 2.0.
|
8 |
Author: mattkeys
|
9 |
Author URI: http://mattkeys.me/
|
10 |
License: GPLv2 or later
|
@@ -24,7 +24,7 @@ if ( ! class_exists('acf_plugin_font_awesome') ) :
|
|
24 |
public function __construct()
|
25 |
{
|
26 |
$this->settings = array(
|
27 |
-
'version' => '2.0.
|
28 |
'url' => plugin_dir_url( __FILE__ ),
|
29 |
'path' => plugin_dir_path( __FILE__ )
|
30 |
);
|
4 |
Plugin Name: Advanced Custom Fields: Font Awesome
|
5 |
Plugin URI: https://wordpress.org/plugins/advanced-custom-fields-font-awesome/
|
6 |
Description: Adds a new 'Font Awesome Icon' field to the popular Advanced Custom Fields plugin.
|
7 |
+
Version: 2.0.6
|
8 |
Author: mattkeys
|
9 |
Author URI: http://mattkeys.me/
|
10 |
License: GPLv2 or later
|
24 |
public function __construct()
|
25 |
{
|
26 |
$this->settings = array(
|
27 |
+
'version' => '2.0.6',
|
28 |
'url' => plugin_dir_url( __FILE__ ),
|
29 |
'path' => plugin_dir_path( __FILE__ )
|
30 |
);
|
assets/js/input-v4.js
CHANGED
@@ -1,9 +1,15 @@
|
|
1 |
(function($){
|
2 |
|
3 |
-
function update_preview(
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
$( '.icon_preview', parent ).html( '<i class="fa ' + value + '" aria-hidden="true"></i>' );
|
5 |
|
6 |
-
$( '.field_option_font-awesome .fa_live_preview' ).html( '<i class="fa ' + value + '" aria-hidden="true"></i>' );
|
7 |
}
|
8 |
|
9 |
function initialize_chosen( $select, allow_deselect ) {
|
@@ -18,10 +24,10 @@
|
|
18 |
$( document ).on( 'acf/setup_fields', function( e, postbox ) {
|
19 |
$( postbox ).find('.field[data-field_type="font-awesome"]').each( function() {
|
20 |
|
21 |
-
var $select = $( '
|
22 |
|
23 |
if ( $select.length ) {
|
24 |
-
update_preview( $select
|
25 |
|
26 |
if ( ACFFA.chosen ) {
|
27 |
initialize_chosen( $select, $select.data('allow_null') );
|
@@ -31,25 +37,6 @@
|
|
31 |
|
32 |
});
|
33 |
|
34 |
-
$( document ).on( 'change', '.field_type select', function() {
|
35 |
-
if ( 'font-awesome' == $( this ).val() ) {
|
36 |
-
if ( ACFFA.chosen ) {
|
37 |
-
var font_awesome_form = $( this ).closest( '.field_form' );
|
38 |
-
var ajaxLoadWait = setInterval( function() {
|
39 |
-
if ( $( '.chosen-fontawesome', font_awesome_form ).length ) {
|
40 |
-
clearInterval( ajaxLoadWait );
|
41 |
-
|
42 |
-
var $select = $( '.chosen-fontawesome:not(.chosen_initialized)', font_awesome_form );
|
43 |
-
|
44 |
-
if ( $select.length ) {
|
45 |
-
initialize_chosen( $select, true );
|
46 |
-
}
|
47 |
-
}
|
48 |
-
}, 100 );
|
49 |
-
}
|
50 |
-
}
|
51 |
-
});
|
52 |
-
|
53 |
$( document ).on( 'click', '.acf-tab-button', function( e ) {
|
54 |
e.preventDefault();
|
55 |
|
@@ -61,29 +48,52 @@
|
|
61 |
|
62 |
if ( key == $tab.attr('data-field_key') ) {
|
63 |
$( this ).nextUntil('.field_type-tab').each( function() {
|
64 |
-
var $select = $( '.chosen-fontawesome:not(.chosen_initialized)', this );
|
65 |
-
|
66 |
if ( $select.length ) {
|
67 |
-
|
|
|
68 |
|
69 |
-
|
70 |
-
|
71 |
-
|
|
|
72 |
}
|
73 |
});
|
74 |
}
|
75 |
});
|
76 |
});
|
77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
$( document ).on( 'acf/field_form-open', function( event, field ) {
|
79 |
var $select = $( '.chosen-fontawesome:not(.chosen_initialized)', field );
|
80 |
|
81 |
if ( $select.length ) {
|
82 |
-
|
|
|
|
|
83 |
|
84 |
-
|
85 |
-
|
86 |
-
|
|
|
87 |
}
|
88 |
});
|
89 |
|
@@ -113,7 +123,7 @@
|
|
113 |
});
|
114 |
|
115 |
$( document ).on( 'change', '.chosen-fontawesome', function( evt, params ) {
|
116 |
-
update_preview( $( this )
|
117 |
});
|
118 |
|
119 |
})(jQuery);
|
1 |
(function($){
|
2 |
|
3 |
+
function update_preview( $select_element, parent ) {
|
4 |
+
var value = $select_element.val();
|
5 |
+
|
6 |
+
if ( ! parent ) {
|
7 |
+
var parent = $select_element.closest('.field');
|
8 |
+
}
|
9 |
+
|
10 |
$( '.icon_preview', parent ).html( '<i class="fa ' + value + '" aria-hidden="true"></i>' );
|
11 |
|
12 |
+
$( '.field_option_font-awesome .fa_live_preview', parent ).html( '<i class="fa ' + value + '" aria-hidden="true"></i>' );
|
13 |
}
|
14 |
|
15 |
function initialize_chosen( $select, allow_deselect ) {
|
24 |
$( document ).on( 'acf/setup_fields', function( e, postbox ) {
|
25 |
$( postbox ).find('.field[data-field_type="font-awesome"]').each( function() {
|
26 |
|
27 |
+
var $select = $( '.chosen-fontawesome:not(.chosen_initialized):visible', this );
|
28 |
|
29 |
if ( $select.length ) {
|
30 |
+
update_preview( $select, false );
|
31 |
|
32 |
if ( ACFFA.chosen ) {
|
33 |
initialize_chosen( $select, $select.data('allow_null') );
|
37 |
|
38 |
});
|
39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
$( document ).on( 'click', '.acf-tab-button', function( e ) {
|
41 |
e.preventDefault();
|
42 |
|
48 |
|
49 |
if ( key == $tab.attr('data-field_key') ) {
|
50 |
$( this ).nextUntil('.field_type-tab').each( function() {
|
51 |
+
var $select = $( '.chosen-fontawesome:not(.chosen_initialized):visible', this );
|
|
|
52 |
if ( $select.length ) {
|
53 |
+
$.each( $select, function( index, select_element ) {
|
54 |
+
update_preview( $( select_element ), false );
|
55 |
|
56 |
+
if ( ACFFA.chosen ) {
|
57 |
+
initialize_chosen( $( select_element ), $( select_element ).data('allow_null') );
|
58 |
+
}
|
59 |
+
});
|
60 |
}
|
61 |
});
|
62 |
}
|
63 |
});
|
64 |
});
|
65 |
|
66 |
+
$( document ).on( 'change', '.field_type select', function() {
|
67 |
+
if ( 'font-awesome' == $( this ).val() ) {
|
68 |
+
if ( ACFFA.chosen ) {
|
69 |
+
var font_awesome_form = $( this ).closest( '.field_form' );
|
70 |
+
var ajaxLoadWait = setInterval( function() {
|
71 |
+
if ( $( '.chosen-fontawesome', font_awesome_form ).length ) {
|
72 |
+
clearInterval( ajaxLoadWait );
|
73 |
+
|
74 |
+
var $select = $( '.chosen-fontawesome:not(.chosen_initialized):visible', font_awesome_form );
|
75 |
+
|
76 |
+
if ( $select.length ) {
|
77 |
+
initialize_chosen( $select, true );
|
78 |
+
}
|
79 |
+
}
|
80 |
+
}, 100 );
|
81 |
+
}
|
82 |
+
}
|
83 |
+
});
|
84 |
+
|
85 |
$( document ).on( 'acf/field_form-open', function( event, field ) {
|
86 |
var $select = $( '.chosen-fontawesome:not(.chosen_initialized)', field );
|
87 |
|
88 |
if ( $select.length ) {
|
89 |
+
$.each( $select, function( index, select_element ) {
|
90 |
+
var parent = $( select_element ).closest('.field');
|
91 |
+
update_preview( $( select_element ), parent );
|
92 |
|
93 |
+
if ( ACFFA.chosen ) {
|
94 |
+
initialize_chosen( $( select_element ), true );
|
95 |
+
}
|
96 |
+
});
|
97 |
}
|
98 |
});
|
99 |
|
123 |
});
|
124 |
|
125 |
$( document ).on( 'change', '.chosen-fontawesome', function( evt, params ) {
|
126 |
+
update_preview( $( this ), false );
|
127 |
});
|
128 |
|
129 |
})(jQuery);
|
assets/js/input-v5.js
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
$( '.acf-field-setting-fa_live_preview .acf-input', parent ).html( '<i class="fa ' + value + '" aria-hidden="true"></i>' );
|
5 |
$( '.icon_preview', parent ).html( '<i class="fa ' + value + '" aria-hidden="true"></i>' );
|
6 |
}
|
7 |
-
|
8 |
function select2_init_args( element ) {
|
9 |
return {
|
10 |
key : $( element ).data('key'),
|
@@ -14,60 +14,49 @@
|
|
14 |
}
|
15 |
}
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
var $field_objects = $('.acf-field-object[data-type="font-awesome"]');
|
21 |
|
22 |
-
$
|
23 |
-
update_preview( $( 'select.fontawesome-create', field_object ).val(), field_object );
|
24 |
-
});
|
25 |
|
26 |
-
|
27 |
-
var $fa_fields = $('.acf-field-font-awesome:visible');
|
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 |
$fa_fields.each( function( index, fa_field ) {
|
54 |
-
|
55 |
-
|
56 |
-
acf.select2.init( $( 'select.fontawesome-edit', fa_field ), select2_init_args( fa_field ), $( fa_field ) );
|
57 |
});
|
58 |
}
|
59 |
});
|
60 |
|
61 |
-
|
62 |
-
|
63 |
-
if ( $select.hasClass('select2-fontawesome') ) {
|
64 |
-
args.dropdownCssClass = 'fa-select2-drop';
|
65 |
-
args.containerCssClass = 'fa-select2';
|
66 |
-
}
|
67 |
-
|
68 |
-
return args;
|
69 |
-
});
|
70 |
-
|
71 |
acf.add_action( 'change', function( $input ) {
|
72 |
|
73 |
if ( $input.hasClass('fontawesome-create') ) {
|
4 |
$( '.acf-field-setting-fa_live_preview .acf-input', parent ).html( '<i class="fa ' + value + '" aria-hidden="true"></i>' );
|
5 |
$( '.icon_preview', parent ).html( '<i class="fa ' + value + '" aria-hidden="true"></i>' );
|
6 |
}
|
7 |
+
|
8 |
function select2_init_args( element ) {
|
9 |
return {
|
10 |
key : $( element ).data('key'),
|
14 |
}
|
15 |
}
|
16 |
|
17 |
+
function select2_init( fa_field ) {
|
18 |
+
var $select = $( fa_field );
|
19 |
+
var parent = $( $select ).closest('.acf-field-font-awesome');
|
|
|
20 |
|
21 |
+
$select.addClass('select2_initalized');
|
|
|
|
|
22 |
|
23 |
+
update_preview( $select.val(), parent );
|
|
|
24 |
|
25 |
+
acf.select2.init( $select, select2_init_args( fa_field ), $( fa_field ) );
|
26 |
+
}
|
27 |
|
28 |
+
// Add our classes to FontAwesome select2 fields
|
29 |
+
acf.add_filter( 'select2_args', function( args, $select, settings, $field ) {
|
|
|
30 |
|
31 |
+
if ( $select.hasClass('select2-fontawesome') ) {
|
32 |
+
args.dropdownCssClass = 'fa-select2-drop';
|
33 |
+
args.containerCssClass = 'fa-select2';
|
34 |
+
}
|
35 |
|
36 |
+
return args;
|
37 |
+
});
|
38 |
|
39 |
+
// Update FontAwesome field previews in field create area
|
40 |
+
acf.add_action( 'ready', function( $el ) {
|
41 |
+
var $field_objects = $('.acf-field-object[data-type="font-awesome"]');
|
42 |
|
43 |
+
$field_objects.each( function( index, field_object ) {
|
44 |
+
update_preview( $( 'select.fontawesome-create', field_object ).val(), field_object );
|
45 |
+
});
|
46 |
});
|
47 |
|
48 |
+
// Update FontAwesome field previews and init select2 in field edit area
|
49 |
+
acf.add_action( 'ready append show_field/type=font-awesome', function( $el ) {
|
50 |
+
var $fa_fields = $( 'select.fontawesome-edit:visible', $el );
|
51 |
|
52 |
+
if ( $fa_fields.length ) {
|
53 |
$fa_fields.each( function( index, fa_field ) {
|
54 |
+
select2_init( fa_field );
|
|
|
|
|
55 |
});
|
56 |
}
|
57 |
});
|
58 |
|
59 |
+
// Update FontAwesome field previews when value changes
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
acf.add_action( 'change', function( $input ) {
|
61 |
|
62 |
if ( $input.hasClass('fontawesome-create') ) {
|
readme.txt
CHANGED
@@ -51,6 +51,9 @@ This ACF field type is compatible with:
|
|
51 |
|
52 |
== Changelog ==
|
53 |
|
|
|
|
|
|
|
54 |
= 2.0.5 =
|
55 |
* Fixed bug with ACF tabs + FontAwesome fields where Chosen/Select2 would not initialize beyond the first tab shown
|
56 |
|
@@ -139,6 +142,9 @@ This ACF field type is compatible with:
|
|
139 |
|
140 |
== Upgrade Notice ==
|
141 |
|
|
|
|
|
|
|
142 |
= 2.0.5 =
|
143 |
* Fixed bug with ACF tabs + FontAwesome fields where Chosen/Select2 would not initialize beyond the first tab shown
|
144 |
|
51 |
|
52 |
== Changelog ==
|
53 |
|
54 |
+
= 2.0.6 =
|
55 |
+
* Refactored JS to simplify codebase and fix bugs where Chosen or Select2 fields would not initialize in a variety of field/sub-field configurations and display options.
|
56 |
+
|
57 |
= 2.0.5 =
|
58 |
* Fixed bug with ACF tabs + FontAwesome fields where Chosen/Select2 would not initialize beyond the first tab shown
|
59 |
|
142 |
|
143 |
== Upgrade Notice ==
|
144 |
|
145 |
+
= 2.0.6 =
|
146 |
+
* Refactored JS to simplify codebase and fix bugs where Chosen or Select2 fields would not initialize in a variety of field/sub-field configurations and display options.
|
147 |
+
|
148 |
= 2.0.5 =
|
149 |
* Fixed bug with ACF tabs + FontAwesome fields where Chosen/Select2 would not initialize beyond the first tab shown
|
150 |
|