diff --git a/.travis.yml b/.travis.yml
index 2b380fc..6e66a6c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -20,10 +20,14 @@ matrix:
include:
- php: 7.4
env: WP_VERSION=latest
+ - php: 7.3
+ env: WP_VERSION=latest
- php: 5.6
env: WP_VERSION=latest
- php: 5.6
env: WP_VERSION=trunk
+ - php: 5.6
+ env: WP_VERSION=4.9
- php: 7.4
env: WP_TRAVISCI=phpcs
diff --git a/Gruntfile.js b/Gruntfile.js
index 0bbcec8..e059d64 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -3,161 +3,165 @@
module.exports = function( grunt ) {
- // Grab package as variable for later use/
- var pkg = grunt.file.readJSON( 'package.json' );
+ // Grab package as variable for later use/
+ var pkg = grunt.file.readJSON( 'package.json' );
- // Load all tasks.
- require('load-grunt-tasks')(grunt, {scope: 'devDependencies'});
+ // Load all tasks.
+ require('load-grunt-tasks')(grunt, {scope: 'devDependencies'});
- // Project configuration
- grunt.initConfig( {
- pkg: pkg,
- devUpdate: {
- main: {
- options: {
- updateType: 'prompt',
- packages: {
- devDependencies: true
- },
- }
- }
- },
- prompt: {
- version: {
- options: {
- questions: [
- {
- config: 'newVersion',
- type: 'input',
- message: 'What specific version would you like?',
- default: '<%= pkg.version %>'
- },
- {
- config: 'updateStable',
- type: 'confirm',
- message: 'Bump stable version?',
- default: false
- }
- ]
- }
- }
- },
- replace: {
- package: {
- src: ['package.json'],
- overwrite: true,
- replacements: [
- {
- "version": "1.0.0",
- from: /("version":\s*).*,\n/g,
- to: '$1"<%= newVersion %>",\n'
- }
- ]
- },
- readme: {
- src: ['readme.txt'],
- overwrite: true,
- replacements: [
- {
- from: /(Stable tag:\s*)(.*)(\n)/g,
- to: function(matchedText, index, fullText, regexMatches) {
- return grunt.config('updateStable') ? regexMatches[0] + grunt.config('newVersion') + regexMatches[2]: matchedText;
- }
- }
- ]
- },
- php: {
- src: ['better-font-awesome.php'],
- overwrite: true,
- replacements: [
- {
- from: /(\*\s*Version:\s*).*\n/g,
- to: '$1<%= newVersion %>\n'
- }
- ]
- }
- },
- makepot: {
- target: {
- options: {
- domainPath: '/languages/', // Where to save the POT file.
- potFilename: 'better-font-awesome.pot', // Name of the POT file.
- type: 'wp-plugin' // Type of project (wp-plugin or wp-theme).
- }
- }
- },
- wp_readme_to_markdown: {
- readme: {
- files: {
- 'readme.md': 'readme.txt'
- },
- options: {
- post_convert: function(text) {
- var prefix = [
- '[![Build Status](https://travis-ci.org/MickeyKay/better-font-awesome.svg?branch=master)](https://travis-ci.org/MickeyKay/better-font-awesome)',
- '[![Downloads](https://img.shields.io/wordpress/plugin/dt/better-font-awesome.svg)](https://wordpress.org/plugins/better-font-awesome/)',
- '[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)'
- ].join(' ');
+ // Project configuration
+ grunt.initConfig( {
+ pkg: pkg,
+ devUpdate: {
+ main: {
+ options: {
+ updateType: 'prompt',
+ packages: {
+ devDependencies: true
+ },
+ }
+ }
+ },
+ prompt: {
+ version: {
+ options: {
+ questions: [
+ {
+ config: 'newVersion',
+ type: 'input',
+ message: 'What specific version would you like?',
+ default: '<%= pkg.version %>'
+ },
+ {
+ config: 'updateStable',
+ type: 'confirm',
+ message: 'Bump stable version?',
+ default: false
+ }
+ ]
+ }
+ }
+ },
+ replace: {
+ package: {
+ src: ['package.json'],
+ overwrite: true,
+ replacements: [
+ {
+ "version": "1.0.0",
+ from: /("version":\s*).*,\n/g,
+ to: '$1"<%= newVersion %>",\n'
+ }
+ ]
+ },
+ readme: {
+ src: ['readme.txt'],
+ overwrite: true,
+ replacements: [
+ {
+ from: /(Stable tag:\s*)(.*)(\n)/g,
+ to: function(matchedText, index, fullText, regexMatches) {
+ return grunt.config('updateStable') ? regexMatches[0] + grunt.config('newVersion') + regexMatches[2]: matchedText;
+ }
+ }
+ ]
+ },
+ php: {
+ src: ['better-font-awesome.php'],
+ overwrite: true,
+ replacements: [
+ {
+ from: /(\*\s*Version:\s*).*\n/g,
+ to: '$1<%= newVersion %>\n'
+ },
+ {
+ from: /(const VERSION = ').*(';)/g,
+ to: '$1<%= newVersion %>$2'
+ }
+ ]
+ }
+ },
+ makepot: {
+ target: {
+ options: {
+ domainPath: '/languages/', // Where to save the POT file.
+ potFilename: 'better-font-awesome.pot', // Name of the POT file.
+ type: 'wp-plugin' // Type of project (wp-plugin or wp-theme).
+ }
+ }
+ },
+ wp_readme_to_markdown: {
+ readme: {
+ files: {
+ 'readme.md': 'readme.txt'
+ },
+ options: {
+ post_convert: function(text) {
+ var prefix = [
+ '[![Build Status](https://travis-ci.com/MickeyKay/better-font-awesome.svg?branch=master)](https://travis-ci.com/MickeyKay/better-font-awesome)',
+ '[![Downloads](https://img.shields.io/wordpress/plugin/dt/better-font-awesome.svg)](https://wordpress.org/plugins/better-font-awesome/)',
+ '[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)'
+ ].join(' ');
- return [prefix,text].join('\n\n');
- }
- }
- },
- },
- copy: {
- composerDeps: {
- src: [
- 'vendor/mickey-kay/**'
- ],
- dest: 'svn/trunk/'
- },
- svnAssets: {
- cwd: 'assets/',
- src: ['**'],
- dest: 'svn/assets/',
- expand: true,
- },
- svnTrunk: {
- src: [
- '**',
- '!node_modules/**',
- '!vendor/**',
- '!svn/**',
- '!.git/**',
- '!.gitignore',
- '!.gitmodules',
- '!.sass-cache/**',
- '!bin/**',
- '!tests/**',
- '!css/src/**',
- '!js/src/**',
- '!img/src/**',
- '!assets/**',
- '!design/**',
- '!Gruntfile.js',
- '!package.json',
- '!composer*',
- ],
- dest: 'svn/trunk/',
- },
- svnTags: {
- cwd: 'svn/trunk/',
- src: ['**'],
- dest: 'svn/tags/<%= newVersion %>/',
- expand: true,
- }
- }
- } );
+ return [prefix,text].join('\n\n');
+ }
+ }
+ },
+ },
+ copy: {
+ composerDeps: {
+ src: [
+ 'vendor/mickey-kay/**'
+ ],
+ dest: 'svn/trunk/'
+ },
+ svnAssets: {
+ cwd: 'assets/',
+ src: ['**'],
+ dest: 'svn/assets/',
+ expand: true,
+ },
+ svnTrunk: {
+ src: [
+ '**',
+ '!node_modules/**',
+ '!vendor/**',
+ '!svn/**',
+ '!.git/**',
+ '!.gitignore',
+ '!.gitmodules',
+ '!.sass-cache/**',
+ '!bin/**',
+ '!tests/**',
+ '!css/src/**',
+ '!js/src/**',
+ '!img/src/**',
+ '!assets/**',
+ '!design/**',
+ '!Gruntfile.js',
+ '!package.json',
+ '!composer*',
+ ],
+ dest: 'svn/trunk/',
+ },
+ svnTags: {
+ cwd: 'svn/trunk/',
+ src: ['**'],
+ dest: 'svn/tags/<%= newVersion %>/',
+ expand: true,
+ }
+ }
+ } );
- grunt.registerTask( 'build', [
- 'prompt',
- 'replace',
- 'makepot',
- 'wp_readme_to_markdown',
- 'copy'
- ] );
+ grunt.registerTask( 'build', [
+ 'prompt',
+ 'replace',
+ 'makepot',
+ 'wp_readme_to_markdown',
+ 'copy'
+ ] );
- grunt.registerTask( 'default', 'build' );
+ grunt.registerTask( 'default', 'build' );
- grunt.util.linefeed = '\n';
+ grunt.util.linefeed = '\n';
};
diff --git a/README.md b/README.md
index b52d4b2..d7cb78c 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-[![Build Status](https://travis-ci.org/MickeyKay/better-font-awesome.svg?branch=master)](https://travis-ci.org/MickeyKay/better-font-awesome) [![Downloads](https://img.shields.io/wordpress/plugin/dt/better-font-awesome.svg)](https://wordpress.org/plugins/better-font-awesome/) [![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
+[![Build Status](https://travis-ci.com/MickeyKay/better-font-awesome.svg?branch=master)](https://travis-ci.com/MickeyKay/better-font-awesome) [![Downloads](https://img.shields.io/wordpress/plugin/dt/better-font-awesome.svg)](https://wordpress.org/plugins/better-font-awesome/) [![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
# Better Font Awesome #
**Contributors:** [McGuive7](https://profiles.wordpress.org/McGuive7), [aaronbmm](https://profiles.wordpress.org/aaronbmm), [mightyminnow](https://profiles.wordpress.org/mightyminnow)
@@ -14,7 +14,7 @@ The Better Font Awesome plugin for WordPress. Shortcodes, HTML, TinyMCE, various
## Description ##
-[![Build Status](https://travis-ci.org/MickeyKay/better-font-awesome.svg?branch=master)](https://travis-ci.org/MickeyKay/better-font-awesome)
+[![Build Status](https://travis-ci.com/MickeyKay/better-font-awesome.svg?branch=master)](https://travis-ci.com/MickeyKay/better-font-awesome)
**Do you find this plugin helpful? Please consider [leaving a 5-star review](https://wordpress.org/support/view/plugin-reviews/better-font-awesome).**
@@ -113,6 +113,18 @@ Better Font Awesome does it's best to load after any existing Font Awesome CSS,
## Changelog ##
+### 2.0.0 ###
+* Add support for Font Awesome v5
+* Integration with Font Awesome GraphQL API for all data fetching (improve performance)
+* Integrate with Font Awesome CDN for all CSS
+* Add option to include the v4 Font Awesome CSS shim to support older icons (default on for upgrades)
+* Updatee hard-coded fallback Font Awesome version
+* Modify version check frequency to a saner 24 hour interval
+* Ensure admin notices are dismissible
+* Lower data fetch timeout to mitigate performance risks
+* Remove legacy options that are no longer relevant (version select, minification opt-out)
+* Add more/better unit tests to ensure things are working as expected
+
### 1.7.6 ###
* Fix: revert to 1.7.4 codebase.
* Fix: remove calls to `ready()` jQuery method to support latest jQuery versions.
@@ -138,126 +150,20 @@ Better Font Awesome does it's best to load after any existing Font Awesome CSS,
* Update fallback Font Awesome to v4.7.0.
* Switch from using git submodules to composer dependency management for core library inclusion.
-### 1.6.0 ###
-* Update fallback Font Awesome to v4.6.3.
-
-### 1.5.0 ###
-* Update fallback Font Awesome to v4.5.0.
-* Add new `bfa_icon_tag` to allow for filtering default `` tag.
-
-### 1.4.3 ###
-* Fix: refactor JS to allow icon shortcode insertion button to work in all instances (ACF Flexible and Repeater fields, divi, Black Studio TinyMCE ).
-
-### 1.4.2 ###
-* Fix: icon picker not working for ACF Pro repeater field.
-
-### 1.4.1 ###
-* Fix: icon picker not working for ACF repeater field.
-
-### 1.4.0 ###
-* Fix: icon picker not working for Black Studio TinyMCE Widget. (props @EJOweb and @marcochiesi)
-* Update fallback Font Awesome to version 4.4.0.
-
-### 1.3.4 ###
-* Update Better Font Awesome Library to version 1.3.4.
-* Fix double shortcode insert issue.
-* Fix behavior in which clicking shortcode insert button scrolls to top of page.
-
-### 1.3.3 ###
-* Update plugin and BFAL to all fire on `init` hook instead of mix of `plugins_loaded` and `after_theme_setup`. This should fix issues in which icons don't show up when BFAL is used in other plugins.
-* Update iconpicker JS to avoid conflict that arose from preventing subsequent `mouseup` event listeners from firing.
-* Change appearance of iconpicker button to match default buttons.
-
-### 1.3.2 ###
-* Update Better Font Awesome Library with better prefix removal method for filtered icons.
-
-### 1.3.1 ###
-* Update admin JS to trigger icon picker on ALL TinyMCE initializations (e.g. Visual Composer and AJAX)
-
-### 1.3.0 ###
-* Replace outdated TinyMCE shortcode selector brand new jQuery dropdown selector that works in both the visual and text editor
-* Clean up CSS and JS
-
-### 1.2.1 ###
-* Update get_instance() call to work for older versions of PHP (< 5.3)
-
-### 1.2.0 ###
-* Attach load functionality to after_theme_setup hook to allow themes to filter options
-* Update fallback Font Awesome to version 4.3.0
-
-### 1.1.0 ###
-* Implement Ajax to save plugin settings (thanks [Braad](https://profiles.wordpress.org/braad))
-
-### 1.0.10 ###
-* Fix SSL bug breaking wp_remote_get() from https.
-
-### 1.0.9 ###
-* Fix debuggin hook set to init instead of plugins_loaded.
-
-### 1.0.8 ###
-* Add admin setting to hide admin notices for API and CDN connectivity warnings.
-* Update translations.
-
-### 1.0.7 ###
-* Update included fallback to Font Awesome version 4.3.
-
-### 1.0.6 ###
-* Unhook library load() function from plugins_loaded and run directly from constructor (fixes bug preventing developers from overriding initialization easily).
-
-### 1.0.5 ###
-* Add fa_force_fallback and bfa_show_errors filters.
-* Add hex icon values as $icon array indexes.
-
-### 1.0.4 ###
-* Add missing isset() check that was causing intermittent warning.
-
-### 1.0.3 ###
-* Add French translation.
-* Correct text domain slug.
-
-### 1.0.2 ###
-* Add updated .pot file.
-* Further improve error handling and fallback.
-
-### 1.0.1 ###
-* Fix error handling for 404 API requests.
-
-### 1.0.0 ###
-* Fully refactor the back-end.
-* Switch to just using the jsDelivr CDN.
-* Implement transients to minimize load time.
-* Implement improved fallback handling (transient → wp_remote_get() → locally included files)
-* Switch out bulky Titan Framework for native Settings API.
-
-### 0.9.6 ###
-* Fixed missing icon previews in WordPress 3.8 and below.
-
-### 0.9.5 ###
-* Added ability to choose which CDN to use.
-* Added `unprefixed_class` shortcode attribute to allow for unprefixed shortcodes.
-* Updated prefixes to now return just the prefix without the dash (-).
-
-### 0.9.4 ###
-* Switched default being output. Now the default "space" attribute is false, and can be set to true to optionally include a space.
-* PLEASE NOTE: this will affect existing shortcodes.
-
-### 0.9.3 ###
-* Fixed admin-styles.css bug that was applying FontAwesome font-face outside TinyMCE
-* Print JS variables in front-end to aid developers
-* Create global $better_font_awesome object for developers to access
-
-### 0.9.2 ###
-* Fixes issue of missing icon drop-down select menu in TinyMCE (adds compatibility for TinyMCE v4)
-
-### 0.9.1 ###
-* Added fixes for older versions of PHP (Titan Framework not found, unexpected "[")
-
-### 0.9.0 ###
-* First release!
-
-
## Upgrade Notice ##
+### 2.0.0 ###
+* Add support for Font Awesome v5
+* Integration with Font Awesome GraphQL API for all data fetching (improve performance)
+* Integrate with Font Awesome CDN for all CSS
+* Add option to include the v4 Font Awesome CSS shim to support older icons (default on for upgrades)
+* Updatee hard-coded fallback Font Awesome version
+* Modify version check frequency to a saner 24 hour interval
+* Ensure admin notices are dismissible
+* Lower data fetch timeout to mitigate performance risks
+* Remove legacy options that are no longer relevant (version select, minification opt-out)
+* Add more/better unit tests to ensure things are working as expected
+
### 1.7.6 ###
* Fix: revert to 1.7.4 codebase.
* Fix: remove calls to `ready()` jQuery method to support latest jQuery versions.
@@ -282,120 +188,3 @@ Better Font Awesome does it's best to load after any existing Font Awesome CSS,
### 1.7.0 ###
* Update fallback Font Awesome to v4.7.0.
* Switch from using git submodules to composer dependency management for core library inclusion.
-
-### 1.6.0 ###
-* Update fallback Font Awesome to v4.6.3.
-
-### 1.5.0 ###
-* Update fallback Font Awesome to v4.5.0.
-* Add new `bfa_icon_tag` to allow for filtering default `` tag.
-
-### 1.4.3 ###
-* Fix: refactor JS to allow icon shortcode insertion button to work in all instances (ACF Flexible and Repeater fields, divi, Black Studio TinyMCE ).
-
-### 1.4.2 ###
-* Fix: icon picker not working for ACF Pro repeater field.
-
-### 1.4.1 ###
-* Fix: icon picker not working for ACF repeater field.
-
-### 1.4.0 ###
-* Fix: icon picker not working for Black Studio TinyMCE Widget. (props @EJOweb and @marcochiesi)
-* Update fallback Font Awesome to version 4.4.0.
-
-### 1.3.4 ###
-* Update Better Font Awesome Library to version 1.3.4.
-* Fix double shortcode insert issue.
-* Fix behavior in which clicking shortcode insert button scrolls to top of page.
-
-### 1.3.3 ###
-* Update plugin and BFAL to all fire on `init` hook instead of mix of `plugins_loaded` and `after_theme_setup`. This should fix issues in which icons don't show up when BFAL is used in other plugins.
-* Update iconpicker JS to avoid conflict that arose from preventing subsequent `mouseup` event listeners from firing.
-* Change appearance of iconpicker button to match default buttons.
-
-### 1.3.2 ###
-* Update Better Font Awesome Library with better prefix removal method.
-
-### 1.3.1 ###
-* Update admin JS to trigger icon picker on ALL TinyMCE initializations (e.g. Visual Composer and AJAX)
-
-### 1.3.0 ###
-* Replace outdated TinyMCE shortcode selector brand new jQuery dropdown selector that works in both the visual and text editor
-* Clean up CSS and JS
-
-### 1.2.1 ###
-* Update get_instance() call to work for older versions of PHP (< 5.3)
-
-### 1.2.0 ###
-* Attach load functionality to after_theme_setup hook to allow themes to filter options
-* Update fallback Font Awesome to version 4.3.0
-
-### 1.1.0 ###
-* Implement Ajax to save plugin settings (thanks [Braad](https://profiles.wordpress.org/braad))
-
-### 1.0.10 ###
-* Fix SSL bug breaking wp_remote_get() from https
-
-### 1.0.9 ###
-* Fix debuggin hook set to init instead of plugins_loaded.
-
-### 1.0.8 ###
-* Add admin setting to hide admin notices for API and CDN connectivity warnings.
-* Update translations.
-
-### 1.0.7 ###
-* Update included fallback to Font Awesome version 4.3.
-
-### 1.0.6 ###
-* Unhook library load() function from plugins_loaded and run directly from constructor (fixes bug preventing developers from overriding initialization easily).
-
-### 1.0.5 ###
-* Add fa_force_fallback and bfa_show_errors filters.
-* Add hex icon values as $icon array indexes.
-
-### 1.0.4 ###
-* Add missing isset() check that was causing intermittent warning.
-
-### 1.0.3 ###
-* Add French translation.
-* Correct text domain slug.
-
-### 1.0.2 ###
-* Add updated .pot file.
-* Further improve error handling and fallback.
-
-### 1.0.1 ###
-* Fix error handling for 404 API requests.
-
-### 1.0.0 ###
-* Fully refactor the back-end.
-* Switch to just using the jsDelivr CDN.
-* Implement transients to minimize load time.
-* Implement improved fallback handling (transient → wp_remote_get() → locally included files)
-* Switch out bulky Titan Framework for native Settings API.
-
-### 0.9.6 ###
-* Fixed missing icon previews in WordPress 3.8 and below.
-
-### 0.9.5 ###
-* Added ability to choose which CDN to use.
-* Added `unprefixed_class` shortcode attribute to allow for unprefixed shortcodes.
-* Updated prefixes to now return just the prefix without the dash (-).
-
-### 0.9.4 ###
-* Switched default being output. Now the default "space" attribute is false, and can be set to true to optionally include a space.
-* PLEASE NOTE: this will affect existing shortcodes.
-
-### 0.9.3 ###
-* Fixed admin-styles.css bug that was applying FontAwesome font-face outside TinyMCE
-* Print JS variables in front-end to aid developers
-* Create global $better_font_awesome object for developers to access
-
-### 0.9.2 ###
-* Fixes issue of missing icon drop-down select menu in TinyMCE (adds compatibility for TinyMCE v4)
-
-### 0.9.1 ###
-* Added fixes for older versions of PHP (Titan Framework not found, unexpected "[")
-
-### 0.9.0 ###
-* First release!
diff --git a/better-font-awesome.php b/better-font-awesome.php
old mode 100644
new mode 100755
index 848eb41..51873ad
--- a/better-font-awesome.php
+++ b/better-font-awesome.php
@@ -12,7 +12,7 @@
* Plugin Name: Better Font Awesome
* Plugin URI: http://wordpress.org/plugins/better-font-awesome
* Description: The ultimate Font Awesome icon plugin for WordPress.
- * Version: 1.7.6
+ * Version: 2.0.0
* Author: Mickey Kay
* Author URI: mickeyskay@gmail.com
* License: GPLv2+
@@ -32,8 +32,8 @@
* @since 0.9.5
*/
function bfa_start() {
- global $better_font_awesome;
- $better_font_awesome = Better_Font_Awesome_Plugin::get_instance();
+ global $better_font_awesome;
+ $better_font_awesome = Better_Font_Awesome_Plugin::get_instance();
}
/**
@@ -43,675 +43,539 @@ function bfa_start() {
*/
class Better_Font_Awesome_Plugin {
- /**
- * Plugin slug.
- *
- * @since 0.9.0
- *
- * @var string
- */
- const SLUG = 'better-font-awesome';
-
- /**
- * The Better Font Awesome Library object.
- *
- * @since 0.1.0
- *
- * @var Better_Font_Awesome_Library
- */
- private $bfa_lib;
-
- /**
- * Path to the Better Font Awesome Library main file.
- *
- * @since 0.1.0
- *
- * @var Better_Font_Awesome_Library
- */
- private $bfa_lib_file_path;
-
- /**
- * Plugin display name.
- *
- * @since 0.9.0
- *
- * @var string
- */
- private $plugin_display_name;
-
- /**
- * Plugin option name.
- *
- * @since 0.9.0
- *
- * @var string
- */
- protected $option_name;
-
- /**
- * Plugin options.
- *
- * @since 0.9.0
- *
- * @var string
- */
- protected $options;
-
- /**
- * Default options.
- *
- * Used for setting uninitialized plugin options.
- *
- * @since 0.9.0
- *
- * @var array
- */
- protected $option_defaults = array(
- 'version' => 'latest',
- 'minified' => 1,
- 'remove_existing_fa' => '',
- 'hide_admin_notices' => '',
- );
-
- /**
- * Instance of this class.
- *
- * @since 0.9.0
- *
- * @var Better_Font_Awesome_Plugin
- */
- protected static $instance = null;
-
-
- /**
- * Returns the instance of this class, and initializes the instance if it
- * doesn't already exist.
- *
- * @return Better_Font_Awesome The BFA object.
- */
- public static function get_instance( $args = array() ) {
-
- // If the single instance hasn't been set, set it now.
- if ( null == self::$instance ) {
- self::$instance = new self( $args );
- }
-
- return self::$instance;
-
- }
-
- /**
- * Better Font Awesome Plugin constructor.
- *
- * @since 0.9.0
- */
- function __construct() {
-
- // Perform plugin initialization actions.
- $this->initialize();
-
- // Stop if the Better Font Awesome Library isn't included.
- if ( ! $this->bfal_exists() ) {
- add_action( 'admin_init', array( $this, 'deactivate' ) );
- return false;
- }
-
- // Include required files.
- $this->includes();
-
- // Initialize the Better Font Awesome Library.
- $this->initialize_better_font_awesome_library( $this->options );
-
- // Load the plugin text domain.
- $this->load_text_domain();
-
- // Output admin notices.
- add_action( 'admin_notices', array( $this, 'do_admin_notices' ) );
-
- // Set up the admin settings page.
- add_action( 'admin_menu', array( $this, 'add_settings_page' ) );
- add_action( 'admin_init', array( $this, 'add_settings' ) );
- add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
-
- // Handle saving options via AJAX
- add_action( 'wp_ajax_bfa_save_options', array( $this, 'save_options' ) );
- add_action( 'wp_ajax_bfa_dismiss_testing_admin_notice', array( $this, 'dismiss_testing_admin_notice' ) );
-
- }
-
- /**
- * Do necessary initialization actions.
- *
- * @since 0.10.0
- */
- private function initialize() {
-
- // Set display name.
- $this->plugin_display_name = __( 'Better Font Awesome', 'better-font-awesome' );
-
- // Set options name.
- $this->option_name = self::SLUG . '_options';
-
- // Set up main Better Font Awesome Library file path.
- $this->bfa_lib_file_path = plugin_dir_path( __FILE__ ) . 'vendor/mickey-kay/better-font-awesome-library/better-font-awesome-library.php';
-
- // Get plugin options, and populate defaults as needed.
- $this->initialize_options( $this->option_name );
-
- }
-
- /**
- * Get class prop.
- *
- * @since 1.7.0
- *
- * @param string $prop Prop to fetch.
- *
- * @return mixed Value of the prop.
- */
- public function get( $prop ) {
- return $this->$prop;
- }
-
- /**
- * Check if the Better Font Awesome Library is included.
- *
- * @since 0.10.0
- */
- public function bfal_exists() {
-
- if ( ! is_readable( $this->bfa_lib_file_path ) ) {
- return false;
- } else {
- return true;
- }
-
- }
-
- /**
- * Deactivate and display an error if the BFAL isn't included.
- *
- * @since 0.10.0
- */
- public function deactivate() {
-
- deactivate_plugins( plugin_basename( __FILE__ ) );
-
- $message = '
' . __( 'Better Font Awesome', 'better-font-awesome' ) . '
';
- $message .= '
' . __( 'It appears that Better Font Awesome is missing it\'s core library, which typically occurs when cloning the Git repository and failing to run composer install. Please refer to the plugin\'s installation instructions for details on how to properly install Better Font Awesome via Git. If you installed from within WordPress, or via the wordpress.org repo, then chances are the install failed and you can try again. If the issue persists, please create a new topic on the plugin\'s support forum or file an issue on the Github repo.' , 'better-font-awesome' ) . '
';
-
- wp_die( $message );
-
- }
-
- /**
- * Include required files.
- *
- * @since 0.10.0
- */
- private function includes() {
-
- // Better Font Awesome Library.
- require_once $this->bfa_lib_file_path;
-
- }
-
- /**
- * Get plugin options, or initialize with default values.
- *
- * @since 0.10.0
- *
- * @return array Plugin options.
- */
- private function initialize_options( $option_name ) {
-
- /**
- * Get plugin options.
- *
- * Run maybe_unserialize() in case we're updating from the old
- * serialized Titan Framwork option to a new, array-based options.
- */
- $this->options = maybe_unserialize( get_option( $option_name ) );
-
- // Initialize the plugin options with defaults if they're not set.
- if ( empty( $this->options ) ) {
- update_option( $option_name, $this->option_defaults );
- }
-
- }
-
- /**
- * Initialize the Better Font Awesome Library object.
- *
- * @since 0.9.0
- *
- * @param array $options Plugin options.
- */
- private function initialize_better_font_awesome_library( $options ) {
-
- // Hide admin notices if setting is checked.
- if ( true == $options['hide_admin_notices'] ) {
- add_filter( 'bfa_show_errors', '__return_false' );
- }
-
- // Initialize BFA library.
- $args = array(
- 'version' => isset( $options['version'] ) ? $options['version'] : $this->option_defaults['version'],
- 'minified' => isset( $options['minified'] ) ? $options['minified'] : '',
- 'remove_existing_fa' => isset( $options['remove_existing_fa'] ) ? $options['remove_existing_fa'] :'',
- 'load_styles' => true,
- 'load_admin_styles' => true,
- 'load_shortcode' => true,
- 'load_tinymce_plugin' => true,
- );
-
- $this->bfa_lib = Better_Font_Awesome_Library::get_instance( $args );
-
- }
-
- /**
- * Load plugin text domain.
- *
- * @since 0.10.0
- */
- function load_text_domain() {
- load_plugin_textdomain( self::SLUG, false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
- }
-
- /**
- * Generate admin notices.
- *
- * @since 1.7.3
+ /**
+ * Plugin slug.
+ *
+ * @since 0.9.0
+ *
+ * @var string
+ */
+ const SLUG = 'better-font-awesome';
+
+ /**
+ * Plugin version.
+ *
+ * @since 2.0.0
+ *
+ * @var string
+ */
+ const VERSION = '2.0.0';
+
+ /**
+ * The Better Font Awesome Library object.
+ *
+ * @since 0.1.0
+ *
+ * @var Better_Font_Awesome_Library
+ */
+ private $bfa_lib;
+
+ /**
+ * Path to the Better Font Awesome Library main file.
+ *
+ * @since 0.1.0
+ *
+ * @var Better_Font_Awesome_Library
+ */
+ private $bfa_lib_file_path;
+
+ /**
+ * Plugin display name.
+ *
+ * @since 0.9.0
+ *
+ * @var string
*/
- public function do_admin_notices() {
+ private $plugin_display_name;
- $user_dismissed_option_data = $this->get_dismissed_admin_notice_testing_data();
+ /**
+ * Plugin option name.
+ *
+ * @since 0.9.0
+ *
+ * @var string
+ */
+ protected $option_name;
+
+ /**
+ * Plugin options.
+ *
+ * @since 0.9.0
+ *
+ * @var string
+ */
+ protected $options;
- if (
- !isset( $user_dismissed_option_data->{get_current_user_id()} ) ||
- true !== $user_dismissed_option_data->{get_current_user_id()}
- ) :
+ /**
+ * Default options.
+ *
+ * Used for setting uninitialized plugin options.
+ *
+ * @since 0.9.0
+ *
+ * @var array
+ */
+ protected $option_defaults = array(
+ 'include_v4_shim' => '',
+ 'remove_existing_fa' => '',
+ 'hide_admin_notices' => '',
+ );
+
+ /**
+ * Instance of this class.
+ *
+ * @since 0.9.0
+ *
+ * @var Better_Font_Awesome_Plugin
+ */
+ protected static $instance = null;
+
+
+ /**
+ * Returns the instance of this class, and initializes the instance if it
+ * doesn't already exist.
+ *
+ * @param array $args Args to instantiate BFA object.
+ *
+ * @return Better_Font_Awesome The BFA object.
+ */
+ public static function get_instance( $args = array() ) {
+
+ // If the single instance hasn't been set, set it now.
+ // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
+ if ( null == self::$instance ) {
+ self::$instance = new self( $args );
+ }
+
+ return self::$instance;
+ }
+
+ /**
+ * Better Font Awesome Plugin constructor.
+ *
+ * @since 0.9.0
+ */
+ protected function __construct() {
+
+ // Perform plugin initialization actions.
+ $this->initialize();
+
+ // Stop if the Better Font Awesome Library isn't included.
+ if ( ! $this->bfal_exists() ) {
+ add_action( 'admin_init', array( $this, 'deactivate' ) );
+ return false;
+ }
+
+ // Include required files.
+ $this->includes();
+
+ // Initialize the Better Font Awesome Library.
+ $this->initialize_better_font_awesome_library( $this->options );
+
+ // Load the plugin text domain.
+ $this->load_text_domain();
+
+ // Set up the admin settings page.
+ add_action( 'admin_menu', array( $this, 'add_settings_page' ) );
+ add_action( 'admin_init', array( $this, 'add_settings' ) );
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
+
+ // Handle saving options via AJAX.
+ add_action( 'wp_ajax_bfa_save_options', array( $this, 'save_options' ) );
+ }
+
+ /**
+ * Do necessary initialization actions.
+ *
+ * @since 0.10.0
+ */
+ private function initialize() {
+
+ // Set display name.
+ $this->plugin_display_name = __( 'Better Font Awesome', 'better-font-awesome' );
+
+ // Set options name.
+ $this->option_name = self::SLUG . '_options';
+
+ // Set up main Better Font Awesome Library file path.
+ $this->bfa_lib_file_path = plugin_dir_path( __FILE__ ) . 'vendor/mickey-kay/better-font-awesome-library/better-font-awesome-library.php';
+
+ // Get plugin options, and populate defaults as needed.
+ $this->initialize_options( $this->option_name );
+ }
+
+ /**
+ * Get class prop.
+ *
+ * @since 1.7.0
+ *
+ * @param string $prop Prop to fetch.
+ *
+ * @return mixed Value of the prop.
+ */
+ public function get( $prop ) {
+ return $this->$prop;
+ }
+
+ /**
+ * Check if the Better Font Awesome Library is included.
+ *
+ * @since 0.10.0
+ */
+ public function bfal_exists() {
+ if ( ! is_readable( $this->bfa_lib_file_path ) ) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ /**
+ * Get BFAL instance.
+ *
+ * @since 2.0.0
+ *
+ * @return Object BFAL instance.
+ */
+ public function get_bfa_lib_instance() {
+ return $this->bfa_lib;
+ }
+
+ /**
+ * Deactivate and display an error if the BFAL isn't included.
+ *
+ * @since 0.10.0
+ */
+ public function deactivate() {
+ deactivate_plugins( plugin_basename( __FILE__ ) );
+
+ $message = '
' . __( 'Better Font Awesome', 'better-font-awesome' ) . '
';
+ $message .= '
' . __( 'It appears that Better Font Awesome is missing it\'s core library, which typically occurs when cloning the Git repository and failing to run composer install. Please refer to the plugin\'s installation instructions for details on how to properly install Better Font Awesome via Git. If you installed from within WordPress, or via the wordpress.org repo, then chances are the install failed and you can try again. If the issue persists, please create a new topic on the plugin\'s support forum or file an issue on the Github repo.', 'better-font-awesome' ) . '