-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathpmxi_attachment_uploaded.php
More file actions
37 lines (32 loc) · 1008 Bytes
/
pmxi_attachment_uploaded.php
File metadata and controls
37 lines (32 loc) · 1008 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
/**
* ==================================
* Action: pmxi_attachment_uploaded
* ==================================
*
* This hook is called after WP All Import creates/updates post attachment file(s).
* See also pmxi_gallery_image
*
* @param $post_id int - The id of the post just created/updated
* @param $att_id int - The attachment id
* @param $file string - The local file path to the attachment
*/
function my_attachment_uploaded($post_id, $att_id, $file)
{
}
add_action('pmxi_attachment_uploaded', 'my_attachment_uploaded', 10, 3);
/**
* Add attachment file extension
*/
function wpai_pmxi_attachment_uploaded( $pid, $attach_id, $attachment_file ) {
$new_file = $attachment_file . '.pdf';
if ( rename($attachment_file, $new_file) )
{
wp_update_post(array(
'ID' => $attach_id,
'post_mime_type' => 'application/pdf'
));
update_attached_file($attach_id,$new_file);
}
}
add_action('pmxi_attachment_uploaded', 'wpai_pmxi_attachment_uploaded', 10, 3);