Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




media_upload_form_handler [ WordPress Function ]

media_upload_form_handler ( No parameters )
Returns:
  • (unknown)
Defined at:



{@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_idARRAY_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_tagsstripslashes($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_idarray_map('trim'preg_split('/,+/'$attachment[$t])), $tfalse);
        }
    }

    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

Meer ...

Gebruikersdiscussies [ wordpress.org ]

0 User Note(s)

Nog geen één. Wees de eerste!

Nieuw toevoegen ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics