Edit File by line
/home/barbar84/www/wp-admin/includes
File: media.php
break;
[3500] Fix | Delete
}
[3501] Fix | Delete
}
[3502] Fix | Delete
[3503] Fix | Delete
if ( ! empty( $data['id3v2']['APIC'] ) ) {
[3504] Fix | Delete
$image = reset( $data['id3v2']['APIC'] );
[3505] Fix | Delete
if ( ! empty( $image['data'] ) ) {
[3506] Fix | Delete
$metadata['image'] = array(
[3507] Fix | Delete
'data' => $image['data'],
[3508] Fix | Delete
'mime' => $image['image_mime'],
[3509] Fix | Delete
'width' => $image['image_width'],
[3510] Fix | Delete
'height' => $image['image_height'],
[3511] Fix | Delete
);
[3512] Fix | Delete
}
[3513] Fix | Delete
} elseif ( ! empty( $data['comments']['picture'] ) ) {
[3514] Fix | Delete
$image = reset( $data['comments']['picture'] );
[3515] Fix | Delete
if ( ! empty( $image['data'] ) ) {
[3516] Fix | Delete
$metadata['image'] = array(
[3517] Fix | Delete
'data' => $image['data'],
[3518] Fix | Delete
'mime' => $image['image_mime'],
[3519] Fix | Delete
);
[3520] Fix | Delete
}
[3521] Fix | Delete
}
[3522] Fix | Delete
}
[3523] Fix | Delete
[3524] Fix | Delete
/**
[3525] Fix | Delete
* Retrieve metadata from a video file's ID3 tags
[3526] Fix | Delete
*
[3527] Fix | Delete
* @since 3.6.0
[3528] Fix | Delete
*
[3529] Fix | Delete
* @param string $file Path to file.
[3530] Fix | Delete
* @return array|false Returns array of metadata, if found.
[3531] Fix | Delete
*/
[3532] Fix | Delete
function wp_read_video_metadata( $file ) {
[3533] Fix | Delete
if ( ! file_exists( $file ) ) {
[3534] Fix | Delete
return false;
[3535] Fix | Delete
}
[3536] Fix | Delete
[3537] Fix | Delete
$metadata = array();
[3538] Fix | Delete
[3539] Fix | Delete
if ( ! defined( 'GETID3_TEMP_DIR' ) ) {
[3540] Fix | Delete
define( 'GETID3_TEMP_DIR', get_temp_dir() );
[3541] Fix | Delete
}
[3542] Fix | Delete
[3543] Fix | Delete
if ( ! class_exists( 'getID3', false ) ) {
[3544] Fix | Delete
require ABSPATH . WPINC . '/ID3/getid3.php';
[3545] Fix | Delete
}
[3546] Fix | Delete
[3547] Fix | Delete
$id3 = new getID3();
[3548] Fix | Delete
$data = $id3->analyze( $file );
[3549] Fix | Delete
[3550] Fix | Delete
if ( isset( $data['video']['lossless'] ) ) {
[3551] Fix | Delete
$metadata['lossless'] = $data['video']['lossless'];
[3552] Fix | Delete
}
[3553] Fix | Delete
[3554] Fix | Delete
if ( ! empty( $data['video']['bitrate'] ) ) {
[3555] Fix | Delete
$metadata['bitrate'] = (int) $data['video']['bitrate'];
[3556] Fix | Delete
}
[3557] Fix | Delete
[3558] Fix | Delete
if ( ! empty( $data['video']['bitrate_mode'] ) ) {
[3559] Fix | Delete
$metadata['bitrate_mode'] = $data['video']['bitrate_mode'];
[3560] Fix | Delete
}
[3561] Fix | Delete
[3562] Fix | Delete
if ( ! empty( $data['filesize'] ) ) {
[3563] Fix | Delete
$metadata['filesize'] = (int) $data['filesize'];
[3564] Fix | Delete
}
[3565] Fix | Delete
[3566] Fix | Delete
if ( ! empty( $data['mime_type'] ) ) {
[3567] Fix | Delete
$metadata['mime_type'] = $data['mime_type'];
[3568] Fix | Delete
}
[3569] Fix | Delete
[3570] Fix | Delete
if ( ! empty( $data['playtime_seconds'] ) ) {
[3571] Fix | Delete
$metadata['length'] = (int) round( $data['playtime_seconds'] );
[3572] Fix | Delete
}
[3573] Fix | Delete
[3574] Fix | Delete
if ( ! empty( $data['playtime_string'] ) ) {
[3575] Fix | Delete
$metadata['length_formatted'] = $data['playtime_string'];
[3576] Fix | Delete
}
[3577] Fix | Delete
[3578] Fix | Delete
if ( ! empty( $data['video']['resolution_x'] ) ) {
[3579] Fix | Delete
$metadata['width'] = (int) $data['video']['resolution_x'];
[3580] Fix | Delete
}
[3581] Fix | Delete
[3582] Fix | Delete
if ( ! empty( $data['video']['resolution_y'] ) ) {
[3583] Fix | Delete
$metadata['height'] = (int) $data['video']['resolution_y'];
[3584] Fix | Delete
}
[3585] Fix | Delete
[3586] Fix | Delete
if ( ! empty( $data['fileformat'] ) ) {
[3587] Fix | Delete
$metadata['fileformat'] = $data['fileformat'];
[3588] Fix | Delete
}
[3589] Fix | Delete
[3590] Fix | Delete
if ( ! empty( $data['video']['dataformat'] ) ) {
[3591] Fix | Delete
$metadata['dataformat'] = $data['video']['dataformat'];
[3592] Fix | Delete
}
[3593] Fix | Delete
[3594] Fix | Delete
if ( ! empty( $data['video']['encoder'] ) ) {
[3595] Fix | Delete
$metadata['encoder'] = $data['video']['encoder'];
[3596] Fix | Delete
}
[3597] Fix | Delete
[3598] Fix | Delete
if ( ! empty( $data['video']['codec'] ) ) {
[3599] Fix | Delete
$metadata['codec'] = $data['video']['codec'];
[3600] Fix | Delete
}
[3601] Fix | Delete
[3602] Fix | Delete
if ( ! empty( $data['audio'] ) ) {
[3603] Fix | Delete
unset( $data['audio']['streams'] );
[3604] Fix | Delete
$metadata['audio'] = $data['audio'];
[3605] Fix | Delete
}
[3606] Fix | Delete
[3607] Fix | Delete
if ( empty( $metadata['created_timestamp'] ) ) {
[3608] Fix | Delete
$created_timestamp = wp_get_media_creation_timestamp( $data );
[3609] Fix | Delete
[3610] Fix | Delete
if ( false !== $created_timestamp ) {
[3611] Fix | Delete
$metadata['created_timestamp'] = $created_timestamp;
[3612] Fix | Delete
}
[3613] Fix | Delete
}
[3614] Fix | Delete
[3615] Fix | Delete
wp_add_id3_tag_data( $metadata, $data );
[3616] Fix | Delete
[3617] Fix | Delete
$file_format = isset( $metadata['fileformat'] ) ? $metadata['fileformat'] : null;
[3618] Fix | Delete
[3619] Fix | Delete
/**
[3620] Fix | Delete
* Filters the array of metadata retrieved from a video.
[3621] Fix | Delete
*
[3622] Fix | Delete
* In core, usually this selection is what is stored.
[3623] Fix | Delete
* More complete data can be parsed from the `$data` parameter.
[3624] Fix | Delete
*
[3625] Fix | Delete
* @since 4.9.0
[3626] Fix | Delete
*
[3627] Fix | Delete
* @param array $metadata Filtered Video metadata.
[3628] Fix | Delete
* @param string $file Path to video file.
[3629] Fix | Delete
* @param string $file_format File format of video, as analyzed by getID3.
[3630] Fix | Delete
* @param string $data Raw metadata from getID3.
[3631] Fix | Delete
*/
[3632] Fix | Delete
return apply_filters( 'wp_read_video_metadata', $metadata, $file, $file_format, $data );
[3633] Fix | Delete
}
[3634] Fix | Delete
[3635] Fix | Delete
/**
[3636] Fix | Delete
* Retrieve metadata from an audio file's ID3 tags.
[3637] Fix | Delete
*
[3638] Fix | Delete
* @since 3.6.0
[3639] Fix | Delete
*
[3640] Fix | Delete
* @param string $file Path to file.
[3641] Fix | Delete
* @return array|false Returns array of metadata, if found.
[3642] Fix | Delete
*/
[3643] Fix | Delete
function wp_read_audio_metadata( $file ) {
[3644] Fix | Delete
if ( ! file_exists( $file ) ) {
[3645] Fix | Delete
return false;
[3646] Fix | Delete
}
[3647] Fix | Delete
[3648] Fix | Delete
$metadata = array();
[3649] Fix | Delete
[3650] Fix | Delete
if ( ! defined( 'GETID3_TEMP_DIR' ) ) {
[3651] Fix | Delete
define( 'GETID3_TEMP_DIR', get_temp_dir() );
[3652] Fix | Delete
}
[3653] Fix | Delete
[3654] Fix | Delete
if ( ! class_exists( 'getID3', false ) ) {
[3655] Fix | Delete
require ABSPATH . WPINC . '/ID3/getid3.php';
[3656] Fix | Delete
}
[3657] Fix | Delete
[3658] Fix | Delete
$id3 = new getID3();
[3659] Fix | Delete
$data = $id3->analyze( $file );
[3660] Fix | Delete
[3661] Fix | Delete
if ( ! empty( $data['audio'] ) ) {
[3662] Fix | Delete
unset( $data['audio']['streams'] );
[3663] Fix | Delete
$metadata = $data['audio'];
[3664] Fix | Delete
}
[3665] Fix | Delete
[3666] Fix | Delete
if ( ! empty( $data['fileformat'] ) ) {
[3667] Fix | Delete
$metadata['fileformat'] = $data['fileformat'];
[3668] Fix | Delete
}
[3669] Fix | Delete
[3670] Fix | Delete
if ( ! empty( $data['filesize'] ) ) {
[3671] Fix | Delete
$metadata['filesize'] = (int) $data['filesize'];
[3672] Fix | Delete
}
[3673] Fix | Delete
[3674] Fix | Delete
if ( ! empty( $data['mime_type'] ) ) {
[3675] Fix | Delete
$metadata['mime_type'] = $data['mime_type'];
[3676] Fix | Delete
}
[3677] Fix | Delete
[3678] Fix | Delete
if ( ! empty( $data['playtime_seconds'] ) ) {
[3679] Fix | Delete
$metadata['length'] = (int) round( $data['playtime_seconds'] );
[3680] Fix | Delete
}
[3681] Fix | Delete
[3682] Fix | Delete
if ( ! empty( $data['playtime_string'] ) ) {
[3683] Fix | Delete
$metadata['length_formatted'] = $data['playtime_string'];
[3684] Fix | Delete
}
[3685] Fix | Delete
[3686] Fix | Delete
if ( empty( $metadata['created_timestamp'] ) ) {
[3687] Fix | Delete
$created_timestamp = wp_get_media_creation_timestamp( $data );
[3688] Fix | Delete
[3689] Fix | Delete
if ( false !== $created_timestamp ) {
[3690] Fix | Delete
$metadata['created_timestamp'] = $created_timestamp;
[3691] Fix | Delete
}
[3692] Fix | Delete
}
[3693] Fix | Delete
[3694] Fix | Delete
wp_add_id3_tag_data( $metadata, $data );
[3695] Fix | Delete
[3696] Fix | Delete
return $metadata;
[3697] Fix | Delete
}
[3698] Fix | Delete
[3699] Fix | Delete
/**
[3700] Fix | Delete
* Parse creation date from media metadata.
[3701] Fix | Delete
*
[3702] Fix | Delete
* The getID3 library doesn't have a standard method for getting creation dates,
[3703] Fix | Delete
* so the location of this data can vary based on the MIME type.
[3704] Fix | Delete
*
[3705] Fix | Delete
* @since 4.9.0
[3706] Fix | Delete
*
[3707] Fix | Delete
* @link https://github.com/JamesHeinrich/getID3/blob/master/structure.txt
[3708] Fix | Delete
*
[3709] Fix | Delete
* @param array $metadata The metadata returned by getID3::analyze().
[3710] Fix | Delete
* @return int|false A UNIX timestamp for the media's creation date if available
[3711] Fix | Delete
* or a boolean FALSE if a timestamp could not be determined.
[3712] Fix | Delete
*/
[3713] Fix | Delete
function wp_get_media_creation_timestamp( $metadata ) {
[3714] Fix | Delete
$creation_date = false;
[3715] Fix | Delete
[3716] Fix | Delete
if ( empty( $metadata['fileformat'] ) ) {
[3717] Fix | Delete
return $creation_date;
[3718] Fix | Delete
}
[3719] Fix | Delete
[3720] Fix | Delete
switch ( $metadata['fileformat'] ) {
[3721] Fix | Delete
case 'asf':
[3722] Fix | Delete
if ( isset( $metadata['asf']['file_properties_object']['creation_date_unix'] ) ) {
[3723] Fix | Delete
$creation_date = (int) $metadata['asf']['file_properties_object']['creation_date_unix'];
[3724] Fix | Delete
}
[3725] Fix | Delete
break;
[3726] Fix | Delete
[3727] Fix | Delete
case 'matroska':
[3728] Fix | Delete
case 'webm':
[3729] Fix | Delete
if ( isset( $metadata['matroska']['comments']['creation_time']['0'] ) ) {
[3730] Fix | Delete
$creation_date = strtotime( $metadata['matroska']['comments']['creation_time']['0'] );
[3731] Fix | Delete
} elseif ( isset( $metadata['matroska']['info']['0']['DateUTC_unix'] ) ) {
[3732] Fix | Delete
$creation_date = (int) $metadata['matroska']['info']['0']['DateUTC_unix'];
[3733] Fix | Delete
}
[3734] Fix | Delete
break;
[3735] Fix | Delete
[3736] Fix | Delete
case 'quicktime':
[3737] Fix | Delete
case 'mp4':
[3738] Fix | Delete
if ( isset( $metadata['quicktime']['moov']['subatoms']['0']['creation_time_unix'] ) ) {
[3739] Fix | Delete
$creation_date = (int) $metadata['quicktime']['moov']['subatoms']['0']['creation_time_unix'];
[3740] Fix | Delete
}
[3741] Fix | Delete
break;
[3742] Fix | Delete
}
[3743] Fix | Delete
[3744] Fix | Delete
return $creation_date;
[3745] Fix | Delete
}
[3746] Fix | Delete
[3747] Fix | Delete
/**
[3748] Fix | Delete
* Encapsulates the logic for Attach/Detach actions.
[3749] Fix | Delete
*
[3750] Fix | Delete
* @since 4.2.0
[3751] Fix | Delete
*
[3752] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[3753] Fix | Delete
*
[3754] Fix | Delete
* @param int $parent_id Attachment parent ID.
[3755] Fix | Delete
* @param string $action Optional. Attach/detach action. Accepts 'attach' or 'detach'.
[3756] Fix | Delete
* Default 'attach'.
[3757] Fix | Delete
*/
[3758] Fix | Delete
function wp_media_attach_action( $parent_id, $action = 'attach' ) {
[3759] Fix | Delete
global $wpdb;
[3760] Fix | Delete
[3761] Fix | Delete
if ( ! $parent_id ) {
[3762] Fix | Delete
return;
[3763] Fix | Delete
}
[3764] Fix | Delete
[3765] Fix | Delete
if ( ! current_user_can( 'edit_post', $parent_id ) ) {
[3766] Fix | Delete
wp_die( __( 'Sorry, you are not allowed to edit this post.' ) );
[3767] Fix | Delete
}
[3768] Fix | Delete
[3769] Fix | Delete
$ids = array();
[3770] Fix | Delete
[3771] Fix | Delete
foreach ( (array) $_REQUEST['media'] as $attachment_id ) {
[3772] Fix | Delete
$attachment_id = (int) $attachment_id;
[3773] Fix | Delete
[3774] Fix | Delete
if ( ! current_user_can( 'edit_post', $attachment_id ) ) {
[3775] Fix | Delete
continue;
[3776] Fix | Delete
}
[3777] Fix | Delete
[3778] Fix | Delete
$ids[] = $attachment_id;
[3779] Fix | Delete
}
[3780] Fix | Delete
[3781] Fix | Delete
if ( ! empty( $ids ) ) {
[3782] Fix | Delete
$ids_string = implode( ',', $ids );
[3783] Fix | Delete
[3784] Fix | Delete
if ( 'attach' === $action ) {
[3785] Fix | Delete
$result = $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET post_parent = %d WHERE post_type = 'attachment' AND ID IN ( $ids_string )", $parent_id ) );
[3786] Fix | Delete
} else {
[3787] Fix | Delete
$result = $wpdb->query( "UPDATE $wpdb->posts SET post_parent = 0 WHERE post_type = 'attachment' AND ID IN ( $ids_string )" );
[3788] Fix | Delete
}
[3789] Fix | Delete
}
[3790] Fix | Delete
[3791] Fix | Delete
if ( isset( $result ) ) {
[3792] Fix | Delete
foreach ( $ids as $attachment_id ) {
[3793] Fix | Delete
/**
[3794] Fix | Delete
* Fires when media is attached or detached from a post.
[3795] Fix | Delete
*
[3796] Fix | Delete
* @since 5.5.0
[3797] Fix | Delete
*
[3798] Fix | Delete
* @param string $action Attach/detach action. Accepts 'attach' or 'detach'.
[3799] Fix | Delete
* @param int $attachment_id The attachment ID.
[3800] Fix | Delete
* @param int $parent_id Attachment parent ID.
[3801] Fix | Delete
*/
[3802] Fix | Delete
do_action( 'wp_media_attach_action', $action, $attachment_id, $parent_id );
[3803] Fix | Delete
[3804] Fix | Delete
clean_attachment_cache( $attachment_id );
[3805] Fix | Delete
}
[3806] Fix | Delete
[3807] Fix | Delete
$location = 'upload.php';
[3808] Fix | Delete
$referer = wp_get_referer();
[3809] Fix | Delete
[3810] Fix | Delete
if ( $referer ) {
[3811] Fix | Delete
if ( false !== strpos( $referer, 'upload.php' ) ) {
[3812] Fix | Delete
$location = remove_query_arg( array( 'attached', 'detach' ), $referer );
[3813] Fix | Delete
}
[3814] Fix | Delete
}
[3815] Fix | Delete
[3816] Fix | Delete
$key = 'attach' === $action ? 'attached' : 'detach';
[3817] Fix | Delete
$location = add_query_arg( array( $key => $result ), $location );
[3818] Fix | Delete
[3819] Fix | Delete
wp_redirect( $location );
[3820] Fix | Delete
exit;
[3821] Fix | Delete
}
[3822] Fix | Delete
}
[3823] Fix | Delete
[3824] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function