: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
} elseif ($data_only !== true) {
if (themify_is_shop() && !in_the_loop()) {
$id = themify_shop_pageId();
} elseif (is_object($post)) {
$val = ( $id !== false && $id !== 0 ) ? get_post_meta($id, $var, true) : '';
* Returns a value referenced by $meta,$var checking in theme settings or post meta data.
* @param $meta - post meta
* @param $var - theme settings
function themify_get_both(string $meta, string $var, $default = null) {
$val = themify_get($meta);
if ($val === null || $val === 'default') {
$val = themify_get($var, $default, true);
* Get a color value, uses themify_get and sanitizes the value
function themify_get_color_both(string $meta, string $var, $default = null) {
$val = themify_get_color($meta);
if ($val === null || $val === 'default') {
$val = themify_get_color($var, $default, true);
* Returns a value referenced by $meta,$var checking in theme settings or post meta data.
* @param $meta - post meta
* @param $var - theme settings
function themify_check_both(string $meta, string $var):bool {
$val = themify_get($meta, null);
if ($val === null || $val === 'default') {
$val = themify_get($var, null, true);
return $val !== null && $val !== '' && $val !== 'off';
function themify_shop_pageId() {
if (themify_is_woocommerce_active()) {
$id = wc_get_page_id('shop');
if ($id <= 0) {//wc bug, page id isn't from wc settings,the default should be page with slug 'shop'
$page = get_page_by_path('shop');
$id = !empty($page) ? (int) $page->ID : false;
* Get a color value, uses themify_get and sanitizes the value
function themify_get_color(string $var, $default = null, bool $data_only = false) {
return themify_sanitize_hex_color(themify_get($var, $default, $data_only));
* Sanitize a string to ensure it's valid hex color code
function themify_sanitize_hex_color($value) {
if ($value===null || false === $value) {
$value = ltrim($value, '#');
/* match 3 to 6 hex digits */
if (preg_match('|^([A-Fa-f0-9]{3}){1,2}$|', $value)) {
if (!function_exists('themify_get_image_sizes_list')) {
* Return list of image sizes with labels for translation.
function themify_get_image_sizes_list(bool $nested = true) {
$size_names = apply_filters('image_size_names_choose',
'thumbnail' => __('Thumbnail', 'themify'),
'medium' => __('Medium', 'themify'),
'large' => __('Large', 'themify'),
'full' => __('Original Image', 'themify')
array('value' => 'blank', 'name' => ''),
foreach ($size_names as $size => $label) {
$out[] = array('value' => $size, 'name' => $label);
return apply_filters('themify_get_image_sizes_list', $nested ? $out : $size_names, $nested);
* Check if the site is using an HTTPS scheme and returns the proper url
* @param String $url requested url
function themify_https_esc(string $url = ''):string {
$url = str_replace('http:', 'https:', $url);
* Returns an array with the post types managed by Themify,
* where the Themify Custom Panel is initialized.
* Filterable using themify_post_types
* @param Array $types additional post types
function themify_post_types(array $types = array()):array {
$defaults = array_merge(array('post', 'page'), apply_filters('themify_specific_post_types', array('menu', 'slider', 'highlight', 'portfolio', 'testimonial', 'section')), $types);
if (themify_is_themify_theme() && themify_is_woocommerce_active() && is_file(THEME_DIR . '/admin/post-type-product.php')) {
return array_keys(array_flip(apply_filters('themify_post_types', $defaults)));
if (!function_exists('themify_options_module')) {
* Returns list of <option>
* @param array $options List of options
* @param bool $associative
function themify_options_module($options = array(), $key = '', $associative = true, $default = ''):string {
$data = themify_get_data();
$sel = isset($data[$key]) ? $data[$key] : $default;
if (true === $associative) {
foreach ($options as $option) {
$output .= '<option ' . selected($option['value'], $sel, false) . ' value="' . esc_attr($option['value']) . '">' . esc_html($option['name']) . '</option>';
foreach ($options as $option) {
$option = esc_attr($option);
$selected = $sel === $option ? ' selected="selected"' : '';
$output .= '<option value="' . $option . '"' . $selected . '>' . esc_html($option) . '</option>';
if (!function_exists('themify_lightbox_vars_init')) {
* Post Gallery lightbox/fullscreen and single lightbox definition
* @return array Lightbox/Fullscreen galleries initialization parameters
function themify_lightbox_vars_init():array {
$gallery_lightbox = themify_get('setting-gallery_lightbox', 'lightbox', true);
// Lightbox default settings
if (themify_check('setting-lightbox_content_images', true)) {
$overlay_args['contentImagesAreas'] = '.post, .type-page, .type-highlight, .type-slider';
if (themify_check('setting-lightbox_disable_share', true)) {
$overlay_args['disable_sharing'] = true;
if ($gallery_lightbox === 'none') {
$overlay_args['gallerySelector'] = '';
$overlay_args = apply_filters('themify_gallery_plugins_args', $overlay_args);
// sanitize contentImagesAreas, ensure it's a valid CSS selector
if (isset($overlay_args['contentImagesAreas'])) {
$overlay_args['contentImagesAreas'] = trim($overlay_args['contentImagesAreas'], ',');
$overlay_args['i18n'] = array(
'tCounter' => __('%curr% of %total%', 'themify'),
if (!function_exists('themify_get_shortcode_template')) {
function themify_get_shortcode_template($posts, string $slug = 'includes/loop', string $name = 'index', array $args = array()):string {
Themify_Enqueue_Assets::loadGridCss($themify->post_layout);
$saved_post = clone $post;
if(property_exists($themify, 'is_shortcode')){
$isShortcode = $themify->is_shortcode === true;
$themify->is_shortcode = true;
// Add flag that template loop is in builder loop
if (class_exists('\Themify_Builder',false)) {
$isLoop = Themify_Builder::$is_loop;
Themify_Builder::$is_loop = true;
// get_template_part, defined in wp-includes/general-template.php
$templates[] = "{$slug}-{$name}.php";
$templates[] = "{$slug}.php";
$template_file = apply_filters('themify_get_shortcode_template_file', locate_template($templates, false, false), $slug, $name);
$isSlider = $themify->post_layout === 'slider' || (isset($args['isSlider']) && $args['isSlider'] === true);
if (!empty($template_file)) {
$before = isset($args['before_post']) ? $args['before_post'] : '';
$after = isset($args['after_post']) ? $args['after_post'] : '';
if ($isSlider === true) {
echo '<div class="tf_lazy tf_swiper-slide">';
if ($isSlider === true) {
if (isset($saved_post)) {
setup_postdata($saved_post);
// Add flag that template loop is in builder loop
Themify_Builder::$is_loop = $isLoop;
$themify->is_shortcode = $isShortcode;
if (!function_exists('themify_get_gallery_shortcode')) {
* Get images from gallery shortcode
function themify_get_gallery_shortcode(?string $shortcode):array {
preg_match('/\[gallery.*ids.*?=.(.*).\]/si', $shortcode, $ids);
$ids = trim($ids[1], '\\');
$image_ids = explode(',', $ids);
// Check if post has more than one image in gallery
'post__in' => $image_ids,
'post_type' => 'attachment',
'post_mime_type' => 'image',
'cache_results' => false,
'update_post_term_cache' => false,
'update_post_meta_cache' => false,
'orderby' => themify_get_gallery_shortcode_params($shortcode, 'orderby', 'post__in'),
'order' => themify_get_gallery_shortcode_params($shortcode, 'order', 'ASC')
if (!function_exists('themify_get_gallery_shortcode_params')) {
* Get gallery shortcode options
function themify_get_gallery_shortcode_params(string $shortcode, string $param = 'link', $default = '') {
$pattern = '/\[gallery .*?(?=' . $param . ')' . $param . '=.([^\']+)./si';
preg_match($pattern, $shortcode, $out);
$out = isset($out[1]) ? explode('"', $out[1]) : array('');
return $out[0] !== '' ? $out[0] : $default;
function themify_get_additional_image_sizes(string $size = 'all', $default = false) {
$allSizes = wp_get_additional_image_sizes();
return isset($allSizes[$size]) ? $allSizes[$size] : $default;
if (!function_exists('themify_get_all_terms_ids')) {
* Returns all IDs from the given taxonomy
* @param string $tax Taxonomy to retrieve terms from.
* @return array $term_ids Array of all taxonomy terms
function themify_get_all_terms_ids(string $tax = 'category') {
if (!$term_ids = wp_cache_get('all_' . $tax . '_ids', $tax)) {
$term_ids = get_terms(array('taxonomy' => $tax, 'fields' => 'ids', 'get' => 'all'));
wp_cache_add('all_' . $tax . '_ids', $term_ids, $tax);
if (!function_exists('themify_is_touch')) {
* According to what $check parameter specifies to check, returns true if it's a phone, tablet, or both.
function themify_is_touch($check = 'all') {
if (!isset($arr[$check])) {
if (!class_exists('Themify_Mobile_Detect',false)) {
require_once 'class-themify-mobile-detect.php';
$detect = new Themify_Mobile_Detect();
$is_tablet = isset($arr['tablet']) ? $arr['tablet'] : $detect->isTablet();
$is_mobile = isset($arr['phone']) ? $arr['phone'] : (wp_is_mobile() || $detect->isMobile());
'phone' => $is_mobile && !$is_tablet,
* Checks that status of the image script.
function themify_is_image_script_disabled():bool {
$is = wp_image_editor_supports() ? themify_check('setting-img_settings_use', true) : false;
if (!function_exists('themify_get_available_menus')) {
* Returns available navigation menus.
function themify_get_available_menus():array {
$out = array(array('name' => '', 'value' => '', 'selected' => true));
$menus = get_terms(array(
'taxonomy' => 'nav_menu',
if (!empty($menus) && !is_wp_error($menus)) {
foreach ($menus as $menu) {
$out[] = array('name' => $menu->name, 'value' => $menu->slug);
return apply_filters('themify_get_available_menus', $out);
* Returns true if the active theme is using Themify framework
function themify_is_themify_theme():bool {
$is = is_file(trailingslashit(get_template_directory()) . 'themify/themify-utils.php');
if (!function_exists('themify_is_woocommerce_active')) {
* Checks if Woocommerce plugin is active and returns the proper value
function themify_is_woocommerce_active():bool {
$plugin = 'woocommerce/woocommerce.php';
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
return is_plugin_active($plugin)
// validate if $plugin actually exists, the plugin might be active however not installed.
&& is_file(trailingslashit(WP_PLUGIN_DIR) . $plugin);
* Calls is_shop() in a safe manner
* @note: this function should not be called before template_redirect.
function themify_is_shop($pageId = false):bool {
$is = themify_is_woocommerce_active();
$is = is_post_type_archive('product') || ($pageId > 0 && $pageId === themify_shop_pageId()); //don't use shop function will give error