: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
$translated_id = icl_object_id( $id, $type, false );
if ( ! is_null( $translated_id ) ) $wpml_ids[] = $translated_id;
return array_map( 'intval', $ids_array );
if ( ! function_exists( 'elegant_is_blog_posts_page' ) ) {
function elegant_is_blog_posts_page() {
* Returns true if static page is set in WP-Admin / Settings / Reading
* and Posts page is displayed
static $et_is_blog_posts_cached = null;
if ( null === $et_is_blog_posts_cached ) {
$et_is_blog_posts_cached = (bool) is_home() && 0 !== intval( get_option( 'page_for_posts', '0' ) );
return $et_is_blog_posts_cached;
// Added for backwards compatibility
if ( ! function_exists( 'elegant_titles' ) ) {
function elegant_titles() {
if ( ! function_exists( 'wp_get_document_title' ) ) {
echo et_core_esc_wp( wp_get_document_title() );
if ( ! function_exists( '_wp_render_title_tag' ) && ! function_exists( 'et_add_title_tag_back_compat' ) ) {
* Manually add <title> tag in head for WordPress 4.1 below for backward compatibility
* Title tag is automatically added for WordPress 4.1 above via theme support
function et_add_title_tag_back_compat() {
<title><?php wp_title( '-', true, 'right' ); ?></title>
add_action( 'wp_head', 'et_add_title_tag_back_compat' );
/*this function controls the meta titles display*/
if ( ! function_exists( 'elegant_titles_filter' ) ) {
function elegant_titles_filter( $custom_title ) {
global $shortname, $themename;
$sitename = get_bloginfo( 'name' );
$site_description = get_bloginfo( 'description' );
#if the title is being displayed on the homepage
if ( ( is_home() || is_front_page() ) && ! elegant_is_blog_posts_page() ) {
if ( 'on' === et_get_option( $shortname . '_seo_home_title' ) ) {
$custom_title = et_get_option( $shortname . '_seo_home_titletext' );
$seo_home_type = et_get_option( $shortname . '_seo_home_type' );
$seo_home_separate = et_get_option( $shortname . '_seo_home_separate' );
if ( $seo_home_type === 'BlogName | Blog description' ) {
$custom_title = $sitename . esc_html( $seo_home_separate ) . $site_description;
if ( $seo_home_type === 'Blog description | BlogName') {
$custom_title = $site_description . esc_html( $seo_home_separate ) . $sitename;
if ( $seo_home_type === 'BlogName only') {
$custom_title = $sitename;
#if the title is being displayed on single posts/pages
if ( ( ( is_single() || is_page() ) && ! is_front_page() ) || elegant_is_blog_posts_page() ) {
$postid = elegant_is_blog_posts_page() ? intval( get_option( 'page_for_posts' ) ) : $wp_query->post->ID;
$key = et_get_option( $shortname . '_seo_single_field_title' );
$exists3 = get_post_meta( $postid, '' . $key . '', true );
if ( 'on' === et_get_option( $shortname . '_seo_single_title' ) && '' !== $exists3 ) {
$custom_title = $exists3;
$seo_single_type = et_get_option( $shortname . '_seo_single_type' );
$seo_single_separate = et_get_option( $shortname . '_seo_single_separate' );
$page_title = single_post_title( '', false );
if ( $seo_single_type === 'BlogName | Post title' ) {
$custom_title = $sitename . esc_html( $seo_single_separate ) . $page_title;
if ( $seo_single_type === 'Post title | BlogName' ) {
$custom_title = $page_title . esc_html( $seo_single_separate ) . $sitename;
if ( $seo_single_type === 'Post title only' ) {
$custom_title = $page_title;
#if the title is being displayed on index pages (categories/archives/search results)
if ( is_category() || is_archive() || is_search() || is_404() ) {
$seo_index_type = et_get_option( $shortname . '_seo_index_type' );
$seo_index_separate = et_get_option( $shortname . '_seo_index_separate' );
if ( is_category() || is_tag() || is_tax() ) {
$page_title = single_term_title( '', false );
} else if ( is_post_type_archive() ) {
$page_title = post_type_archive_title( '', false );
} else if ( is_author() ) {
$page_title = get_the_author_meta( 'display_name', get_query_var( 'author' ) );
} else if ( is_date() ) {
$page_title = esc_html__( 'Archives', $themename );
} else if ( is_search() ) {
$page_title = sprintf( esc_html__( 'Search results for "%s"', $themename ), esc_attr( get_search_query() ) );
$page_title = esc_html__( '404 Not Found', $themename );
if ( $seo_index_type === 'BlogName | Category name' ) {
$custom_title = $sitename . esc_html( $seo_index_separate ) . $page_title;
if ( $seo_index_type === 'Category name | BlogName') {
$custom_title = $page_title . esc_html( $seo_index_separate ) . $sitename;
if ( $seo_index_type === 'Category name only') {
$custom_title = $page_title;
$custom_title = wp_strip_all_tags( $custom_title );
add_filter( 'pre_get_document_title', 'elegant_titles_filter' );
/*this function controls the meta description display*/
if ( ! function_exists( 'elegant_description' ) ) {
function elegant_description() {
// Don't use ePanel SEO if WordPress SEO or All In One SEO Pack plugins are active
if ( class_exists( 'WPSEO_Frontend' ) || class_exists( 'All_in_One_SEO_Pack' ) ) {
global $shortname, $themename;
if ( et_get_option( $shortname.'_seo_home_description' ) === 'on' && ( ( is_home() || is_front_page() ) && ! elegant_is_blog_posts_page() ) ) {
echo '<meta name="description" content="' . esc_attr( et_get_option( $shortname.'_seo_home_descriptiontext' ) ) .'" />';
#single page descriptions
if ( et_get_option( $shortname.'_seo_single_description' ) === 'on' && ( is_single() || is_page() || elegant_is_blog_posts_page() ) ) {
if ( isset( $wp_query->post->ID ) || elegant_is_blog_posts_page() ) {
$postid = elegant_is_blog_posts_page() ? intval( get_option( 'page_for_posts' ) ) : $wp_query->post->ID;
$key2 = et_get_option( $shortname.'_seo_single_field_description' );
if ( isset( $postid ) ) $exists = get_post_meta( $postid, ''.$key2.'', true );
echo '<meta name="description" content="' . esc_attr( $exists ) . '" />';
$seo_index_description = et_get_option( $shortname.'_seo_index_description' );
if ( $seo_index_description === 'on' ) {
$is_pre_4_4 = version_compare( $GLOBALS['wp_version'], '4.4', '<' );
$description_added = false;
remove_filter( 'term_description', 'wpautop' );
$cat = get_query_var( 'cat' );
$exists2 = category_description( $cat );
echo '<meta name="description" content="' . esc_attr( $exists2 ) . '" />';
$description_added = true;
if ( is_archive() && ! $description_added ) {
$description_text = $is_pre_4_4 ? sprintf( esc_html__( 'Currently viewing archives from %1$s', $themename ),
wp_title( '', false, '' )
) : get_the_archive_title();
printf( '<meta name="description" content="%1$s" />',
esc_attr( $description_text )
$description_added = true;
if ( is_search() && ! $description_added ) {
$description_text = $is_pre_4_4 ? wp_title( '', false, '' ) : sprintf(
esc_html__( 'Search Results for: %s', $themename ),
echo '<meta name="description" content="' . esc_attr( $description_text ) . '" />';
$description_added = true;
/*this function controls the meta keywords display*/
if ( ! function_exists( 'elegant_keywords' ) ) {
function elegant_keywords() {
// Don't use ePanel SEO if WordPress SEO or All In One SEO Pack plugins are active
if ( class_exists( 'WPSEO_Frontend' ) || class_exists( 'All_in_One_SEO_Pack' ) ) {
if ( et_get_option( $shortname.'_seo_home_keywords' ) === 'on' && ( ( is_home() || is_front_page() ) && ! elegant_is_blog_posts_page() ) ) {
echo '<meta name="keywords" content="' . esc_attr( et_get_option( $shortname.'_seo_home_keywordstext' ) ) . '" />';
if ( et_get_option( $shortname.'_seo_single_keywords' ) === 'on' ) {
if ( isset( $wp_query->post->ID ) || elegant_is_blog_posts_page() ) {
$postid = elegant_is_blog_posts_page() ? intval( get_option( 'page_for_posts' ) ) : $wp_query->post->ID;
$key3 = et_get_option( $shortname.'_seo_single_field_keywords' );
if (isset( $postid )) $exists4 = get_post_meta( $postid, ''.$key3.'', true );
if ( isset( $exists4 ) && $exists4 !== '' ) {
if ( is_single() || is_page() || elegant_is_blog_posts_page() ) echo '<meta name="keywords" content="' . esc_attr( $exists4 ) . '" />';
/*this function controls canonical urls*/
if ( ! function_exists( 'elegant_canonical' ) ) {
function elegant_canonical() {
// Don't use ePanel SEO if WordPress SEO or All In One SEO Pack plugins are active
if ( class_exists( 'WPSEO_Frontend' ) || class_exists( 'All_in_One_SEO_Pack' ) ) {
if ( et_get_option( $shortname.'_seo_home_canonical' ) === 'on' && is_home() && ! elegant_is_blog_posts_page() ) {
echo '<link rel="canonical" href="'. esc_url( home_url() ).'" />';
if ( et_get_option( $shortname.'_seo_single_canonical' ) === 'on' ) {
if ( isset( $wp_query->post->ID ) || elegant_is_blog_posts_page() ) {
$postid = elegant_is_blog_posts_page() ? intval( get_option( 'page_for_posts' ) ) : $wp_query->post->ID;
if ( ( is_single() || is_page() || elegant_is_blog_posts_page() ) && ! is_front_page() ) {
echo '<link rel="canonical" href="' . esc_url( get_permalink( $postid ) ) . '" />';
if ( et_get_option( $shortname.'_seo_index_canonical' ) === 'on' ) {
$current_page_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
if ( is_archive() || is_category() || is_search() ) echo '<link rel="canonical" href="'. esc_url( $current_page_url ).'" />';
add_action( 'wp_head', 'add_favicon' );
$faviconUrl = et_get_option( $shortname.'_favicon' );
// If the `has_site_icon` function doesn't exist (ie we're on < WP 4.3) or if the site icon has not been set,
// and when we have a icon URL from theme option
if ( ( ! function_exists( 'has_site_icon' ) || ! has_site_icon() ) && '' !== $faviconUrl ) {
echo '<link rel="shortcut icon" href="' . esc_url( $faviconUrl ) . '" />';
} elseif ( function_exists( 'has_site_icon' ) && has_site_icon() ) {
et_update_option( $shortname . '_favicon', '' );
add_action( 'init', 'et_create_images_temp_folder' );
function et_create_images_temp_folder(){
$et_images_temp_folder = get_option( 'et_images_temp_folder' );
#clean et_temp folder once per week
if ( false !== $last_time = get_option( 'et_schedule_clean_images_last_time' ) ) {
if ( ( $timeout < ( time() - $last_time ) ) && ! empty( $et_images_temp_folder ) ) et_clean_temp_images( $et_images_temp_folder );
if ( false !== $et_images_temp_folder ) return;
$uploads_dir = wp_upload_dir();
$destination_dir = ( false === $uploads_dir['error'] ) ? path_join( $uploads_dir['basedir'], 'et_temp' ) : null;
if ( ! wp_mkdir_p( $destination_dir ) ) update_option( 'et_images_temp_folder', '' );
update_option( 'et_images_temp_folder', preg_replace( '#\/\/#', '/', $destination_dir ) );
update_option( 'et_schedule_clean_images_last_time', time() );
if ( ! function_exists( 'et_clean_temp_images' ) ) {
function et_clean_temp_images( $directory ){
$dir_to_clean = @ opendir( $directory );
while (($file = readdir( $dir_to_clean ) ) !== false ) {
if ( substr( $file, 0, 1 ) === '.' )
if ( is_dir( $directory.'/'.$file ) )
et_clean_temp_images( path_join( $directory, $file ) );
@ unlink( path_join( $directory, $file ) );
closedir( $dir_to_clean );
#set last time cleaning was performed
update_option( 'et_schedule_clean_images_last_time', time() );
add_filter( 'update_option_upload_path', 'et_update_uploads_dir' );
function et_update_uploads_dir( $upload_path ){
#check if we have 'et_temp' folder within $uploads_dir['basedir'] directory, if not - try creating it, if it's not possible $destination_dir = null
$uploads_dir = wp_upload_dir();
$et_temp_dir = path_join( $uploads_dir['basedir'], 'et_temp' );
if ( is_dir( $et_temp_dir ) || ( false === $uploads_dir['error'] && wp_mkdir_p( $et_temp_dir ) ) ) {
$destination_dir = $et_temp_dir;
update_option( 'et_schedule_clean_images_last_time', time() );
update_option( 'et_images_temp_folder', preg_replace( '#\/\/#', '/', $destination_dir ) );
if ( ! function_exists( 'et_resize_image' ) ) {
function et_resize_image( $thumb, $new_width, $new_height, $crop ){
* Fixes the issue with x symbol between width and height values in the filename.
* For instance, sports-400x400.jpg file results in 'image not found' in getimagesize() function.
$thumb = str_replace( '%26%23215%3B', 'x', rawurlencode( $thumb ) );
$thumb = rawurldecode( $thumb );
if ( is_ssl() ) $thumb = preg_replace( '#^http://#', 'https://', $thumb );
$info = pathinfo( $thumb );
$ext = $info['extension'];
$name = wp_basename( $thumb, ".$ext" );
$site_uri = apply_filters( 'et_resize_image_site_uri', site_url() );
$site_dir = apply_filters( 'et_resize_image_site_dir', ABSPATH );
// If multisite, not the main site, WordPress version < 3.5 or ms-files rewriting is enabled ( not the fresh WordPress installation, updated from the 3.4 version )
if ( is_multisite() && ! is_main_site() && ( ! function_exists( 'wp_get_mime_types' ) || get_site_option( 'ms_files_rewriting' ) ) ) {
//Get main site url on multisite installation
* If we're dealing with an external image ( might be the result of Grab the first image function ),
* return original image url
if ( false === strpos( $thumb, $site_uri ) )
$name = preg_replace( '#.jpeg$#', '', $name );
$suffix = "{$new_width}x{$new_height}";
$et_images_temp_folder = get_option( 'et_images_temp_folder' );
$destination_dir = ! empty( $et_images_temp_folder ) ? preg_replace( '#\/\/#', '/', $et_images_temp_folder ) : null;
$matches = apply_filters( 'et_resize_image_site_dir', array(), $site_dir );
if ( !empty( $matches ) ) {
preg_match( '#'.$matches[1].'$#', $site_uri, $site_uri_matches );
if ( !empty( $site_uri_matches ) ) {
$site_uri = str_replace( $matches[1], '', $site_uri );
$site_uri = preg_replace( '#/$#', '', $site_uri );
$site_dir = str_replace( $matches[1], '', $site_dir );
$site_dir = preg_replace( '#\\\/$#', '', $site_dir );
#get local name for use in file_exists() and get_imagesize() functions
$localfile = str_replace( apply_filters( 'et_resize_image_localfile', $site_uri, $site_dir, et_multisite_thumbnail( $thumb ) ), $site_dir, et_multisite_thumbnail( $thumb ) );
if ( file_exists( $localfile ) ) $add_to_suffix = filesize( $localfile ) . '_';
#prepend image filesize to be able to use images with the same filename
$suffix = $add_to_suffix . $suffix;
$destfilename_attributes = '-' . $suffix . '.' . strtolower( $ext );
$checkfilename = ( ! empty( $destination_dir ) && null !== $destination_dir ) ? path_join( $destination_dir, $name ) : path_join( dirname( $localfile ), $name );
$checkfilename .= $destfilename_attributes;
if ( $is_jpeg ) $checkfilename = preg_replace( '#.jpg$#', '.jpeg', $checkfilename );
$uploads_dir = wp_upload_dir();
$uploads_dir['basedir'] = preg_replace( '#\/\/#', '/', $uploads_dir['basedir'] );
if ( null !== $destination_dir && ! empty( $destination_dir ) && apply_filters( 'et_enable_uploads_detection', true ) ) {
$site_dir = trailingslashit( preg_replace( '#\/\/#', '/', $uploads_dir['basedir'] ) );
$site_uri = trailingslashit( $uploads_dir['baseurl'] );
#check if we have an image with specified width and height
if ( file_exists( $checkfilename ) ) return str_replace( $site_dir, trailingslashit( $site_uri ), $checkfilename );
$size = @getimagesize( $localfile );
if ( !$size ) return new WP_Error( 'invalid_image_path', esc_html__( 'Image doesn\'t exist' ), $thumb );
list($orig_width, $orig_height, $orig_type) = $size;
#check if we're resizing the image to smaller dimensions
if ( $orig_width > $new_width || $orig_height > $new_height ) {
if ( $orig_width < $new_width || $orig_height < $new_height ) {
#don't resize image if new dimensions > than its original ones
if ( $orig_width < $new_width ) $new_width = $orig_width;
if ( $orig_height < $new_height ) $new_height = $orig_height;
#regenerate suffix and appended attributes in case we changed new width or new height dimensions
$suffix = "{$add_to_suffix}{$new_width}x{$new_height}";
$destfilename_attributes = '-' . $suffix . '.' . $ext;
$checkfilename = ( ! empty( $destination_dir ) && null !== $destination_dir ) ? path_join( $destination_dir, $name ) : path_join( dirname( $localfile ), $name );
$checkfilename .= $destfilename_attributes;
#check if we have an image with new calculated width and height parameters
if ( file_exists( $checkfilename ) ) return str_replace( $site_dir, trailingslashit( $site_uri ), $checkfilename );
#we didn't find the image in cache, resizing is done here
$et_image_editor = wp_get_image_editor( $localfile );
if ( ! is_wp_error( $et_image_editor ) ) {
$et_image_editor->resize( $new_width, $new_height, $crop );
// generate correct file name/path
$et_new_image_name = $et_image_editor->generate_filename( $suffix, $destination_dir );
do_action( 'et_resize_image_before_save', $et_image_editor, $et_new_image_name );
$et_image_editor->save( $et_new_image_name );
$result = $et_new_image_name;
// assign a WP_ERROR ( WP_Image_Editor instance wasn't created properly )
$result = $et_image_editor;
if ( ! is_wp_error( $result ) ) {
// transform local image path into URI