| Server IP : 38.190.208.107 / Your IP : 216.73.217.46 Web Server : nginx/1.28.1 System : Linux ht2026040333114 6.1.0-10-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.37-1 (2023-07-03) x86_64 User : root ( 0) PHP Version : 8.2.28 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv,eval,assert,passthru,system,exec,shell_exec,popen,proc_open MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/wp.9/wp-content/themes/dt-the7/inc/ |
Upload File : |
<?php
/**
* Optimize Font Awesome enqueue on front end.
*
* @package The7
*/
defined( 'ABSPATH' ) || exit;
/**
* Class The7_FontAwesome_Enqueue_Optimizer
*/
class The7_FontAwesome_Enqueue_Optimizer {
/**
* Main method. Add all necessary hooks.
*/
public function run() {
add_action( 'wp_footer', array( $this, 'optimize_in_footer' ), 9 );
if ( The7_Icon_Manager::is_fontawesome_enabled() ) {
// Envato Theme Checker. This is important stuff, do not optimize hook name.
add_filter( 'style' . '_loader_src', array( $this, 'disable_vc_font_awesome' ), 10, 2 ); // phpcs:ignore
add_filter( 'revslider_layer_content', array( $this, 'fix_icons_in_revslider_content' ) );
}
}
/**
* Override revslider font logic.
*/
public function optimize_in_footer() {
$vc_fa_is_enqueued = wp_style_is( 'font-awesome', 'enqueued' );
$revslider_fa_is_enqueued = ! empty( $GLOBALS['fa_icon_var'] ) || ! empty( $GLOBALS['fa_var'] );
if ( The7_Icon_Manager::is_fontawesome_enabled() ) {
if ( $vc_fa_is_enqueued ) {
wp_enqueue_style( 'the7-awesome-fonts-back' );
wp_dequeue_style( 'font-awesome' );
wp_deregister_style( 'font-awesome' );
}
if ( $revslider_fa_is_enqueued && ! $this->is_revslider6() ) {
wp_enqueue_style( 'the7-awesome-fonts-back' );
$GLOBALS['fa_icon_var'] = false;
$GLOBALS['fa_var'] = false;
}
} elseif ( $vc_fa_is_enqueued && $revslider_fa_is_enqueued && $this->is_revslider6() ) {
$GLOBALS['fa_icon_var'] = false;
$GLOBALS['fa_var'] = false;
}
}
/**
* Override visual composer font logic.
*
* @param string $src Style src.
* @param string $handle Style handle.
*
* @return bool
*/
public function disable_vc_font_awesome( $src, $handle ) {
if ( in_array( $handle, array( 'font-awesome', 'vc_font_awesome_5_shims', 'vc_font_awesome_5', 'vc_font_awesome_6' ), true ) ) {
return false;
}
return $src;
}
/**
* Replace custom revslider icons classes with more common one for older plugin versions.
*
* Replace 'fa-icon-' with 'fa fa-' if revslidr version less than 6.0.0.
*
* @param string $html Revslider layer HTML.
*
* @return string
*/
public function fix_icons_in_revslider_content( $html ) {
if ( ! $this->is_revslider6() ) {
$html = str_replace( 'fa-icon-', 'fa fa-', $html );
}
return $html;
}
/**
* Return true if active revslidr version is 6.0.0 or greater, otherwise return false.
*
* @return bool
*/
public function is_revslider6() {
return defined( 'RS_REVISION' ) && version_compare( RS_REVISION, '6.0.0', '>=' );
}
}