Definition:
function media_upload_form_handler() {}
Defined filters
- attachment_fields_to_save
apply_filters('attachment_fields_to_save', $post, $attachment)
- media_send_to_editor
apply_filters('media_send_to_editor', $html, $send_id, $attachment)
Source code
function media_upload_form_handler() { check_admin_referer('media-form'); $errors = null; if ( isset($_POST['send']) ) { $keys = array_keys($_POST['send']); $send_id = (int) array_shift($keys); } if ( !empty($_POST['attachments']) ) foreach ( $_POST['attachments'] as $attachment_id => $attachment ) { $post = $_post = get_post($attachment_id, ARRAY_A); $post_type_object = get_post_type_object( $post[ 'post_type' ] ); if ( !current_user_can( $post_type_object->cap->edit_post, $attachment_id ) ) continue; if ( isset($attachment['post_content']) ) $post['post_content'] = $attachment['post_content']; if ( isset($attachment['post_title']) ) $post['post_title'] = $attachment['post_title']; if ( isset($attachment['post_excerpt']) ) $post['post_excerpt'] = $attachment['post_excerpt']; if ( isset($attachment['menu_order']) ) $post['menu_order'] = $attachment['menu_order']; if ( isset($send_id) && $attachment_id == $send_id ) { if ( isset($attachment['post_parent']) ) $post['post_parent'] = $attachment['post_parent']; } $post = apply_filters('attachment_fields_to_save', $post, $attachment); if ( isset($attachment['image_alt']) ) { $image_alt = get_post_meta($attachment_id, '_wp_attachment_image_alt', true); if ( $image_alt != stripslashes($attachment['image_alt']) ) { $image_alt = wp_strip_all_tags( stripslashes($attachment['image_alt']), true ); // update_meta expects slashed update_post_meta( $attachment_id, '_wp_attachment_image_alt', addslashes($image_alt) ); } } if ( isset($post['errors']) ) { $errors[$attachment_id] = $post['errors']; unset($post['errors']); } if ( $post != $_post ) wp_update_post($post); foreach ( get_attachment_taxonomies($post) as $t ) { if ( isset($attachment[$t]) ) wp_set_object_terms($attachment_id, array_map('trim', preg_split('/,+/', $attachment[$t])), $t, false); } } if ( isset($_POST['insert-gallery']) || isset($_POST['update-gallery']) ) { ?> <script type="text/javascript"> /* <![CDATA[ */ var win = window.dialogArguments || opener || parent || top; win.tb_remove(); /* ]]> */ </script> <?php exit; } if ( isset($send_id) ) { $attachment = stripslashes_deep( $_POST['attachments'][$send_id] ); $html = $attachment['post_title']; if ( !empty($attachment['url']) ) { $rel = ''; if ( strpos($attachment['url'], 'attachment_id') || get_attachment_link($send_id) == $attachment['url'] ) $rel = " rel='attachment wp-att-" . esc_attr($send_id) . "'"; $html = "<a href='{$attachment['url']}'$rel>$html</a>"; } $html = apply_filters('media_send_to_editor', $html, $send_id, $attachment); return media_send_to_editor($html); }
2371
No comments yet... Be the first to leave a reply!