mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-16 19:46:21 +00:00
Media: Remove attachment_fields_to_save
filter and deprecate image_attachment_fields_to_save()
.
This filter prevented removing attachment titles. This changeset removes the filter and deprecates the related function since it is no longer used. Props dromero20, desrosj, Junaidkbr, francina, antpb, audrasjb, aadilali, etaproducto, azouamauriac, Boniu91, SergeyBiryukov. Fixes #39108. Built from https://develop.svn.wordpress.org/trunk@53228 git-svn-id: http://core.svn.wordpress.org/trunk@52817 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
eeedcfac4b
commit
aab2815d58
@ -31,8 +31,6 @@ add_filter( 'async_upload_audio', 'get_media_item', 10, 2 );
|
||||
add_filter( 'async_upload_video', 'get_media_item', 10, 2 );
|
||||
add_filter( 'async_upload_file', 'get_media_item', 10, 2 );
|
||||
|
||||
add_filter( 'attachment_fields_to_save', 'image_attachment_fields_to_save', 10, 2 );
|
||||
|
||||
add_filter( 'media_upload_gallery', 'media_upload_gallery' );
|
||||
add_filter( 'media_upload_library', 'media_upload_library' );
|
||||
|
||||
|
@ -1567,3 +1567,20 @@ class WP_Privacy_Data_Removal_Requests_Table extends WP_Privacy_Data_Removal_Req
|
||||
function _wp_privacy_requests_screen_options() {
|
||||
_deprecated_function( __FUNCTION__, '5.3.0' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Was used to filter input from media_upload_form_handler() and to assign a default
|
||||
* post_title from the file name if none supplied.
|
||||
*
|
||||
* @since 2.5.0
|
||||
* @deprecated 6.0.0
|
||||
*
|
||||
* @param array $post The WP_Post attachment object converted to an array.
|
||||
* @param array $attachment An array of attachment metadata.
|
||||
* @return array Attachment post object converted to an array.
|
||||
*/
|
||||
function image_attachment_fields_to_save( $post, $attachment ) {
|
||||
_deprecated_function( __FUNCTION__, '6.0.0' );
|
||||
|
||||
return $post;
|
||||
}
|
||||
|
@ -1321,31 +1321,6 @@ function media_post_single_attachment_fields_to_edit( $form_fields, $post ) {
|
||||
return $form_fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters input from media_upload_form_handler() and assigns a default
|
||||
* post_title from the file name if none supplied.
|
||||
*
|
||||
* Illustrates the use of the {@see 'attachment_fields_to_save'} filter
|
||||
* which can be used to add default values to any field before saving to DB.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param array $post The WP_Post attachment object converted to an array.
|
||||
* @param array $attachment An array of attachment metadata.
|
||||
* @return array Filtered attachment post object.
|
||||
*/
|
||||
function image_attachment_fields_to_save( $post, $attachment ) {
|
||||
if ( 'image' === substr( $post['post_mime_type'], 0, 5 ) ) {
|
||||
if ( strlen( trim( $post['post_title'] ) ) == 0 ) {
|
||||
$attachment_url = ( isset( $post['attachment_url'] ) ) ? $post['attachment_url'] : $post['guid'];
|
||||
$post['post_title'] = preg_replace( '/\.\w+$/', '', wp_basename( $attachment_url ) );
|
||||
$post['errors']['post_title']['errors'][] = __( 'Empty Title filled from filename.' );
|
||||
}
|
||||
}
|
||||
|
||||
return $post;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the media element HTML to send to the editor.
|
||||
*
|
||||
|
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.0-beta2-53227';
|
||||
$wp_version = '6.0-beta2-53228';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
x
Reference in New Issue
Block a user