Font Awesome Icons - Version 4.0.0-rc20

Version Description

  • developer-oriented update to support building themes that use this code as a composer package
Download this release

Release Info

Developer mlwilkerson
Plugin Icon 128x128 Font Awesome Icons
Version 4.0.0-rc20
Comparing to
See all releases

Code changes from version 4.0.0-rc19 to 4.0.0-rc20

defines.php CHANGED
@@ -31,8 +31,8 @@ if ( ! defined( 'FONTAWESOME_DIR_URL' ) ) {
31
  /**
32
  * Active Font Awesome plugin installation directory URL.
33
  *
34
- * The result of `plugin_dir_url()` on the `defines.php` file for the actively
35
- * executing installation of the Font Awesome plugin.
36
  *
37
  * For example, if the example plugin under `integrations/plugins/plugin-sigma`
38
  * in this repo were installed, activated, and its copy of the Font Awesome
@@ -46,9 +46,26 @@ if ( ! defined( 'FONTAWESOME_DIR_URL' ) ) {
46
  * of this constant would look more like this:
47
  * `http://localhost:8765/wp-content/plugins/font-awesome/`
48
  *
 
 
 
 
 
 
 
49
  * @since 4.0.0
50
  */
51
- define( 'FONTAWESOME_DIR_URL', plugin_dir_url( __FILE__ ) );
 
 
 
 
 
 
 
 
 
 
52
  }
53
 
54
  if ( ! defined( 'FONTAWESOME_ENV' ) ) {
31
  /**
32
  * Active Font Awesome plugin installation directory URL.
33
  *
34
+ * The url that corresponds to the top level of the executing installation
35
+ * of the Font Awesome plugin (where the `defines.php` file lives).
36
  *
37
  * For example, if the example plugin under `integrations/plugins/plugin-sigma`
38
  * in this repo were installed, activated, and its copy of the Font Awesome
46
  * of this constant would look more like this:
47
  * `http://localhost:8765/wp-content/plugins/font-awesome/`
48
  *
49
+ * This also accounts for the possibility that current Font Awesome is installed
50
+ * as a composer package required by the current theme. For example, if the
51
+ * example theme under `integrations/themes/plugin-mu` in this repo were installed,
52
+ * activated, and its copy of the Font Awesome plugin were the one selected for execution,
53
+ * then the value of this constant would be something like this:
54
+ * `http://localhost:8765/wp-content/themes/theme-mu/vendor/fortawesome/wordpress-fontawesome/`
55
+ *
56
  * @since 4.0.0
57
  */
58
+ $ss_dir = get_stylesheet_directory();
59
+ /**
60
+ * If the current file path begins with the stylesheet directory, then we
61
+ * know that Font Awesome is being loaded as a dependency of a theme.
62
+ */
63
+ if ( substr( __FILE__, 0, strlen( $ss_dir ) ) === $ss_dir ) {
64
+ $fa_sub_path = substr( __DIR__, strlen( $ss_dir ) );
65
+ define( 'FONTAWESOME_DIR_URL', untrailingslashit( get_stylesheet_directory_uri() ) . '/' . trailingslashit( $fa_sub_path ) );
66
+ } else {
67
+ define( 'FONTAWESOME_DIR_URL', plugin_dir_url( __FILE__ ) );
68
+ }
69
  }
70
 
71
  if ( ! defined( 'FONTAWESOME_ENV' ) ) {
font-awesome.php CHANGED
@@ -123,7 +123,7 @@ if ( ! class_exists( 'FortAwesome\FontAwesome_Loader' ) ) :
123
  * @internal
124
  */
125
  private function __construct() {
126
- add_action( 'plugins_loaded', [ &$this, 'load_plugin' ], -1 );
127
  add_action( 'activate_' . FONTAWESOME_PLUGIN_FILE, [ &$this, 'activate_plugin' ], -1 );
128
  }
129
 
@@ -137,18 +137,16 @@ if ( ! class_exists( 'FortAwesome\FontAwesome_Loader' ) ) :
137
  * @throws Exception
138
  */
139
  private function select_latest_version_plugin_installation() {
140
- if ( count( self::$_loaded ) > 0 ) {
141
  return;
142
  }
143
 
144
- $versions = array_keys( self::$data );
145
-
146
  usort(
147
- $versions,
148
  function( $a, $b ) {
149
- if ( version_compare( $a, $b, '=' ) ) {
150
  return 0;
151
- } elseif ( version_compare( $a, $b, 'gt' ) ) {
152
  return -1;
153
  } else {
154
  return 1;
@@ -156,10 +154,9 @@ if ( ! class_exists( 'FortAwesome\FontAwesome_Loader' ) ) :
156
  }
157
  );
158
 
159
- $latest_version = $versions[0];
160
- $info = ( isset( self::$data[ $latest_version ] ) ) ? self::$data[ $latest_version ] : [];
161
 
162
- if ( empty( $info ) ) {
163
  throw new Exception(
164
  sprintf(
165
  esc_html__(
@@ -187,14 +184,11 @@ if ( ! class_exists( 'FortAwesome\FontAwesome_Loader' ) ) :
187
  );
188
  }
189
 
190
- self::$_loaded = array(
191
- 'path' => $info,
192
- 'version' => $latest_version,
193
- );
194
  }
195
 
196
  /**
197
- * Loads the plugin installation that has been selected for loading.
198
  *
199
  * This is public because it's a callback, but should not be considered
200
  * part of this plugin's API.
@@ -206,7 +200,7 @@ if ( ! class_exists( 'FortAwesome\FontAwesome_Loader' ) ) :
206
  * @internal
207
  * @ignore
208
  */
209
- public function load_plugin() {
210
  try {
211
  $this->select_latest_version_plugin_installation();
212
  require self::$_loaded['path'] . 'font-awesome-init.php';
@@ -442,9 +436,7 @@ if ( ! class_exists( 'FortAwesome\FontAwesome_Loader' ) ) :
442
  // If there's only installation in the list, then it's
443
  // the one that has invoked this function and is is about to
444
  // go away, so it's safe to clean up.
445
- $version_key = array_keys( self::$data )[0];
446
-
447
- require_once trailingslashit( self::$data[ $version_key ] ) . 'includes/class-fontawesome-deactivator.php';
448
  FontAwesome_Deactivator::uninstall();
449
  }
450
  }
@@ -471,9 +463,7 @@ if ( ! class_exists( 'FortAwesome\FontAwesome_Loader' ) ) :
471
  */
472
  public static function maybe_deactivate() {
473
  if ( count( self::$data ) === 1 ) {
474
- $version_key = array_keys( self::$data )[0];
475
-
476
- require_once trailingslashit( self::$data[ $version_key ] ) . 'includes/class-fontawesome-deactivator.php';
477
  FontAwesome_Deactivator::deactivate();
478
  }
479
  }
@@ -517,7 +507,13 @@ if ( ! class_exists( 'FortAwesome\FontAwesome_Loader' ) ) :
517
  $args = get_file_data( trailingslashit( $data ) . 'index.php', array( 'version' => 'Version' ) );
518
  $version = ( isset( $args['version'] ) && ! empty( $args['version'] ) ) ? $args['version'] : $version;
519
  }
520
- self::$data[ $version ] = trailingslashit( $data );
 
 
 
 
 
 
521
  }
522
  return $this;
523
  }
123
  * @internal
124
  */
125
  private function __construct() {
126
+ add_action( 'wp_loaded', [ &$this, 'run_plugin' ], -1 );
127
  add_action( 'activate_' . FONTAWESOME_PLUGIN_FILE, [ &$this, 'activate_plugin' ], -1 );
128
  }
129
 
137
  * @throws Exception
138
  */
139
  private function select_latest_version_plugin_installation() {
140
+ if ( count( self::$_loaded ) > 0 || count( self::$data ) === 0 ) {
141
  return;
142
  }
143
 
 
 
144
  usort(
145
+ self::$data,
146
  function( $a, $b ) {
147
+ if ( version_compare( $a['version'], $b['version'], '=' ) ) {
148
  return 0;
149
+ } elseif ( version_compare( $a['version'], $b['version'], 'gt' ) ) {
150
  return -1;
151
  } else {
152
  return 1;
154
  }
155
  );
156
 
157
+ $selected_installation = self::$data[0];
 
158
 
159
+ if ( empty( $selected_installation ) ) {
160
  throw new Exception(
161
  sprintf(
162
  esc_html__(
184
  );
185
  }
186
 
187
+ self::$_loaded = $selected_installation;
 
 
 
188
  }
189
 
190
  /**
191
+ * Runs the main plugin logic from the installation that has been selected.
192
  *
193
  * This is public because it's a callback, but should not be considered
194
  * part of this plugin's API.
200
  * @internal
201
  * @ignore
202
  */
203
+ public function run_plugin() {
204
  try {
205
  $this->select_latest_version_plugin_installation();
206
  require self::$_loaded['path'] . 'font-awesome-init.php';
436
  // If there's only installation in the list, then it's
437
  // the one that has invoked this function and is is about to
438
  // go away, so it's safe to clean up.
439
+ require_once trailingslashit( self::$data[0]['path'] ) . 'includes/class-fontawesome-deactivator.php';
 
 
440
  FontAwesome_Deactivator::uninstall();
441
  }
442
  }
463
  */
464
  public static function maybe_deactivate() {
465
  if ( count( self::$data ) === 1 ) {
466
+ require_once trailingslashit( self::$data[0]['path'] ) . 'includes/class-fontawesome-deactivator.php';
 
 
467
  FontAwesome_Deactivator::deactivate();
468
  }
469
  }
507
  $args = get_file_data( trailingslashit( $data ) . 'index.php', array( 'version' => 'Version' ) );
508
  $version = ( isset( $args['version'] ) && ! empty( $args['version'] ) ) ? $args['version'] : $version;
509
  }
510
+ array_push(
511
+ self::$data,
512
+ [
513
+ 'version' => $version,
514
+ 'path' => trailingslashit( $data ),
515
+ ]
516
+ );
517
  }
518
  return $this;
519
  }
includes/class-fontawesome-api-controller.php CHANGED
@@ -32,7 +32,7 @@ use \WP_REST_Controller, \WP_Error, \Error, \Exception;
32
  * version numbers:
33
  *
34
  * ```
35
- * query { versions }
36
  * ```
37
  *
38
  * <h3>Internal Use vs. Public API</h3>
32
  * version numbers:
33
  *
34
  * ```
35
+ * query { releases { version } }
36
  * ```
37
  *
38
  * <h3>Internal Use vs. Public API</h3>
includes/class-fontawesome.php CHANGED
@@ -126,7 +126,7 @@ class FontAwesome {
126
  *
127
  * @since 4.0.0
128
  */
129
- const PLUGIN_VERSION = '4.0.0-rc19';
130
  /**
131
  * The namespace for this plugin's REST API.
132
  *
@@ -344,17 +344,7 @@ class FontAwesome {
344
  * @ignore
345
  */
346
  public function run() {
347
- add_action(
348
- 'init',
349
- [ $this, 'init' ],
350
- 10,
351
- /**
352
- * Explicitly indicate to the init action hook that 0 args should be passed in when invoking the
353
- * callback function, so that the default parameter will be used.
354
- * Otherwise, the callback seems to be called with a single empty string parameter, which confuses it.
355
- */
356
- 0
357
- );
358
 
359
  $this->initialize_rest_api();
360
 
@@ -2342,7 +2332,7 @@ EOT;
2342
  /**
2343
  * Runs a GraphQL query against the Font Awesome GraphQL API.
2344
  *
2345
- * It accepts a GraphQL query string like 'query { versions }' and returns
2346
  * the json encoded body of response from the API server when the response
2347
  * has an HTTP status of 200. Otherwise, it throws an exception whose
2348
  * message, if non-null, is appropriate for displaying in the WordPress admin ui
126
  *
127
  * @since 4.0.0
128
  */
129
+ const PLUGIN_VERSION = '4.0.0-rc20';
130
  /**
131
  * The namespace for this plugin's REST API.
132
  *
344
  * @ignore
345
  */
346
  public function run() {
347
+ $this->init();
 
 
 
 
 
 
 
 
 
 
348
 
349
  $this->initialize_rest_api();
350
 
2332
  /**
2333
  * Runs a GraphQL query against the Font Awesome GraphQL API.
2334
  *
2335
+ * It accepts a GraphQL query string like 'query { releases { version } }' and returns
2336
  * the json encoded body of response from the API server when the response
2337
  * has an HTTP status of 200. Otherwise, it throws an exception whose
2338
  * message, if non-null, is appropriate for displaying in the WordPress admin ui
index.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Font Awesome
4
  * Plugin URI: https://fontawesome.com/how-to-use/on-the-web/using-with/wordpress
5
  * Description: The official way to use Font Awesome Free or Pro icons on your site, brought to you by the Font Awesome team.
6
- * Version: 4.0.0-rc19
7
  * Author: Font Awesome
8
  * Author URI: https://fontawesome.com/
9
  * License: GPLv2 (or later)
3
  * Plugin Name: Font Awesome
4
  * Plugin URI: https://fontawesome.com/how-to-use/on-the-web/using-with/wordpress
5
  * Description: The official way to use Font Awesome Free or Pro icons on your site, brought to you by the Font Awesome team.
6
+ * Version: 4.0.0-rc20
7
  * Author: Font Awesome
8
  * Author URI: https://fontawesome.com/
9
  * License: GPLv2 (or later)
readme.txt CHANGED
@@ -1,6 +1,6 @@
1
  === Font Awesome ===
2
  Contributors: fontawesome, mlwilkerson, robmadole, frrrances, deathnfudge
3
- Stable tag: 4.0.0-rc19
4
  Tags: font, awesome, fontawesome, font-awesome, icon, svg, webfont
5
  Requires at least: 4.7
6
  Tested up to: 5.4
@@ -132,6 +132,10 @@ Once you activate the Font Awesome plugin, you will see a top-level menu item fo
132
 
133
  == Changelog ==
134
 
 
 
 
 
135
  = 4.0.0-rc19 =
136
 
137
  * another minor update with additional error logging
1
  === Font Awesome ===
2
  Contributors: fontawesome, mlwilkerson, robmadole, frrrances, deathnfudge
3
+ Stable tag: 4.0.0-rc20
4
  Tags: font, awesome, fontawesome, font-awesome, icon, svg, webfont
5
  Requires at least: 4.7
6
  Tested up to: 5.4
132
 
133
  == Changelog ==
134
 
135
+ = 4.0.0-rc20 =
136
+
137
+ * developer-oriented update to support building themes that use this code as a composer package
138
+
139
  = 4.0.0-rc19 =
140
 
141
  * another minor update with additional error logging