Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-conte.../themes/Divi/epanel
File: custom_functions.php
$translated_id = icl_object_id( $id, $type, false );
[1000] Fix | Delete
if ( ! is_null( $translated_id ) ) $wpml_ids[] = $translated_id;
[1001] Fix | Delete
}
[1002] Fix | Delete
$ids_array = $wpml_ids;
[1003] Fix | Delete
}
[1004] Fix | Delete
[1005] Fix | Delete
return array_map( 'intval', $ids_array );
[1006] Fix | Delete
}
[1007] Fix | Delete
[1008] Fix | Delete
}
[1009] Fix | Delete
[1010] Fix | Delete
if ( ! function_exists( 'elegant_is_blog_posts_page' ) ) {
[1011] Fix | Delete
[1012] Fix | Delete
function elegant_is_blog_posts_page() {
[1013] Fix | Delete
/**
[1014] Fix | Delete
* Returns true if static page is set in WP-Admin / Settings / Reading
[1015] Fix | Delete
* and Posts page is displayed
[1016] Fix | Delete
*/
[1017] Fix | Delete
[1018] Fix | Delete
static $et_is_blog_posts_cached = null;
[1019] Fix | Delete
[1020] Fix | Delete
if ( null === $et_is_blog_posts_cached ) {
[1021] Fix | Delete
$et_is_blog_posts_cached = (bool) is_home() && 0 !== intval( get_option( 'page_for_posts', '0' ) );
[1022] Fix | Delete
}
[1023] Fix | Delete
[1024] Fix | Delete
return $et_is_blog_posts_cached;
[1025] Fix | Delete
}
[1026] Fix | Delete
[1027] Fix | Delete
}
[1028] Fix | Delete
[1029] Fix | Delete
// Added for backwards compatibility
[1030] Fix | Delete
if ( ! function_exists( 'elegant_titles' ) ) {
[1031] Fix | Delete
[1032] Fix | Delete
function elegant_titles() {
[1033] Fix | Delete
if ( ! function_exists( 'wp_get_document_title' ) ) {
[1034] Fix | Delete
wp_title();
[1035] Fix | Delete
} else {
[1036] Fix | Delete
echo et_core_esc_wp( wp_get_document_title() );
[1037] Fix | Delete
}
[1038] Fix | Delete
}
[1039] Fix | Delete
[1040] Fix | Delete
}
[1041] Fix | Delete
[1042] Fix | Delete
if ( ! function_exists( '_wp_render_title_tag' ) && ! function_exists( 'et_add_title_tag_back_compat' ) ) {
[1043] Fix | Delete
[1044] Fix | Delete
/**
[1045] Fix | Delete
* Manually add <title> tag in head for WordPress 4.1 below for backward compatibility
[1046] Fix | Delete
* Title tag is automatically added for WordPress 4.1 above via theme support
[1047] Fix | Delete
* @return void
[1048] Fix | Delete
*/
[1049] Fix | Delete
function et_add_title_tag_back_compat() {
[1050] Fix | Delete
?>
[1051] Fix | Delete
<title><?php wp_title( '-', true, 'right' ); ?></title>
[1052] Fix | Delete
<?php
[1053] Fix | Delete
}
[1054] Fix | Delete
[1055] Fix | Delete
add_action( 'wp_head', 'et_add_title_tag_back_compat' );
[1056] Fix | Delete
}
[1057] Fix | Delete
[1058] Fix | Delete
/*this function controls the meta titles display*/
[1059] Fix | Delete
if ( ! function_exists( 'elegant_titles_filter' ) ) {
[1060] Fix | Delete
[1061] Fix | Delete
function elegant_titles_filter( $custom_title ) {
[1062] Fix | Delete
global $shortname, $themename;
[1063] Fix | Delete
$custom_title = '';
[1064] Fix | Delete
$sitename = get_bloginfo( 'name' );
[1065] Fix | Delete
$site_description = get_bloginfo( 'description' );
[1066] Fix | Delete
#if the title is being displayed on the homepage
[1067] Fix | Delete
if ( ( is_home() || is_front_page() ) && ! elegant_is_blog_posts_page() ) {
[1068] Fix | Delete
if ( 'on' === et_get_option( $shortname . '_seo_home_title' ) ) {
[1069] Fix | Delete
$custom_title = et_get_option( $shortname . '_seo_home_titletext' );
[1070] Fix | Delete
} else {
[1071] Fix | Delete
$seo_home_type = et_get_option( $shortname . '_seo_home_type' );
[1072] Fix | Delete
$seo_home_separate = et_get_option( $shortname . '_seo_home_separate' );
[1073] Fix | Delete
if ( $seo_home_type === 'BlogName | Blog description' ) {
[1074] Fix | Delete
$custom_title = $sitename . esc_html( $seo_home_separate ) . $site_description;
[1075] Fix | Delete
}
[1076] Fix | Delete
if ( $seo_home_type === 'Blog description | BlogName') {
[1077] Fix | Delete
$custom_title = $site_description . esc_html( $seo_home_separate ) . $sitename;
[1078] Fix | Delete
}
[1079] Fix | Delete
if ( $seo_home_type === 'BlogName only') {
[1080] Fix | Delete
$custom_title = $sitename;
[1081] Fix | Delete
}
[1082] Fix | Delete
}
[1083] Fix | Delete
}
[1084] Fix | Delete
#if the title is being displayed on single posts/pages
[1085] Fix | Delete
if ( ( ( is_single() || is_page() ) && ! is_front_page() ) || elegant_is_blog_posts_page() ) {
[1086] Fix | Delete
global $wp_query;
[1087] Fix | Delete
$postid = elegant_is_blog_posts_page() ? intval( get_option( 'page_for_posts' ) ) : $wp_query->post->ID;
[1088] Fix | Delete
$key = et_get_option( $shortname . '_seo_single_field_title' );
[1089] Fix | Delete
$exists3 = get_post_meta( $postid, '' . $key . '', true );
[1090] Fix | Delete
if ( 'on' === et_get_option( $shortname . '_seo_single_title' ) && '' !== $exists3 ) {
[1091] Fix | Delete
$custom_title = $exists3;
[1092] Fix | Delete
} else {
[1093] Fix | Delete
$seo_single_type = et_get_option( $shortname . '_seo_single_type' );
[1094] Fix | Delete
$seo_single_separate = et_get_option( $shortname . '_seo_single_separate' );
[1095] Fix | Delete
$page_title = single_post_title( '', false );
[1096] Fix | Delete
if ( $seo_single_type === 'BlogName | Post title' ) {
[1097] Fix | Delete
$custom_title = $sitename . esc_html( $seo_single_separate ) . $page_title;
[1098] Fix | Delete
}
[1099] Fix | Delete
if ( $seo_single_type === 'Post title | BlogName' ) {
[1100] Fix | Delete
$custom_title = $page_title . esc_html( $seo_single_separate ) . $sitename;
[1101] Fix | Delete
}
[1102] Fix | Delete
if ( $seo_single_type === 'Post title only' ) {
[1103] Fix | Delete
$custom_title = $page_title;
[1104] Fix | Delete
}
[1105] Fix | Delete
}
[1106] Fix | Delete
}
[1107] Fix | Delete
#if the title is being displayed on index pages (categories/archives/search results)
[1108] Fix | Delete
if ( is_category() || is_archive() || is_search() || is_404() ) {
[1109] Fix | Delete
$page_title = '';
[1110] Fix | Delete
$seo_index_type = et_get_option( $shortname . '_seo_index_type' );
[1111] Fix | Delete
$seo_index_separate = et_get_option( $shortname . '_seo_index_separate' );
[1112] Fix | Delete
if ( is_category() || is_tag() || is_tax() ) {
[1113] Fix | Delete
$page_title = single_term_title( '', false );
[1114] Fix | Delete
} else if ( is_post_type_archive() ) {
[1115] Fix | Delete
$page_title = post_type_archive_title( '', false );
[1116] Fix | Delete
} else if ( is_author() ) {
[1117] Fix | Delete
$page_title = get_the_author_meta( 'display_name', get_query_var( 'author' ) );
[1118] Fix | Delete
} else if ( is_date() ) {
[1119] Fix | Delete
$page_title = esc_html__( 'Archives', $themename );
[1120] Fix | Delete
} else if ( is_search() ) {
[1121] Fix | Delete
$page_title = sprintf( esc_html__( 'Search results for "%s"', $themename ), esc_attr( get_search_query() ) );
[1122] Fix | Delete
} else if ( is_404() ) {
[1123] Fix | Delete
$page_title = esc_html__( '404 Not Found', $themename );
[1124] Fix | Delete
}
[1125] Fix | Delete
if ( $seo_index_type === 'BlogName | Category name' ) {
[1126] Fix | Delete
$custom_title = $sitename . esc_html( $seo_index_separate ) . $page_title;
[1127] Fix | Delete
}
[1128] Fix | Delete
if ( $seo_index_type === 'Category name | BlogName') {
[1129] Fix | Delete
$custom_title = $page_title . esc_html( $seo_index_separate ) . $sitename;
[1130] Fix | Delete
}
[1131] Fix | Delete
if ( $seo_index_type === 'Category name only') {
[1132] Fix | Delete
$custom_title = $page_title;
[1133] Fix | Delete
}
[1134] Fix | Delete
}
[1135] Fix | Delete
$custom_title = wp_strip_all_tags( $custom_title );
[1136] Fix | Delete
return $custom_title;
[1137] Fix | Delete
}
[1138] Fix | Delete
[1139] Fix | Delete
}
[1140] Fix | Delete
add_filter( 'pre_get_document_title', 'elegant_titles_filter' );
[1141] Fix | Delete
[1142] Fix | Delete
/*this function controls the meta description display*/
[1143] Fix | Delete
if ( ! function_exists( 'elegant_description' ) ) {
[1144] Fix | Delete
[1145] Fix | Delete
function elegant_description() {
[1146] Fix | Delete
// Don't use ePanel SEO if WordPress SEO or All In One SEO Pack plugins are active
[1147] Fix | Delete
if ( class_exists( 'WPSEO_Frontend' ) || class_exists( 'All_in_One_SEO_Pack' ) ) {
[1148] Fix | Delete
return;
[1149] Fix | Delete
}
[1150] Fix | Delete
[1151] Fix | Delete
global $shortname, $themename;
[1152] Fix | Delete
[1153] Fix | Delete
#homepage descriptions
[1154] Fix | Delete
if ( et_get_option( $shortname.'_seo_home_description' ) === 'on' && ( ( is_home() || is_front_page() ) && ! elegant_is_blog_posts_page() ) ) {
[1155] Fix | Delete
echo '<meta name="description" content="' . esc_attr( et_get_option( $shortname.'_seo_home_descriptiontext' ) ) .'" />';
[1156] Fix | Delete
}
[1157] Fix | Delete
[1158] Fix | Delete
#single page descriptions
[1159] Fix | Delete
if ( et_get_option( $shortname.'_seo_single_description' ) === 'on' && ( is_single() || is_page() || elegant_is_blog_posts_page() ) ) {
[1160] Fix | Delete
global $wp_query;
[1161] Fix | Delete
[1162] Fix | Delete
if ( isset( $wp_query->post->ID ) || elegant_is_blog_posts_page() ) {
[1163] Fix | Delete
$postid = elegant_is_blog_posts_page() ? intval( get_option( 'page_for_posts' ) ) : $wp_query->post->ID;
[1164] Fix | Delete
}
[1165] Fix | Delete
[1166] Fix | Delete
$key2 = et_get_option( $shortname.'_seo_single_field_description' );
[1167] Fix | Delete
[1168] Fix | Delete
if ( isset( $postid ) ) $exists = get_post_meta( $postid, ''.$key2.'', true );
[1169] Fix | Delete
[1170] Fix | Delete
if ( $exists !== '' ) {
[1171] Fix | Delete
echo '<meta name="description" content="' . esc_attr( $exists ) . '" />';
[1172] Fix | Delete
}
[1173] Fix | Delete
}
[1174] Fix | Delete
[1175] Fix | Delete
#index descriptions
[1176] Fix | Delete
$seo_index_description = et_get_option( $shortname.'_seo_index_description' );
[1177] Fix | Delete
if ( $seo_index_description === 'on' ) {
[1178] Fix | Delete
$is_pre_4_4 = version_compare( $GLOBALS['wp_version'], '4.4', '<' );
[1179] Fix | Delete
$description_added = false;
[1180] Fix | Delete
[1181] Fix | Delete
if ( is_category() ) {
[1182] Fix | Delete
remove_filter( 'term_description', 'wpautop' );
[1183] Fix | Delete
$cat = get_query_var( 'cat' );
[1184] Fix | Delete
$exists2 = category_description( $cat );
[1185] Fix | Delete
[1186] Fix | Delete
if ( $exists2 !== '' ) {
[1187] Fix | Delete
echo '<meta name="description" content="' . esc_attr( $exists2 ) . '" />';
[1188] Fix | Delete
$description_added = true;
[1189] Fix | Delete
}
[1190] Fix | Delete
}
[1191] Fix | Delete
[1192] Fix | Delete
if ( is_archive() && ! $description_added ) {
[1193] Fix | Delete
$description_text = $is_pre_4_4 ? sprintf( esc_html__( 'Currently viewing archives from %1$s', $themename ),
[1194] Fix | Delete
wp_title( '', false, '' )
[1195] Fix | Delete
) : get_the_archive_title();
[1196] Fix | Delete
[1197] Fix | Delete
printf( '<meta name="description" content="%1$s" />',
[1198] Fix | Delete
esc_attr( $description_text )
[1199] Fix | Delete
);
[1200] Fix | Delete
[1201] Fix | Delete
$description_added = true;
[1202] Fix | Delete
}
[1203] Fix | Delete
[1204] Fix | Delete
if ( is_search() && ! $description_added ) {
[1205] Fix | Delete
$description_text = $is_pre_4_4 ? wp_title( '', false, '' ) : sprintf(
[1206] Fix | Delete
esc_html__( 'Search Results for: %s', $themename ),
[1207] Fix | Delete
get_search_query()
[1208] Fix | Delete
);
[1209] Fix | Delete
[1210] Fix | Delete
echo '<meta name="description" content="' . esc_attr( $description_text ) . '" />';
[1211] Fix | Delete
$description_added = true;
[1212] Fix | Delete
}
[1213] Fix | Delete
}
[1214] Fix | Delete
}
[1215] Fix | Delete
[1216] Fix | Delete
}
[1217] Fix | Delete
[1218] Fix | Delete
/*this function controls the meta keywords display*/
[1219] Fix | Delete
if ( ! function_exists( 'elegant_keywords' ) ) {
[1220] Fix | Delete
[1221] Fix | Delete
function elegant_keywords() {
[1222] Fix | Delete
// Don't use ePanel SEO if WordPress SEO or All In One SEO Pack plugins are active
[1223] Fix | Delete
if ( class_exists( 'WPSEO_Frontend' ) || class_exists( 'All_in_One_SEO_Pack' ) ) {
[1224] Fix | Delete
return;
[1225] Fix | Delete
}
[1226] Fix | Delete
[1227] Fix | Delete
global $shortname;
[1228] Fix | Delete
[1229] Fix | Delete
#homepage keywords
[1230] Fix | Delete
if ( et_get_option( $shortname.'_seo_home_keywords' ) === 'on' && ( ( is_home() || is_front_page() ) && ! elegant_is_blog_posts_page() ) ) {
[1231] Fix | Delete
echo '<meta name="keywords" content="' . esc_attr( et_get_option( $shortname.'_seo_home_keywordstext' ) ) . '" />';
[1232] Fix | Delete
}
[1233] Fix | Delete
[1234] Fix | Delete
#single page keywords
[1235] Fix | Delete
if ( et_get_option( $shortname.'_seo_single_keywords' ) === 'on' ) {
[1236] Fix | Delete
global $wp_query;
[1237] Fix | Delete
if ( isset( $wp_query->post->ID ) || elegant_is_blog_posts_page() ) {
[1238] Fix | Delete
$postid = elegant_is_blog_posts_page() ? intval( get_option( 'page_for_posts' ) ) : $wp_query->post->ID;
[1239] Fix | Delete
}
[1240] Fix | Delete
[1241] Fix | Delete
$key3 = et_get_option( $shortname.'_seo_single_field_keywords' );
[1242] Fix | Delete
[1243] Fix | Delete
if (isset( $postid )) $exists4 = get_post_meta( $postid, ''.$key3.'', true );
[1244] Fix | Delete
[1245] Fix | Delete
if ( isset( $exists4 ) && $exists4 !== '' ) {
[1246] Fix | Delete
if ( is_single() || is_page() || elegant_is_blog_posts_page() ) echo '<meta name="keywords" content="' . esc_attr( $exists4 ) . '" />';
[1247] Fix | Delete
}
[1248] Fix | Delete
}
[1249] Fix | Delete
}
[1250] Fix | Delete
[1251] Fix | Delete
}
[1252] Fix | Delete
[1253] Fix | Delete
/*this function controls canonical urls*/
[1254] Fix | Delete
if ( ! function_exists( 'elegant_canonical' ) ) {
[1255] Fix | Delete
[1256] Fix | Delete
function elegant_canonical() {
[1257] Fix | Delete
// Don't use ePanel SEO if WordPress SEO or All In One SEO Pack plugins are active
[1258] Fix | Delete
if ( class_exists( 'WPSEO_Frontend' ) || class_exists( 'All_in_One_SEO_Pack' ) ) {
[1259] Fix | Delete
return;
[1260] Fix | Delete
}
[1261] Fix | Delete
[1262] Fix | Delete
global $shortname;
[1263] Fix | Delete
[1264] Fix | Delete
#homepage urls
[1265] Fix | Delete
if ( et_get_option( $shortname.'_seo_home_canonical' ) === 'on' && is_home() && ! elegant_is_blog_posts_page() ) {
[1266] Fix | Delete
echo '<link rel="canonical" href="'. esc_url( home_url() ).'" />';
[1267] Fix | Delete
}
[1268] Fix | Delete
[1269] Fix | Delete
#single page urls
[1270] Fix | Delete
if ( et_get_option( $shortname.'_seo_single_canonical' ) === 'on' ) {
[1271] Fix | Delete
global $wp_query;
[1272] Fix | Delete
if ( isset( $wp_query->post->ID ) || elegant_is_blog_posts_page() ) {
[1273] Fix | Delete
$postid = elegant_is_blog_posts_page() ? intval( get_option( 'page_for_posts' ) ) : $wp_query->post->ID;
[1274] Fix | Delete
}
[1275] Fix | Delete
[1276] Fix | Delete
if ( ( is_single() || is_page() || elegant_is_blog_posts_page() ) && ! is_front_page() ) {
[1277] Fix | Delete
echo '<link rel="canonical" href="' . esc_url( get_permalink( $postid ) ) . '" />';
[1278] Fix | Delete
}
[1279] Fix | Delete
}
[1280] Fix | Delete
[1281] Fix | Delete
#index page urls
[1282] Fix | Delete
if ( et_get_option( $shortname.'_seo_index_canonical' ) === 'on' ) {
[1283] Fix | Delete
$current_page_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
[1284] Fix | Delete
if ( is_archive() || is_category() || is_search() ) echo '<link rel="canonical" href="'. esc_url( $current_page_url ).'" />';
[1285] Fix | Delete
}
[1286] Fix | Delete
}
[1287] Fix | Delete
[1288] Fix | Delete
}
[1289] Fix | Delete
[1290] Fix | Delete
add_action( 'wp_head', 'add_favicon' );
[1291] Fix | Delete
[1292] Fix | Delete
function add_favicon(){
[1293] Fix | Delete
global $shortname;
[1294] Fix | Delete
[1295] Fix | Delete
$faviconUrl = et_get_option( $shortname.'_favicon' );
[1296] Fix | Delete
[1297] Fix | Delete
// 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,
[1298] Fix | Delete
// and when we have a icon URL from theme option
[1299] Fix | Delete
if ( ( ! function_exists( 'has_site_icon' ) || ! has_site_icon() ) && '' !== $faviconUrl ) {
[1300] Fix | Delete
echo '<link rel="shortcut icon" href="' . esc_url( $faviconUrl ) . '" />';
[1301] Fix | Delete
} elseif ( function_exists( 'has_site_icon' ) && has_site_icon() ) {
[1302] Fix | Delete
et_update_option( $shortname . '_favicon', '' );
[1303] Fix | Delete
}
[1304] Fix | Delete
}
[1305] Fix | Delete
[1306] Fix | Delete
add_action( 'init', 'et_create_images_temp_folder' );
[1307] Fix | Delete
[1308] Fix | Delete
function et_create_images_temp_folder(){
[1309] Fix | Delete
$et_images_temp_folder = get_option( 'et_images_temp_folder' );
[1310] Fix | Delete
[1311] Fix | Delete
#clean et_temp folder once per week
[1312] Fix | Delete
if ( false !== $last_time = get_option( 'et_schedule_clean_images_last_time' ) ) {
[1313] Fix | Delete
$timeout = 86400 * 7;
[1314] Fix | Delete
[1315] Fix | Delete
if ( ( $timeout < ( time() - $last_time ) ) && ! empty( $et_images_temp_folder ) ) et_clean_temp_images( $et_images_temp_folder );
[1316] Fix | Delete
}
[1317] Fix | Delete
[1318] Fix | Delete
if ( false !== $et_images_temp_folder ) return;
[1319] Fix | Delete
[1320] Fix | Delete
$uploads_dir = wp_upload_dir();
[1321] Fix | Delete
$destination_dir = ( false === $uploads_dir['error'] ) ? path_join( $uploads_dir['basedir'], 'et_temp' ) : null;
[1322] Fix | Delete
[1323] Fix | Delete
if ( ! wp_mkdir_p( $destination_dir ) ) update_option( 'et_images_temp_folder', '' );
[1324] Fix | Delete
else {
[1325] Fix | Delete
update_option( 'et_images_temp_folder', preg_replace( '#\/\/#', '/', $destination_dir ) );
[1326] Fix | Delete
update_option( 'et_schedule_clean_images_last_time', time() );
[1327] Fix | Delete
}
[1328] Fix | Delete
}
[1329] Fix | Delete
[1330] Fix | Delete
if ( ! function_exists( 'et_clean_temp_images' ) ) {
[1331] Fix | Delete
[1332] Fix | Delete
function et_clean_temp_images( $directory ){
[1333] Fix | Delete
$dir_to_clean = @ opendir( $directory );
[1334] Fix | Delete
[1335] Fix | Delete
if ( $dir_to_clean ) {
[1336] Fix | Delete
while (($file = readdir( $dir_to_clean ) ) !== false ) {
[1337] Fix | Delete
if ( substr( $file, 0, 1 ) === '.' )
[1338] Fix | Delete
continue;
[1339] Fix | Delete
if ( is_dir( $directory.'/'.$file ) )
[1340] Fix | Delete
et_clean_temp_images( path_join( $directory, $file ) );
[1341] Fix | Delete
else
[1342] Fix | Delete
@ unlink( path_join( $directory, $file ) );
[1343] Fix | Delete
}
[1344] Fix | Delete
closedir( $dir_to_clean );
[1345] Fix | Delete
}
[1346] Fix | Delete
[1347] Fix | Delete
#set last time cleaning was performed
[1348] Fix | Delete
update_option( 'et_schedule_clean_images_last_time', time() );
[1349] Fix | Delete
}
[1350] Fix | Delete
[1351] Fix | Delete
}
[1352] Fix | Delete
[1353] Fix | Delete
add_filter( 'update_option_upload_path', 'et_update_uploads_dir' );
[1354] Fix | Delete
[1355] Fix | Delete
function et_update_uploads_dir( $upload_path ){
[1356] Fix | Delete
#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
[1357] Fix | Delete
[1358] Fix | Delete
$destination_dir = '';
[1359] Fix | Delete
$uploads_dir = wp_upload_dir();
[1360] Fix | Delete
$et_temp_dir = path_join( $uploads_dir['basedir'], 'et_temp' );
[1361] Fix | Delete
[1362] Fix | Delete
if ( is_dir( $et_temp_dir ) || ( false === $uploads_dir['error'] && wp_mkdir_p( $et_temp_dir ) ) ) {
[1363] Fix | Delete
$destination_dir = $et_temp_dir;
[1364] Fix | Delete
update_option( 'et_schedule_clean_images_last_time', time() );
[1365] Fix | Delete
}
[1366] Fix | Delete
[1367] Fix | Delete
update_option( 'et_images_temp_folder', preg_replace( '#\/\/#', '/', $destination_dir ) );
[1368] Fix | Delete
[1369] Fix | Delete
return $upload_path;
[1370] Fix | Delete
}
[1371] Fix | Delete
[1372] Fix | Delete
if ( ! function_exists( 'et_resize_image' ) ) {
[1373] Fix | Delete
[1374] Fix | Delete
function et_resize_image( $thumb, $new_width, $new_height, $crop ){
[1375] Fix | Delete
/*
[1376] Fix | Delete
* Fixes the issue with x symbol between width and height values in the filename.
[1377] Fix | Delete
* For instance, sports-400x400.jpg file results in 'image not found' in getimagesize() function.
[1378] Fix | Delete
*/
[1379] Fix | Delete
$thumb = str_replace( '%26%23215%3B', 'x', rawurlencode( $thumb ) );
[1380] Fix | Delete
$thumb = rawurldecode( $thumb );
[1381] Fix | Delete
[1382] Fix | Delete
if ( is_ssl() ) $thumb = preg_replace( '#^http://#', 'https://', $thumb );
[1383] Fix | Delete
$info = pathinfo( $thumb );
[1384] Fix | Delete
$ext = $info['extension'];
[1385] Fix | Delete
$name = wp_basename( $thumb, ".$ext" );
[1386] Fix | Delete
$is_jpeg = false;
[1387] Fix | Delete
$site_uri = apply_filters( 'et_resize_image_site_uri', site_url() );
[1388] Fix | Delete
$site_dir = apply_filters( 'et_resize_image_site_dir', ABSPATH );
[1389] Fix | Delete
[1390] Fix | Delete
// 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 )
[1391] Fix | Delete
if ( is_multisite() && ! is_main_site() && ( ! function_exists( 'wp_get_mime_types' ) || get_site_option( 'ms_files_rewriting' ) ) ) {
[1392] Fix | Delete
//Get main site url on multisite installation
[1393] Fix | Delete
[1394] Fix | Delete
switch_to_blog( 1 );
[1395] Fix | Delete
$site_uri = site_url();
[1396] Fix | Delete
restore_current_blog();
[1397] Fix | Delete
}
[1398] Fix | Delete
[1399] Fix | Delete
/*
[1400] Fix | Delete
* If we're dealing with an external image ( might be the result of Grab the first image function ),
[1401] Fix | Delete
* return original image url
[1402] Fix | Delete
*/
[1403] Fix | Delete
if ( false === strpos( $thumb, $site_uri ) )
[1404] Fix | Delete
return $thumb;
[1405] Fix | Delete
[1406] Fix | Delete
if ( 'jpeg' === $ext ) {
[1407] Fix | Delete
$ext = 'jpg';
[1408] Fix | Delete
$name = preg_replace( '#.jpeg$#', '', $name );
[1409] Fix | Delete
$is_jpeg = true;
[1410] Fix | Delete
}
[1411] Fix | Delete
[1412] Fix | Delete
$suffix = "{$new_width}x{$new_height}";
[1413] Fix | Delete
[1414] Fix | Delete
$et_images_temp_folder = get_option( 'et_images_temp_folder' );
[1415] Fix | Delete
$destination_dir = ! empty( $et_images_temp_folder ) ? preg_replace( '#\/\/#', '/', $et_images_temp_folder ) : null;
[1416] Fix | Delete
[1417] Fix | Delete
$matches = apply_filters( 'et_resize_image_site_dir', array(), $site_dir );
[1418] Fix | Delete
if ( !empty( $matches ) ) {
[1419] Fix | Delete
preg_match( '#'.$matches[1].'$#', $site_uri, $site_uri_matches );
[1420] Fix | Delete
if ( !empty( $site_uri_matches ) ) {
[1421] Fix | Delete
$site_uri = str_replace( $matches[1], '', $site_uri );
[1422] Fix | Delete
$site_uri = preg_replace( '#/$#', '', $site_uri );
[1423] Fix | Delete
$site_dir = str_replace( $matches[1], '', $site_dir );
[1424] Fix | Delete
$site_dir = preg_replace( '#\\\/$#', '', $site_dir );
[1425] Fix | Delete
}
[1426] Fix | Delete
}
[1427] Fix | Delete
[1428] Fix | Delete
#get local name for use in file_exists() and get_imagesize() functions
[1429] Fix | Delete
$localfile = str_replace( apply_filters( 'et_resize_image_localfile', $site_uri, $site_dir, et_multisite_thumbnail( $thumb ) ), $site_dir, et_multisite_thumbnail( $thumb ) );
[1430] Fix | Delete
[1431] Fix | Delete
$add_to_suffix = '';
[1432] Fix | Delete
if ( file_exists( $localfile ) ) $add_to_suffix = filesize( $localfile ) . '_';
[1433] Fix | Delete
[1434] Fix | Delete
#prepend image filesize to be able to use images with the same filename
[1435] Fix | Delete
$suffix = $add_to_suffix . $suffix;
[1436] Fix | Delete
$destfilename_attributes = '-' . $suffix . '.' . strtolower( $ext );
[1437] Fix | Delete
[1438] Fix | Delete
$checkfilename = ( ! empty( $destination_dir ) && null !== $destination_dir ) ? path_join( $destination_dir, $name ) : path_join( dirname( $localfile ), $name );
[1439] Fix | Delete
$checkfilename .= $destfilename_attributes;
[1440] Fix | Delete
[1441] Fix | Delete
if ( $is_jpeg ) $checkfilename = preg_replace( '#.jpg$#', '.jpeg', $checkfilename );
[1442] Fix | Delete
[1443] Fix | Delete
$uploads_dir = wp_upload_dir();
[1444] Fix | Delete
$uploads_dir['basedir'] = preg_replace( '#\/\/#', '/', $uploads_dir['basedir'] );
[1445] Fix | Delete
[1446] Fix | Delete
if ( null !== $destination_dir && ! empty( $destination_dir ) && apply_filters( 'et_enable_uploads_detection', true ) ) {
[1447] Fix | Delete
$site_dir = trailingslashit( preg_replace( '#\/\/#', '/', $uploads_dir['basedir'] ) );
[1448] Fix | Delete
$site_uri = trailingslashit( $uploads_dir['baseurl'] );
[1449] Fix | Delete
}
[1450] Fix | Delete
[1451] Fix | Delete
#check if we have an image with specified width and height
[1452] Fix | Delete
[1453] Fix | Delete
if ( file_exists( $checkfilename ) ) return str_replace( $site_dir, trailingslashit( $site_uri ), $checkfilename );
[1454] Fix | Delete
[1455] Fix | Delete
$size = @getimagesize( $localfile );
[1456] Fix | Delete
if ( !$size ) return new WP_Error( 'invalid_image_path', esc_html__( 'Image doesn\'t exist' ), $thumb );
[1457] Fix | Delete
list($orig_width, $orig_height, $orig_type) = $size;
[1458] Fix | Delete
[1459] Fix | Delete
#check if we're resizing the image to smaller dimensions
[1460] Fix | Delete
if ( $orig_width > $new_width || $orig_height > $new_height ) {
[1461] Fix | Delete
if ( $orig_width < $new_width || $orig_height < $new_height ) {
[1462] Fix | Delete
#don't resize image if new dimensions > than its original ones
[1463] Fix | Delete
if ( $orig_width < $new_width ) $new_width = $orig_width;
[1464] Fix | Delete
if ( $orig_height < $new_height ) $new_height = $orig_height;
[1465] Fix | Delete
[1466] Fix | Delete
#regenerate suffix and appended attributes in case we changed new width or new height dimensions
[1467] Fix | Delete
$suffix = "{$add_to_suffix}{$new_width}x{$new_height}";
[1468] Fix | Delete
$destfilename_attributes = '-' . $suffix . '.' . $ext;
[1469] Fix | Delete
[1470] Fix | Delete
$checkfilename = ( ! empty( $destination_dir ) && null !== $destination_dir ) ? path_join( $destination_dir, $name ) : path_join( dirname( $localfile ), $name );
[1471] Fix | Delete
$checkfilename .= $destfilename_attributes;
[1472] Fix | Delete
[1473] Fix | Delete
#check if we have an image with new calculated width and height parameters
[1474] Fix | Delete
if ( file_exists( $checkfilename ) ) return str_replace( $site_dir, trailingslashit( $site_uri ), $checkfilename );
[1475] Fix | Delete
}
[1476] Fix | Delete
[1477] Fix | Delete
#we didn't find the image in cache, resizing is done here
[1478] Fix | Delete
$et_image_editor = wp_get_image_editor( $localfile );
[1479] Fix | Delete
[1480] Fix | Delete
if ( ! is_wp_error( $et_image_editor ) ) {
[1481] Fix | Delete
$et_image_editor->resize( $new_width, $new_height, $crop );
[1482] Fix | Delete
[1483] Fix | Delete
// generate correct file name/path
[1484] Fix | Delete
$et_new_image_name = $et_image_editor->generate_filename( $suffix, $destination_dir );
[1485] Fix | Delete
[1486] Fix | Delete
do_action( 'et_resize_image_before_save', $et_image_editor, $et_new_image_name );
[1487] Fix | Delete
[1488] Fix | Delete
$et_image_editor->save( $et_new_image_name );
[1489] Fix | Delete
[1490] Fix | Delete
// assign new image path
[1491] Fix | Delete
$result = $et_new_image_name;
[1492] Fix | Delete
} else {
[1493] Fix | Delete
// assign a WP_ERROR ( WP_Image_Editor instance wasn't created properly )
[1494] Fix | Delete
$result = $et_image_editor;
[1495] Fix | Delete
}
[1496] Fix | Delete
[1497] Fix | Delete
if ( ! is_wp_error( $result ) ) {
[1498] Fix | Delete
// transform local image path into URI
[1499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function