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/wp-admin/includes
File: image.php
}
[1000] Fix | Delete
if ( ! empty( $exif['ExposureTime'] ) ) {
[1001] Fix | Delete
$meta['shutter_speed'] = (string) $exif['ExposureTime'];
[1002] Fix | Delete
if ( is_scalar( $exif['ExposureTime'] ) ) {
[1003] Fix | Delete
$meta['shutter_speed'] = (string) wp_exif_frac2dec( $exif['ExposureTime'] );
[1004] Fix | Delete
}
[1005] Fix | Delete
}
[1006] Fix | Delete
if ( ! empty( $exif['Orientation'] ) ) {
[1007] Fix | Delete
$meta['orientation'] = $exif['Orientation'];
[1008] Fix | Delete
}
[1009] Fix | Delete
}
[1010] Fix | Delete
[1011] Fix | Delete
foreach ( array( 'title', 'caption', 'credit', 'copyright', 'camera', 'iso' ) as $key ) {
[1012] Fix | Delete
if ( $meta[ $key ] && ! seems_utf8( $meta[ $key ] ) ) {
[1013] Fix | Delete
$meta[ $key ] = utf8_encode( $meta[ $key ] );
[1014] Fix | Delete
}
[1015] Fix | Delete
}
[1016] Fix | Delete
[1017] Fix | Delete
foreach ( $meta['keywords'] as $key => $keyword ) {
[1018] Fix | Delete
if ( ! seems_utf8( $keyword ) ) {
[1019] Fix | Delete
$meta['keywords'][ $key ] = utf8_encode( $keyword );
[1020] Fix | Delete
}
[1021] Fix | Delete
}
[1022] Fix | Delete
[1023] Fix | Delete
$meta = wp_kses_post_deep( $meta );
[1024] Fix | Delete
[1025] Fix | Delete
/**
[1026] Fix | Delete
* Filters the array of meta data read from an image's exif data.
[1027] Fix | Delete
*
[1028] Fix | Delete
* @since 2.5.0
[1029] Fix | Delete
* @since 4.4.0 The `$iptc` parameter was added.
[1030] Fix | Delete
* @since 5.0.0 The `$exif` parameter was added.
[1031] Fix | Delete
*
[1032] Fix | Delete
* @param array $meta Image meta data.
[1033] Fix | Delete
* @param string $file Path to image file.
[1034] Fix | Delete
* @param int $image_type Type of image, one of the `IMAGETYPE_XXX` constants.
[1035] Fix | Delete
* @param array $iptc IPTC data.
[1036] Fix | Delete
* @param array $exif EXIF data.
[1037] Fix | Delete
*/
[1038] Fix | Delete
return apply_filters( 'wp_read_image_metadata', $meta, $file, $image_type, $iptc, $exif );
[1039] Fix | Delete
}
[1040] Fix | Delete
[1041] Fix | Delete
/**
[1042] Fix | Delete
* Validates that file is an image.
[1043] Fix | Delete
*
[1044] Fix | Delete
* @since 2.5.0
[1045] Fix | Delete
*
[1046] Fix | Delete
* @param string $path File path to test if valid image.
[1047] Fix | Delete
* @return bool True if valid image, false if not valid image.
[1048] Fix | Delete
*/
[1049] Fix | Delete
function file_is_valid_image( $path ) {
[1050] Fix | Delete
$size = wp_getimagesize( $path );
[1051] Fix | Delete
return ! empty( $size );
[1052] Fix | Delete
}
[1053] Fix | Delete
[1054] Fix | Delete
/**
[1055] Fix | Delete
* Validates that file is suitable for displaying within a web page.
[1056] Fix | Delete
*
[1057] Fix | Delete
* @since 2.5.0
[1058] Fix | Delete
*
[1059] Fix | Delete
* @param string $path File path to test.
[1060] Fix | Delete
* @return bool True if suitable, false if not suitable.
[1061] Fix | Delete
*/
[1062] Fix | Delete
function file_is_displayable_image( $path ) {
[1063] Fix | Delete
$displayable_image_types = array( IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG, IMAGETYPE_BMP, IMAGETYPE_ICO, IMAGETYPE_WEBP, IMAGETYPE_AVIF );
[1064] Fix | Delete
[1065] Fix | Delete
$info = wp_getimagesize( $path );
[1066] Fix | Delete
if ( empty( $info ) ) {
[1067] Fix | Delete
$result = false;
[1068] Fix | Delete
} elseif ( ! in_array( $info[2], $displayable_image_types, true ) ) {
[1069] Fix | Delete
$result = false;
[1070] Fix | Delete
} else {
[1071] Fix | Delete
$result = true;
[1072] Fix | Delete
}
[1073] Fix | Delete
[1074] Fix | Delete
/**
[1075] Fix | Delete
* Filters whether the current image is displayable in the browser.
[1076] Fix | Delete
*
[1077] Fix | Delete
* @since 2.5.0
[1078] Fix | Delete
*
[1079] Fix | Delete
* @param bool $result Whether the image can be displayed. Default true.
[1080] Fix | Delete
* @param string $path Path to the image.
[1081] Fix | Delete
*/
[1082] Fix | Delete
return apply_filters( 'file_is_displayable_image', $result, $path );
[1083] Fix | Delete
}
[1084] Fix | Delete
[1085] Fix | Delete
/**
[1086] Fix | Delete
* Loads an image resource for editing.
[1087] Fix | Delete
*
[1088] Fix | Delete
* @since 2.9.0
[1089] Fix | Delete
*
[1090] Fix | Delete
* @param int $attachment_id Attachment ID.
[1091] Fix | Delete
* @param string $mime_type Image mime type.
[1092] Fix | Delete
* @param string|int[] $size Optional. Image size. Accepts any registered image size name, or an array
[1093] Fix | Delete
* of width and height values in pixels (in that order). Default 'full'.
[1094] Fix | Delete
* @return resource|GdImage|false The resulting image resource or GdImage instance on success,
[1095] Fix | Delete
* false on failure.
[1096] Fix | Delete
*/
[1097] Fix | Delete
function load_image_to_edit( $attachment_id, $mime_type, $size = 'full' ) {
[1098] Fix | Delete
$filepath = _load_image_to_edit_path( $attachment_id, $size );
[1099] Fix | Delete
if ( empty( $filepath ) ) {
[1100] Fix | Delete
return false;
[1101] Fix | Delete
}
[1102] Fix | Delete
[1103] Fix | Delete
switch ( $mime_type ) {
[1104] Fix | Delete
case 'image/jpeg':
[1105] Fix | Delete
$image = imagecreatefromjpeg( $filepath );
[1106] Fix | Delete
break;
[1107] Fix | Delete
case 'image/png':
[1108] Fix | Delete
$image = imagecreatefrompng( $filepath );
[1109] Fix | Delete
break;
[1110] Fix | Delete
case 'image/gif':
[1111] Fix | Delete
$image = imagecreatefromgif( $filepath );
[1112] Fix | Delete
break;
[1113] Fix | Delete
case 'image/webp':
[1114] Fix | Delete
$image = false;
[1115] Fix | Delete
if ( function_exists( 'imagecreatefromwebp' ) ) {
[1116] Fix | Delete
$image = imagecreatefromwebp( $filepath );
[1117] Fix | Delete
}
[1118] Fix | Delete
break;
[1119] Fix | Delete
default:
[1120] Fix | Delete
$image = false;
[1121] Fix | Delete
break;
[1122] Fix | Delete
}
[1123] Fix | Delete
[1124] Fix | Delete
if ( is_gd_image( $image ) ) {
[1125] Fix | Delete
/**
[1126] Fix | Delete
* Filters the current image being loaded for editing.
[1127] Fix | Delete
*
[1128] Fix | Delete
* @since 2.9.0
[1129] Fix | Delete
*
[1130] Fix | Delete
* @param resource|GdImage $image Current image.
[1131] Fix | Delete
* @param int $attachment_id Attachment ID.
[1132] Fix | Delete
* @param string|int[] $size Requested image size. Can be any registered image size name, or
[1133] Fix | Delete
* an array of width and height values in pixels (in that order).
[1134] Fix | Delete
*/
[1135] Fix | Delete
$image = apply_filters( 'load_image_to_edit', $image, $attachment_id, $size );
[1136] Fix | Delete
[1137] Fix | Delete
if ( function_exists( 'imagealphablending' ) && function_exists( 'imagesavealpha' ) ) {
[1138] Fix | Delete
imagealphablending( $image, false );
[1139] Fix | Delete
imagesavealpha( $image, true );
[1140] Fix | Delete
}
[1141] Fix | Delete
}
[1142] Fix | Delete
[1143] Fix | Delete
return $image;
[1144] Fix | Delete
}
[1145] Fix | Delete
[1146] Fix | Delete
/**
[1147] Fix | Delete
* Retrieves the path or URL of an attachment's attached file.
[1148] Fix | Delete
*
[1149] Fix | Delete
* If the attached file is not present on the local filesystem (usually due to replication plugins),
[1150] Fix | Delete
* then the URL of the file is returned if `allow_url_fopen` is supported.
[1151] Fix | Delete
*
[1152] Fix | Delete
* @since 3.4.0
[1153] Fix | Delete
* @access private
[1154] Fix | Delete
*
[1155] Fix | Delete
* @param int $attachment_id Attachment ID.
[1156] Fix | Delete
* @param string|int[] $size Optional. Image size. Accepts any registered image size name, or an array
[1157] Fix | Delete
* of width and height values in pixels (in that order). Default 'full'.
[1158] Fix | Delete
* @return string|false File path or URL on success, false on failure.
[1159] Fix | Delete
*/
[1160] Fix | Delete
function _load_image_to_edit_path( $attachment_id, $size = 'full' ) {
[1161] Fix | Delete
$filepath = get_attached_file( $attachment_id );
[1162] Fix | Delete
[1163] Fix | Delete
if ( $filepath && file_exists( $filepath ) ) {
[1164] Fix | Delete
if ( 'full' !== $size ) {
[1165] Fix | Delete
$data = image_get_intermediate_size( $attachment_id, $size );
[1166] Fix | Delete
[1167] Fix | Delete
if ( $data ) {
[1168] Fix | Delete
$filepath = path_join( dirname( $filepath ), $data['file'] );
[1169] Fix | Delete
[1170] Fix | Delete
/**
[1171] Fix | Delete
* Filters the path to an attachment's file when editing the image.
[1172] Fix | Delete
*
[1173] Fix | Delete
* The filter is evaluated for all image sizes except 'full'.
[1174] Fix | Delete
*
[1175] Fix | Delete
* @since 3.1.0
[1176] Fix | Delete
*
[1177] Fix | Delete
* @param string $path Path to the current image.
[1178] Fix | Delete
* @param int $attachment_id Attachment ID.
[1179] Fix | Delete
* @param string|int[] $size Requested image size. Can be any registered image size name, or
[1180] Fix | Delete
* an array of width and height values in pixels (in that order).
[1181] Fix | Delete
*/
[1182] Fix | Delete
$filepath = apply_filters( 'load_image_to_edit_filesystempath', $filepath, $attachment_id, $size );
[1183] Fix | Delete
}
[1184] Fix | Delete
}
[1185] Fix | Delete
} elseif ( function_exists( 'fopen' ) && ini_get( 'allow_url_fopen' ) ) {
[1186] Fix | Delete
/**
[1187] Fix | Delete
* Filters the path to an attachment's URL when editing the image.
[1188] Fix | Delete
*
[1189] Fix | Delete
* The filter is only evaluated if the file isn't stored locally and `allow_url_fopen` is enabled on the server.
[1190] Fix | Delete
*
[1191] Fix | Delete
* @since 3.1.0
[1192] Fix | Delete
*
[1193] Fix | Delete
* @param string|false $image_url Current image URL.
[1194] Fix | Delete
* @param int $attachment_id Attachment ID.
[1195] Fix | Delete
* @param string|int[] $size Requested image size. Can be any registered image size name, or
[1196] Fix | Delete
* an array of width and height values in pixels (in that order).
[1197] Fix | Delete
*/
[1198] Fix | Delete
$filepath = apply_filters( 'load_image_to_edit_attachmenturl', wp_get_attachment_url( $attachment_id ), $attachment_id, $size );
[1199] Fix | Delete
}
[1200] Fix | Delete
[1201] Fix | Delete
/**
[1202] Fix | Delete
* Filters the returned path or URL of the current image.
[1203] Fix | Delete
*
[1204] Fix | Delete
* @since 2.9.0
[1205] Fix | Delete
*
[1206] Fix | Delete
* @param string|false $filepath File path or URL to current image, or false.
[1207] Fix | Delete
* @param int $attachment_id Attachment ID.
[1208] Fix | Delete
* @param string|int[] $size Requested image size. Can be any registered image size name, or
[1209] Fix | Delete
* an array of width and height values in pixels (in that order).
[1210] Fix | Delete
*/
[1211] Fix | Delete
return apply_filters( 'load_image_to_edit_path', $filepath, $attachment_id, $size );
[1212] Fix | Delete
}
[1213] Fix | Delete
[1214] Fix | Delete
/**
[1215] Fix | Delete
* Copies an existing image file.
[1216] Fix | Delete
*
[1217] Fix | Delete
* @since 3.4.0
[1218] Fix | Delete
* @access private
[1219] Fix | Delete
*
[1220] Fix | Delete
* @param int $attachment_id Attachment ID.
[1221] Fix | Delete
* @return string|false New file path on success, false on failure.
[1222] Fix | Delete
*/
[1223] Fix | Delete
function _copy_image_file( $attachment_id ) {
[1224] Fix | Delete
$dst_file = get_attached_file( $attachment_id );
[1225] Fix | Delete
$src_file = $dst_file;
[1226] Fix | Delete
[1227] Fix | Delete
if ( ! file_exists( $src_file ) ) {
[1228] Fix | Delete
$src_file = _load_image_to_edit_path( $attachment_id );
[1229] Fix | Delete
}
[1230] Fix | Delete
[1231] Fix | Delete
if ( $src_file ) {
[1232] Fix | Delete
$dst_file = str_replace( wp_basename( $dst_file ), 'copy-' . wp_basename( $dst_file ), $dst_file );
[1233] Fix | Delete
$dst_file = dirname( $dst_file ) . '/' . wp_unique_filename( dirname( $dst_file ), wp_basename( $dst_file ) );
[1234] Fix | Delete
[1235] Fix | Delete
/*
[1236] Fix | Delete
* The directory containing the original file may no longer
[1237] Fix | Delete
* exist when using a replication plugin.
[1238] Fix | Delete
*/
[1239] Fix | Delete
wp_mkdir_p( dirname( $dst_file ) );
[1240] Fix | Delete
[1241] Fix | Delete
if ( ! copy( $src_file, $dst_file ) ) {
[1242] Fix | Delete
$dst_file = false;
[1243] Fix | Delete
}
[1244] Fix | Delete
} else {
[1245] Fix | Delete
$dst_file = false;
[1246] Fix | Delete
}
[1247] Fix | Delete
[1248] Fix | Delete
return $dst_file;
[1249] Fix | Delete
}
[1250] Fix | Delete
[1251] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function