Advanced Custom Fields: Font Awesome Field - Version 2.0.4

Version Description

  • Added filter (ACFFA_always_enqueue_fa) to allow FontAwesome to always be enqueued on your sites frontend, even if no ACF FontAwesome fields are in use on the page.
Download this release

Release Info

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

Code changes from version 2.0.3 to 2.0.4

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.3
8
  Author: mattkeys
9
  Author URI: http://mattkeys.me/
10
  License: GPLv2 or later
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.4
8
  Author: mattkeys
9
  Author URI: http://mattkeys.me/
10
  License: GPLv2 or later
fields/acf-font-awesome-v4.php CHANGED
@@ -36,7 +36,12 @@ if ( ! class_exists( 'acf_field_font_awesome' ) ) :
36
 
37
  parent::__construct();
38
 
39
- add_filter('acf/load_field', array( $this, 'maybe_enqueue_font_awesome' ) );
 
 
 
 
 
40
  }
41
 
42
  private function get_icons( $format = 'list' )
@@ -151,26 +156,28 @@ if ( ! class_exists( 'acf_field_font_awesome' ) ) :
151
  </td>
152
  </tr>
153
 
154
- <tr class="field_option field_option_<?php echo $this->name; ?>">
155
- <td class="label">
156
- <label><?php _e( 'Enqueue FontAwesome?', 'acf-font-awesome' ); ?></label>
157
- <p class="description"><?php _e( 'Set to \'Yes\' to enqueue FA in the footer on any pages using this field.', 'acf-font-awesome' ); ?></p>
158
- </td>
159
- <td>
160
- <?php
161
- do_action('acf/create_field', array(
162
- 'type' => 'radio',
163
- 'name' => 'fields['.$key.'][enqueue_fa]',
164
- 'value' => $field['enqueue_fa'],
165
- 'choices' => array(
166
- 1 => __( 'Yes', 'acf-font-awesome' ),
167
- 0 => __( 'No', 'acf-font-awesome' ),
168
- ),
169
- 'layout' => 'horizontal',
170
- ));
171
- ?>
172
- </td>
173
- </tr>
 
 
174
  <?php
175
  }
176
 
36
 
37
  parent::__construct();
38
 
39
+
40
+ if ( apply_filters( 'ACFFA_always_enqueue_fa', false ) ) {
41
+ add_action( 'wp_enqueue_scripts', array( $this, 'frontend_enqueue_scripts' ) );
42
+ } else {
43
+ add_filter('acf/load_field', array( $this, 'maybe_enqueue_font_awesome' ) );
44
+ }
45
  }
46
 
47
  private function get_icons( $format = 'list' )
156
  </td>
157
  </tr>
158
 
159
+ <?php if ( ! apply_filters( 'ACFFA_always_enqueue_fa', false ) ) : ?>
160
+ <tr class="field_option field_option_<?php echo $this->name; ?>">
161
+ <td class="label">
162
+ <label><?php _e( 'Enqueue FontAwesome?', 'acf-font-awesome' ); ?></label>
163
+ <p class="description"><?php _e( 'Set to \'Yes\' to enqueue FA in the footer on any pages using this field.', 'acf-font-awesome' ); ?></p>
164
+ </td>
165
+ <td>
166
+ <?php
167
+ do_action('acf/create_field', array(
168
+ 'type' => 'radio',
169
+ 'name' => 'fields['.$key.'][enqueue_fa]',
170
+ 'value' => $field['enqueue_fa'],
171
+ 'choices' => array(
172
+ 1 => __( 'Yes', 'acf-font-awesome' ),
173
+ 0 => __( 'No', 'acf-font-awesome' ),
174
+ ),
175
+ 'layout' => 'horizontal',
176
+ ));
177
+ ?>
178
+ </td>
179
+ </tr>
180
+ <?php endif; ?>
181
  <?php
182
  }
183
 
fields/acf-font-awesome-v5.php CHANGED
@@ -28,9 +28,13 @@ if ( ! class_exists( 'acf_field_font_awesome' ) ) :
28
  'choices' => $this->get_icons('list')
29
  );
30
 
31
- parent::__construct();
32
 
33
- add_filter('acf/load_field', array( $this, 'maybe_enqueue_font_awesome' ) );
 
 
 
 
34
  }
35
 
36
  private function get_icons( $format = 'list' )
@@ -106,16 +110,18 @@ if ( ! class_exists( 'acf_field_font_awesome' ) ) :
106
  )
107
  ));
108
 
109
- acf_render_field_setting( $field, array(
110
- 'label' => __( 'Enqueue FontAwesome?', 'acf-font-awesome' ),
111
- 'instructions' => __( 'Set to \'Yes\' to enqueue FA in the footer on any pages using this field.', 'acf-font-awesome' ),
112
- 'type' => 'radio',
113
- 'name' => 'enqueue_fa',
114
- 'choices' => array(
115
- 1 => __( 'Yes', 'acf-font-awesome' ),
116
- 0 => __( 'No', 'acf-font-awesome' )
117
- )
118
- ));
 
 
119
  }
120
 
121
  public function render_field( $field )
28
  'choices' => $this->get_icons('list')
29
  );
30
 
31
+ parent::__construct();
32
 
33
+ if ( apply_filters( 'ACFFA_always_enqueue_fa', false ) ) {
34
+ add_action( 'wp_enqueue_scripts', array( $this, 'frontend_enqueue_scripts' ) );
35
+ } else {
36
+ add_filter('acf/load_field', array( $this, 'maybe_enqueue_font_awesome' ) );
37
+ }
38
  }
39
 
40
  private function get_icons( $format = 'list' )
110
  )
111
  ));
112
 
113
+ if ( ! apply_filters( 'ACFFA_always_enqueue_fa', false ) ) {
114
+ acf_render_field_setting( $field, array(
115
+ 'label' => __( 'Enqueue FontAwesome?', 'acf-font-awesome' ),
116
+ 'instructions' => __( 'Set to \'Yes\' to enqueue FA in the footer on any pages using this field.', 'acf-font-awesome' ),
117
+ 'type' => 'radio',
118
+ 'name' => 'enqueue_fa',
119
+ 'choices' => array(
120
+ 1 => __( 'Yes', 'acf-font-awesome' ),
121
+ 0 => __( 'No', 'acf-font-awesome' )
122
+ )
123
+ ));
124
+ }
125
  }
126
 
127
  public function render_field( $field )
readme.txt CHANGED
@@ -37,8 +37,9 @@ This ACF field type is compatible with:
37
 
38
  === Filters ===
39
 
 
40
  * **ACFFA_override_version**: Use to override the default FontAwesome icon version (latest). Return any valid version number from [jsDelivr](https://www.jsdelivr.com/projects/fontawesome)
41
- * **ACFFA_admin_enqueue_fa**: Return false to stop enqueueing FontAwesome in the admin area. Useful if you already have FontAwesome enqueued by some other means.
42
  * **ACFFA_load_chosen**: Return false to stop loading the [Chosen JS](https://harvesthq.github.io/chosen/) library in the admin area. Used in v4 of ACF only.
43
  * **ACFFA_get_icons**: Filter the array of icons and icon details loaded from the database
44
  * **ACFFA_get_fa_url**: Filter the URL used for enqueuing FontAwesome in the frontend and admin areas of the site.
@@ -50,6 +51,9 @@ This ACF field type is compatible with:
50
 
51
  == Changelog ==
52
 
 
 
 
53
  = 2.0.3 =
54
  * Fixed bug where a field set to return 'Icon Object' would instead return an array
55
 
@@ -132,6 +136,9 @@ This ACF field type is compatible with:
132
 
133
  == Upgrade Notice ==
134
 
 
 
 
135
  = 2.0.3 =
136
  * Fixed bug where a field set to return 'Icon Object' would instead return an array
137
 
37
 
38
  === Filters ===
39
 
40
+ * **ACFFA_always_enqueue_fa**: Return true to always enqueue FontAwesome on the frontend, even if no ACF FontAwesome fields are in use on the page. This will enqueue FontAwesome in the header instead of the footer.
41
  * **ACFFA_override_version**: Use to override the default FontAwesome icon version (latest). Return any valid version number from [jsDelivr](https://www.jsdelivr.com/projects/fontawesome)
42
+ * **ACFFA_admin_enqueue_fa**: Return false to stop enqueueing FontAwesome in the admin area. Useful if you already have FontAwesome enqueued by some other means.
43
  * **ACFFA_load_chosen**: Return false to stop loading the [Chosen JS](https://harvesthq.github.io/chosen/) library in the admin area. Used in v4 of ACF only.
44
  * **ACFFA_get_icons**: Filter the array of icons and icon details loaded from the database
45
  * **ACFFA_get_fa_url**: Filter the URL used for enqueuing FontAwesome in the frontend and admin areas of the site.
51
 
52
  == Changelog ==
53
 
54
+ = 2.0.4 =
55
+ * Added filter (ACFFA_always_enqueue_fa) to allow FontAwesome to always be enqueued on your sites frontend, even if no ACF FontAwesome fields are in use on the page.
56
+
57
  = 2.0.3 =
58
  * Fixed bug where a field set to return 'Icon Object' would instead return an array
59
 
136
 
137
  == Upgrade Notice ==
138
 
139
+ = 2.0.4 =
140
+ * Added filter (ACFFA_always_enqueue_fa) to allow FontAwesome to always be enqueued on your sites frontend, even if no ACF FontAwesome fields are in use on the page.
141
+
142
  = 2.0.3 =
143
  * Fixed bug where a field set to return 'Icon Object' would instead return an array
144