: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
// Prevent file from being loaded directly
if ( ! defined( 'ABSPATH' ) ) {
add_theme_support( 'custom-background', apply_filters( 'et_custom_background_args', array() ) );
if ( function_exists( 'add_post_type_support' ) ) {
add_post_type_support( 'page', 'excerpt' );
add_theme_support( 'automatic-feed-links' );
add_action( 'init', 'et_activate_features' );
function et_activate_features() {
if ( ! defined( 'ET_SHORTCODES_VERSION' ) ) {
define( 'ET_SHORTCODES_VERSION', et_get_theme_version() );
if ( ! defined( 'ET_SHORTCODES_DIR' ) ) {
define( 'ET_SHORTCODES_DIR', get_template_directory_uri() . '/epanel/shortcodes' );
/* activate shortcodes */
require_once TEMPLATEPATH . '/epanel/shortcodes/shortcodes.php';
/* activate page templates */
require_once TEMPLATEPATH . '/includes/page_templates/page_templates.php';
/* import epanel settings */
require_once TEMPLATEPATH . '/includes/import_settings.php';
add_filter( 'widget_text', 'do_shortcode' );
add_filter( 'the_excerpt', 'do_shortcode' );
if ( ! function_exists( 'et_get_theme_version' ) ) :
function et_get_theme_version() {
$theme_info = wp_get_theme();
if ( is_child_theme() ) {
$theme_info = wp_get_theme( $theme_info->parent_theme );
$theme_version = $theme_info->display( 'Version' );
if ( ! function_exists( 'et_options_stored_in_one_row' ) ) {
function et_options_stored_in_one_row(){
global $et_store_options_in_one_row;
return isset( $et_store_options_in_one_row ) ? (bool) $et_store_options_in_one_row : false;
/* sync custom CSS from ePanel with WP custom CSS option introduced in WP 4.7 */
if ( ! function_exists( 'et_sync_custom_css_options' ) ) {
function et_sync_custom_css_options() {
$legacy_custom_css = wp_unslash( et_get_option( "{$shortname}_custom_css" ) );
// nothing to sync if no custom css saved in ePanel
if ( '' === $legacy_custom_css || ! $legacy_custom_css || empty( $legacy_custom_css ) ) {
set_theme_mod( 'et_pb_css_synced', 'yes' );
// don't proceed with the sync logic if the custom CSS option does not exist
if ( ! function_exists( 'wp_get_custom_css' ) ) {
$css_synced = get_theme_mod( 'et_pb_css_synced', 'no' );
// get custom css string from WP customizer
$wp_custom_css = wp_get_custom_css();
// force sync if the current custom CSS is empty
if ( 'yes' === $css_synced && '' !== $wp_custom_css ) {
// ePanel is completely synced with Customizer
if ( $wp_custom_css === $legacy_custom_css || false !== strpos( $wp_custom_css, $legacy_custom_css ) ) {
set_theme_mod( 'et_pb_css_synced', 'yes' );
// merge custom css from WP customizer with ePanel custom css
$updated_custom_css = $legacy_custom_css . ' ' . $wp_custom_css;
$updated_status = wp_update_custom_css_post( $updated_custom_css );
// set theme mod in case of success
if ( is_object( $updated_status ) && ! empty( $updated_status ) ) {
set_theme_mod( 'et_pb_css_synced', 'yes' );
add_action( 'init', 'et_sync_custom_css_options' );
* sync custom CSS from WP custom CSS option introduced in WP 4.7 with theme options for backward compatibility
* it should be removed after a few WP major updates when we fully migrate to WP custom CSS system
if ( ! function_exists( 'et_back_sync_custom_css_options' ) ) {
function et_back_sync_custom_css_options( $data ) {
if ( ! empty( $data ) && isset( $data['css'] ) ) {
et_update_option( "{$shortname}_custom_css", $data['css'] );
add_filter( 'update_custom_css_data', 'et_back_sync_custom_css_options' );
if ( ! function_exists( 'et_update_custom_css_data_cb' ) ):
function et_update_custom_css_data_cb( $data ) {
ET_Core_PageResource::remove_static_resources( 'all', 'all' );
add_filter( 'update_custom_css_data', 'et_update_custom_css_data_cb' );
if ( ! function_exists( 'et_epanel_handle_custom_css_output' ) ):
function et_epanel_handle_custom_css_output( $css, $stylesheet ) {
global $wp_current_filter, $shortname;
/** @see ET_Core_SupportCenter::toggle_safe_mode */
if ( et_core_is_safe_mode_active() ) {
if ( ! $css || ! in_array( 'wp_head', $wp_current_filter ) || is_admin() && ! is_customize_preview() ) {
$post_id = et_core_page_resource_get_the_ID();
$is_preview = is_preview() || isset( $_GET['et_pb_preview_nonce'] ) || is_customize_preview(); // phpcs:ignore WordPress.Security.NonceVerification.NoNonceVerification
$is_singular = et_core_page_resource_is_singular();
$disabled_global = 'off' === et_get_option( 'et_pb_static_css_file', 'on' );
$disabled_post = $disabled_global || ( $is_singular && 'off' === get_post_meta( $post_id, '_et_pb_static_css_file', true ) );
$forced_inline = $is_preview || $disabled_global || $disabled_post || post_password_required();
$builder_in_footer = 'on' === et_get_option( 'et_pb_css_in_footer', 'off' );
$unified_styles = $is_singular && ! $forced_inline && ! $builder_in_footer && et_core_is_builder_used_on_current_request();
$resource_owner = $unified_styles ? 'core' : $shortname;
$resource_slug = $unified_styles ? 'unified' : 'customizer';
// Don't let previews cause existing saved static css files to be modified.
$resource_slug .= '-preview';
if ( function_exists( 'et_fb_is_enabled' ) && et_fb_is_enabled() ) {
if ( ! $unified_styles ) {
$styles_manager = et_core_page_resource_get( $resource_owner, $resource_slug, $post_id, 30 );
if ( $styles_manager->forced_inline || ! $styles_manager->has_file() ) {
$styles_manager->set_data( $css, 30 );
return ''; // We're handling the custom CSS output ourselves.
add_filter( 'wp_get_custom_css', 'et_epanel_handle_custom_css_output', 999, 2 );
* Gets option value from the single theme option, stored as an array in the database
* if all options stored in one row.
* Stores the serialized array with theme options into the global variable on the first function run on the page.
* If options are stored as separate rows in database, it simply uses get_option() function.
* @param string $option_name Theme option name.
* @param string $default_value Default value that should be set if the theme option isn't set.
* @param string $used_for_object "Object" name that should be translated into corresponding "object" if WPML is activated.
* @return mixed Theme option value or false if not found.
if ( ! function_exists( 'et_get_option' ) ) {
function et_get_option( $option_name, $default_value = '', $used_for_object = '', $force_default_value = false, $is_global_setting = false, $global_setting_main_name = '', $global_setting_sub_name = '' ){
global $et_theme_options, $shortname;
$et_one_row_option_name = '';
if ( $is_global_setting ) {
$et_global_setting = get_option( $global_setting_main_name );
if ( false !== $et_global_setting && isset( $et_global_setting[ $global_setting_sub_name ] ) ) {
$option_value = $et_global_setting[ $global_setting_sub_name ];
} else if ( et_options_stored_in_one_row() ) {
$et_theme_options_name = 'et_' . $shortname;
if ( ! isset( $et_theme_options ) || is_customize_preview() ) {
$et_theme_options = get_option( $et_theme_options_name );
$option_value = isset( $et_theme_options[$option_name] ) ? $et_theme_options[$option_name] : false;
$et_one_row_option_name = $et_theme_options_name . '_' . $option_name;
$option_value = $force_default_value ? get_option( $option_name, $default_value ) : get_option( $option_name );
// option value might be equal to false, so check if the option is not set in the database
if ( et_options_stored_in_one_row() && ! isset( $et_theme_options[ $option_name ] ) && ( ! empty( $default_value ) || $force_default_value ) ) {
$option_value = $default_value;
if ( ! empty( $used_for_object ) && in_array( $used_for_object, array( 'page', 'category' ) ) && is_array( $option_value ) )
$option_value = et_generate_wpml_ids( $option_value, $used_for_object );
if ( ! empty( $et_one_row_option_name ) ) {
$option_value = apply_filters( 'et_get_option_' . $et_one_row_option_name, $option_value, $et_one_row_option_name );
if ( ! function_exists( 'et_update_option' ) ) {
function et_update_option( $option_name, $new_value, $is_new_global_setting = false, $global_setting_main_name = '', $global_setting_sub_name = '' ){
global $et_theme_options, $shortname;
if ( $is_new_global_setting && '' !== $global_setting_main_name && '' !== $global_setting_sub_name ) {
$global_setting = get_option( $global_setting_main_name, array() );
// $global_setting has to be array otherwise setting can't be saved so it needs
// to be treated as empty array
if ( ! is_array( $global_setting ) ) {
$global_setting = array();
$global_setting[ $global_setting_sub_name ] = $new_value;
update_option( $global_setting_main_name, $global_setting );
} else if ( et_options_stored_in_one_row() ) {
$et_theme_options_name = 'et_' . $shortname;
if ( ! isset( $et_theme_options ) || is_customize_preview() ) {
$et_theme_options = get_option( $et_theme_options_name );
$et_theme_options[$option_name] = $new_value;
update_option( $et_theme_options_name, $et_theme_options );
update_option( $option_name, $new_value );
if ( ! function_exists( 'et_delete_option' ) ) {
function et_delete_option( $option_name ){
global $et_theme_options, $shortname;
if ( et_options_stored_in_one_row() ) {
$et_theme_options_name = 'et_' . $shortname;
if ( ! isset( $et_theme_options ) ) $et_theme_options = get_option( $et_theme_options_name );
unset( $et_theme_options[$option_name] );
update_option( $et_theme_options_name, $et_theme_options );
delete_option( $option_name );
/*this function allows for the auto-creation of post excerpts*/
if ( ! function_exists( 'truncate_post' ) ) {
function truncate_post( $amount, $echo = true, $post = '', $strip_shortcodes = false ) {
if ( empty( $post ) ) global $post;
if ( post_password_required( $post ) ) {
$post_excerpt = get_the_password_form();
echo et_core_intentionally_unescaped( $post_excerpt, 'html' );
$post_excerpt = apply_filters( 'the_excerpt', $post->post_excerpt );
if ( 'on' === et_get_option( $shortname . '_use_excerpt' ) && ! empty( $post_excerpt ) ) {
echo et_core_intentionally_unescaped( $post_excerpt, 'html' );
$truncate = $post->post_content;
// remove caption shortcode from the post content
$truncate = preg_replace( '@\[caption[^\]]*?\].*?\[\/caption]@si', '', $truncate );
// remove post nav shortcode from the post content
$truncate = preg_replace( '@\[et_pb_post_nav[^\]]*?\].*?\[\/et_pb_post_nav]@si', '', $truncate );
// Remove audio shortcode from post content to prevent unwanted audio file on the excerpt
// due to unparsed audio shortcode
$truncate = preg_replace( '@\[audio[^\]]*?\].*?\[\/audio]@si', '', $truncate );
// Remove embed shortcode from post content
$truncate = preg_replace( '@\[embed[^\]]*?\].*?\[\/embed]@si', '', $truncate );
// Remove script and style tags from the post content
$truncate = wp_strip_all_tags( $truncate );
if ( $strip_shortcodes ) {
$truncate = et_strip_shortcodes( $truncate );
$truncate = et_builder_strip_dynamic_content( $truncate );
// Check if content should be overridden with a custom value.
$custom = apply_filters( 'et_truncate_post_use_custom_content', false, $truncate, $post );
$truncate = false === $custom ? apply_filters( 'the_content', $truncate ) : $custom;
* Filter automatically generated post excerpt before it gets truncated.
* @param integer $post_id
$truncate = apply_filters( 'et_truncate_post', $truncate, $post->ID );
// decide if we need to append dots at the end of the string
if ( strlen( $truncate ) <= $amount ) {
// $amount = $amount - 3;
// trim text to a certain number of characters, also remove spaces from the end of a string ( space counts as a character )
$truncate = rtrim( et_wp_trim_words( $truncate, $amount, '' ) );
// remove the last word to make sure we display all words correctly
if ( ! empty( $echo_out ) ) {
$new_words_array = (array) explode( ' ', $truncate );
array_pop( $new_words_array );
$truncate = implode( ' ', $new_words_array );
// append dots to the end of the string
echo et_core_intentionally_unescaped( $truncate, 'html' );
if ( ! function_exists( 'et_wp_trim_words' ) ) {
function et_wp_trim_words( $text, $num_words = 55, $more = null ) {
$more = esc_html__( '…' );
// Completely remove icons so that unicode hex entities representing the icons do not get included in words.
$text = preg_replace( '/<span class="et-pb-icon .*<\/span>/', '', $text );
$text = wp_strip_all_tags( $text );
$text = trim( preg_replace( "/[\n\r\t ]+/", ' ', $text ), ' ' );
preg_match_all( '/./u', $text, $words_array );
$words_array = array_slice( $words_array[0], 0, $num_words + 1 );
if ( count( $words_array ) > $num_words ) {
array_pop( $words_array );
$text = implode( $sep, $words_array );
$text = implode( $sep, $words_array );
/*this function truncates titles to create preview excerpts*/
if ( ! function_exists( 'truncate_title' ) ) {
function truncate_title( $amount, $echo = true, $post = '' ) {
if ( empty( $post ) ) $truncate = get_the_title();
else $truncate = $post->post_title;
if ( strlen( $truncate ) <= $amount ) $echo_out = '';
$truncate = et_wp_trim_words( $truncate, $amount, '' );
if ( ! empty( $echo_out ) ) $truncate .= $echo_out;
echo et_core_intentionally_unescaped( $truncate, 'html' );
/*this function allows users to use the first image in their post as their thumbnail*/
if ( ! function_exists( 'et_first_image' ) ) {
function et_first_image() {
if ( empty( $post->ID ) ) {
$unprocessed_content = $post->post_content;
// truncate Post based shortcodes if Divi Builder enabled to avoid infinite loops
if ( function_exists( 'et_strip_shortcodes' ) ) {
$unprocessed_content = et_strip_shortcodes( $post->post_content, true );
// Check if content should be overridden with a custom value.
$custom = apply_filters( 'et_first_image_use_custom_content', false, $unprocessed_content, $post );
// apply the_content filter to execute all shortcodes and get the correct image from the processed content
$processed_content = false === $custom ? apply_filters( 'the_content', $unprocessed_content ) : $custom;
$output = preg_match_all( '/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $processed_content, $matches );
if ( isset( $matches[1][0] ) ) $img = $matches[1][0];
/* this function gets thumbnail from Post Thumbnail or Custom field or First post image */
if ( ! function_exists( 'get_thumbnail' ) ) {
function get_thumbnail($width=100, $height=100, $class='', $alttext='', $titletext='', $fullpath=false, $custom_field='', $post='') {
if ( empty( $post ) ) global $post;
$thumb_array['thumb'] = '';
$thumb_array['use_timthumb'] = true;
if ($fullpath) $thumb_array['fullpath'] = ''; //full image url for lightbox
if ( has_post_thumbnail( $post->ID ) ) {
$thumb_array['use_timthumb'] = false;
$et_fullpath = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
if ( is_array( $et_fullpath ) ) {