: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
exit; // Exit if accessed directly
* The file that defines css/js loading class and concate css files
class Themify_Enqueue_Assets {
public const THEMIFY_CSS_MODULES_URI=THEMIFY_URI . '/css/modules/';
private static $wc_shortcode_type = array();
private static $wc_data = array();
private static $css = array('mobile_concate' => array());
private static $done = array();
private static $localiztion = array();
private static $theme_css_support = array('mobile-menu'=>true,'rtl'=>true);
private static $concateFile = null;
private static $googleFonts = array();
private static $guttenbergCss = array();
public static $preLoadMedia = array();
public static $disableGoogleFontsLoad = null;
public static $isHeader = false;
public static $isFooter = false;
public static $mediaMaxWidth = 1200;
public static $mobileMenuActive = 1100;
public static $THEME_CSS_MODULES_URI = null;
public static $THEME_CSS_MODULES_DIR = null;
public static $THEME_WC_CSS_MODULES_DIR = null;
public static $THEME_WC_CSS_MODULES_URI = null;
public static $themeVersion = null;
public static function init() {
if (themify_is_themify_theme()) {
self::$THEME_CSS_MODULES_DIR = THEME_DIR . '/styles/modules/';
self::$THEME_CSS_MODULES_URI = THEME_URI . '/styles/modules/';
self::$THEME_WC_CSS_MODULES_DIR = THEME_DIR . '/styles/wc/modules/';
self::$THEME_WC_CSS_MODULES_URI = THEME_URI . '/styles/wc/modules/';
self::$themeVersion = wp_get_theme(get_template())->display('Version');
self::$mobileMenuActive = (int) themify_get('setting-mobile_menu_trigger_point', self::$mobileMenuActive, true);
add_action('wp_body_open', array(__CLASS__, 'body_open'), 1);
add_filter('wp_default_scripts', array(__CLASS__, 'remove_default_js'));
add_action('wp', array(__CLASS__, 'lazy_init'), 1);
add_action('wp_loaded', array(__CLASS__, 'lazy_init'), 1);
add_action('admin_init', array(__CLASS__, 'loadMainScript'));
add_action('admin_footer', array(__CLASS__, 'js_localize'), 18);
add_filter('themify_loops_wrapper_class', array(__CLASS__, 'load_loop_css'), 100, 6);
add_filter('kses_allowed_protocols', array(__CLASS__, 'allow_lazy_protocols'), 100, 1);
add_filter('sgo_js_minify_exclude', array(__CLASS__,'exclude_main_js' ),1);
add_filter('sgo_javascript_combine_exclude', array( __CLASS__, 'exclude_main_js' ),1 );
add_filter('autoptimize_filter_js_exclude', array(__CLASS__,'exclude_main_js' ),1);
add_filter('autoptimize_filter_js_consider_minified',array(__CLASS__,'exclude_main_js' ),1);
add_filter('rocket_delay_js_exclusions', array( __CLASS__, 'exclude_main_js' ),1 );
add_filter('rocket_exclude_js',array( __CLASS__, 'exclude_main_js' ),1 );
add_filter( 'js_do_concat', [ __CLASS__, 'Automattic_page_optimize_js_exclude' ], 10, 2 );
add_action('pre_get_search_form', array(__CLASS__, 'load_search_form_css'), 9);
if (!is_admin() || themify_is_ajax()) {
add_filter('post_playlist', array(__CLASS__, 'wp_media_playlist'), 100, 3);
add_filter('cron_schedules', array(__CLASS__, 'cron_schedules'));
add_action('themify_cron_clear_css', array(__CLASS__, 'cron'));
if (!wp_next_scheduled('themify_cron_clear_css')) {
wp_schedule_event(time() + WEEK_IN_SECONDS * 4, 'four_week', 'themify_cron_clear_css');
public static function lazy_init() {
if (!is_admin() && !themify_is_login_page()) {
remove_action('wp_head', 'wp_resource_hints', 2);
if (self::$themeVersion !== null) {
add_action('wp_head', array(__CLASS__, 'header_meta'),-1111);
add_action('wp_head', array(__CLASS__, 'header_html'));
add_filter('wp_title', array(__CLASS__, 'wp_title'), 10, 2);
remove_action('wp_head', 'locale_stylesheet'); //remove rtl loading
add_action( 'template_redirect', array( __CLASS__, 'start_buffer' ) );
add_action('wp_enqueue_scripts', array(__CLASS__, 'before_enqueue'), 7);
add_action('wp_enqueue_scripts', array(__CLASS__, 'after_enqueue'), 11);
add_filter('style_loader_tag', array(__CLASS__, 'style_header_tag'), 10, 4);
add_filter('render_block_data', array(__CLASS__, 'loadGuttenbergCss'), PHP_INT_MAX, 2);
add_action('wp_head', array(__CLASS__, 'css_position'),100);
add_action('wp_head', array(__CLASS__, 'wp_head'),-100);
add_action('wp_footer', array(__CLASS__, 'before_footer'), -1111);
add_action('wp_footer', array(__CLASS__, 'js_localize'), 18);
add_action('wp_footer', array(__CLASS__, 'wp_footer'), 100);
add_action('admin_head', array(__CLASS__, 'dev_mode_styles'));
if(!is_admin() || themify_is_ajax()){
add_filter('widget_display_callback', array(__CLASS__, 'widget_css'), 100, 3);
add_action('wp_playlist_scripts',array(__CLASS__,'disable_playlist_template'),0,1);
add_filter('wp_audio_shortcode_library', array(__CLASS__, 'media_shortcode_library'), 100, 1);
add_filter('wp_video_shortcode_library', array(__CLASS__, 'media_shortcode_library'), 10, 1);
add_filter('wp_audio_shortcode', array(__CLASS__, 'audio_shortcode'), 100, 5);
add_filter('wp_video_shortcode_override', array(__CLASS__, 'video_shortcode'), 100, 4);
add_filter('embed_oembed_html',array(__CLASS__,'embed'),100,4);
if (themify_is_lazyloading()) {
themify_disable_other_lazy();
$cdn=' https://cdn.jsdelivr.net https://cdnjs.cloudflare.com *.lottiefiles.com';
themify_set_headers(array(
'CONTENT-SECURITY-POLICY'=>array(
'style-src'=>"'unsafe-inline'".$cdn,
'style-src-elem'=>"'unsafe-inline'".$cdn,
'script-src'=>"'unsafe-inline' data:".$cdn,
'script-src-elem'=>"'unsafe-inline' data:".$cdn,
'connect-src'=>'https://themify.org *.lottiefiles.com',
'default-src'=>'https://themify.org data:'.$cdn
public static function start_buffer(){
ob_start(array(__CLASS__, 'getBuffer'));
public static function createDir():bool {
if (self::$concateFile === null) {
self::$concateFile = self::getCurrentVersionFolder();
if (!is_dir(self::$concateFile)) {
Themify_Filesystem::mkdir(self::$concateFile,true);
if (!Themify_Filesystem::is_dir(self::$concateFile)) {
Themify_Filesystem::mkdir(self::$concateFile,true);
if (!Themify_Filesystem::is_dir(self::$concateFile)) {
self::$concateFile = null;
public static function remove_default_js($scripts) {
if (!themify_builder_check('setting-jquery-migrate', 'performance-jquery_migrate') && !themify_is_login_page()) {
$script = $scripts->registered['jquery'];
if (!empty($script->deps)) { // Check whether the script has any dependencies
$index = isset($script->deps[1]) && $script->deps[1] === $key ? 1 : array_search($key, $script->deps, true);
unset($script->deps[$index]);
public static function before_enqueue() {
self::add_css('tf_base', THEMIFY_URI . '/css/base.min.css', null, THEMIFY_VERSION);
if (self::$themeVersion !== null) {
self::add_css('themify_common', THEMIFY_URI . '/css/themify-common.css', null, THEMIFY_VERSION);
if(is_admin_bar_showing()){
self::add_css('themify_common_logged', THEMIFY_URI . '/css/themify-common-logged.css', null, THEMIFY_VERSION,'',true);
public static function after_enqueue() {
global $wp_styles, $wp_version;
$css = array('wp-block-library');
$is_theme = self::$themeVersion !== null;
if ($is_theme === true && themify_is_woocommerce_active()) {
add_filter('woocommerce_shortcode_products_query', array(__CLASS__, 'wc_shortcode_product'), 10, 3);
add_action('woocommerce_before_single_product_summary', array(__CLASS__, 'wc_shortcode_product_page'));
add_action('woocommerce_before_checkout_form_cart_notices', array(__CLASS__, 'wc_shortcode_checkout'));
add_action('woocommerce_account_content', array(__CLASS__, 'wc_shortcode_account'));
self::$localiztion['wc_version'] = $wc_ver;
wp_enqueue_script('wc-cart-fragments');//default load has been removed from wc 7.8.0
if (themify_is_shop() || is_product() || (!is_checkout() && !is_account_page() && !is_checkout_pay_page() && !is_edit_account_page() && !is_order_received_page() && !is_add_payment_method_page())) {
wp_enqueue_script('wc-add-to-cart-variation'); //load tmpl files
wp_enqueue_script('wc-single-product');
wp_enqueue_script('jquery-blockui');
WC_Frontend_Scripts::localize_printed_scripts();
$js = array('js-cookie', 'wc-add-to-cart', 'wc-add-to-cart-variation', 'wc-cart-fragments', 'woocommerce', 'wc_additional_variation_images_script', 'wc-single-product');
$disableOptimize = themify_check('setting-optimize-wc', true);
$isDefered=themify_check('setting-jquery', true)?true:($disableOptimize?false:!themify_check('setting-defer-wc', true));
if (isset($wp_scripts->registered[$v]) && wp_script_is($v)) {
if ($isDefered === true && !empty($wp_scripts->registered[$v]->extra['data'])) {
self::$wc_data[] = $wp_scripts->registered[$v]->extra['data'];
$wp_scripts->registered[$v]->extra['data']='';
if ($v === 'wc-single-product' && is_product()) {
if ($disableOptimize === false) {
$wp_scripts->done[] = $v;
$arr[$v] = $wp_scripts->registered[$v]->src;
if ($wc_ver !== $wp_scripts->registered[$v]->ver) {
$arr[$v] .= '?ver=' . $wp_scripts->registered[$v]->ver;
self::$localiztion['wc_js'] = $arr;
if ($disableOptimize === true) {
self::$localiztion['wc_js_normal'] = true;
// Localize photoswipe css
if (!empty($wp_styles->registered['photoswipe']->src)) {
wp_dequeue_style('photoswipe');
wp_dequeue_style('photoswipe-default-skin');
self::$localiztion['photoswipe'] = array('main' => $wp_styles->registered['photoswipe']->src, 'skin' => $wp_styles->registered['photoswipe-default-skin']->src);
$wc_block_prefix = 'wc-block';
if (intval($wc_ver[0]) >= 6) {
$css[] = $wc_block_prefix . '-vendors-style';
$css[] = $wc_block_prefix . '-style';
$css[] = 'wp-block-library-theme';
$css[] = 'woocommerce-layout';
$css[] = 'woocommerce-smallscreen';
$css[] = 'woocommerce-general';
$css[]='woocommerce-blocktheme';
$css[] = 'woocommerce_prettyPhoto_css';
$css = apply_filters('themify_deq_css', $css);
if (isset($wp_styles->registered[$v]) && wp_style_is($v)) {
$src = $wp_styles->registered[$v]->src;
if ($v === 'wp-block-library' || $v === 'wp-block-library-theme' || $v === $wc_block_prefix . '-style' || $v === $wc_block_prefix . '-vendors-style') {
if (empty($wp_styles->registered[$v]->deps) || ($v === $wc_block_prefix . '-style' && count($wp_styles->registered[$v]->deps) === 1 && $wp_styles->registered[$v]->deps[0] === $wc_block_prefix . '-vendors-style')) {
self::$guttenbergCss[$v] = $src;
$ver = $wp_styles->registered[$v]->ver;
if ($src[0] === '/' && $src[1] === '/') {
$src = (is_ssl() ? 'https:' : 'http:') . $src;
if (strpos($src, 'http') === false) {
self::add_css($v, $src, $wp_styles->registered[$v]->deps, $ver, $wp_styles->registered[$v]->args);
if ($is_theme === true) {
if (isset(self::$theme_css_support['mobile-menu'])) {
self::addMobileMenuCss('mobile-menu', THEME_URI . '/mobile-menu.css');
if (function_exists('themify_theme_enqueue_header')) {
themify_theme_enqueue_header();
/* Disabel Guttenberg Global Style WP 5.9 */
// remove_action( 'wp_body_open', 'wp_global_styles_render_svg_filters' );
// wp_dequeue_style('global-styles');
public static function add_css(string $handle, string $src,?array $deps,?string $ver,?string $media = '',bool $in_footer = false) {
if (!isset(self::$css[$handle], self::$done[$src])) {
self::$done[$src] = true;
if (self::$concateFile === null || is_admin()) {
if (strpos($handle, 'http') !== false) {
$handle = crc32($handle);
self::$css[$handle] = array('s' => $src, 'v' => $ver);
if ($media !== 'all') {//need to get css files in ajax call(e.g builder live preview)
self::$css[$handle]['m'] = $media;
wp_enqueue_style($handle, $src, $deps, $ver, $media);
if ($in_footer === true || self::$isFooter === true) {
if (!isset(self::$css['in_footer'])) {
self::$css['in_footer'] = array();
self::$css['in_footer'][$handle] = array('s' => $src, 'v' => $ver);
self::$css['in_footer'][$handle]['m'] = $media;
self::$css[$handle] = array('s' => $src, 'v' => $ver);
self::$css[$handle]['m'] = $media;
* Deregister an stylesheet
public static function remove_css(string $handle, string $type = 'both') {
if ($handle !== 'in_footer' && self::$css !== null) {
if ($type === 'both' || $type === 'main') {
unset(self::$css[$handle], self::$css['in_footer'][$handle]);
if ($type === 'both' || $type === 'mobile') {
unset(self::$css['mobile_concate'][$handle]);
public static function header_meta() {
<meta charset="<?php echo get_bloginfo('charset') ?>">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
public static function dev_mode_styles(){
if ( ( themify_is_dev_mode() || Themify_Maintenance_Mode::is_enabled() ) && is_admin_bar_showing() ){
#wpadminbar #wp-toolbar .tf_admin_bar_alert .ab-item{
.tf_admin_bar_alert>.ab-item:after{
transform:translateY(-50%);
animation:tf_bg 2s infinite alternate
#wpadminbar .tf_admin_bar_tooltip{
background-color:rgba(51,51,51,.9);
#wpadminbar .tf_admin_bar_alert>.ab-item:hover .tf_admin_bar_tooltip{display:block}
@keyframes tf_bg{0%{background:#ffb800}100%{background:#ff1212}}
public static function wp_head() {
if (themify_is_lazyloading() === true) {
$blur = (int) themify_get('setting-lazy-blur', 25, true);
<style id="tf_lazy_style" data-no-optimize="1">
background-size:100% 25%!important;
background-repeat:no-repeat!important;
background-position:0 0, 0 33.4%,0 66.6%,0 100%!important;
transition:filter .3s linear!important;
<?php if ($blur > 0): ?>filter:blur(<?php echo $blur ?>px)!important;<?php endif; ?>
[data-lazy]:is(.module,.module_row:not(.tb_first)),.module[data-lazy] .ui,.module_row[data-lazy]:not(.tb_first):is(>.row_inner,.module_column[data-lazy],.module_subrow[data-lazy]){
background-image:none!important
<style id="tf_lazy_common" data-no-optimize="1">
<?php if (self::$themeVersion !== null): ?>
<?php self::dev_mode_styles()?>
:where(.tf_in_flx,.tf_flx){display:inline-flex;flex-wrap:wrap;place-items:center}
.tf_fa,:is(em,i) tf-lottie{display:inline-block;vertical-align:middle}:is(em,i) tf-lottie{width:1.5em;height:1.5em}.tf_fa{width:1em;height:1em;stroke-width:0;stroke:currentColor;overflow:visible;fill:currentColor;pointer-events:none;text-rendering:optimizeSpeed;buffered-rendering:static}#tf_svg symbol{overflow:visible}:where(.tf_lazy){position:relative;visibility:visible;display:block;opacity:.3}.wow .tf_lazy:not(.tf_swiper-slide){visibility:hidden;opacity:1}div.tf_audio_lazy audio{visibility:hidden;height:0;display:inline}.mejs-container{visibility:visible}.tf_iframe_lazy{transition:opacity .3s ease-in-out;min-height:10px}:where(.tf_flx),.tf_swiper-wrapper{display:flex}.tf_swiper-slide{flex-shrink:0;opacity:0;width:100%;height:100%}.tf_swiper-wrapper>br,.tf_lazy.tf_swiper-wrapper .tf_lazy:after,.tf_lazy.tf_swiper-wrapper .tf_lazy:before{display:none}.tf_lazy:after,.tf_lazy:before{content:'';display:inline-block;position:absolute;width:10px!important;height:10px!important;margin:0 3px;top:50%!important;inset-inline:auto 50%!important;border-radius:100%;background-color:currentColor;visibility:visible;animation:tf-hrz-loader infinite .75s cubic-bezier(.2,.68,.18,1.08)}.tf_lazy:after{width:6px!important;height:6px!important;inset-inline:50% auto!important;margin-top:3px;animation-delay:-.4s}@keyframes tf-hrz-loader{0%,100%{transform:scale(1);opacity:1}50%{transform:scale(.1);opacity:.6}}.tf_lazy_lightbox{position:fixed;background:rgba(11,11,11,.8);color:#ccc;top:0;left:0;display:flex;align-items:center;justify-content:center;z-index:999}.tf_lazy_lightbox .tf_lazy:after,.tf_lazy_lightbox .tf_lazy:before{background:#fff}.tf_vd_lazy,tf-lottie{display:flex;flex-wrap:wrap}tf-lottie{aspect-ratio:1.777}.tf_w.tf_vd_lazy video{width:100%;height:auto;position:static;object-fit:cover}
<?php if (self::$themeVersion !== null){
themify_favicon_action();
* Hooked to "wp_head"[10], load after other scripts in the header
public static function header_html(){
echo themify_get('setting-header_html', '', true);
public static function css_position(){
echo '<!--tf_css_position-->';//bug in chrome https://bugs.chromium.org/p/chromium/issues/detail?id=332189x
public static function style_header_tag(string $tag, string $handle,string $href,string $media):string {
$src = strtok($href, '?');
unset(self::$preLoadMedia[$src]);
$preload = '<link rel="preload" href="' . $href . '" as="style"';
if ($media !== 'all' && $media) {
$preload .= ' media="' . $media . '"';
* Set a default title for the front page
public static function wp_title(string $title,string $sep):string {
if (empty($title) && ( is_home() || is_front_page() )) {
return !empty($aioseop_options) && class_exists('All_in_One_SEO_Pack',false) ? $aioseop_options['aiosp_home_title'] : get_bloginfo('name');
return str_replace($sep, '', $title);
public static function wc_shortcode_product($query_args, $attr, $type) {
if ($type === 'product') {
self::$wc_shortcode_type[$type] = true;
public static function wc_shortcode_product_page() {
self::$wc_shortcode_type['product'] = true;
public static function wc_shortcode_checkout() {
self::$wc_shortcode_type['checkout'] = true;
public static function wc_shortcode_account($msg = '') {
self::$wc_shortcode_type['account'] = true;
public static function js_localize() {
//remove_action('wp_footer', array(__CLASS__, 'js_localize'), 18);
self::localize_script('themify-main-script', 'themify_vars', apply_filters('themify_main_script_vars', self::$localiztion));
$inline_js=$wp_scripts->registered['themify-main-script']->extra['data'];
if(!empty(self::$wc_data)){
$inline_js.=implode('',self::$wc_data);