'._x('You do not have proper permissions to upload a new image', 'Permissions warning for image uplaod', 'anno').''; return; } global $type, $tab, $pagenow; $flash_action_url = admin_url('async-upload.php'); // If Mac and mod_security, no Flash. :( $flash = true; if ( false !== stripos($_SERVER['HTTP_USER_AGENT'], 'mac') && apache_mod_loaded('mod_security') ) $flash = false; $flash = apply_filters('flash_uploader', $flash); $post_id = isset($_REQUEST['post_id']) ? intval($_REQUEST['post_id']) : 0; $upload_size_unit = $max_upload_size = wp_max_upload_size(); $sizes = array( 'KB', 'MB', 'GB' ); for ( $u = -1; $upload_size_unit > 1024 && $u < count( $sizes ) - 1; $u++ ) $upload_size_unit /= 1024; if ( $u < 0 ) { $upload_size_unit = 0; $u = 0; } else { $upload_size_unit = (int) $upload_size_unit; } ?>
get_error_message(); ?>
' . sprintf( _x( 'Sorry, you have filled your storage quota (%s MB).', 'Media upload error text', 'anno'), get_space_allowed() ) . '

'; return; } do_action('pre-upload-ui'); if ( $flash ) : // Set the post params, which SWFUpload will post back with the file, and pass // them through a filter. $post_params = array( 'post_id' => anno_get_post_id(), 'auth_cookie' => (is_ssl() ? $_COOKIE[SECURE_AUTH_COOKIE] : $_COOKIE[AUTH_COOKIE]), 'logged_in_cookie' => $_COOKIE[LOGGED_IN_COOKIE], '_wpnonce' => wp_create_nonce('media-form'), 'type' => $type, 'tab' => $tab, 'short' => '1', 'action' => 'tinymce_upload', ); $post_params = apply_filters( 'swfupload_post_params', $post_params ); $p = array(); foreach ( $post_params as $param => $val ) $p[] = "\t\t'$param' : '$val'"; $post_params_str = implode( ", \n", $p ); // #8545. wmode=transparent cannot be used with SWFUpload if ( 'media-new.php' == $pagenow ) { $upload_image_path = get_user_option( 'admin_color' ); if ( 'classic' != $upload_image_path ) $upload_image_path = 'fresh'; $upload_image_path = admin_url( 'images/upload-' . $upload_image_path . '.png?ver=20101205' ); } else { $upload_image_path = includes_url( 'images/upload.png?ver=20100531' ); } ?>

post_type == 'attachment' ) $attachments = array($post->ID => $post); else $attachments = get_children( array( 'post_parent' => $post_id, 'post_type' => 'attachment', 'orderby' => 'menu_order ASC, ID', 'order' => 'DESC') ); } else { if ( is_array($GLOBALS['wp_the_query']->posts) ) foreach ( $GLOBALS['wp_the_query']->posts as $attachment ) $attachments[$attachment->ID] = $attachment; } $output = ''; foreach ( (array) $attachments as $id => $attachment ) { if ( $attachment->post_status == 'trash' ) continue; if ( $item = anno_get_media_item( $id, array( 'errors' => isset($errors[$id]) ? $errors[$id] : null) ) ) $output .= "\n
$item\n
"; } return $output; } function anno_get_media_item($attachment_id, $args = null) { global $redir_tab; $post = get_post($attachment_id); $default_args = array( 'errors' => null, 'send' => $post->post_parent ? post_type_supports( get_post_type( $post->post_parent ), 'editor' ) : true, 'delete' => true, 'toggle' => true, 'show_title' => true, ); $args = wp_parse_args($args, $default_args); extract($args, EXTR_SKIP); $filename = esc_html(basename( $post->guid)); $title = esc_attr($post->post_title); ob_start(); anno_popup_images_row_display($post); anno_popup_images_row_edit($post); $display = ob_get_contents(); ob_end_clean(); return $display; } // Request handler for uploading // Then do our magic function anno_tinymce_request_handler() { if ((isset($_POST['anno_action']) && $_POST['anno_action'] == 'anno_async_upload') && (isset($_POST['tinymce_upload']) || (isset($_POST['fetch']) && isset($_POST['attachment_id'])))) { anno_async_upload(); } } add_action('init', 'anno_tinymce_request_handler'); function anno_async_upload() { // Flash often fails to send cookies with the POST or upload, so we need to pass it in GET or POST instead if ( is_ssl() && empty($_COOKIE[SECURE_AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie']) ) $_COOKIE[SECURE_AUTH_COOKIE] = $_REQUEST['auth_cookie']; elseif ( empty($_COOKIE[AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie']) ) $_COOKIE[AUTH_COOKIE] = $_REQUEST['auth_cookie']; if ( empty($_COOKIE[LOGGED_IN_COOKIE]) && !empty($_REQUEST['logged_in_cookie']) ) $_COOKIE[LOGGED_IN_COOKIE] = $_REQUEST['logged_in_cookie']; unset($current_user); header('Content-Type: text/plain; charset=' . get_option('blog_charset')); if ( !current_user_can('upload_files') ) wp_die(_x('You do not have permission to upload files.', 'Media upload error text', 'anno')); // just fetch the detail form for that attachment if ( isset($_REQUEST['attachment_id']) && ($id = intval($_REQUEST['attachment_id'])) && $_REQUEST['fetch'] ) { $post = get_post($id); if ('attachment' != $post->post_type) wp_die(_x('Unknown post type.', 'Media upload error text', 'anno')); $post_type_object = get_post_type_object('attachment'); if (!current_user_can( $post_type_object->cap->edit_post, $id)) wp_die(_x( 'You are not allowed to edit this item.', 'Media upload error text', 'anno')); add_filter('attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2); echo anno_get_media_item($id); exit; } check_admin_referer('media-form'); $id = media_handle_upload('async-upload', $_REQUEST['post_id']); if ( is_wp_error($id) ) { echo '
' . _x('Dismiss', 'Media upload helper', 'anno') . ' ' . sprintf(_x('“%s” has failed to upload due to an error', 'Media upload error text', 'anno'), esc_html($_FILES['async-upload']['name']) ) . '
' . esc_html($id->get_error_message()) . '
'; exit; } if ( $_REQUEST['short'] ) { // short form response - attachment ID only echo $id; } else { // long form response - big chunk o html $type = $_REQUEST['type']; echo apply_filters("async_upload_{$type}", $id); } } ?>