PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.2.65
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.2.65
1.2.77 1.2.76 1.2.75 1.2.74 1.2.73 1.2.72 1.2.71 1.2.70 1.2.69 1.2.68 1.2.67 1.2.66 1.2.65 1.2.64 1.2.63 trunk 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 All 177 releases
userswp / vendor / ayecode / wp-font-awesome-settings / wp-font-awesome-settings.php

wp-font-awesome-settings.php in UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP 1.2.65, at vendor/ayecode/wp-font-awesome-settings/wp-font-awesome-settings.php

1,057 lines 44.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * A class for adjusting font awesome settings on WordPress
4 *
5 * This class can be added to any plugin or theme and will add a settings screen to WordPress to control Font Awesome settings.
6 *
7 * @link https://github.com/AyeCode/wp-font-awesome-settings
8 *
9 * @internal This file should not be edited directly but pulled from the github repo above.
10 */
11
12 /**
13 * Bail if we are not in WP.
14 */
15 if ( ! defined( 'ABSPATH' ) ) {
16 exit;
17 }
18
19 /**
20 * Only add if the class does not already exist.
21 */
22 if ( ! class_exists( 'WP_Font_Awesome_Settings' ) ) {
23
24 /**
25 * A Class to be able to change settings for Font Awesome.
26 *
27 * Class WP_Font_Awesome_Settings
28 */
29 class WP_Font_Awesome_Settings {
30
31 /**
32 * Class version version.
33 *
34 * @var string
35 */
36 public $version = '1.1.11';
37
38 /**
39 * Class textdomain.
40 *
41 * @var string
42 */
43 public $textdomain = 'font-awesome-settings';
44
45 /**
46 * Latest version of Font Awesome at time of publish published.
47 *
48 * @var string
49 */
50 public $latest = "6.4.2";
51
52 /**
53 * The title.
54 *
55 * @var string
56 */
57 public $name = 'Font Awesome';
58
59 /**
60 * Holds the settings values.
61 *
62 * @var array
63 */
64 private $settings;
65
66 /**
67 * WP_Font_Awesome_Settings instance.
68 *
69 * @access private
70 * @since 1.0.0
71 * @var WP_Font_Awesome_Settings There can be only one!
72 */
73 private static $instance = null;
74
75 /**
76 * Main WP_Font_Awesome_Settings Instance.
77 *
78 * Ensures only one instance of WP_Font_Awesome_Settings is loaded or can be loaded.
79 *
80 * @since 1.0.0
81 * @static
82 * @return WP_Font_Awesome_Settings - Main instance.
83 */
84 public static function instance() {
85 if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WP_Font_Awesome_Settings ) ) {
86 self::$instance = new WP_Font_Awesome_Settings;
87
88 add_action( 'init', array( self::$instance, 'init' ) ); // set settings
89
90 if ( is_admin() ) {
91 add_action( 'admin_menu', array( self::$instance, 'menu_item' ) );
92 add_action( 'admin_init', array( self::$instance, 'register_settings' ) );
93 add_action( 'admin_init', array( self::$instance, 'constants' ) );
94 add_action( 'admin_notices', array( self::$instance, 'admin_notices' ) );
95 }
96
97 do_action( 'wp_font_awesome_settings_loaded' );
98 }
99
100 return self::$instance;
101 }
102
103 /**
104 * Define any constants that may be needed by other packages.
105 *
106 * @return void
107 */
108 public function constants(){
109
110 // register iconpicker constant
111 if ( ! defined( 'FAS_ICONPICKER_JS_URL' ) ) {
112 $url = $this->get_path_url();
113 $version = $this->settings['version'];
114
115 if( !$version || version_compare($version,'5.999','>')){
116 $url .= 'assets/js/fa-iconpicker-v6.min.js';
117 }else{
118 $url .= 'assets/js/fa-iconpicker-v5.min.js';
119 }
120
121 define( 'FAS_ICONPICKER_JS_URL', $url );
122
123 }
124
125 // Set a constant if pro enabled
126 if ( ! defined( 'FAS_PRO' ) && $this->settings['pro'] ) {
127 define( 'FAS_PRO', true );
128 }
129 }
130
131 /**
132 * Get the url path to the current folder.
133 *
134 * @return string
135 */
136 public function get_path_url() {
137 $content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) );
138 $content_url = untrailingslashit( WP_CONTENT_URL );
139
140 // Replace http:// to https://.
141 if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) {
142 $content_url = str_replace( 'http://', 'https://', $content_url );
143 }
144
145 // Check if we are inside a plugin
146 $file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) );
147 $url = str_replace( $content_dir, $content_url, $file_dir );
148
149 return trailingslashit( $url );
150 }
151
152 /**
153 * Initiate the settings and add the required action hooks.
154 *
155 * @since 1.0.8 Settings name wrong - FIXED
156 */
157 public function init() {
158 // Download fontawesome locally.
159 add_action( 'add_option_wp-font-awesome-settings', array( $this, 'add_option_wp_font_awesome_settings' ), 10, 2 );
160 add_action( 'update_option_wp-font-awesome-settings', array( $this, 'update_option_wp_font_awesome_settings' ), 10, 2 );
161
162 $this->settings = $this->get_settings();
163
164 // Check if the official plugin is active and use that instead if so.
165 if ( ! defined( 'FONTAWESOME_PLUGIN_FILE' ) ) {
166 if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
167 add_action( 'admin_head', array( $this, 'add_generator' ), 99 );
168 }
169
170 if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
171 add_action( 'wp_head', array( $this, 'add_generator' ), 99 );
172 }
173
174 if ( $this->settings['type'] == 'CSS' ) {
175 if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
176 add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
177 //add_action( 'wp_footer', array( $this, 'enqueue_style' ), 5000 ); // not sure why this was added, seems to break frontend
178 }
179
180 if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
181 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
182 add_filter( 'block_editor_settings_all', array( $this, 'enqueue_editor_styles' ), 10, 2 );
183 }
184 } else {
185 $enqueue = false;
186
187 if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
188 $enqueue = true;
189 add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
190 }
191
192 if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
193 $enqueue = true;
194 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
195 add_filter( 'block_editor_settings_all', array( $this, 'enqueue_editor_scripts' ), 10, 2 );
196 }
197
198 if ( $enqueue ) {
199 add_filter( 'script_loader_tag', array( $this, 'script_loader_tag' ), 20, 3 );
200 }
201 }
202
203 // remove font awesome if set to do so
204 if ( $this->settings['dequeue'] == '1' ) {
205 add_action( 'clean_url', array( $this, 'remove_font_awesome' ), 5000, 3 );
206 }
207 }
208
209 }
210
211 /**
212 * Add FA to the FSE.
213 *
214 * @param $editor_settings
215 * @param $block_editor_context
216 *
217 * @return array
218 */
219 public function enqueue_editor_styles( $editor_settings, $block_editor_context ){
220
221 if ( ! empty( $editor_settings['__unstableResolvedAssets']['styles'] ) ) {
222 $url = $this->get_url();
223 $editor_settings['__unstableResolvedAssets']['styles'] .= "<link rel='stylesheet' id='font-awesome-css' href='$url' media='all' />";
224 }
225
226 return $editor_settings;
227 }
228
229 /**
230 * Add FA to the FSE.
231 *
232 * @param $editor_settings
233 * @param $block_editor_context
234 *
235 * @return array
236 */
237 public function enqueue_editor_scripts( $editor_settings, $block_editor_context ) {
238 $url = $this->get_url();
239
240 $editor_settings['__unstableResolvedAssets']['scripts'] .= "<script src='$url' id='font-awesome-js' defer crossorigin='anonymous'></script>";
241
242 return $editor_settings;
243 }
244
245 /**
246 * Adds the Font Awesome styles.
247 */
248 public function enqueue_style() {
249 // build url
250 $url = $this->get_url();
251 $version = ! empty( $this->settings['local'] ) && empty( $this->settings['pro'] ) ? strip_tags( $this->settings['local_version'] ) : null;
252
253 wp_deregister_style( 'font-awesome' ); // deregister in case its already there
254 wp_register_style( 'font-awesome', $url, array(), $version );
255 wp_enqueue_style( 'font-awesome' );
256
257 // RTL language support CSS.
258 if ( is_rtl() ) {
259 wp_add_inline_style( 'font-awesome', $this->rtl_inline_css() );
260 }
261
262 if ( $this->settings['shims'] ) {
263 $url = $this->get_url( true );
264 wp_deregister_style( 'font-awesome-shims' ); // deregister in case its already there
265 wp_register_style( 'font-awesome-shims', $url, array(), $version );
266 wp_enqueue_style( 'font-awesome-shims' );
267 }
268 }
269
270 /**
271 * Adds the Font Awesome JS.
272 */
273 public function enqueue_scripts() {
274 // build url
275 $url = $this->get_url();
276
277 $deregister_function = 'wp' . '_' . 'deregister' . '_' . 'script';
278 call_user_func( $deregister_function, 'font-awesome' ); // deregister in case its already there
279 wp_register_script( 'font-awesome', $url, array(), null );
280 wp_enqueue_script( 'font-awesome' );
281
282 if ( $this->settings['shims'] ) {
283 $url = $this->get_url( true );
284 call_user_func( $deregister_function, 'font-awesome-shims' ); // deregister in case its already there
285 wp_register_script( 'font-awesome-shims', $url, array(), null );
286 wp_enqueue_script( 'font-awesome-shims' );
287 }
288 }
289
290 /**
291 * Get the url of the Font Awesome files.
292 *
293 * @param bool $shims If this is a shim file or not.
294 * @param bool $local Load locally if allowed.
295 *
296 * @return string The url to the file.
297 */
298 public function get_url( $shims = false, $local = true ) {
299 $script = $shims ? 'v4-shims' : 'all';
300 $sub = $this->settings['pro'] ? 'pro' : 'use';
301 $type = $this->settings['type'];
302 $version = $this->settings['version'];
303 $kit_url = $this->settings['kit-url'] ? sanitize_text_field( $this->settings['kit-url'] ) : '';
304 $url = '';
305
306 if ( $type == 'KIT' && $kit_url ) {
307 if ( $shims ) {
308 // if its a kit then we don't add shims here
309 return '';
310 }
311 $url .= $kit_url; // CDN
312 $url .= "?wpfas=true"; // set our var so our version is not removed
313 } else {
314 $v = '';
315 // Check and load locally.
316 if ( $local && $this->has_local() ) {
317 $script .= ".min";
318 $v .= '&ver=' . strip_tags( $this->settings['local_version'] );
319 $url .= $this->get_fonts_url(); // Local fonts url.
320 } else {
321 $url .= "https://$sub.fontawesome.com/releases/"; // CDN
322 $url .= ! empty( $version ) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
323 }
324 $url .= $type == 'CSS' ? 'css/' : 'js/'; // type
325 $url .= $type == 'CSS' ? $script . '.css' : $script . '.js'; // type
326 $url .= "?wpfas=true" . $v; // set our var so our version is not removed
327 }
328
329 return $url;
330 }
331
332 /**
333 * Try and remove any other versions of Font Awesome added by other plugins/themes.
334 *
335 * Uses the clean_url filter to try and remove any other Font Awesome files added, it can also add pseudo-elements flag for the JS version.
336 *
337 * @param $url
338 * @param $original_url
339 * @param $_context
340 *
341 * @return string The filtered url.
342 */
343 public function remove_font_awesome( $url, $original_url, $_context ) {
344 if ( $_context == 'display'
345 && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false )
346 && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false )
347 && ( strpos( $url, "iconpicker" ) === false )
348 ) {// it's a font-awesome-url (probably)
349
350 if ( strstr( $url, "wpfas=true" ) !== false ) {
351 if ( $this->settings['type'] == 'JS' ) {
352 if ( $this->settings['js-pseudo'] ) {
353 $url .= "' data-search-pseudo-elements defer='defer";
354 } else {
355 $url .= "' defer='defer";
356 }
357 }
358 } else {
359 $url = ''; // removing the url removes the file
360 }
361 }
362
363 return $url;
364 }
365
366 /**
367 * Register the database settings with WordPress.
368 */
369 public function register_settings() {
370 register_setting( 'wp-font-awesome-settings', 'wp-font-awesome-settings' );
371 }
372
373 /**
374 * Add the WordPress settings menu item.
375 * @since 1.0.10 Calling function name direct will fail theme check so we don't.
376 */
377 public function menu_item() {
378 $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme
379 call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array(
380 $this,
381 'settings_page'
382 ) );
383 }
384
385 /**
386 * Get the current Font Awesome output settings.
387 *
388 * @return array The array of settings.
389 */
390 public function get_settings() {
391 $db_settings = get_option( 'wp-font-awesome-settings' );
392
393 $defaults = array(
394 'type' => 'CSS', // type to use, CSS or JS or KIT
395 'version' => '', // latest
396 'enqueue' => '', // front and backend
397 'shims' => '0', // default OFF now in 2020
398 'js-pseudo' => '0', // if the pseudo elements flag should be set (CPU intensive)
399 'dequeue' => '0', // if we should try to remove other versions added by other plugins/themes
400 'pro' => '0', // if pro CDN url should be used
401 'local' => '0', // Store fonts locally.
402 'local_version' => '', // Local fonts version.
403 'kit-url' => '', // the kit url
404 );
405
406 $settings = wp_parse_args( $db_settings, $defaults );
407
408 /**
409 * Filter the Font Awesome settings.
410 *
411 * @todo if we add this filer people might use it and then it defeates the purpose of this class :/
412 */
413 return $this->settings = apply_filters( 'wp-font-awesome-settings', $settings, $db_settings, $defaults );
414 }
415
416 /**
417 * The settings page html output.
418 */
419 public function settings_page() {
420 if ( ! current_user_can( 'manage_options' ) ) {
421 wp_die( __( 'You do not have sufficient permissions to access this page.', 'ayecode-connect' ) );
422 }
423
424 // a hidden way to force the update of the version number via api instead of waiting the 48 hours
425 if ( isset( $_REQUEST['force-version-check'] ) ) {
426 $this->get_latest_version( $force_api = true );
427 }
428
429 if ( ! defined( 'FONTAWESOME_PLUGIN_FILE' ) ) {
430 ?>
431 <style>
432 .wpfas-kit-show {
433 display: none;
434 }
435 .wpfas-kit-set .wpfas-kit-hide,.wpfas-has-pro .wpfas-hide-pro {
436 display: none;
437 }
438 .wpfas-kit-set .wpfas-kit-show {
439 display: table-row;
440 }
441 .fas-settings-form .submit{
442 display: inline;
443 padding-right: 5px;
444 }
445 .fas-settings-form .fas-buttons{
446 margin: 15px 0;
447 }
448 #wpfas-version{
449 color: #646970;
450 }
451 </style>
452 <div class="wrap">
453 <h1><?php echo $this->name; ?></h1>
454 <form method="post" action="options.php" class="fas-settings-form">
455 <?php
456 settings_fields( 'wp-font-awesome-settings' );
457 do_settings_sections( 'wp-font-awesome-settings' );
458 $table_class = '';
459 if ( $this->settings['type'] ) {
460 $table_class .= 'wpfas-' . sanitize_html_class( strtolower( $this->settings['type'] ) ) . '-set';
461 }
462 if ( ! empty( $this->settings['pro'] ) ) {
463 $table_class .= ' wpfas-has-pro';
464 }
465 ?>
466 <?php if ( $this->settings['type'] != 'KIT' && ! empty( $this->settings['local'] ) && empty( $this->settings['pro'] ) ) { ?>
467 <?php if ( $this->has_local() ) { ?>
468 <div class="notice notice-info"><p><strong><?php _e( 'Font Awesome fonts are loading locally.', 'ayecode-connect' ); ?></strong></p></div>
469 <?php } else { ?>
470 <div class="notice notice-error"><p><strong><?php _e( 'Font Awesome fonts are not loading locally!', 'ayecode-connect' ); ?></strong></p></div>
471 <?php } ?>
472 <?php } ?>
473 <table class="form-table wpfas-table-settings <?php echo esc_attr( $table_class ); ?>">
474 <tr valign="top">
475 <th scope="row"><label for="wpfas-type"><?php _e( 'Type', 'ayecode-connect' ); ?></label></th>
476 <td>
477 <select name="wp-font-awesome-settings[type]" id="wpfas-type" onchange="if(this.value=='KIT'){jQuery('.wpfas-table-settings').addClass('wpfas-kit-set');}else{jQuery('.wpfas-table-settings').removeClass('wpfas-kit-set');}">
478 <option value="CSS" <?php selected( $this->settings['type'], 'CSS' ); ?>><?php _e( 'CSS (default)', 'ayecode-connect' ); ?></option>
479 <option value="JS" <?php selected( $this->settings['type'], 'JS' ); ?>>JS</option>
480 <option value="KIT" <?php selected( $this->settings['type'], 'KIT' ); ?>><?php _e( 'Kits (settings managed on fontawesome.com)', 'ayecode-connect' ); ?></option>
481 </select>
482 </td>
483 </tr>
484
485 <tr valign="top" class="wpfas-kit-show">
486 <th scope="row"><label for="wpfas-kit-url"><?php _e( 'Kit URL', 'ayecode-connect' ); ?></label></th>
487 <td>
488 <input class="regular-text" id="wpfas-kit-url" type="url" name="wp-font-awesome-settings[kit-url]" value="<?php echo esc_attr( $this->settings['kit-url'] ); ?>" placeholder="<?php echo 'https://kit.font';echo 'awesome.com/123abc.js'; // this won't pass theme check :(?>"/>
489 <span><?php
490 echo wp_sprintf(
491 __( 'Requires a free account with Font Awesome. %sGet kit url%s', 'ayecode-connect' ),
492 '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/kits"><i class="fas fa-external-link-alt"></i> ',
493 '</a>'
494 );
495 ?></span>
496 </td>
497 </tr>
498 <tr valign="top" class="wpfas-kit-hide">
499 <th scope="row"><label for="wpfas-version"><?php _e( 'Version', 'ayecode-connect' ); ?></label></th>
500 <td>
501 <select name="wp-font-awesome-settings[version]" id="wpfas-version">
502 <?php /* @todo Remove after FA7 compatibility */ ?>
503 <option value="" <?php selected( $this->settings['version'], '' ); ?>><?php echo wp_sprintf( __( '%s (default)', 'ayecode-connect' ), '6.7.2' ); ?></option>
504 <?php $latest_version = $this->get_latest_version( false, true ); if ( $latest_version && version_compare( $latest_version, '7.0.0', '>' ) ) { ?>
505 <option value="<?php echo esc_attr( $latest_version ); ?>" <?php selected( $this->settings['version'], $latest_version ); ?>><?php echo esc_html( $latest_version ); ?></option>
506 <?php } ?>
507 <?php /* @todo Remove after after FA7 compatibility */ ?>
508
509 <?php /* @todo Un-comment after FA7 compatibility */ ?>
510 <?php /* ?><option value="" <?php selected( $this->settings['version'], '' ); ?>><?php echo wp_sprintf( __( 'Latest - %s (default)', 'ayecode-connect' ), $this->get_latest_version() ); ?></option><?php */ ?>
511 <option value="7.0.0" <?php selected( $this->settings['version'], '7.0.0' ); ?>>7.0.0</option>
512 <option value="6.4.2" <?php selected( $this->settings['version'], '6.4.2' ); ?>>6.4.2</option>
513 <option value="6.1.0" <?php selected( $this->settings['version'], '6.1.0' ); ?>>6.1.0</option>
514 <option value="6.0.0" <?php selected( $this->settings['version'], '6.0.0' ); ?>>6.0.0</option>
515 <option value="5.15.4" <?php selected( $this->settings['version'], '5.15.4' ); ?>>5.15.4</option>
516 <option value="5.6.0" <?php selected( $this->settings['version'], '5.6.0' ); ?>>5.6.0</option>
517 <option value="5.5.0" <?php selected( $this->settings['version'], '5.5.0' ); ?>>5.5.0</option>
518 <option value="5.4.0" <?php selected( $this->settings['version'], '5.4.0' ); ?>>5.4.0</option>
519 <option value="5.3.0" <?php selected( $this->settings['version'], '5.3.0' ); ?>>5.3.0</option>
520 <option value="5.2.0" <?php selected( $this->settings['version'], '5.2.0' ); ?>>5.2.0</option>
521 <option value="5.1.0" <?php selected( $this->settings['version'], '5.1.0' ); ?>>5.1.0</option>
522 <option value="4.7.0" <?php selected( $this->settings['version'], '4.7.0' ); ?>>4.7.1 (CSS only)</option>
523 </select>
524 </td>
525 </tr>
526
527 <tr valign="top">
528 <th scope="row"><label for="wpfas-enqueue"><?php _e( 'Enqueue', 'ayecode-connect' ); ?></label></th>
529 <td>
530 <select name="wp-font-awesome-settings[enqueue]" id="wpfas-enqueue">
531 <option value="" <?php selected( $this->settings['enqueue'], '' ); ?>><?php _e( 'Frontend + Backend (default)', 'ayecode-connect' ); ?></option>
532 <option value="frontend" <?php selected( $this->settings['enqueue'], 'frontend' ); ?>><?php _e( 'Frontend', 'ayecode-connect' ); ?></option>
533 <option value="backend" <?php selected( $this->settings['enqueue'], 'backend' ); ?>><?php _e( 'Backend', 'ayecode-connect' ); ?></option>
534 </select>
535 </td>
536 </tr>
537
538 <tr valign="top" class="wpfas-kit-hide">
539 <th scope="row"><label
540 for="wpfas-pro"><?php _e( 'Enable pro', 'ayecode-connect' ); ?></label></th>
541 <td>
542 <input type="hidden" name="wp-font-awesome-settings[pro]" value="0"/>
543 <input type="checkbox" name="wp-font-awesome-settings[pro]" value="1" <?php checked( $this->settings['pro'], '1' ); ?> id="wpfas-pro" onchange="if(jQuery(this).is(':checked')){jQuery('.wpfas-table-settings').addClass('wpfas-has-pro')}else{jQuery('.wpfas-table-settings').removeClass('wpfas-has-pro')}"/>
544 <span><?php
545 echo wp_sprintf(
546 __( 'Requires a subscription. %sLearn more%s %sManage my allowed domains%s', 'ayecode-connect' ),
547 '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/referral?a=c9b89e1418">',
548 ' <i class="fas fa-external-link-alt"></i></a>',
549 '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/account/cdn">',
550 ' <i class="fas fa-external-link-alt"></i></a>'
551 );
552 ?></span>
553 </td>
554 </tr>
555
556 <tr valign="top" class="wpfas-kit-hide wpfas-hide-pro">
557 <th scope="row"><label for="wpfas-local"><?php _e( 'Load Fonts Locally', 'ayecode-connect' ); ?></label></th>
558 <td>
559 <input type="hidden" name="wp-font-awesome-settings[local]" value="0"/>
560 <input type="hidden" name="wp-font-awesome-settings[local_version]" value="<?php echo esc_attr( $this->settings['local_version'] ); ?>"/>
561 <input type="checkbox" name="wp-font-awesome-settings[local]" value="1" <?php checked( $this->settings['local'], '1' ); ?> id="wpfas-local"/>
562 <span><?php _e( '(For free version only) Load FontAwesome fonts from locally. This downloads FontAwesome fonts from fontawesome.com & stores at the local site.', 'ayecode-connect' ); ?></span>
563 </td>
564 </tr>
565
566 <tr valign="top" class="wpfas-kit-hide">
567 <th scope="row"><label
568 for="wpfas-shims"><?php _e( 'Enable v4 shims compatibility', 'ayecode-connect' ); ?></label>
569 </th>
570 <td>
571 <input type="hidden" name="wp-font-awesome-settings[shims]" value="0"/>
572 <input type="checkbox" name="wp-font-awesome-settings[shims]"
573 value="1" <?php checked( $this->settings['shims'], '1' ); ?> id="wpfas-shims"/>
574 <span><?php _e( 'This enables v4 classes to work with v5, sort of like a band-aid until everyone has updated everything to v5.', 'ayecode-connect' ); ?></span>
575 </td>
576 </tr>
577
578 <tr valign="top" class="wpfas-kit-hide">
579 <th scope="row"><label
580 for="wpfas-js-pseudo"><?php _e( 'Enable JS pseudo elements (not recommended)', 'ayecode-connect' ); ?></label>
581 </th>
582 <td>
583 <input type="hidden" name="wp-font-awesome-settings[js-pseudo]" value="0"/>
584 <input type="checkbox" name="wp-font-awesome-settings[js-pseudo]"
585 value="1" <?php checked( $this->settings['js-pseudo'], '1' ); ?>
586 id="wpfas-js-pseudo"/>
587 <span><?php _e( 'Used only with the JS version, this will make pseudo-elements work but can be CPU intensive on some sites.', 'ayecode-connect' ); ?></span>
588 </td>
589 </tr>
590
591 <tr valign="top">
592 <th scope="row"><label
593 for="wpfas-dequeue"><?php _e( 'Dequeue', 'ayecode-connect' ); ?></label></th>
594 <td>
595 <input type="hidden" name="wp-font-awesome-settings[dequeue]" value="0"/>
596 <input type="checkbox" name="wp-font-awesome-settings[dequeue]"
597 value="1" <?php checked( $this->settings['dequeue'], '1' ); ?>
598 id="wpfas-dequeue"/>
599 <span><?php _e( 'This will try to dequeue any other Font Awesome versions loaded by other sources if they are added with `font-awesome` or `fontawesome` in the name.', 'ayecode-connect' ); ?></span>
600 </td>
601 </tr>
602
603 </table>
604 <div class="fas-buttons">
605 <?php
606 submit_button();
607 ?>
608 <p class="submit"><a href="https://fontawesome.com/referral?a=c9b89e1418" class="button button-secondary"><?php _e('Get 24,000+ more icons with Font Awesome Pro','ayecode-connect'); ?> <i class="fas fa-external-link-alt"></i></a></p>
609
610 </div>
611 </form>
612
613 <div id="wpfas-version"><?php echo wp_sprintf(__( 'Version: %s (affiliate links provided)', 'ayecode-connect' ), $this->version ); ?></div>
614 </div>
615 <?php
616 }
617 }
618
619 /**
620 * Check a version number is valid and if so return it or else return an empty string.
621 *
622 * @param $version string The version number to check.
623 *
624 * @since 1.0.6
625 *
626 * @return string Either a valid version number or an empty string.
627 */
628 public function validate_version_number( $version ) {
629
630 if ( version_compare( $version, '0.0.1', '>=' ) >= 0 ) {
631 // valid
632 } else {
633 $version = '';// not validated
634 }
635
636 return $version;
637 }
638
639
640 /**
641 * Get the latest version of Font Awesome.
642 *
643 * We check for a cached version and if none we will check for a live version via API and then cache it for 48 hours.
644 *
645 * @since 1.0.7
646 * @return mixed|string The latest version number found.
647 */
648 public function get_latest_version( $force_api = false, $force_latest = false ) {
649 $latest_version = $this->latest;
650
651 $cache = get_transient( 'wp-font-awesome-settings-version' );
652
653 if ( $cache === false || $force_api ) { // its not set
654 $api_ver = $this->get_latest_version_from_api();
655 if ( version_compare( $api_ver, $this->latest, '>=' ) >= 0 ) {
656 $latest_version = $api_ver;
657 set_transient( 'wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS );
658 }
659 } elseif ( $this->validate_version_number( $cache ) ) {
660 if ( version_compare( $cache, $this->latest, '>=' ) >= 0 ) {
661 $latest_version = $cache;
662 }
663 }
664
665 // @todo remove after FA7 compatibility
666 if ( ! $force_latest && version_compare( $cache, '7.0.0', '>=' ) >= 0 ) {
667 $latest_version = '6.7.2';
668 }
669
670 // Check and auto download fonts locally.
671 if ( empty( $this->settings['pro'] ) && empty( $this->settings['version'] ) && $this->settings['type'] != 'KIT' && ! empty( $this->settings['local'] ) && ! empty( $this->settings['local_version'] ) && ! empty( $latest_version ) ) {
672 if ( version_compare( $latest_version, $this->settings['local_version'], '>' ) && is_admin() && ! wp_doing_ajax() ) {
673 $this->download_package( $latest_version );
674 }
675 }
676
677 return $latest_version;
678 }
679
680 /**
681 * Get the latest Font Awesome version from the github API.
682 *
683 * @since 1.0.7
684 * @return string The latest version number or `0` on API fail.
685 */
686 public function get_latest_version_from_api() {
687 $version = "0";
688 $response = wp_remote_get( "https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest" );
689 if ( ! is_wp_error( $response ) && is_array( $response ) ) {
690 $api_response = json_decode( wp_remote_retrieve_body( $response ), true );
691 if ( isset( $api_response['tag_name'] ) && version_compare( $api_response['tag_name'], $this->latest, '>=' ) >= 0 && empty( $api_response['prerelease'] ) ) {
692 $version = $api_response['tag_name'];
693 }
694 }
695
696 return $version;
697 }
698
699 /**
700 * Inline CSS for RTL language support.
701 *
702 * @since 1.0.13
703 * @return string Inline CSS.
704 */
705 public function rtl_inline_css() {
706 $inline_css = '[dir=rtl] .fa-address,[dir=rtl] .fa-address-card,[dir=rtl] .fa-adjust,[dir=rtl] .fa-alarm-clock,[dir=rtl] .fa-align-left,[dir=rtl] .fa-align-right,[dir=rtl] .fa-analytics,[dir=rtl] .fa-angle-double-left,[dir=rtl] .fa-angle-double-right,[dir=rtl] .fa-angle-left,[dir=rtl] .fa-angle-right,[dir=rtl] .fa-arrow-alt-circle-left,[dir=rtl] .fa-arrow-alt-circle-right,[dir=rtl] .fa-arrow-alt-from-left,[dir=rtl] .fa-arrow-alt-from-right,[dir=rtl] .fa-arrow-alt-left,[dir=rtl] .fa-arrow-alt-right,[dir=rtl] .fa-arrow-alt-square-left,[dir=rtl] .fa-arrow-alt-square-right,[dir=rtl] .fa-arrow-alt-to-left,[dir=rtl] .fa-arrow-alt-to-right,[dir=rtl] .fa-arrow-circle-left,[dir=rtl] .fa-arrow-circle-right,[dir=rtl] .fa-arrow-from-left,[dir=rtl] .fa-arrow-from-right,[dir=rtl] .fa-arrow-left,[dir=rtl] .fa-arrow-right,[dir=rtl] .fa-arrow-square-left,[dir=rtl] .fa-arrow-square-right,[dir=rtl] .fa-arrow-to-left,[dir=rtl] .fa-arrow-to-right,[dir=rtl] .fa-balance-scale-left,[dir=rtl] .fa-balance-scale-right,[dir=rtl] .fa-bed,[dir=rtl] .fa-bed-bunk,[dir=rtl] .fa-bed-empty,[dir=rtl] .fa-border-left,[dir=rtl] .fa-border-right,[dir=rtl] .fa-calendar-check,[dir=rtl] .fa-caret-circle-left,[dir=rtl] .fa-caret-circle-right,[dir=rtl] .fa-caret-left,[dir=rtl] .fa-caret-right,[dir=rtl] .fa-caret-square-left,[dir=rtl] .fa-caret-square-right,[dir=rtl] .fa-cart-arrow-down,[dir=rtl] .fa-cart-plus,[dir=rtl] .fa-chart-area,[dir=rtl] .fa-chart-bar,[dir=rtl] .fa-chart-line,[dir=rtl] .fa-chart-line-down,[dir=rtl] .fa-chart-network,[dir=rtl] .fa-chart-pie,[dir=rtl] .fa-chart-pie-alt,[dir=rtl] .fa-chart-scatter,[dir=rtl] .fa-check-circle,[dir=rtl] .fa-check-square,[dir=rtl] .fa-chevron-circle-left,[dir=rtl] .fa-chevron-circle-right,[dir=rtl] .fa-chevron-double-left,[dir=rtl] .fa-chevron-double-right,[dir=rtl] .fa-chevron-left,[dir=rtl] .fa-chevron-right,[dir=rtl] .fa-chevron-square-left,[dir=rtl] .fa-chevron-square-right,[dir=rtl] .fa-clock,[dir=rtl] .fa-file,[dir=rtl] .fa-file-alt,[dir=rtl] .fa-file-archive,[dir=rtl] .fa-file-audio,[dir=rtl] .fa-file-chart-line,[dir=rtl] .fa-file-chart-pie,[dir=rtl] .fa-file-code,[dir=rtl] .fa-file-excel,[dir=rtl] .fa-file-image,[dir=rtl] .fa-file-pdf,[dir=rtl] .fa-file-powerpoint,[dir=rtl] .fa-file-video,[dir=rtl] .fa-file-word,[dir=rtl] .fa-flag,[dir=rtl] .fa-folder,[dir=rtl] .fa-folder-open,[dir=rtl] .fa-hand-lizard,[dir=rtl] .fa-hand-point-down,[dir=rtl] .fa-hand-point-left,[dir=rtl] .fa-hand-point-right,[dir=rtl] .fa-hand-point-up,[dir=rtl] .fa-hand-scissors,[dir=rtl] .fa-image,[dir=rtl] .fa-long-arrow-alt-left,[dir=rtl] .fa-long-arrow-alt-right,[dir=rtl] .fa-long-arrow-left,[dir=rtl] .fa-long-arrow-right,[dir=rtl] .fa-luggage-cart,[dir=rtl] .fa-moon,[dir=rtl] .fa-pencil,[dir=rtl] .fa-pencil-alt,[dir=rtl] .fa-play-circle,[dir=rtl] .fa-project-diagram,[dir=rtl] .fa-quote-left,[dir=rtl] .fa-quote-right,[dir=rtl] .fa-shopping-cart,[dir=rtl] .fa-thumbs-down,[dir=rtl] .fa-thumbs-up,[dir=rtl] .fa-user-chart{filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1);transform:scale(-1,1)}[dir=rtl] .fa-spin{animation-direction:reverse}';
707
708 return $inline_css;
709 }
710
711 /**
712 * Show any warnings as an admin notice.
713 *
714 * @return void
715 */
716 public function admin_notices() {
717 $settings = $this->settings;
718
719 if ( defined( 'FONTAWESOME_PLUGIN_FILE' ) ) {
720 if ( ! empty( $_REQUEST['page'] ) && $_REQUEST['page'] == 'wp-font-awesome-settings' ) {
721 ?>
722 <div class="notice notice-error is-dismissible">
723 <p><?php _e( 'The Official Font Awesome Plugin is active, please adjust your settings there.', 'ayecode-connect' ); ?></p>
724 </div>
725 <?php
726 }
727 } else {
728 if ( ! empty( $settings ) ) {
729 if ( $settings['type'] != 'KIT' && $settings['pro'] && ( $settings['version'] == '' || version_compare( $settings['version'], '6', '>=' ) ) ) {
730 $link = admin_url('options-general.php?page=wp-font-awesome-settings');
731 ?>
732 <div class="notice notice-error is-dismissible">
733 <p><?php echo wp_sprintf( __( 'Font Awesome Pro v6 requires the use of a kit, please setup your kit in %ssettings.%s', 'ayecode-connect' ),"<a href='". esc_url_raw( $link )."'>","</a>" ); ?></p>
734 </div>
735 <?php
736 }
737 }
738 }
739 }
740
741 /**
742 * Handle fontawesome add settings to download fontawesome to store locally.
743 *
744 * @since 1.1.1
745 *
746 * @param string $option The option name.
747 * @param mixed $value The option value.
748 */
749 public function add_option_wp_font_awesome_settings( $option, $value ) {
750 // Do nothing if WordPress is being installed.
751 if ( wp_installing() ) {
752 return;
753 }
754
755 if ( ! empty( $value['local'] ) && empty( $value['pro'] ) && ! ( ! empty( $value['type'] ) && $value['type'] == 'KIT' ) ) {
756 $version = isset( $value['version'] ) && $value['version'] ? $value['version'] : $this->get_latest_version();
757
758 if ( ! empty( $version ) ) {
759 $response = $this->download_package( $version, $value );
760
761 if ( is_wp_error( $response ) ) {
762 add_settings_error( 'general', 'fontawesome_download', __( 'ERROR:', 'ayecode-connect' ) . ' ' . $response->get_error_message(), 'error' );
763 }
764 }
765 }
766 }
767
768 /**
769 * Handle fontawesome update settings to download fontawesome to store locally.
770 *
771 * @since 1.1.0
772 *
773 * @param mixed $old_value The old option value.
774 * @param mixed $value The new option value.
775 */
776 public function update_option_wp_font_awesome_settings( $old_value, $new_value ) {
777 // Do nothing if WordPress is being installed.
778 if ( wp_installing() ) {
779 return;
780 }
781
782 if ( ! empty( $new_value['local'] ) && empty( $new_value['pro'] ) && ! ( ! empty( $new_value['type'] ) && $new_value['type'] == 'KIT' ) ) {
783 // Old values
784 $old_version = isset( $old_value['version'] ) && $old_value['version'] ? $old_value['version'] : ( isset( $old_value['local_version'] ) ? $old_value['local_version'] : '' );
785 $old_local = isset( $old_value['local'] ) ? (int) $old_value['local'] : 0;
786
787 // New values
788 $new_version = isset( $new_value['version'] ) && $new_value['version'] ? $new_value['version'] : $this->get_latest_version();
789
790 if ( empty( $old_local ) || $old_version !== $new_version || ! file_exists( $this->get_fonts_dir() . 'css' . DIRECTORY_SEPARATOR . 'all.css' ) ) {
791 $response = $this->download_package( $new_version, $new_value );
792
793 if ( is_wp_error( $response ) ) {
794 add_settings_error( 'general', 'fontawesome_download', __( 'ERROR:', 'ayecode-connect' ) . ' ' . $response->get_error_message(), 'error' );
795 }
796 }
797 }
798 }
799
800 /**
801 * Get the fonts directory local path.
802 *
803 * @since 1.1.0
804 *
805 * @param string Fonts directory local path.
806 */
807 public function get_fonts_dir() {
808 $upload_dir = wp_upload_dir( null, false );
809
810 return $upload_dir['basedir'] . DIRECTORY_SEPARATOR . 'ayefonts' . DIRECTORY_SEPARATOR . 'fa' . DIRECTORY_SEPARATOR;
811 }
812
813 /**
814 * Get the fonts directory local url.
815 *
816 * @since 1.1.0
817 *
818 * @param string Fonts directory local url.
819 */
820 public function get_fonts_url() {
821 $upload_dir = wp_upload_dir( null, false );
822
823 return $upload_dir['baseurl'] . '/ayefonts/fa/';
824 }
825
826 /**
827 * Check whether load locally active.
828 *
829 * @since 1.1.0
830 *
831 * @return bool True if active else false.
832 */
833 public function has_local() {
834 if ( ! empty( $this->settings['local'] ) && empty( $this->settings['pro'] ) && file_exists( $this->get_fonts_dir() . 'css' . DIRECTORY_SEPARATOR . 'all.css' ) ) {
835 return true;
836 }
837
838 return false;
839 }
840
841 /**
842 * Get the WP Filesystem access.
843 *
844 * @since 1.1.0
845 *
846 * @return object The WP Filesystem.
847 */
848 public function get_wp_filesystem() {
849 if ( ! function_exists( 'get_filesystem_method' ) ) {
850 require_once( ABSPATH . "/wp-admin/includes/file.php" );
851 }
852
853 $access_type = get_filesystem_method();
854
855 if ( $access_type === 'direct' ) {
856 /* You can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */
857 $creds = request_filesystem_credentials( trailingslashit( site_url() ) . 'wp-admin/', '', false, false, array() );
858
859 /* Initialize the API */
860 if ( ! WP_Filesystem( $creds ) ) {
861 /* Any problems and we exit */
862 return false;
863 }
864
865 global $wp_filesystem;
866
867 return $wp_filesystem;
868 /* Do our file manipulations below */
869 } else if ( defined( 'FTP_USER' ) ) {
870 $creds = request_filesystem_credentials( trailingslashit( site_url() ) . 'wp-admin/', '', false, false, array() );
871
872 /* Initialize the API */
873 if ( ! WP_Filesystem( $creds ) ) {
874 /* Any problems and we exit */
875 return false;
876 }
877
878 global $wp_filesystem;
879
880 return $wp_filesystem;
881 } else {
882 /* Don't have direct write access. Prompt user with our notice */
883 return false;
884 }
885 }
886
887 /**
888 * Download the fontawesome package file.
889 *
890 * @since 1.1.0
891 *
892 * @param mixed $version The font awesome.
893 * @param array $option Fontawesome settings.
894 * @return WP_ERROR|bool Error on fail and true on success.
895 */
896 public function download_package( $version, $option = array() ) {
897 $filename = 'fontawesome-free-' . $version . '-web';
898 $url = 'https://use.fontawesome.com/releases/v' . $version . '/' . $filename . '.zip';
899
900 if ( ! function_exists( 'wp_handle_upload' ) ) {
901 require_once ABSPATH . 'wp-admin/includes/file.php';
902 }
903
904 $download_file = download_url( esc_url_raw( $url ) );
905
906 if ( is_wp_error( $download_file ) ) {
907 return new WP_Error( 'fontawesome_download_failed', __( $download_file->get_error_message(), 'ayecode-connect' ) );
908 } else if ( empty( $download_file ) ) {
909 return new WP_Error( 'fontawesome_download_failed', __( 'Something went wrong in downloading the font awesome to store locally.', 'ayecode-connect' ) );
910 }
911
912 $response = $this->extract_package( $download_file, $filename, true );
913
914 // Update local version.
915 if ( is_wp_error( $response ) ) {
916 return $response;
917 } else if ( $response ) {
918 if ( empty( $option ) ) {
919 $option = get_option( 'wp-font-awesome-settings' );
920 }
921
922 $option['local_version'] = $version;
923
924 // Remove action to prevent looping.
925 remove_action( 'update_option_wp-font-awesome-settings', array( $this, 'update_option_wp_font_awesome_settings' ), 10, 2 );
926
927 update_option( 'wp-font-awesome-settings', $option );
928
929 return true;
930 }
931
932 return false;
933 }
934
935 /**
936 * Extract the fontawesome package file.
937 *
938 * @since 1.1.0
939 *
940 * @param string $package The package file path.
941 * @param string $dirname Package file name.
942 * @param bool $delete_package Delete temp file or not.
943 * @return WP_Error|bool True on success WP_Error on fail.
944 */
945 public function extract_package( $package, $dirname = '', $delete_package = false ) {
946 global $wp_filesystem;
947
948 $wp_filesystem = $this->get_wp_filesystem();
949
950 if ( empty( $wp_filesystem ) && isset( $wp_filesystem->errors ) && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) {
951 return new WP_Error( 'fontawesome_filesystem_error', __( $wp_filesystem->errors->get_error_message(), 'ayecode-connect' ) );
952 } else if ( empty( $wp_filesystem ) ) {
953 return new WP_Error( 'fontawesome_filesystem_error', __( 'Failed to initialise WP_Filesystem while trying to download the Font Awesome package.', 'ayecode-connect' ) );
954 }
955
956 $fonts_dir = $this->get_fonts_dir();
957 $fonts_tmp_dir = dirname( $fonts_dir ) . DIRECTORY_SEPARATOR . 'fa-tmp' . DIRECTORY_SEPARATOR;
958
959 if ( $wp_filesystem->is_dir( $fonts_tmp_dir ) ) {
960 $wp_filesystem->delete( $fonts_tmp_dir, true );
961 }
962
963 // Unzip package to working directory.
964 $result = unzip_file( $package, $fonts_tmp_dir );
965
966 if ( is_wp_error( $result ) ) {
967 $wp_filesystem->delete( $fonts_tmp_dir, true );
968
969 if ( 'incompatible_archive' === $result->get_error_code() ) {
970 return new WP_Error( 'fontawesome_incompatible_archive', __( $result->get_error_message(), 'ayecode-connect' ) );
971 }
972
973 return $result;
974 }
975
976 if ( $wp_filesystem->is_dir( $fonts_dir ) ) {
977 $wp_filesystem->delete( $fonts_dir, true );
978 }
979
980 $extract_dir = $fonts_tmp_dir;
981
982 if ( $dirname && $wp_filesystem->is_dir( $extract_dir . $dirname . DIRECTORY_SEPARATOR ) ) {
983 $extract_dir .= $dirname . DIRECTORY_SEPARATOR;
984 }
985
986 try {
987 $return = $wp_filesystem->move( $extract_dir, $fonts_dir, true );
988 } catch ( Exception $e ) {
989 $return = new WP_Error( 'fontawesome_move_package', __( 'Fail to move font awesome package!', 'ayecode-connect' ) );
990 }
991
992 if ( $wp_filesystem->is_dir( $fonts_tmp_dir ) ) {
993 $wp_filesystem->delete( $fonts_tmp_dir, true );
994 }
995
996 // Once extracted, delete the package if required.
997 if ( $delete_package ) {
998 unlink( $package );
999 }
1000
1001 return $return;
1002 }
1003
1004 /**
1005 * Output the version in the header.
1006 */
1007 public function add_generator() {
1008 $file = str_replace( array( "/", "\\" ), "/", realpath( __FILE__ ) );
1009 $plugins_dir = str_replace( array( "/", "\\" ), "/", realpath( WP_PLUGIN_DIR ) );
1010
1011 // Find source plugin/theme.
1012 $source = array();
1013 if ( strpos( $file, $plugins_dir ) !== false ) {
1014 $source = explode( "/", plugin_basename( $file ) );
1015 } else if ( function_exists( 'get_theme_root' ) ) {
1016 $themes_dir = str_replace( array( "/", "\\" ), "/", realpath( get_theme_root() ) );
1017
1018 if ( strpos( $file, $themes_dir ) !== false ) {
1019 $source = explode( "/", ltrim( str_replace( $themes_dir, "", $file ), "/" ) );
1020 }
1021 }
1022
1023 echo '<meta name="generator" content="WP Font Awesome Settings v' . esc_attr( $this->version ) . '"' . ( ! empty( $source[0] ) ? ' data-ac-source="' . esc_attr( $source[0] ) . '"' : '' ) . ' />';
1024 }
1025
1026 /**
1027 * Add extra parameters to the script tag.
1028 *
1029 * Add crossorigin="anonymous" to prevent OpaqueResponseBlocking
1030 * (NS_BINDING_ABORTED) http error.
1031 *
1032 * @since 1.1.8
1033 *
1034 * @param string $tag The script tag.
1035 * @param string $handle The script handle.
1036 * @param string $src The script url.
1037 * @return string The script tag.
1038 */
1039 public function script_loader_tag( $tag, $handle, $src ) {
1040 if ( ( $handle == 'font-awesome' || $handle == 'font-awesome-shims' ) && ( strpos( $src, "kit.fontawesome.com" ) !== false || strpos( $src, ".fontawesome.com/releases/" ) !== false ) ) {
1041 $tag = preg_replace(
1042 '/<script[\s]+(.*?)>/',
1043 '<script defer crossorigin="anonymous" \1>',
1044 $tag
1045 );
1046 }
1047
1048 return $tag;
1049 }
1050 }
1051
1052 /**
1053 * Run the class if found.
1054 */
1055 WP_Font_Awesome_Settings::instance();
1056 }
1057