: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
if ( $is_jpeg ) $thumb = preg_replace( '#.jpeg$#', '.jpg', $thumb );
$site_dir = str_replace( '\\', '/', $site_dir );
$result = str_replace( '\\', '/', $result );
$result = str_replace( '//', '/', $result );
$result = str_replace( $site_dir, trailingslashit( $site_uri ), $result );
#returns resized image path or WP_Error ( if something went wrong during resizing )
#returns unmodified image, for example in case if the user is trying to resize 800x600px to 1920x1080px image
add_action( 'pre_get_posts', 'et_custom_posts_per_page' );
function et_custom_posts_per_page( $query = false ) {
// phpcs:disable WordPress.Security.NonceVerification.NoNonceVerification
if ( ! is_a( $query, 'WP_Query' ) || ( ! $query->is_main_query() || ! empty( $query->et_pb_shop_query ) ) ) {
if ( $query->is_category ) {
$query->set( 'posts_per_page', (int) et_get_option( $shortname . '_catnum_posts', '5' ) );
} elseif ( $query->is_tag ) {
$query->set( 'posts_per_page', (int) et_get_option( $shortname . '_tagnum_posts', '5' ) );
} elseif ( $query->is_search ) {
if ( isset( $_GET['et_searchform_submit'] ) ) {
if ( !isset( $_GET['et-inc-posts'] ) && !isset( $_GET['et-inc-pages'] ) ) $postTypes = array('post');
if ( isset( $_GET['et-inc-pages'] ) ) $postTypes = array('page');
if ( isset( $_GET['et-inc-posts'] ) ) $postTypes[] = 'post';
$query->set( 'post_type', $postTypes );
if ( isset( $_GET['et-month-choice'] ) && $_GET['et-month-choice'] !== 'no-choice' ) {
$et_year = substr( $_GET['et-month-choice'], 0, 4 );
$et_month = substr( $_GET['et-month-choice'], 4, strlen( $_GET['et-month-choice'] ) - 4 );
$query->set( 'year', absint( $et_year ) );
$query->set( 'monthnum', absint( $et_month ) );
if ( isset( $_GET['et-cat'] ) && $_GET['et-cat'] !== '0' )
$query->set( 'cat', absint( $_GET['et-cat'] ) );
$query->set( 'posts_per_page', (int) et_get_option( $shortname . '_searchnum_posts', '5' ) );
} elseif ( $query->is_archive ) {
if ( function_exists( 'is_woocommerce' ) && is_woocommerce() ) {
// Plugin Compatibility :: Skip query->set if "loop_shop_per_page" filter is being used by 3rd party plugins
if ( ! has_filter( 'loop_shop_per_page' ) ) {
$posts_number = (int) et_get_option( $shortname . '_woocommerce_archive_num_posts', '9' );
$query->set( 'posts_per_page', $posts_number );
$posts_number = (int) et_get_option( $shortname . '_archivenum_posts', '5' );
$query->set( 'posts_per_page', $posts_number );
add_filter( 'default_hidden_meta_boxes', 'et_show_hidden_metaboxes', 10, 2 );
function et_show_hidden_metaboxes( $hidden, $screen ){
# make custom fields and excerpt meta boxes show by default
if ( 'post' === $screen->base || 'page' === $screen->base )
add_filter( 'widget_title', 'et_widget_force_title' );
function et_widget_force_title( $title ){
#add an empty title for widgets ( otherwise it might break the sidebar layout )
if ( empty( $title ) ) $title = ' ';
//modify the comment counts to only reflect the number of comments minus pings
if( version_compare( phpversion(), '4.4', '>=' ) ) add_filter( 'get_comments_number', 'et_comment_count', 0, 2 );
function et_comment_count( $count, $post_id ) {
$is_doing_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX ? true : false;
if ( ! is_admin() || $is_doing_ajax ) {
$post_id = $post_id ? $post_id : $id;
$get_comments = get_comments( array('post_id' => $post_id, 'status' => 'approve') );
$comments_by_type = separate_comments( $get_comments );
return count( $comments_by_type['comment'] );
add_action( 'admin_init', 'et_theme_check_clean_installation' );
function et_theme_check_clean_installation(){
add_action( 'admin_notices', 'et_theme_epanel_reminder' );
if ( ! function_exists( 'et_theme_epanel_reminder' ) ) {
function et_theme_epanel_reminder(){
global $shortname, $themename, $current_screen;
if ( false === et_get_option( $shortname . '_logo' ) && 'appearance_page_core_functions' !== $current_screen->id ) {
printf( et_get_safe_localization( __( '<div class="updated"><p>This is a fresh installation of %1$s theme. Don\'t forget to go to <a href="%2$s">ePanel</a> to set it up. This message will disappear once you have clicked the Save button within the <a href="%2$s">theme\'s options page</a>.</p></div>', $themename ) ), esc_html( wp_get_theme() ), esc_url( admin_url( 'themes.php?page=core_functions.php' ) ) );
add_filter( 'body_class', 'et_add_fullwidth_body_class' );
function et_add_fullwidth_body_class( $classes ){
if ( is_page_template( 'page-full.php' ) ) $fullwidth_view = true;
if ( is_page() || is_single() ) {
$et_ptemplate_settings = get_post_meta( get_queried_object_id(), 'et_ptemplate_settings', true );
$fullwidth = isset( $et_ptemplate_settings['et_fullwidthpage'] ) ? (bool) $et_ptemplate_settings['et_fullwidthpage'] : false;
if ( $fullwidth ) $fullwidth_view = true;
if ( is_single() && 'on' === get_post_meta( get_queried_object_id(), '_et_full_post', true ) ) $fullwidth_view = true;
$classes[] = apply_filters( 'et_fullwidth_view_body_class', $fullwidth_view ) ? 'et_fullwidth_view' : 'et_includes_sidebar';
function et_add_responsive_shortcodes_css() {
if ( 'on' === et_get_option( $shortname . '_responsive_shortcodes', 'on' ) )
wp_enqueue_style( 'et-shortcodes-responsive-css', ET_SHORTCODES_DIR . '/css/shortcodes_responsive.css', false, ET_SHORTCODES_VERSION, 'all' );
if ( ! function_exists( 'et_load_core_options' ) ) {
function et_load_core_options() {
require_once get_template_directory() . esc_attr( "/options_{$shortname}.php" );
* Adds custom css option content to <head>
function et_add_custom_css() {
// use default wp custom css system starting from WP 4.7
// fallback to our legacy custom css system otherwise
if ( function_exists( 'wp_get_custom_css_post' ) ) {
$custom_css = et_get_option( "{$shortname}_custom_css" );
if ( empty( $custom_css ) ) return;
* The theme doesn't strip slashes from custom css, when saving to the database,
* so it does that before outputting the code on front-end
echo '<style type="text/css" id="et-custom-css">' . "\n" . et_core_intentionally_unescaped( stripslashes( $custom_css ), 'html' ) . "\n" . '</style>';
add_action( 'wp_head', 'et_add_custom_css', 100 );
if ( ! function_exists( 'et_get_google_fonts' ) ) :
* Returns the list of popular google fonts
* Fallback to websafe fonts if disabled
function et_get_google_fonts() {
$websafe_fonts = et_core_get_websafe_fonts();
$google_fonts = et_core_use_google_fonts() ? et_core_get_saved_google_fonts() : $websafe_fonts;
return apply_filters( 'et_google_fonts', $google_fonts );
if ( ! function_exists( 'et_get_websafe_font_stack' ) ) :
* Determines a websafe font stack, using font type
function et_get_websafe_font_stack( $type = 'sans-serif' ) {
$font_stack = 'Helvetica, Arial, Lucida, sans-serif';
$font_stack = 'Georgia, "Times New Roman", serif';
if ( ! function_exists( 'et_gf_attach_font' ) ) :
* Attaches Google Font to given css elements
function et_gf_attach_font( $et_gf_font_name, $elements ) {
$google_fonts = et_get_google_fonts();
printf( '%s { font-family: \'%s\', %s; }',
esc_html( $et_gf_font_name ),
et_core_esc_previously( et_get_websafe_font_stack( $google_fonts[$et_gf_font_name]['type'] ) )
if ( ! function_exists( 'et_gf_enqueue_fonts' ) ) :
function et_gf_enqueue_fonts( $et_gf_font_names ) {
if ( ! is_array( $et_gf_font_names ) || empty( $et_gf_font_names ) || ! et_core_use_google_fonts() ) {
$google_fonts = et_get_google_fonts();
$protocol = is_ssl() ? 'https' : 'http';
foreach ( $et_gf_font_names as $et_gf_font_name ) {
$google_font_character_set = $google_fonts[$et_gf_font_name]['character_set'];
// By default, only latin and latin-ext subsets are loaded, all available subsets can be enabled in ePanel
if ( 'false' === et_get_option( "{$shortname}_gf_enable_all_character_sets", 'false' ) ) {
if ( false !== strpos( $google_fonts[$et_gf_font_name]['character_set'], 'latin-ext' ) )
$latin_ext = ',latin-ext';
$google_font_character_set = "latin{$latin_ext}";
'family' => sprintf( '%s:%s',
str_replace( ' ', '+', $et_gf_font_name ),
apply_filters( 'et_gf_set_styles', $google_fonts[$et_gf_font_name]['styles'], $et_gf_font_name )
'subset' => apply_filters( 'et_gf_set_character_set', $google_font_character_set, $et_gf_font_name ),
$et_gf_font_name_slug = strtolower( str_replace( ' ', '-', $et_gf_font_name ) );
wp_enqueue_style( 'et-gf-' . $et_gf_font_name_slug, esc_url( add_query_arg( $query_args, "$protocol://fonts.googleapis.com/css" ) ), array(), null );
if ( ! function_exists( 'et_pb_get_google_api_key' ) ) :
function et_pb_get_google_api_key() {
$google_api_option = get_option( 'et_google_api_settings' );
$google_api_key = isset( $google_api_option['api_key'] ) ? $google_api_option['api_key'] : '';
if ( ! function_exists( 'et_uc_theme_name' ) ) :
* Fixes the bug with lowercase theme name, preventing a theme to update correctly,
* when an update is being performed via Themes page
function et_uc_theme_name( $key, $raw_key ) {
if ( ! ( is_admin() && isset( $_REQUEST['action'] ) && 'update-theme' === $_REQUEST['action'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.NoNonceVerification
$theme_info = wp_get_theme();
if ( is_child_theme() ) {
$theme_info = wp_get_theme( $theme_info->parent_theme );
$theme_name = $theme_info->display( 'Name' );
if ( $raw_key !== $theme_name ) {
add_filter( 'sanitize_key', 'et_uc_theme_name', 10, 2 );
if ( ! function_exists( 'et_core_exists_in_active_plugins' ) ) :
function et_core_exists_in_active_plugins() {
$result = defined( 'ET_BUILDER_PLUGIN_DIR' )
|| defined( 'ET_BLOOM_PLUGIN_DIR' )
|| defined( 'ET_MONARCH_PLUGIN_DIR' );