: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
$s .= ' data-tf-not-load="1"';
if (strpos($item, ' class=', 4) === false) {
$s .= ' class="' . $class . '"';
$item = str_replace(' class="', ' class="' . $class . ' ', $item);
foreach($sizes['c'] as $i=>$c){
$color.='linear-gradient(to right';
$color.=' '.($j-1)*$svgStep.'%';
$color.=' '.$j*$svgStep.'%';
$color='background:'.$color.')';
if (strpos($item, ' style=', 4) === false) {
$s .= ' style="'.$color.'"';
$item = str_replace(' style="', ' style="' . $color . ';', $item);
if(strpos($item, ' width=', 4)!==false){
preg_match('/ width=["\']([^"]+?)["\']/', $item, $w,0,4);
if (strpos($item, ' height=', 4) === false) {
preg_match('/ height=["\']([^"]+?)["\']/', $item, $h,0,4);
$height=!empty($h[1])?$h[1]:$width;
$item = strtr($item, array(' srcset=' => ' data-tf-srcset=', ' sizes=' => ' data-tf-sizes=', ' src=' => ' data-tf-src=')); //sizes need to be replaced to pass html validation
$s = ' src="' . strtr($placeHolder, array('{w}'=>$width,'{h}'=>$height)) . '"' . $s;
$s = ' data-tf-not-load="1"';
if (strpos($s, 'fetchpriority=') === false) {
$s .= ' fetchpriority="high"';
$s .= ' loading="auto" decoding="auto"';
if (strpos($item, ' decoding=', 4) === false) {
$s .= ' decoding="async"';
if (strpos($item, ' width=', 4) === false) {
$s .= ' width="' . $sizes['w'] . '"';
if (strpos($item, ' height=', 4) === false) {
$s .= ' height="' . $sizes['h'] . '"';
$item = str_replace('<' . $ext, '<' . $ext . $s, $item);
if ($ext === 'audio' || $ext === 'video') {
$c = 'tf_lazy tf_' . ($ext === 'video' ? 'vd' : $ext) . '_lazy tf_w tf_rel tf_box';
if (strpos($item, ' data-lazy') !== false) {
$r['<' . $ext] = '<' . $ext . ' data-lazy="1"';
$c .= ' tf_rel tf_overflow';
themify_get_icon('fas volume-mute', 'fa');
themify_get_icon('fas volume-up', 'fa');
//themify_get_icon('fas undo', 'fa');
//themify_get_icon('fas redo', 'fa');
//themify_get_icon('far closed-captioning', 'fa');
themify_get_icon('fas external-link-alt', 'fa');
themify_get_icon('fas airplay', 'fa');
themify_get_icon('fas expand', 'fa');
themify_get_icon('fas download', 'fa');
if (strpos($item, ' poster') !== false) {
$r[' poster'] = ' data-poster';
if ($url && $url !== true && strpos($item, ' width') === false || strpos($item, ' height') === false) {
$size = themify_get_video_size($url);
if ($size['w'] !== '' && strpos($item, ' width') === false) {
$sv = ' width="' . $size['w'] . '"';
if ($size['h'] !== '' && strpos($item, ' height') === false) {
$sv .= ' height="' . $size['h'] . '"';
$r[' preload'] = $sv . ' preload';
if (strpos($item, ' autoplay') !== false) {
$r[' autoplay'] = ' data-autoplay';
$item = strtr($item, $r);
$item = '<div class="' . $c . '">' . $item . '</div>';
if ($ext === 'img' && $stopLazy === false && $useJs === true) {
$part .= '<noscript>' . strtr($orig, array(' src=' => ' data-tf-not-load src=')) . '</noscript>';
unset($matches, $tags, $extCount);
$html = str_replace($search, $replace, $html);
function themify_upload_dir(string $mode = 'all', bool $reinit = false) {
if ($dir === null || $reinit === true) {
/* foolproof the paths, in case they mistakenly have trailing slash */
$dir = array_map('untrailingslashit', wp_get_upload_dir());
$dir['baseurl'] = themify_https_esc($dir['baseurl']);
return $mode === 'all' ? $dir : $dir[$mode];
function themify_generateWebp(string $url):string {
$is = !themify_builder_check('setting-webp', 'performance-webp', true) ? true : (is_admin() && !themify_is_ajax());
return themify_create_webp($url);
function themify_is_prefetch_request():bool {
if (isset($_SERVER['HTTP_PURPOSE'])) {
} elseif (isset($_SERVER["HTTP_X_PURPOSE"])) {
$prev = 'HTTP_X_PURPOSE';
} elseif (isset($_SERVER['HTTP_X_MOZ'])) {
$prev = strtolower($_SERVER[$prev]);
$is = $prev === 'prefetch' || $prev === 'preview';
function themify_is_dev_mode():bool {
$is = themify_check('setting-dev-mode', true) || (defined('THEMIFY_DEV') && THEMIFY_DEV);
$is = apply_filters('themify_dev_mode', $is);
function themify_is_concate_disabled():bool {
return themify_is_dev_mode() && (themify_check('setting-dev-mode-concate', true) || (defined('THEMIFY_DEV') && THEMIFY_DEV));
function themify_disable_other_lazy() {
add_filter('wp_lazy_loading_enabled', '__return_false', 100);
add_filter('lazyload_is_enabled', '__return_false', 1, 100); //disable jetpack lazy load
add_filter('rocket_use_native_lazyload', '__return_false', 1, 100);
function themify_get_server():string {
if (!empty($_SERVER['SERVER_SOFTWARE'])) {
$is = explode('/', $_SERVER['SERVER_SOFTWARE']);
$is = str_replace('microsoft-', '', strtolower($is[0]));
} elseif (is_file(get_home_path() . 'web.config')) {
} elseif (!is_file(Themify_Enqueue_Assets::getHtaccessFile()) || is_file('/etc/nginx/nginx.conf')) {
function themify_help(string $content):string {
return sprintf('<span class="tf_help"><i tabindex="-1" class="icon" onclick="return false;">%s</i><span class="tf_help_content">%s</span></span>',
themify_get_icon('ti-help', 'ti'),
* Search $subject for $search and replace the first occurrence of it.
function themify_str_replace_first(string $search, string $replace,string $subject):string {
return implode($replace, explode($search, $subject, 2));
* Search $subject for $search and replace the last occurrence of it.
function themify_str_replace_last(string $search, string $replace, string $subject):string {
if (( $pos = strrpos($subject, $search) ) !== false) {
$subject = substr_replace($subject, $replace, $pos, strlen($search));
* Gets the ID of an object (post or term) and returns that object ID in current language.
function themify_maybe_translate_object_id(?int $id, string $type = 'page'):?int {
if (defined('ICL_SITEPRESS_VERSION')) {
$id = apply_filters('wpml_object_id', $id, $type, true);
} elseif (defined('POLYLANG_VERSION') && function_exists('pll_get_post')) {
$translatedpageid = pll_get_post($id);
if (!empty($translatedpageid) && 'publish' === get_post_status($translatedpageid)) {
* Returns and caches URL to the homepage, properly filtered for multilingual setups
function themify_home_url():string {
$url = function_exists('pll_home_url') ? pll_home_url() : home_url();
* Download file from external URL and returns the file
* @param $post_id Attachments may be associated with a parent post or page.
* @return WP_Error|int ID of created attachment, or WP_Error
function tf_fetch_remote_file($url, $post_id = null, $title = '') {
// extract the file name and extension from the url
$file_name = basename($url);
// get placeholder file in the upload dir with a unique, sanitized filename
$upload = wp_upload_bits($file_name, 0, '');
return new WP_Error('upload_dir_error', $upload['error']);
// fetch the remote url and write it to the placeholder file
$remote_response = wp_safe_remote_get($url, array(
'filename' => $upload['file'],
$headers = wp_remote_retrieve_headers($remote_response);
@unlink($upload['file']);
return new WP_Error('import_file_error', __('Remote server did not respond', 'themify'));
$remote_response_code = wp_remote_retrieve_response_code($remote_response);
// make sure the fetch was successful
if ($remote_response_code != '200') {
@unlink($upload['file']);
return new WP_Error('import_file_error', sprintf(__('Remote server returned error response %1$d %2$s', 'themify'), esc_html($remote_response_code), get_status_header_desc($remote_response_code)));
$filesize = filesize($upload['file']);
@unlink($upload['file']);
return new WP_Error('import_file_error', __('Zero size file downloaded', 'themify'));
'post_status' => 'inherit',
if ($info = wp_check_filetype($upload['file']))
$post['post_mime_type'] = $info['type'];
return new WP_Error('mime_type_error', __('Invalid file type', 'themify'));
$attach_id = wp_insert_attachment($post, $upload['file'], $post_id);
wp_update_attachment_metadata($attach_id, wp_generate_attachment_metadata($attach_id, $upload['file']));
* Mimics get_template_part but loads a template from THEMIFY_DIR
function themify_get_template(string $slug, string $name = '', array $args = array()) {
if ($name !== null && '' !== $name) {
$templates[] = "{$base_dir}/{$slug}-{$name}.php";
$templates[] = "{$base_dir}/{$slug}.php";
foreach ($templates as $template) {
if (is_file($template)) {
load_template($located, false, $args);
/* Add category id class in post loop for Masonry filter */
if (!function_exists('themify_post_filter_class')) {
function themify_post_filter_class(array $classes, $class, $post_id):array {
$categories = wp_get_object_terms($post_id, get_query_var('tf_query_tax', 'category'));
foreach ($categories as $category) {
$classes[] = ' cat-' . $category->term_id;
$is_ajax = get_query_var('tf_ajax_filter', false);
if (isset($_POST['action'], $_POST['tax']) && $_POST['action'] === 'themify_ajax_load_more') {
$classes[] = 'ajax-cat-' . (int) $_POST['tax'];
$classes[] = 'initial-cat';
function themify_custom_except($excerpt) {
$excerpt = wp_trim_words(get_the_excerpt(), apply_filters('excerpt_length', 55));
function themify_set_headers(array $headers) {
$head = strtoupper(trim(explode(':', $h)[0]));
if (isset($headers[$head])) {
$vals = trim(trim(str_ireplace($head, '', $h)), ':');
if ($head === 'CONTENT-SECURITY-POLICY' || is_array($headers[$head])) {
$vals = explode(';', $vals);
$policy = $headers[$head];
foreach ($vals as $i => $c) {
$c = preg_replace('!\s+!', ' ', $c);
$values = explode(' ', $c);
if (isset($policy[$values[0]])) {
$none = array_search('none', $values, true);
$values = array_merge($values, explode(' ', $policy[$values[0]]));
$vals[$i] = implode(' ', array_keys(array_flip($values)));
if ($hasChange === true) {
header($head . ':' . implode(';', $vals));
} elseif ($vals !== $headers[$head]) {
header($head . ':' . $headers[$head]);
function themify_get_lottie(array $arr, string $sel = '') {
if (!empty($arr['path']) && !empty($arr['seg'])) {
if (!empty($arr['st'])) {
$lottie['st'] = $arr['st'];
if (isset($arr['sp']) && $arr['sp'] != 1) {
$lottie['sp'] = $arr['sp'];
if (!empty($arr['dir'])) {
$lottie['dir'] = $arr['dir'];
if (!empty($arr['fid'])) {
$lottie['fid'] = $arr['fid'];
if (isset($arr['r']) && $arr['r'] !== 'svg') {
$lottie['r'] = $arr['r'];
if (isset($arr['count']) && ($arr['count'] > 1 || $arr['count'] == -1)) {
$lottie['count'] = $arr['count'];
if (!isset($arr['lp'])) {
$lottie = array('actions' => $lottie, 'loop' => 1);
return sprintf('<tf-lottie data-lazy="1" class="tf_lazy"><template>%s</template></tf-lottie>', json_encode($lottie));