media_upload_form_handler [ WordPress Function ]
media_upload_form_handler ( No parameters )
| Returns: |
|
| Defined at: |
|
Soorgelijke functies: wp_media_upload_handler, media_upload_header, media_upload_form, media_upload_gallery, media_upload_file
{@internal Missing Short Description}}
Source
<?php
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 = isset( $attachment['post_title'] ) ? $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);
}
return $errors;
}
?>
Examples [ wp-snippets.com ]
Top Google zoekresultaten
- #17812 (media_upload_form_handler runs twice when editing ...
media_upload_form_handler runs twice when editing attachment from "From Computer" media upload tab (browser uploader) ...
core.trac.wordpress.org - media_upload_form_handler (WordPress Function) - WPSeek.com
WordPress lookup for media_upload_form_handler, a WordPress Function. wpseek.com is a WordPress-centric search tool for developers and theme authors.
wpseek.com - media_upload_form_handler() WordPress function reference ...
function media_upload_form_handler() { check_admin_referer('media-form'); $ errors = null; if ( isset($_POST['send']) ) { $keys = array_keys($_POST['send']); ...
queryposts.com - Creating Custom Fields for Attachments in Wordpress | Nettuts+
Jul 20, 2010 ... function media_upload_form_handler() { // ... $post = apply_filters(" attachment_fields_to_save", $post, $attachment); // ... } $post is the ...
net.tutsplus.com