Advanced Custom Fields: Font Awesome Field - Version 1.6.4

Version Description

  • Misc JS performance improvements
  • Fixed bug where select2 would not initialize on repeater items added mid-rows (using the plus icon at the end of a repeater row)
Download this release

Release Info

Developer mattkeys
Plugin Icon 128x128 Advanced Custom Fields: Font Awesome Field
Version 1.6.4
Comparing to
See all releases

Code changes from version 1.6.3 to 1.6.4

Files changed (3) hide show
  1. acf-font-awesome.php +1 -1
  2. js/edit_input.js +2 -64
  3. readme.txt +8 -10
acf-font-awesome.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: Advanced Custom Fields: Font Awesome
4
  Description: Add a Font Awesome field type to Advanced Custom Fields
5
- Version: 1.6.3
6
  Author: Matt Keys
7
  Author URI: http://mattkeys.me/
8
  License: GPLv2 or later
2
  /*
3
  Plugin Name: Advanced Custom Fields: Font Awesome
4
  Description: Add a Font Awesome field type to Advanced Custom Fields
5
+ Version: 1.6.4
6
  Author: Matt Keys
7
  Author URI: http://mattkeys.me/
8
  License: GPLv2 or later
js/edit_input.js CHANGED
@@ -4,75 +4,15 @@
4
 
5
  function initialize_field( $el ) {
6
 
7
- if( fa_initialized ) {
8
-
9
- // ACF 5
10
- var last_row = $( '.acf-clone' ).prev( '.acf-row' );
11
-
12
- // ACF 4
13
- if ( last_row.length === 0 ) {
14
- last_row = $( '.row-clone' ).prev( '.row' );
15
- }
16
-
17
- $( last_row ).each( function() {
18
- $( 'select.fa-select2-field', this ).each( function() {
19
- $(this).select2({
20
- width : '100%'
21
- });
22
- update_preview( this, $(this).val() );
23
- });
24
- });
25
-
26
- // ACF 5
27
- var last_layout = $( '.acf-flexible-content .values' ).last();
28
-
29
- // ACF 4
30
- if ( last_layout.length === 0 ) {
31
- last_layout = $( '.acf_flexible_content .values' ).last();
32
- }
33
-
34
- $( '.field_type-font-awesome select.fa-select2-field', last_layout ).each( function() {
35
- $(this).select2({
36
- width : '100%'
37
- });
38
- update_preview( this, $(this).val() );
39
- });
40
-
41
- } else {
42
-
43
- // Initialize flexible content Font Awesome fields
44
- $( '.acf-flexible-content .values tbody > tr.field_type-font-awesome select.fa-select2-field' ).each( function() {
45
- $(this).select2({
46
- width : '100%'
47
- });
48
- update_preview( this, $(this).val() );
49
- });
50
-
51
- // Initialize basic (not repeater, not flexible content) Font Awesome fields
52
- $( '.field_type-font-awesome select.fa-select2-field' ).each( function() {
53
  $(this).select2({
54
  width : '100%'
55
  });
56
  update_preview( this, $(this).val() );
57
  });
58
-
59
  }
60
 
61
- // ACF 5 Flex Clones
62
- $( '.clones select.fa-select2-field' ).each(function() {
63
- $(this).select2( 'destroy' );
64
- });
65
-
66
- // ACF 5 Repeater Clones
67
- $( 'tr.acf-row.acf-clone select.fa-select2-field' ).each(function() {
68
- $(this).select2( 'destroy' );
69
- });
70
-
71
- // ACF 4 Repeater & Flex Clones
72
- $( 'tr.row-clone select.fa-select2-field' ).each(function() {
73
- $(this).select2( 'destroy' );
74
- });
75
-
76
  $( 'select.fa-select2-field' ).on( 'select2-selecting', function( object ) {
77
  update_preview( this, object.val );
78
  });
@@ -85,8 +25,6 @@
85
  update_preview( this, $(this).val() );
86
  });
87
 
88
- fa_initialized = true;
89
-
90
  }
91
 
92
  function update_preview( element, selected ) {
4
 
5
  function initialize_field( $el ) {
6
 
7
+ if ( $el.parent('.row-clone').length === 0 && $el.parents('.clones').length === 0 ) {
8
+ $( 'select.fa-select2-field', $el ).each( function() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  $(this).select2({
10
  width : '100%'
11
  });
12
  update_preview( this, $(this).val() );
13
  });
 
14
  }
15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  $( 'select.fa-select2-field' ).on( 'select2-selecting', function( object ) {
17
  update_preview( this, object.val );
18
  });
25
  update_preview( this, $(this).val() );
26
  });
27
 
 
 
28
  }
29
 
30
  function update_preview( element, selected ) {
readme.txt CHANGED
@@ -40,6 +40,10 @@ This ACF field type is compatible with:
40
 
41
  == Changelog ==
42
 
 
 
 
 
43
  = 1.6.3 =
44
  * Fixed asset path errors when including this add-on from a theme instead of the plugins directory
45
 
@@ -82,6 +86,9 @@ This ACF field type is compatible with:
82
 
83
  == Upgrade Notice ==
84
 
 
 
 
85
  = 1.6.3 =
86
  Fixed asset path errors when including this add-on from a theme instead of the plugins directory
87
 
@@ -92,13 +99,4 @@ Rolling back changes from 1.6.1 after a number of bugs were reported. Incompatib
92
  Addressing incompatibility issues between this plugin and the Better Font Awesome plugin
93
 
94
  = 1.6 =
95
- Misc fixes to JS to properly target ACF fields in the DOM (based on changes to the ACF structure). This should resolve issues with duplicate, or missing select2 fields when picking font awesome icons. Note: this has been tested only on the latest versions of 4.x and 5.x, if you are not on the latest versions I suggest that you ugprade to them before updating this plugin.
96
-
97
- = 1.5 =
98
- This plugin now integrates with the [Better Font Awesome Library](https://github.com/MickeyKay/better-font-awesome-library) to automatically use the latest version of the Font Awesome icons
99
-
100
- = 1.4 =
101
- * Updated included FontAwesome to version 4.2 (40 more icons)
102
-
103
- = 1.3 =
104
- Advanced Custom Fields version 5.x support
40
 
41
  == Changelog ==
42
 
43
+ = 1.6.4 =
44
+ * Misc JS performance improvements
45
+ * Fixed bug where select2 would not initialize on repeater items added mid-rows (using the plus icon at the end of a repeater row)
46
+
47
  = 1.6.3 =
48
  * Fixed asset path errors when including this add-on from a theme instead of the plugins directory
49
 
86
 
87
  == Upgrade Notice ==
88
 
89
+ = 1.6.4 =
90
+ Misc JS performance improvements and fixed bug where select2 would not initialize on repeater items added mid-rows (using the plus icon at the end of a repeater row)
91
+
92
  = 1.6.3 =
93
  Fixed asset path errors when including this add-on from a theme instead of the plugins directory
94
 
99
  Addressing incompatibility issues between this plugin and the Better Font Awesome plugin
100
 
101
  = 1.6 =
102
+ Misc fixes to JS to properly target ACF fields in the DOM (based on changes to the ACF structure). This should resolve issues with duplicate, or missing select2 fields when picking font awesome icons. Note: this has been tested only on the latest versions of 4.x and 5.x, if you are not on the latest versions I suggest that you ugprade to them before updating this plugin.