wp_insert_attachment_data
Filter HookDescription
Filters attachment post data before it is updated in or added to the database.Hook Information
File Location |
wp-includes/post.php
View on GitHub
|
Hook Type | Filter |
Line Number | 4796 |
Hook Parameters
Type | Name | Description |
---|---|---|
array
|
$data
|
An array of slashed, sanitized, and processed attachment post data. |
array
|
$postarr
|
An array of slashed and sanitized attachment post data, but not processed. |
array
|
$unsanitized_postarr
|
An array of slashed yet *unsanitized* and unprocessed attachment post data as originally passed to wp_insert_post(). |
bool
|
$update
|
Whether this is an existing attachment post being updated. |
Usage Examples
Basic Usage
<?php
// Hook into wp_insert_attachment_data
add_filter('wp_insert_attachment_data', 'my_custom_filter', 10, 4);
function my_custom_filter($data, $postarr, $unsanitized_postarr, $update) {
// Your custom filtering logic here
return $data;
}
Source Code Context
wp-includes/post.php:4796
- How this hook is used in WordPress core
<?php
4791 * @param array $postarr An array of slashed and sanitized attachment post data, but not processed.
4792 * @param array $unsanitized_postarr An array of slashed yet *unsanitized* and unprocessed attachment post data
4793 * as originally passed to wp_insert_post().
4794 * @param bool $update Whether this is an existing attachment post being updated.
4795 */
4796 $data = apply_filters( 'wp_insert_attachment_data', $data, $postarr, $unsanitized_postarr, $update );
4797 } else {
4798 /**
4799 * Filters slashed post data just before it is inserted into the database.
4800 *
4801 * @since 2.7.0
PHP Documentation
<?php
/**
* Filters attachment post data before it is updated in or added to the database.
*
* @since 3.9.0
* @since 5.4.1 The `$unsanitized_postarr` parameter was added.
* @since 6.0.0 The `$update` parameter was added.
*
* @param array $data An array of slashed, sanitized, and processed attachment post data.
* @param array $postarr An array of slashed and sanitized attachment post data, but not processed.
* @param array $unsanitized_postarr An array of slashed yet *unsanitized* and unprocessed attachment post data
* as originally passed to wp_insert_post().
* @param bool $update Whether this is an existing attachment post being updated.
*/
Quick Info
- Hook Type: Filter
- Parameters: 4
- File: wp-includes/post.php
Related Hooks
Related hooks will be displayed here in future updates.