Better Font Awesome - Version 1.3.1

Version Description

  • Update admin JS to trigger icon picker on ALL TinyMCE initializations (e.g. Visual Composer and AJAX)
Download this release

Release Info

Developer McGuive7
Plugin Icon 128x128 Better Font Awesome
Version 1.3.1
Comparing to
See all releases

Code changes from version 1.3.0 to 1.3.1

better-font-awesome.php CHANGED
@@ -12,7 +12,7 @@
12
  * Plugin Name: Better Font Awesome
13
  * Plugin URI: http://wordpress.org/plugins/better-font-awesome
14
  * Description: The ultimate Font Awesome icon plugin for WordPress.
15
- * Version: 1.3.0
16
  * Author: MIGHTYminnow & Mickey Kay
17
  * Author URI: mickey@mickeykaycreative.com
18
  * License: GPLv2+
12
  * Plugin Name: Better Font Awesome
13
  * Plugin URI: http://wordpress.org/plugins/better-font-awesome
14
  * Description: The ultimate Font Awesome icon plugin for WordPress.
15
+ * Version: 1.3.1
16
  * Author: MIGHTYminnow & Mickey Kay
17
  * Author URI: mickey@mickeykaycreative.com
18
  * License: GPLv2+
lib/better-font-awesome-library/better-font-awesome-library.php CHANGED
@@ -32,8 +32,8 @@ class Better_Font_Awesome_Library {
32
  /**
33
  * Better Font Awesome Library slug.
34
  *
35
- * @since 1.0.0
36
- *
37
  * @var string
38
  */
39
  const SLUG = 'bfa';
@@ -42,7 +42,7 @@ class Better_Font_Awesome_Library {
42
  * Better Font Awesome Library version slug.
43
  *
44
  * @since 1.0.0
45
- *
46
  * @var string
47
  */
48
  const VERSION = '1.0.0';
@@ -51,16 +51,16 @@ class Better_Font_Awesome_Library {
51
  * jsDelivr API URL for Font Awesome version info.
52
  *
53
  * @since 1.0.0
54
- *
55
  * @var string
56
  */
57
  const JSDELIVR_API_URL = 'http://api.jsdelivr.com/v1/jsdelivr/libraries/fontawesome/?fields=versions,lastversion';
58
-
59
  /**
60
  * Initialization args.
61
  *
62
- * @since 1.0.0
63
- *
64
  * @var array
65
  */
66
  private $args;
@@ -69,7 +69,7 @@ class Better_Font_Awesome_Library {
69
  * Default args to use if any $arg isn't specified.
70
  *
71
  * @since 1.0.0
72
- *
73
  * @var array
74
  */
75
  private $default_args = array(
@@ -107,7 +107,7 @@ class Better_Font_Awesome_Library {
107
  * Array to hold the jsDelivr API data.
108
  *
109
  * @since 1.0.0
110
- *
111
  * @var string
112
  */
113
  private $api_data = array();
@@ -116,7 +116,7 @@ class Better_Font_Awesome_Library {
116
  * Version of Font Awesome being used.
117
  *
118
  * @since 1.0.0
119
- *
120
  * @var string
121
  */
122
  private $font_awesome_version;
@@ -125,7 +125,7 @@ class Better_Font_Awesome_Library {
125
  * Font Awesome stylesheet URL.
126
  *
127
  * @since 1.0.0
128
- *
129
  * @var string
130
  */
131
  private $stylesheet_url;
@@ -134,7 +134,7 @@ class Better_Font_Awesome_Library {
134
  * Font Awesome CSS.
135
  *
136
  * @since 1.0.0
137
- *
138
  * @var string
139
  */
140
  private $css;
@@ -143,7 +143,7 @@ class Better_Font_Awesome_Library {
143
  * Data associated with the local fallback version of Font Awesome.
144
  *
145
  * @since 1.0.0
146
- *
147
  * @var string
148
  */
149
  private $fallback_data = array(
@@ -158,7 +158,7 @@ class Better_Font_Awesome_Library {
158
  * Array of available Font Awesome icon slugs.
159
  *
160
  * @since 1.0.0
161
- *
162
  * @var string
163
  */
164
  private $icons = array();
@@ -167,7 +167,7 @@ class Better_Font_Awesome_Library {
167
  * Font Awesome prefix to be used ('icon' or 'fa').
168
  *
169
  * @since 1.0.0
170
- *
171
  * @var string
172
  */
173
  private $prefix;
@@ -176,7 +176,7 @@ class Better_Font_Awesome_Library {
176
  * Array to track errors and wp_remote_get() failures.
177
  *
178
  * @since 1.0.0
179
- *
180
  * @var array
181
  */
182
  private $errors = array();
@@ -199,7 +199,7 @@ class Better_Font_Awesome_Library {
199
  * @return Better_Font_Awesome_Library The BFAL object.
200
  */
201
  public static function get_instance( $args = array() ) {
202
-
203
  // If the single instance hasn't been set, set it now.
204
  if ( null == self::$instance ) {
205
  self::$instance = new self( $args );
@@ -257,7 +257,7 @@ class Better_Font_Awesome_Library {
257
  * remove them.
258
  */
259
  if ( $this->args['remove_existing_fa'] ) {
260
-
261
  add_action( 'wp_enqueue_scripts', array( $this, 'remove_font_awesome_css' ), 15 );
262
  add_action( 'init', array( $this, 'remove_icon_shortcode' ), 15 );
263
 
@@ -296,7 +296,7 @@ class Better_Font_Awesome_Library {
296
 
297
  // Load TinyMCE functionality.
298
  if ( $this->args['load_tinymce_plugin'] ) {
299
-
300
  add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) );
301
 
302
  // Add shortcode insertion button.
@@ -366,7 +366,7 @@ class Better_Font_Awesome_Library {
366
  */
367
  function setup_root_url() {
368
 
369
- // Get BFA directory and theme root directory paths.
370
  $bfa_directory = dirname(__FILE__);
371
  $theme_directory = get_stylesheet_directory();
372
  $plugin_dir = plugin_dir_url( __FILE__ );
@@ -389,13 +389,13 @@ class Better_Font_Awesome_Library {
389
  // Get relative BFA directory by removing theme root directory path.
390
  $bfa_rel_path = str_replace( $theme_directory, '', $bfa_directory );
391
  $this->root_url = trailingslashit( get_stylesheet_directory_uri() . $bfa_rel_path );
392
-
393
  } else { // Otherwise we're inside a plugin.
394
 
395
  $this->root_url = trailingslashit( plugin_dir_url( __FILE__ ) );
396
 
397
- }
398
-
399
  }
400
 
401
  /**
@@ -457,11 +457,11 @@ class Better_Font_Awesome_Library {
457
  private function fetch_api_data( $url ) {
458
 
459
  if ( false === ( $response = get_transient( self::SLUG . '-api-versions' ) ) ) {
460
-
461
  $response = wp_remote_get( $url, $this->wp_remote_get_args );
462
 
463
  if ( 200 == wp_remote_retrieve_response_code( $response ) ) {
464
-
465
  // Decode the API data and grab the versions info.
466
  $json_data = json_decode( wp_remote_retrieve_body( $response ) );
467
  $response = $json_data[0];
@@ -484,7 +484,7 @@ class Better_Font_Awesome_Library {
484
  $response = '';
485
 
486
  } elseif ( isset( $response['response'] ) ) { // Check for 404 and other non-WP_ERROR codes
487
-
488
  $this->set_error( 'api', $response['response']['code'], $response['response']['message'] . " (URL: $url)" );
489
  $response = '';
490
 
@@ -549,9 +549,9 @@ class Better_Font_Awesome_Library {
549
 
550
  $css_transient_latest_version = $this->get_css_transient_latest_version();
551
 
552
- if ( version_compare( $css_transient_latest_version, $this->fallback_data['version'], '>' ) ) {
553
  return $css_transient_latest_version;
554
- } else {
555
  return $this->fallback_data['version'];
556
  }
557
 
@@ -568,7 +568,7 @@ class Better_Font_Awesome_Library {
568
  private function get_css_transient_latest_version() {
569
 
570
  $transient_css_array = get_transient( self::SLUG . '-css' );
571
-
572
  if ( ! empty( $transient_css_array ) ) {
573
  return max( array_keys( $transient_css_array ) );
574
  } else {
@@ -617,14 +617,14 @@ class Better_Font_Awesome_Library {
617
  *
618
  * @return string $response Font Awesome CSS, from either:
619
  * 1. transient,
620
- * 2. wp_remote_get(), or
621
  * 3. fallback CSS.
622
  */
623
  private function get_css( $url, $version ) {
624
-
625
  // First try getting the transient CSS.
626
  $response = $this->get_transient_css( $version );
627
-
628
  // Next, try fetching the CSS from the remote jsDelivr CDN.
629
  if ( ! $response ) {
630
  $response = $this->get_remote_css( $url, $version );
@@ -674,7 +674,7 @@ class Better_Font_Awesome_Library {
674
  * @return string Transient CSS if it exists, otherwise null.
675
  */
676
  private function get_transient_css( $version ) {
677
-
678
  $transient_css_array = get_transient( self::SLUG . '-css' );
679
  return isset( $transient_css_array[ $version ] ) ? $transient_css_array[ $version ] : '';
680
 
@@ -696,13 +696,13 @@ class Better_Font_Awesome_Library {
696
  // Get the remote Font Awesome CSS.
697
  $url = set_url_scheme( $url );
698
  $response = wp_remote_get( $url, $this->wp_remote_get_args );
699
-
700
  /**
701
  * If fetch was successful, return the remote CSS, and set the CSS
702
  * transient for this version. Otherwise, return a WP_Error object.
703
  */
704
  if ( 200 == wp_remote_retrieve_response_code( $response ) ) {
705
-
706
  $response = wp_remote_retrieve_body( $response );
707
  $this->set_css_transient( $version, $response );
708
 
@@ -734,7 +734,7 @@ class Better_Font_Awesome_Library {
734
  * Awesome version.
735
  */
736
  $transient_css_array = get_transient( self::SLUG . '-css' );
737
-
738
  // Set the new value for the specified Font Awesome version.
739
  $transient_css_array[ $version ] = $value;
740
 
@@ -746,7 +746,7 @@ class Better_Font_Awesome_Library {
746
  * @param int Expiration for the CSS transient.
747
  */
748
  $transient_expiration = apply_filters( 'bfa_css_transient_expiration', 30 * DAY_IN_SECONDS );
749
-
750
  // Set the new CSS array transient.
751
  set_transient( self::SLUG . '-css', $transient_css_array, $transient_expiration );
752
 
@@ -773,7 +773,7 @@ class Better_Font_Awesome_Library {
773
  * @return array All available icon names (e.g. adjust, car, pencil).
774
  */
775
  private function setup_icon_array( $css ) {
776
-
777
  $icons = array();
778
  $hex_codes = array();
779
 
@@ -795,7 +795,7 @@ class Better_Font_Awesome_Library {
795
  * Filter the array of available icons.
796
  *
797
  * @since 1.0.0
798
- *
799
  * @param array $icons Array of all available icons.
800
  */
801
  $icons = apply_filters( 'bfa_icon_list', $icons );
@@ -840,12 +840,12 @@ class Better_Font_Awesome_Library {
840
  * @since 1.0.0
841
  */
842
  public function remove_font_awesome_css() {
843
-
844
  global $wp_styles;
845
 
846
  // Loop through all registered styles and remove any that appear to be Font Awesome.
847
  foreach ( $wp_styles->registered as $script => $details ) {
848
-
849
  if ( false !== strpos( $script, 'fontawesome' ) || false !== strpos( $script, 'font-awesome' ) ) {
850
  wp_dequeue_style( $script );
851
  }
@@ -885,7 +885,7 @@ class Better_Font_Awesome_Library {
885
  * @return string $output Icon HTML (e.g. <i class="fa fa-car"></i>).
886
  */
887
  public function render_shortcode( $atts ) {
888
-
889
  extract( shortcode_atts( array(
890
  'name' => '',
891
  'class' => '',
@@ -909,15 +909,23 @@ class Better_Font_Awesome_Library {
909
  // This helps both:
910
  // 1. Incorrect shortcodes (when user includes full class name including prefix)
911
  // 2. Old shortcodes from other plugins that required prefixes
912
-
913
  /**
914
- * Strip 'icon-' and 'fa-' from $name.
915
- *
916
  * This corrects for:
917
  * 1. Incorrect shortcodes (when user includes full class name including prefix)
918
  * 2. Old shortcodes from other plugins that required prefixes
919
  */
920
- $name = str_replace( 'icon-', '', $name );
 
 
 
 
 
 
 
 
921
  $name = str_replace( 'fa-', '', $name );
922
 
923
  // Add the version-specific prefix back on to $name, if it exists.
@@ -996,7 +1004,7 @@ class Better_Font_Awesome_Library {
996
  * @since 1.0.0
997
  */
998
  public function enqueue_admin_scripts() {
999
-
1000
  // Custom admin CSS.
1001
  wp_enqueue_style( self::SLUG . '-admin', $this->root_url . 'css/admin-styles.css' );
1002
 
@@ -1007,7 +1015,7 @@ class Better_Font_Awesome_Library {
1007
  wp_enqueue_style( 'fontawesome-iconpicker', $this->root_url . 'lib/fontawesome-iconpicker/css/fontawesome-iconpicker.min.css' );
1008
  wp_enqueue_script( 'fontawesome-iconpicker', $this->root_url . 'lib/fontawesome-iconpicker/js/fontawesome-iconpicker.min.js' );
1009
 
1010
- // Output PHP variables to JS.
1011
  $bfa_vars = array(
1012
  'fa_prefix' => $this->prefix,
1013
  'fa_icons' => $this->get_icons(),
@@ -1042,7 +1050,7 @@ class Better_Font_Awesome_Library {
1042
  *
1043
  * @since 1.0.0
1044
  */
1045
- public function do_admin_notice() {
1046
 
1047
  if ( ! empty( $this->errors ) && apply_filters( 'bfa_show_errors', true ) ) :
1048
  ?>
@@ -1050,13 +1058,13 @@ class Better_Font_Awesome_Library {
1050
  <p>
1051
  <b><?php _e( 'Better Font Awesome', 'better-font-awesome' ); ?></b>
1052
  </p>
1053
-
1054
  <!-- API Error -->
1055
  <?php if ( is_wp_error ( $this->get_error('api') ) ) : ?>
1056
  <p>
1057
  <b><?php _e( 'API Error', 'better-font-awesome' ); ?></b><br />
1058
- <?php
1059
- printf( __( 'The attempt to reach the jsDelivr API server failed with the following error: %s', 'better-font-awesome' ),
1060
  '<code>' . $this->get_error('api')->get_error_code() . ': ' . $this->get_error('api')->get_error_message() . '</code>'
1061
  );
1062
  ?>
@@ -1067,8 +1075,8 @@ class Better_Font_Awesome_Library {
1067
  <?php if ( is_wp_error ( $this->get_error('css') ) ) : ?>
1068
  <p>
1069
  <b><?php _e( 'Remote CSS Error', 'better-font-awesome' ); ?></b><br />
1070
- <?php
1071
- printf( __( 'The attempt to fetch the remote Font Awesome stylesheet failed with the following error: %s %s The embedded fallback Font Awesome will be used instead (version: %s).', 'better-font-awesome' ),
1072
  '<code>' . $this->get_error('css')->get_error_code() . ': ' . $this->get_error('css')->get_error_message() . '</code>',
1073
  '<br />',
1074
  '<code>' . $this->font_awesome_version . '</code>'
@@ -1109,7 +1117,7 @@ class Better_Font_Awesome_Library {
1109
  * @return string $contents Content of local file.
1110
  */
1111
  private function get_local_file_contents( $file_path ) {
1112
-
1113
  ob_start();
1114
  include $file_path;
1115
  $contents = ob_get_clean();
@@ -1138,7 +1146,7 @@ class Better_Font_Awesome_Library {
1138
  * @param string $error_type Type of error (api, css, etc).
1139
  * @param string $code Error code.
1140
  * @param string $message Error message.
1141
- */
1142
  private function set_error( $error_type, $code, $message ) {
1143
  $this->errors[ $error_type ] = new WP_Error( $code, $message );
1144
  }
@@ -1168,7 +1176,7 @@ class Better_Font_Awesome_Library {
1168
  if ( $this->api_data ) {
1169
  return true;
1170
  } else {
1171
- return false;
1172
  }
1173
 
1174
  }
@@ -1183,7 +1191,7 @@ class Better_Font_Awesome_Library {
1183
  * @return mixed $value Value associated with specified key.
1184
  */
1185
  public function get_api_value( $key ) {
1186
-
1187
  if ( $this->api_data ) {
1188
  $value = $this->api_data->$key;
1189
  } else {
32
  /**
33
  * Better Font Awesome Library slug.
34
  *
35
+ * @since 1.0.0
36
+ *
37
  * @var string
38
  */
39
  const SLUG = 'bfa';
42
  * Better Font Awesome Library version slug.
43
  *
44
  * @since 1.0.0
45
+ *
46
  * @var string
47
  */
48
  const VERSION = '1.0.0';
51
  * jsDelivr API URL for Font Awesome version info.
52
  *
53
  * @since 1.0.0
54
+ *
55
  * @var string
56
  */
57
  const JSDELIVR_API_URL = 'http://api.jsdelivr.com/v1/jsdelivr/libraries/fontawesome/?fields=versions,lastversion';
58
+
59
  /**
60
  * Initialization args.
61
  *
62
+ * @since 1.0.0
63
+ *
64
  * @var array
65
  */
66
  private $args;
69
  * Default args to use if any $arg isn't specified.
70
  *
71
  * @since 1.0.0
72
+ *
73
  * @var array
74
  */
75
  private $default_args = array(
107
  * Array to hold the jsDelivr API data.
108
  *
109
  * @since 1.0.0
110
+ *
111
  * @var string
112
  */
113
  private $api_data = array();
116
  * Version of Font Awesome being used.
117
  *
118
  * @since 1.0.0
119
+ *
120
  * @var string
121
  */
122
  private $font_awesome_version;
125
  * Font Awesome stylesheet URL.
126
  *
127
  * @since 1.0.0
128
+ *
129
  * @var string
130
  */
131
  private $stylesheet_url;
134
  * Font Awesome CSS.
135
  *
136
  * @since 1.0.0
137
+ *
138
  * @var string
139
  */
140
  private $css;
143
  * Data associated with the local fallback version of Font Awesome.
144
  *
145
  * @since 1.0.0
146
+ *
147
  * @var string
148
  */
149
  private $fallback_data = array(
158
  * Array of available Font Awesome icon slugs.
159
  *
160
  * @since 1.0.0
161
+ *
162
  * @var string
163
  */
164
  private $icons = array();
167
  * Font Awesome prefix to be used ('icon' or 'fa').
168
  *
169
  * @since 1.0.0
170
+ *
171
  * @var string
172
  */
173
  private $prefix;
176
  * Array to track errors and wp_remote_get() failures.
177
  *
178
  * @since 1.0.0
179
+ *
180
  * @var array
181
  */
182
  private $errors = array();
199
  * @return Better_Font_Awesome_Library The BFAL object.
200
  */
201
  public static function get_instance( $args = array() ) {
202
+
203
  // If the single instance hasn't been set, set it now.
204
  if ( null == self::$instance ) {
205
  self::$instance = new self( $args );
257
  * remove them.
258
  */
259
  if ( $this->args['remove_existing_fa'] ) {
260
+
261
  add_action( 'wp_enqueue_scripts', array( $this, 'remove_font_awesome_css' ), 15 );
262
  add_action( 'init', array( $this, 'remove_icon_shortcode' ), 15 );
263
 
296
 
297
  // Load TinyMCE functionality.
298
  if ( $this->args['load_tinymce_plugin'] ) {
299
+
300
  add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) );
301
 
302
  // Add shortcode insertion button.
366
  */
367
  function setup_root_url() {
368
 
369
+ // Get BFA directory and theme root directory paths.
370
  $bfa_directory = dirname(__FILE__);
371
  $theme_directory = get_stylesheet_directory();
372
  $plugin_dir = plugin_dir_url( __FILE__ );
389
  // Get relative BFA directory by removing theme root directory path.
390
  $bfa_rel_path = str_replace( $theme_directory, '', $bfa_directory );
391
  $this->root_url = trailingslashit( get_stylesheet_directory_uri() . $bfa_rel_path );
392
+
393
  } else { // Otherwise we're inside a plugin.
394
 
395
  $this->root_url = trailingslashit( plugin_dir_url( __FILE__ ) );
396
 
397
+ }
398
+
399
  }
400
 
401
  /**
457
  private function fetch_api_data( $url ) {
458
 
459
  if ( false === ( $response = get_transient( self::SLUG . '-api-versions' ) ) ) {
460
+
461
  $response = wp_remote_get( $url, $this->wp_remote_get_args );
462
 
463
  if ( 200 == wp_remote_retrieve_response_code( $response ) ) {
464
+
465
  // Decode the API data and grab the versions info.
466
  $json_data = json_decode( wp_remote_retrieve_body( $response ) );
467
  $response = $json_data[0];
484
  $response = '';
485
 
486
  } elseif ( isset( $response['response'] ) ) { // Check for 404 and other non-WP_ERROR codes
487
+
488
  $this->set_error( 'api', $response['response']['code'], $response['response']['message'] . " (URL: $url)" );
489
  $response = '';
490
 
549
 
550
  $css_transient_latest_version = $this->get_css_transient_latest_version();
551
 
552
+ if ( version_compare( $css_transient_latest_version, $this->fallback_data['version'], '>' ) ) {
553
  return $css_transient_latest_version;
554
+ } else {
555
  return $this->fallback_data['version'];
556
  }
557
 
568
  private function get_css_transient_latest_version() {
569
 
570
  $transient_css_array = get_transient( self::SLUG . '-css' );
571
+
572
  if ( ! empty( $transient_css_array ) ) {
573
  return max( array_keys( $transient_css_array ) );
574
  } else {
617
  *
618
  * @return string $response Font Awesome CSS, from either:
619
  * 1. transient,
620
+ * 2. wp_remote_get(), or
621
  * 3. fallback CSS.
622
  */
623
  private function get_css( $url, $version ) {
624
+
625
  // First try getting the transient CSS.
626
  $response = $this->get_transient_css( $version );
627
+
628
  // Next, try fetching the CSS from the remote jsDelivr CDN.
629
  if ( ! $response ) {
630
  $response = $this->get_remote_css( $url, $version );
674
  * @return string Transient CSS if it exists, otherwise null.
675
  */
676
  private function get_transient_css( $version ) {
677
+
678
  $transient_css_array = get_transient( self::SLUG . '-css' );
679
  return isset( $transient_css_array[ $version ] ) ? $transient_css_array[ $version ] : '';
680
 
696
  // Get the remote Font Awesome CSS.
697
  $url = set_url_scheme( $url );
698
  $response = wp_remote_get( $url, $this->wp_remote_get_args );
699
+
700
  /**
701
  * If fetch was successful, return the remote CSS, and set the CSS
702
  * transient for this version. Otherwise, return a WP_Error object.
703
  */
704
  if ( 200 == wp_remote_retrieve_response_code( $response ) ) {
705
+
706
  $response = wp_remote_retrieve_body( $response );
707
  $this->set_css_transient( $version, $response );
708
 
734
  * Awesome version.
735
  */
736
  $transient_css_array = get_transient( self::SLUG . '-css' );
737
+
738
  // Set the new value for the specified Font Awesome version.
739
  $transient_css_array[ $version ] = $value;
740
 
746
  * @param int Expiration for the CSS transient.
747
  */
748
  $transient_expiration = apply_filters( 'bfa_css_transient_expiration', 30 * DAY_IN_SECONDS );
749
+
750
  // Set the new CSS array transient.
751
  set_transient( self::SLUG . '-css', $transient_css_array, $transient_expiration );
752
 
773
  * @return array All available icon names (e.g. adjust, car, pencil).
774
  */
775
  private function setup_icon_array( $css ) {
776
+
777
  $icons = array();
778
  $hex_codes = array();
779
 
795
  * Filter the array of available icons.
796
  *
797
  * @since 1.0.0
798
+ *
799
  * @param array $icons Array of all available icons.
800
  */
801
  $icons = apply_filters( 'bfa_icon_list', $icons );
840
  * @since 1.0.0
841
  */
842
  public function remove_font_awesome_css() {
843
+
844
  global $wp_styles;
845
 
846
  // Loop through all registered styles and remove any that appear to be Font Awesome.
847
  foreach ( $wp_styles->registered as $script => $details ) {
848
+
849
  if ( false !== strpos( $script, 'fontawesome' ) || false !== strpos( $script, 'font-awesome' ) ) {
850
  wp_dequeue_style( $script );
851
  }
885
  * @return string $output Icon HTML (e.g. <i class="fa fa-car"></i>).
886
  */
887
  public function render_shortcode( $atts ) {
888
+
889
  extract( shortcode_atts( array(
890
  'name' => '',
891
  'class' => '',
909
  // This helps both:
910
  // 1. Incorrect shortcodes (when user includes full class name including prefix)
911
  // 2. Old shortcodes from other plugins that required prefixes
912
+
913
  /**
914
+ * Strip 'icon-' and 'fa-' from the BEGINNING of $name.
915
+ *
916
  * This corrects for:
917
  * 1. Incorrect shortcodes (when user includes full class name including prefix)
918
  * 2. Old shortcodes from other plugins that required prefixes
919
  */
920
+ $prefixes = array( 'icon-', 'fa-' );
921
+ foreach ( $prefixes as $prefix ) {
922
+
923
+ if ( substr( $name, 0, strlen( $prefix ) ) == $prefix ) {
924
+ $name = substr( $name, strlen( $prefix ) );
925
+ }
926
+
927
+ }
928
+
929
  $name = str_replace( 'fa-', '', $name );
930
 
931
  // Add the version-specific prefix back on to $name, if it exists.
1004
  * @since 1.0.0
1005
  */
1006
  public function enqueue_admin_scripts() {
1007
+
1008
  // Custom admin CSS.
1009
  wp_enqueue_style( self::SLUG . '-admin', $this->root_url . 'css/admin-styles.css' );
1010
 
1015
  wp_enqueue_style( 'fontawesome-iconpicker', $this->root_url . 'lib/fontawesome-iconpicker/css/fontawesome-iconpicker.min.css' );
1016
  wp_enqueue_script( 'fontawesome-iconpicker', $this->root_url . 'lib/fontawesome-iconpicker/js/fontawesome-iconpicker.min.js' );
1017
 
1018
+ // Output PHP variables to JS.
1019
  $bfa_vars = array(
1020
  'fa_prefix' => $this->prefix,
1021
  'fa_icons' => $this->get_icons(),
1050
  *
1051
  * @since 1.0.0
1052
  */
1053
+ public function do_admin_notice() {
1054
 
1055
  if ( ! empty( $this->errors ) && apply_filters( 'bfa_show_errors', true ) ) :
1056
  ?>
1058
  <p>
1059
  <b><?php _e( 'Better Font Awesome', 'better-font-awesome' ); ?></b>
1060
  </p>
1061
+
1062
  <!-- API Error -->
1063
  <?php if ( is_wp_error ( $this->get_error('api') ) ) : ?>
1064
  <p>
1065
  <b><?php _e( 'API Error', 'better-font-awesome' ); ?></b><br />
1066
+ <?php
1067
+ printf( __( 'The attempt to reach the jsDelivr API server failed with the following error: %s', 'better-font-awesome' ),
1068
  '<code>' . $this->get_error('api')->get_error_code() . ': ' . $this->get_error('api')->get_error_message() . '</code>'
1069
  );
1070
  ?>
1075
  <?php if ( is_wp_error ( $this->get_error('css') ) ) : ?>
1076
  <p>
1077
  <b><?php _e( 'Remote CSS Error', 'better-font-awesome' ); ?></b><br />
1078
+ <?php
1079
+ printf( __( 'The attempt to fetch the remote Font Awesome stylesheet failed with the following error: %s %s The embedded fallback Font Awesome will be used instead (version: %s).', 'better-font-awesome' ),
1080
  '<code>' . $this->get_error('css')->get_error_code() . ': ' . $this->get_error('css')->get_error_message() . '</code>',
1081
  '<br />',
1082
  '<code>' . $this->font_awesome_version . '</code>'
1117
  * @return string $contents Content of local file.
1118
  */
1119
  private function get_local_file_contents( $file_path ) {
1120
+
1121
  ob_start();
1122
  include $file_path;
1123
  $contents = ob_get_clean();
1146
  * @param string $error_type Type of error (api, css, etc).
1147
  * @param string $code Error code.
1148
  * @param string $message Error message.
1149
+ */
1150
  private function set_error( $error_type, $code, $message ) {
1151
  $this->errors[ $error_type ] = new WP_Error( $code, $message );
1152
  }
1176
  if ( $this->api_data ) {
1177
  return true;
1178
  } else {
1179
+ return false;
1180
  }
1181
 
1182
  }
1191
  * @return mixed $value Value associated with specified key.
1192
  */
1193
  public function get_api_value( $key ) {
1194
+
1195
  if ( $this->api_data ) {
1196
  $value = $this->api_data->$key;
1197
  } else {
lib/better-font-awesome-library/js/admin.js CHANGED
@@ -8,7 +8,7 @@
8
 
9
  ( function( $ ) {
10
 
11
- $( document ).ready( function() {
12
 
13
  $( '.bfa-iconpicker' )
14
  .iconpicker({
8
 
9
  ( function( $ ) {
10
 
11
+ $( document ).on( 'tinymce-editor-init', function() {
12
 
13
  $( '.bfa-iconpicker' )
14
  .iconpicker({
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: better, font, awesome, icon, icons, bootstrap, fontstrap, cdn, shortcode
4
  Donate link: http://mightyminnow.com
5
  Requires at least: 3.0
6
  Tested up to: 4.3
7
- Stable tag: 1.3.0
8
  License: GPLv2+
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -12,6 +12,8 @@ The Better Font Awesome plugin for WordPress. Shortcodes, HTML, TinyMCE, various
12
 
13
  == Description ==
14
 
 
 
15
  Better Font Awesome allows you to automatically integrate the latest available version of [Font Awesome](http://fontawesome.io/) into your WordPress project, along with accompanying CSS, shortcodes, and TinyMCE icon shortcode generator.
16
 
17
 
@@ -107,6 +109,9 @@ Better Font Awesome does it's best to load after any existing Font Awesome CSS,
107
 
108
  == Changelog ==
109
 
 
 
 
110
  = 1.3.0 =
111
  * Replace outdated TinyMCE shortcode selector brand new jQuery dropdown selector that works in both the visual and text editor
112
  * Clean up CSS and JS
@@ -191,6 +196,9 @@ Better Font Awesome does it's best to load after any existing Font Awesome CSS,
191
 
192
  == Upgrade Notice ==
193
 
 
 
 
194
  = 1.3.0 =
195
  * Replace outdated TinyMCE shortcode selector brand new jQuery dropdown selector that works in both the visual and text editor
196
  * Clean up CSS and JS
4
  Donate link: http://mightyminnow.com
5
  Requires at least: 3.0
6
  Tested up to: 4.3
7
+ Stable tag: 1.3.1
8
  License: GPLv2+
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
12
 
13
  == Description ==
14
 
15
+ **Do you find this plugin helpful? Please consider [leaving a 5-star review](https://wordpress.org/support/view/plugin-reviews/better-font-awesome).**
16
+
17
  Better Font Awesome allows you to automatically integrate the latest available version of [Font Awesome](http://fontawesome.io/) into your WordPress project, along with accompanying CSS, shortcodes, and TinyMCE icon shortcode generator.
18
 
19
 
109
 
110
  == Changelog ==
111
 
112
+ = 1.3.1 =
113
+ * Update admin JS to trigger icon picker on ALL TinyMCE initializations (e.g. Visual Composer and AJAX)
114
+
115
  = 1.3.0 =
116
  * Replace outdated TinyMCE shortcode selector brand new jQuery dropdown selector that works in both the visual and text editor
117
  * Clean up CSS and JS
196
 
197
  == Upgrade Notice ==
198
 
199
+ = 1.3.1 =
200
+ * Update admin JS to trigger icon picker on ALL TinyMCE initializations (e.g. Visual Composer and AJAX)
201
+
202
  = 1.3.0 =
203
  * Replace outdated TinyMCE shortcode selector brand new jQuery dropdown selector that works in both the visual and text editor
204
  * Clean up CSS and JS