Example #1
0
 /**
  * If image is sucessfully uploaded, automatically close the editor 
  * and store the image URL in the image input
  * @param array $args the default args
  * @return array the original args, unmodified
  * @uses media_send_to_editor()
  * @uses send_to_editor() (javascript)
  */
 function send_to_editor($args)
 {
     global $wpdb;
     if (isset($GLOBALS['HTTP_POST_FILES']['async-upload'])) {
         if ($args['errors'] !== null) {
             return $args;
         }
         if (isset($_GET['attachment_id'])) {
             $id = $_GET['attachment_id'];
             //workaround for WP 3.2 non-flash upload
             //not ideal, but works for an edge case
         } else {
             //because we can't get the attachment ID at this point, try to pull it from the database
             //look for the most recent parent-less attachment with same title and mime-type
             $upload = $GLOBALS['HTTP_POST_FILES']['async-upload'];
             $title = substr($upload['name'], 0, strrpos($upload['name'], '.'));
             $id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_type = 'attachment' AND post_mime_type = '" . $upload['type'] . "' AND post_parent = '0' AND post_title = '{$title}' ORDER BY ID DESC LIMIT 1");
             //if for some reason we couldn't pull the ID, simply kick
             //the user will just have to click insert to close the dialog
             if (!$id) {
                 return $args;
             }
         }
         //rely on WordPress's internal function to output script tags and call send_to_editor()
         media_send_to_editor(wp_get_attachment_url($id));
     }
     return $args;
 }
Example #2
0
function media_upload_flag()
{
    // Generate TinyMCE HTML output
    if (isset($_POST['send'])) {
        $keys = array_keys($_POST['send']);
        $send_id = (int) array_shift($keys);
        $image = $_POST['image'][$send_id];
        $alttext = stripslashes(htmlspecialchars($image['alttext'], ENT_QUOTES));
        $description = stripslashes(htmlspecialchars($image['description'], ENT_QUOTES));
        // here is no new line allowed
        $clean_description = preg_replace("/\n|\r\n|\r\$/", " ", $description);
        $img = flagdb::find_image($send_id);
        $class = "flag-singlepic flag-{$image['align']}";
        // Build output
        if ($image['size'] == "thumbnail") {
            $html = "<img src='{$image['thumb']}' alt='{$alttext}' class='{$class}' align='{$image['align']}' />";
        }
        // Wrap the link to the fullsize image around
        $html = "<a href='{$image['url']}' title='{$clean_description}'>{$html}</a>";
        if ($image['size'] == "full") {
            $html = "<img src='{$image['url']}' alt='{$alttext}' class='{$class}' align='{$image['align']}' />";
        }
        media_upload_flag_save_image();
        // Return it to TinyMCE
        media_send_to_editor($html);
    }
    // Save button
    if (isset($_POST['save'])) {
        media_upload_flag_save_image();
    }
    wp_iframe('media_upload_flag_form');
}
function wpgmappity_upload()
{
    $map_meta_data = $_REQUEST['wpgmappity-submit-info'];
    //die(var_dump($_REQUEST));
    if ($_REQUEST['wpgmappity-edit-map'] == 'true') {
        $map_id = esc_attr($_REQUEST['wpgmappity-map-id']);
        $map_number = wpgmappity_update_meta_data($map_meta_data, $map_id);
    } else {
        $map_number = wpgmappity_insert_meta_data($map_meta_data);
    }
    $html = '<p>[wpgmappity id="' . $map_number . '"]</p>';
    return media_send_to_editor($html);
}
Example #4
0
 private function insert_doc_into_post($vars)
 {
     //strip blank values
     $vars['insert_existing'] = 0;
     $vars['insert_new'] = 0;
     $vars = array_filter($vars);
     $html = '[pdf ';
     foreach ($vars as $key => $val) {
         $html .= " {$key}=" . (is_numeric($val) ? $val : "'" . $val . "'");
     }
     $html .= ']';
     $html = apply_filters('media_send_to_editor', $html, $send_id, $attachment);
     return media_send_to_editor($html);
 }
/**
 * 
 * Insert a playlist into the editor for a page or post through the media manager
 * 
 */
function s3video_playlist_media_manager()
{
    if (isset($_POST['insertPlaylistId']) && !empty($_POST['insertPlaylistId'])) {
        $insertHtml = "[S3_embed_playlist id='" . $_POST['insertPlaylistId'] . "']";
        media_send_to_editor($insertHtml);
        die;
    }
    $pluginSettings = s3_video_check_plugin_settings();
    // Load playlist management class
    require_once WP_PLUGIN_DIR . '/s3-video/includes/playlist_management.php';
    $playlistManagement = new s3_playlist_management();
    // Load all of the existing playlists
    $existingPlaylists = $playlistManagement->getAllPlaylists();
    require_once WP_PLUGIN_DIR . '/s3-video/views/playlist-management/media_manager_show_playlists.php';
}
Example #6
0
function media_upload_nextgen()
{
    // Not in use
    $errors = false;
    // Generate TinyMCE HTML output
    if (isset($_POST['send'])) {
        $keys = array_keys($_POST['send']);
        $send_id = (int) array_shift($keys);
        $image = $_POST['image'][$send_id];
        $alttext = stripslashes(htmlspecialchars($image['alttext'], ENT_QUOTES));
        $description = stripslashes(htmlspecialchars($image['description'], ENT_QUOTES));
        // here is no new line allowed
        $clean_description = preg_replace("/\n|\r\n|\r\$/", " ", $description);
        $img = nggdb::find_image($send_id);
        $thumbcode = $img->get_thumbcode();
        $class = "ngg-singlepic ngg-{$image['align']}";
        // Create a shell displayed-gallery so we can inspect its settings
        $registry = C_Component_Registry::get_instance();
        $mapper = $registry->get_utility('I_Displayed_Gallery_Mapper');
        $factory = $registry->get_utility('I_Component_Factory');
        $args = array('display_type' => NGG_BASIC_SINGLEPIC);
        $displayed_gallery = $factory->create('displayed_gallery', $args, $mapper);
        $width = $displayed_gallery->display_settings['width'];
        $height = $displayed_gallery->display_settings['height'];
        // Build output
        if ($image['size'] == "thumbnail") {
            $html = "<img src='{$image['thumb']}' alt='{$alttext}' class='{$class}' />";
        } else {
            $html = '';
        }
        // Wrap the link to the fullsize image around
        $html = "<a {$thumbcode} href='{$image['url']}' title='{$clean_description}'>{$html}</a>";
        if ($image['size'] == "full") {
            $html = "<img src='{$image['url']}' alt='{$alttext}' class='{$class}' />";
        }
        if ($image['size'] == "singlepic") {
            $html = "[singlepic id={$send_id} w={$width} h={$height} float={$image['align']}]";
        }
        media_upload_nextgen_save_image();
        // Return it to TinyMCE
        return media_send_to_editor($html);
    }
    // Save button
    if (isset($_POST['save'])) {
        media_upload_nextgen_save_image();
    }
    return wp_iframe('media_upload_nextgen_form', $errors);
}
 public static function render_media_embed_playlist_tab()
 {
     $no_video_error = false;
     if (isset($_POST[JWP6 . 'playlistid']) && $_POST[JWP6 . 'playlistid']) {
         $shortcode = new JWP6_Shortcode();
         media_send_to_editor($shortcode->shortcode());
         exit;
     } else {
         if (count($_POST)) {
             $no_video_error = true;
         }
     }
     wp_enqueue_style('media');
     JWP6_Media::enqueue_scripts();
     wp_enqueue_script('admin-gallery');
     require_once dirname(__FILE__) . "/jwp6-media-embed-playlist.php";
     return wp_iframe("jwp6_media_embed_playlist", $no_video_error);
 }
Example #8
0
 function send_to_editor($args)
 {
     global $wpdb;
     if ($args['errors'] !== null) {
         return $args;
     }
     if (isset($_GET['attachment_id'])) {
         $id = $_GET['attachment_id'];
     } else {
         $upload = $GLOBALS['HTTP_POST_FILES']['async-upload'];
         $title = substr($upload['name'], 0, strrpos($upload['name'], '.'));
         $id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_type = 'attachment' AND post_mime_type = '" . $upload['type'] . "' AND post_parent = '0' AND post_title = '{$title}' ORDER BY ID DESC LIMIT 1");
         if (!$id) {
             return $args;
         }
     }
     media_send_to_editor(wp_get_attachment_url($id));
     return $args;
 }
Example #9
0
function media_upload_crystal_form_handler()
{
    if (isset($_POST['insert-gallery'])) {
        return media_send_to_editor('[crystal-gallery]');
    }
    if (isset($_POST['send'])) {
        $keys = array_keys($_POST['send']);
        $send_id = (int) array_shift($keys);
        $attachment = $_POST['attachments'][$send_id];
        $html = $attachment['post_title'];
        if (!empty($attachment['url'])) {
            if (strpos($attachment['url'], 'attachment_id') || false !== strpos($attachment['url'], get_permalink($_POST['post_id']))) {
                $rel = " rel='attachment wp-att-" . attribute_escape($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 wp_iframe('media_upload_crystal_form');
}
/**
 * Modified from media_upload_file in WordPress 3.2.1
 * {@internal Missing Short Description}}
 *
 * @since 2.5.0
 *
 * @return unknown
 */
function s2sfu_media_upload_handler()
{
    add_filter('media_upload_tabs', '__return_false');
    add_filter('upload_dir', 's2sfu_upload_dir');
    $errors = array();
    $id = 0;
    if (isset($_POST['html-upload']) && !empty($_FILES)) {
        check_admin_referer('media-form');
        // Upload File button was clicked
        $id = media_handle_upload('async-upload', $_REQUEST['post_id']);
        unset($_FILES);
        if (is_wp_error($id)) {
            $errors['upload_error'] = $id;
            $id = false;
        }
        //http://domain/?s2member_file_download=
        $filename = get_post_meta($id, '_wp_attached_file', true);
        $html = '<a href="' . site_url() . '/?s2member_file_download=' . $filename . '">' . $filename . '</a>';
        return media_send_to_editor($html);
    }
    return wp_iframe('media_upload_type_s2sfu', 's2sfu', $errors, $id);
}
Example #11
0
function media_upload_nextgen()
{
    // Not in use
    $errors = false;
    // Generate TinyMCE HTML output
    if (isset($_POST['send'])) {
        $keys = array_keys($_POST['send']);
        $send_id = (int) array_shift($keys);
        $image = $_POST['image'][$send_id];
        $alttext = stripslashes(htmlspecialchars($image['alttext'], ENT_QUOTES));
        $description = stripslashes(htmlspecialchars($image['description'], ENT_QUOTES));
        // here is no new line allowed
        $clean_description = preg_replace("/\n|\r\n|\r\$/", " ", $description);
        $img = nggdb::find_image($send_id);
        $thumbcode = $img->get_thumbcode();
        $class = "ngg-singlepic ngg-{$image['align']}";
        // Build output
        if ($image['size'] == "thumbnail") {
            $html = "<img src='{$image['thumb']}' alt='{$alttext}' class='{$class}' />";
        }
        // Wrap the link to the fullsize image around
        $html = "<a {$thumbcode} href='{$image['url']}' title='{$clean_description}'>{$html}</a>";
        if ($image['size'] == "full") {
            $html = "<img src='{$image['url']}' alt='{$alttext}' class='{$class}' />";
        }
        if ($image['size'] == "singlepic") {
            $html = "[singlepic id={$send_id} w=320 h=240 float={$image['align']}]";
        }
        media_upload_nextgen_save_image();
        // Return it to TinyMCE
        return media_send_to_editor($html);
    }
    // Save button
    if (isset($_POST['save'])) {
        media_upload_nextgen_save_image();
    }
    return wp_iframe('media_upload_nextgen_form', $errors);
}
function media_upload_file() {
	if ( isset($_POST['html-upload']) && !empty($_FILES) ) {
		// Upload File button was clicked
		$id = media_handle_upload('async-upload', $_REQUEST['post_id']);
		unset($_FILES);
		if ( is_wp_error($id) ) {
			$errors['upload_error'] = $id;
			$id = false;
		}
	}

	if ( !empty($_POST['insertonlybutton']) ) {
		$href = $_POST['insertonly']['href'];
		if ( !empty($href) && !strpos($href, '://') )
			$href = "http://$href";
		$title = attribute_escape($_POST['insertonly']['title']);
		if ( empty($title) )
			$title = basename($href);
		if ( !empty($title) && !empty($href) )
			$html = "<a href='$href' >$title</a>";
		return media_send_to_editor($html);
	}

	if ( !empty($_POST) ) {
		$return = media_upload_form_handler();

		if ( is_string($return) )
			return $return;
		if ( is_array($return) )
			$errors = $return;
	}

	if ( isset($_POST['save']) ) {
		$errors['upload_notice'] = __('Saved.');
		return media_upload_gallery();
	}

	return wp_iframe( 'media_upload_type_form', 'file', $errors, $id );
}
Example #13
0
/**
 * {@internal Missing Short Description}}
 *
 * @since 2.5.0
 *
 * @return mixed
 */
function wp_media_upload_handler()
{
    $errors = array();
    $id = 0;
    if (isset($_POST['html-upload']) && !empty($_FILES)) {
        check_admin_referer('media-form');
        // Upload File button was clicked
        $id = media_handle_upload('async-upload', $_REQUEST['post_id']);
        unset($_FILES);
        if (is_wp_error($id)) {
            $errors['upload_error'] = $id;
            $id = false;
        }
    }
    if (!empty($_POST['insertonlybutton'])) {
        $src = $_POST['src'];
        if (!empty($src) && !strpos($src, '://')) {
            $src = "http://{$src}";
        }
        if (isset($_POST['media_type']) && 'image' != $_POST['media_type']) {
            $title = esc_html(wp_unslash($_POST['title']));
            if (empty($title)) {
                $title = esc_html(basename($src));
            }
            if ($title && $src) {
                $html = "<a href='" . esc_url($src) . "'>{$title}</a>";
            }
            $type = 'file';
            if (($ext = preg_replace('/^.+?\\.([^.]+)$/', '$1', $src)) && ($ext_type = wp_ext2type($ext)) && ('audio' == $ext_type || 'video' == $ext_type)) {
                $type = $ext_type;
            }
            $html = apply_filters($type . '_send_to_editor_url', $html, esc_url_raw($src), $title);
        } else {
            $align = '';
            $alt = esc_attr(wp_unslash($_POST['alt']));
            if (isset($_POST['align'])) {
                $align = esc_attr(wp_unslash($_POST['align']));
                $class = " class='align{$align}'";
            }
            if (!empty($src)) {
                $html = "<img src='" . esc_url($src) . "' alt='{$alt}'{$class} />";
            }
            $html = apply_filters('image_send_to_editor_url', $html, esc_url_raw($src), $alt, $align);
        }
        return media_send_to_editor($html);
    }
    if (!empty($_POST)) {
        $return = media_upload_form_handler();
        if (is_string($return)) {
            return $return;
        }
        if (is_array($return)) {
            $errors = $return;
        }
    }
    if (isset($_POST['save'])) {
        $errors['upload_notice'] = __('Saved.');
        return media_upload_gallery();
    }
    if (isset($_GET['tab']) && $_GET['tab'] == 'type_url') {
        $type = 'image';
        if (isset($_GET['type']) && in_array($_GET['type'], array('video', 'audio', 'file'))) {
            $type = $_GET['type'];
        }
        return wp_iframe('media_upload_type_url_form', $type, $errors, $id);
    }
    return wp_iframe('media_upload_type_form', 'image', $errors, $id);
}
Example #14
0
	function media_upload_flash() {
		if ( isset($_POST['html-upload']) && !empty($_FILES) ) {
			// Upload File button was clicked
			$id = media_handle_upload('async-upload', $_REQUEST['post_id']);
			unset($_FILES);
			if ( is_wp_error($id) ) {
				$errors['upload_error'] = $id;
				$id = false;
			}
		}

		if ( !empty($_POST['insertonlybutton']) ) {

			$src      = $_POST['insertonly']['src'];
			$title    = stripslashes( htmlspecialchars ($_POST['insertonly']['post_title'], ENT_QUOTES));
			$alt      = $_POST['insertonly']['post_content'];

			if ( !empty($src) && !strpos($src, '://') ) {
				$src = "http://$src";
			}

			// append any additional properties passed to the object.
			// I don't like that I'm doing the same thing here in two places
			// TODO: Need to make this so it only happens in one location.
			$extras   = '';
			if ( !empty($_POST['insertonly']['width']) && intval($_POST['insertonly']['width']) ) {
				$extras .= ' width="'.stripslashes( htmlspecialchars ($_POST['insertonly']['width'], ENT_QUOTES)).'"';
			}
			if ( !empty($_POST['insertonly']['height']) && intval($_POST['insertonly']['height']) ) {
				$extras .= ' height="'.stripslashes( htmlspecialchars ($_POST['insertonly']['height'], ENT_QUOTES)).'"';
			}
			if ( !empty($_POST['insertonly']['id']) ) {
				$extras .= ' id="'.stripslashes( htmlspecialchars ($_POST['insertonly']['id'], ENT_QUOTES)).'"';
			}
			if ( !empty($_POST['insertonly']['name']) ) {
				$extras .= ' name="'.stripslashes( htmlspecialchars ($_POST['insertonly']['name'], ENT_QUOTES)).'"';
			}
			if ( !empty($_POST['insertonly']['class']) ) {
				$extras .= ' class="'.stripslashes( htmlspecialchars ($_POST['insertonly']['class'], ENT_QUOTES)).'"';
			}
			if ( isset($_POST['insertonly']['align']) ) {
				$extras .= ' align="'.$_POST['insertonly']['align'].'"';
			}
			if ( isset($_POST['insertonly']['allowfullscreen']) ) {
				$extras .= ' allowfullscreen="'.$_POST['insertonly']['allowfullscreen'].'"';
			}
			if ( !empty($_POST['insertonly']['required_player_version']) ) {
				$extras .= ' required_player_version="'.stripslashes( htmlspecialchars ($_POST['insertonly']['required_player_version'], ENT_QUOTES)).'"';
			}

			if ( !empty($src) ) {
				$html  = '[swfobj src="'.$src.'"'.$extras.( ($alt != '') ? ']'.$alt.'[/swfobj]' : '] ');
			}

			return media_send_to_editor($html);
		}

		if ( !empty($_POST) ) {
			$return = media_upload_form_handler();

			if ( is_string($return) )
				return $return;
			if ( is_array($return) )
				$errors = $return;
		}

		if ( isset($_POST['save']) ) {
			$errors['upload_notice'] = __('Saved.');
		}

		if ( isset($_GET['tab']) && $_GET['tab'] == 'type_url' ) {
			return wp_iframe( 'media_upload_type_url_form', 'flash', $errors, $id );
		}

		return wp_iframe( 'media_upload_type_form', 'flash', $errors, $id );
	}
Example #15
0
function media_upload_gmedia()
{
    global $gmCore, $gmDB;
    add_action('admin_enqueue_scripts', 'gmedia_add_media_popup_enqueue_scripts');
    $action = $gmCore->_get('action');
    if (did_action('media_upload_gmedia_galleries')) {
        wp_iframe('gmedia_add_media_galleries');
    } elseif (did_action('media_upload_gmedia_terms')) {
        wp_iframe('gmedia_add_media_terms');
    } elseif (did_action('media_upload_gmedia_library')) {
        if ('upload' == $action && current_user_can('gmedia_upload')) {
            wp_iframe('gmedia_add_media_upload');
        } else {
            wp_iframe('gmedia_add_media_library');
        }
    }
    // Generate TinyMCE HTML output
    if (isset($_POST['gmedia_library_insert'])) {
        $id = $gmCore->_post('ID', 0);
        if ($gmedia = $gmDB->get_gmedia($id)) {
            $meta = $gmDB->get_metadata('gmedia', $gmedia->ID, '_metadata', true);
            $size = $gmCore->_post('size', 'web');
            $src = $gmCore->gm_get_media_image($gmedia, $size);
            $width = $meta[$size]['width'];
            $height = $meta[$size]['height'];
            $title = esc_attr($gmCore->_post('title', ''));
            $align = esc_attr($gmCore->_post('align', 'none'));
            $link = trim(esc_attr($gmCore->_post('link', '')));
            $caption = trim($gmCore->_post('description', ''));
            $html = "<img src='{$src}' width='{$width}' height='{$height}' alt='{$title}' title='{$title}' id='gmedia-image-{$id}' class='gmedia-singlepic align{$align}' />";
            if ($link) {
                $html = "<a href='{$link}'>{$html}</a>";
            }
            if ($caption) {
                $html = image_add_caption($html, false, $caption, $title, $align, $src, $size, $title);
            }
            ?>
            <script type="text/javascript">
                /* <![CDATA[ */
                var win = window.dialogArguments || opener || parent || top;
                jQuery('#__gm-uploader', win.document).css('display', 'none');
                /* ]]> */
            </script>
            <?php 
            // Return it to TinyMCE
            media_send_to_editor($html);
        }
    }
    if (isset($_POST['gmedia_gallery_insert'])) {
        $sc = $gmCore->_post('shortcode');
        ?>
        <script type="text/javascript">
            /* <![CDATA[ */
            var win = window.dialogArguments || opener || parent || top;
            jQuery('#__gm-uploader', win.document).css('display', 'none');
            /* ]]> */
        </script>
        <?php 
        // Return it to TinyMCE
        media_send_to_editor($sc);
    }
    if (isset($_POST['gmedia_term_insert'])) {
        $module_preset = $gmCore->_post('module_preset');
        $module = '';
        $preset = '';
        if (!empty($module_preset)) {
            if ($gmCore->is_digit($module_preset)) {
                $module_preset = $gmDB->get_term((int) $module_preset);
                $module = ' module=' . $module_preset->status;
                $preset = ' preset=' . $module_preset->term_id;
            } else {
                $module = ' module=' . $module_preset;
            }
        }
        $tax = $gmCore->_post('taxonomy');
        $term_id = $gmCore->_post('term_id');
        if ($tax && $term_id) {
            $tax = str_replace('gmedia_', '', $tax);
            $sc = "[gm {$tax}={$term_id}{$module}{$preset}]";
            ?>
            <script type="text/javascript">
                /* <![CDATA[ */
                var win = window.dialogArguments || opener || parent || top;
                jQuery('#__gm-uploader', win.document).css('display', 'none');
                /* ]]> */
            </script>
            <?php 
            // Return it to TinyMCE
            media_send_to_editor($sc);
        }
    }
}
Example #16
0
 /**
  * LazyestUploadTab::image_to_editor()
  * 
  * @param mixed $whathtml what to insert, shortcode
  * @return void
  */
 function image_to_editor($whathtml)
 {
     global $lg_gallery;
     $file = urldecode($_POST['lg_folder']);
     $single = urldecode($_POST['lg_image']);
     $folder = new LazyestFolder($file);
     $folder->open();
     $image = $folder->single_image($single, $_POST["image-size"] . 's');
     $onclick = $image->on_click('widget');
     $caption = isset($_POST["short_code_caption"]) ? $_POST["short_code_caption"] : '';
     $html = '';
     switch ($whathtml) {
         case 'shortcode':
             $caption = '' != $caption ? sprintf('caption="%s"', $caption) : $caption;
             $align = isset($_POST["image_align"]) ? sprintf('align="%s"', $_POST["image_align"]) : '';
             $display = sprintf('display="%s"', $_POST["image-size"]);
             $html .= sprintf('[lg_image folder="%s" image="%s" %s %s %s]', $file, $single, $caption, $align, $display);
             break;
     }
     return media_send_to_editor($html);
 }
Example #17
0
function webodf_media_send_to_editor($html, $send_id, $attachment)
{
    // if this POST did not came from our "special button", just call super()
    if ($_POST["send"][$send_id] != 'Insert WebODF Viewer') {
        return media_send_to_editor($html);
    }
    // place shortcode
    return "[webodf_viewer " . $attachment['webodf_document_url'] . "]";
}
Example #18
0
/**
 * {@internal Missing Short Description}}
 *
 * @since unknown
 *
 * @return unknown
 */
function media_upload_file()
{
    $errors = array();
    $id = 0;
    if (isset($_POST['html-upload']) && !empty($_FILES)) {
        // Upload File button was clicked
        $id = media_handle_upload('async-upload', $_REQUEST['post_id']);
        unset($_FILES);
        if (is_wp_error($id)) {
            $errors['upload_error'] = $id;
            $id = false;
        }
    }
    if (!empty($_POST['insertonlybutton'])) {
        $href = $_POST['insertonly']['href'];
        if (!empty($href) && !strpos($href, '://')) {
            $href = "http://{$href}";
        }
        $title = esc_attr($_POST['insertonly']['title']);
        if (empty($title)) {
            $title = basename($href);
        }
        if (!empty($title) && !empty($href)) {
            $html = "<a href='{$href}' >{$title}</a>";
        }
        $html = apply_filters('file_send_to_editor_url', $html, $href, $title);
        return media_send_to_editor($html);
    }
    if (!empty($_POST)) {
        $return = media_upload_form_handler();
        if (is_string($return)) {
            return $return;
        }
        if (is_array($return)) {
            $errors = $return;
        }
    }
    if (isset($_POST['save'])) {
        $errors['upload_notice'] = __('Saved.');
        return media_upload_gallery();
    }
    if (isset($_GET['tab']) && $_GET['tab'] == 'type_url') {
        return wp_iframe('media_upload_type_url_form', 'file', $errors, $id);
    }
    return wp_iframe('media_upload_type_form', 'file', $errors, $id);
}
Example #19
0
 function special_wordp_upload()
 {
     wp_enqueue_script('swfupload-all');
     wp_enqueue_script('swfupload-handlers');
     wp_enqueue_script('wysija-upload-handlers', WYSIJA_URL . "js/jquery/uploadHandlers.js");
     wp_enqueue_script('image-edit');
     wp_enqueue_script('set-post-thumbnail');
     wp_enqueue_style('imgareaselect');
     $errors = array();
     $id = 0;
     if (isset($_GET['flash'])) {
         $_GET['flash'] = 1;
     }
     if (isset($_POST['html-upload']) && !empty($_FILES)) {
         // Upload File button was clicked
         $id = media_handle_upload('async-upload', $_REQUEST['post_id']);
         unset($_FILES);
         if (is_wp_error($id)) {
             $errors['upload_error'] = $id;
             $id = false;
         }
     }
     if (!empty($_POST['insertonlybutton'])) {
         $href = $_POST['insertonly']['href'];
         if (!empty($href) && !strpos($href, '://')) {
             $href = "http://{$href}";
         }
         $title = esc_attr($_POST['insertonly']['title']);
         if (empty($title)) {
             $title = basename($href);
         }
         if (!empty($title) && !empty($href)) {
             $html = "<a href='" . esc_url($href) . "' >{$title}</a>";
         }
         $html = apply_filters('file_send_to_editor_url', $html, esc_url_raw($href), $title);
         return media_send_to_editor($html);
     }
     if (!empty($_POST)) {
         $return = media_upload_form_handler();
         if (is_string($return)) {
             return $return;
         }
         if (is_array($return)) {
             $errors = $return;
         }
     }
     if (isset($_POST['save'])) {
         $errors['upload_notice'] = __('Saved.', WYSIJA);
         return media_upload_gallery();
     }
     return wp_iframe(array($this->viewObj, 'popup_wp_upload'), $errors);
 }
Example #20
0
 function insert_images()
 {
     if (!isset($_POST['classy-insert']) || empty($_POST['attachments'])) {
         return;
     }
     check_admin_referer('media-form');
     $nonce = wp_create_nonce('rw_ajax_delete');
     $post_id = $_POST['post_id'];
     $id = $_POST['field_id'];
     // modify the insertion string
     $html = '';
     foreach ($_POST['attachments'] as $attachment_id => $attachment) {
         $attachment = stripslashes_deep($attachment);
         if (empty($attachment['selected']) || empty($attachment['url'])) {
             continue;
         }
         $li = "<li id='item_{$attachment_id}'>";
         $li .= "<img src='{$attachment['url']}' />";
         $li .= "<a title='" . __('Delete this image', 'classy') . "' class='classy-delete-file' href='#' rel='{$nonce}|{$post_id}|{$id}|{$attachment_id}'>" . __('Delete', 'classy') . "</a>";
         $li .= "<input type='hidden' name='{$id}[]' value='{$attachment_id}' />";
         $li .= "</li>";
         $html .= $li;
     }
     media_send_to_editor($html);
 }
// Include the necessary admin stuff.
require_once '../../../../wp-load.php';
require_once '../../../../wp-admin/includes/admin.php';
if (!current_user_can('administrator') && !current_user_can('editor') && !current_user_can('contributor')) {
    exit;
}
//global $wp_version;
define('MEDIA_MANAGER_35', version_compare($wp_version, '3.5', '>='));
require_once JWP6_PLUGIN_DIR . '/jwp6-class-plugin.php';
require_once JWP6_PLUGIN_DIR . '/jwp6-class-media.php';
require_once JWP6_PLUGIN_DIR . '/jwp6-class-shortcode.php';
$jwp6m = new JWP6_Media();
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    if ($_POST[JWP6 . 'mediaid'] || $_POST[JWP6 . 'file'] || $_POST[JWP6 . 'playlistid']) {
        $shortcode = new JWP6_Shortcode();
        media_send_to_editor($shortcode->shortcode());
        exit;
    } else {
        $no_video_error = true;
    }
}
?>
<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" href="<?php 
echo JWP6_PLUGIN_URL;
?>
/css/jquery.select2.css" type="text/css" media="screen" />
    if (!empty($attachment['url'])) {
        $url = $attachment['url'];
        if (strpos($url, 'attachment_id') || get_attachment_link($id) == $url) {
            $rel = ' rel="attachment wp-att-' . $id . '"';
        }
        $html = '<a href="' . esc_url($url) . '"' . $rel . '>' . $html . '</a>';
    }
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        $align = isset($attachment['align']) ? $attachment['align'] : 'none';
        $size = isset($attachment['image-size']) ? $attachment['image-size'] : 'medium';
        $alt = isset($attachment['image_alt']) ? $attachment['image_alt'] : '';
        $caption = isset($attachment['post_excerpt']) ? $attachment['post_excerpt'] : '';
        $title = '';
        // We no longer insert title tags into <img> tags, as they are redundant.
        $html = get_image_send_to_editor($id, $caption, $title, $align, $url, (bool) $rel, $size, $alt);
    } elseif ('video' === substr($post->post_mime_type, 0, 5) || 'audio' === substr($post->post_mime_type, 0, 5)) {
        global $wp_embed;
        $meta = get_post_meta($id, '_wp_attachment_metadata', true);
        $html = $wp_embed->shortcode($meta, $url);
    }
    /** This filter is documented in wp-admin/includes/media.php */
    $html = apply_filters('media_send_to_editor', $html, $id, $attachment);
    // replace wp-image-<id>, wp-att-<id> and attachment_<id>
    $html = preg_replace(array('#(caption id="attachment_)(\\d+")#', '#(wp-image-|wp-att-)(\\d+)#'), array(sprintf('${1}nsm_%s_${2}', esc_attr($nsm_blog_id)), sprintf('${1}nsm-%s-${2}', esc_attr($nsm_blog_id))), $html);
    if (isset($_POST['chromeless']) && $_POST['chromeless']) {
        // WP3.5+ media browser is identified by the 'chromeless' parameter
        exit($html);
    } else {
        return media_send_to_editor($html);
    }
}
/**
 * {@internal Missing Short Description}}
 *
 * @since 1.4.0
 *
 * @return unknown
 */
function hacklogra_upyun_media_upload_handler()
{
    global $is_iphone;
    $errors = array();
    $id = 0;
    if (isset($_GET['code']) && isset($_GET['message']) && isset($_GET['url']) && isset($_GET['time'])) {
        $id = hacklogra_upyun::handle_form_api_upload($_REQUEST['post_id'], $post_data = array());
        unset($_FILES);
        if (is_wp_error($id)) {
            $errors['upload_error'] = $id;
            $id = false;
        }
    }
    if (!empty($_POST['insertonlybutton'])) {
        $src = $_POST['src'];
        if (!empty($src) && !strpos($src, '://')) {
            $src = "http://{$src}";
        }
        if (isset($_POST['media_type']) && 'image' != $_POST['media_type']) {
            $title = esc_html(stripslashes($_POST['title']));
            if (empty($title)) {
                $title = esc_html(basename($src));
            }
            if ($title && $src) {
                $html = "<a href='" . esc_url($src) . "'>{$title}</a>";
            }
            $type = 'file';
            if (($ext = preg_replace('/^.+?\\.([^.]+)$/', '$1', $src)) && ($ext_type = wp_ext2type($ext)) && ('audio' == $ext_type || 'video' == $ext_type)) {
                $type = $ext_type;
            }
            $html = apply_filters($type . '_send_to_editor_url', $html, esc_url_raw($src), $title);
        } else {
            $align = '';
            $alt = esc_attr(stripslashes($_POST['alt']));
            if (isset($_POST['align'])) {
                $align = esc_attr(stripslashes($_POST['align']));
                $class = " class='align{$align}'";
            }
            if (!empty($src)) {
                $html = "<img src='" . esc_url($src) . "' alt='{$alt}'{$class} />";
            }
            $html = apply_filters('image_send_to_editor_url', $html, esc_url_raw($src), $alt, $align);
        }
        return media_send_to_editor($html);
    }
    if (!empty($_POST)) {
        $return = media_upload_form_handler();
        if (is_string($return)) {
            return $return;
        }
        if (is_array($return)) {
            $errors = $return;
        }
    }
    if (isset($_POST['save'])) {
        $errors['upload_notice'] = __('Saved.');
        return media_upload_gallery();
    }
    if (isset($_GET['tab']) && $_GET['tab'] == 'type_url') {
        $type = 'image';
        if (isset($_GET['type']) && in_array($_GET['type'], array('video', 'audio', 'file'))) {
            $type = $_GET['type'];
        }
        return wp_iframe('media_upload_type_url_form', $type, $errors, $id);
    }
    if ($is_iphone) {
        return wp_iframe('media_upload_type_url_form', 'image', $errors, $id);
    } else {
        return wp_iframe(array('hacklogra_upyun', 'media_upload_type_form_upyun'), 'file', $errors, $id);
    }
}
Example #24
0
function media_sfc_photos_form($errors)
{
    global $redir_tab, $type;
    $redir_tab = 'sfcphotos';
    media_upload_header();
    $post_id = intval($_REQUEST['post_id']);
    $user = sfc_cookie_parse();
    if (!isset($user['user_id'])) {
        ?>
<p><?php 
        _e("You don't appear to be logged into Facebook. Click the button below to login and grant photo access.", 'sfc');
        ?>
</p>
		<fb:login-button v="2" scope="offline_access,user_photos" onlogin="******"><?php 
        _e('Connect with Facebook', 'sfc');
        ?>
</fb:login-button><?php 
    }
    if (isset($_GET['send']) && !preg_match('/^[0-9]+$/i', $_GET['send'])) {
        // photo ids are bigints
        unset($_GET['send']);
    }
    if (isset($_GET['send'])) {
        $send_id = $_GET['send'];
        $photo = sfc_photo_get_photo($send_id, $user['code']);
        $photo = apply_filters('sfc_photo_insert', $photo);
        list($width, $height) = image_constrain_size_for_editor($photo['width'], $photo['height'], 'large');
        $alt = '';
        if (!empty($photo['name'])) {
            $alt = esc_attr($photo['name']);
        }
        $html = "<a href='{$photo['link']}'><img src='{$photo['source']}' alt='{$alt}' width='{$width}' height='{$height}' class='size-full fb-image-{$photo['id']}'/></a>";
        if (!empty($photo['name'])) {
            $html = "[caption id='fb_attachment_{$photo['id']}' width='{$width}' caption='{$alt}']" . $html . '[/caption]';
        }
        return media_send_to_editor($html);
    }
    if (!empty($_GET['album']) && !preg_match('/^[0-9]+$/i', $_GET['album'])) {
        // album ids are bigints
        unset($_GET['album']);
    }
    if (!empty($_GET['album'])) {
        // show an album
        $album = $_GET['album'];
        if (false === ($photos = get_transient('sfcphotos-' . $album))) {
            $photos = sfc_remote($album, 'photos', array('code' => $user['code'], 'timeout' => 60, 'limit' => 0));
            if ($photos === false) {
                ?>
<p><?php 
                _e('Facebook is being really, really slow and not responding to requests in a reasonable period of time. Try again later.', 'sfc');
                ?>
</p><?php 
                return;
            }
            // cache the data because Facebook's Graph API is slow as hell
            if (!empty($photos)) {
                set_transient('sfcphotos-' . $album, $photos, 6 * 60 * 60);
            }
            // 6 hours
        }
        if (empty($photos['data'])) {
            ?>
<p><?php 
            _e('This album appears to be empty', 'sfc');
            ?>
</p><?php 
            $link = admin_url("media-upload.php?post_id={$post_id}&type={$type}&tab={$redir_tab}");
            echo "<p><a href='{$link}'>" . __('Go Back', 'sfc') . "</a></p>";
            return;
        }
        $photos = $photos['data'];
        $link = admin_url("media-upload.php?post_id={$post_id}&type={$type}&tab={$redir_tab}");
        echo "<p><a href='{$link}'>" . __('Go Back', 'sfc') . "</a></p>";
        echo '<table><tr>';
        $i = 1;
        foreach ($photos as $photo) {
            echo '<td>';
            $link = admin_url("media-upload.php?post_id={$post_id}&type={$type}&tab={$redir_tab}&album={$album['id']}&send={$photo['id']}");
            echo "<p><a href='{$link}'><img src='{$photo['picture']}' /></a></p>";
            echo '</td>';
            if ($i % 3 == 0) {
                echo '</tr><tr>';
            }
            $i++;
        }
        echo '</tr></table>';
    } else {
        if (false === ($albums = get_transient('sfcphotos-' . $user['user_id']))) {
            $albums = sfc_remote($user['user_id'], 'albums', array('code' => $user['code'], 'timeout' => 60, 'limit' => 0));
            if ($albums === false) {
                ?>
<p><?php 
                _e('Facebook is being really, really slow and not responding to requests in a reasonable period of time. Try again later.', 'sfc');
                ?>
</p><?php 
                return;
            }
            // cache the data because Facebook's Graph API is slow as hell
            if (!empty($albums['data'])) {
                set_transient('sfcphotos-' . $user['user_id'], $albums, 6 * 60 * 60);
            }
            // 6 hours
        }
        if (empty($albums['data'])) {
            ?>
<p><?php 
            _e('Either you have no photo albums on Facebook, or you have not granted the site permission to access them. Either way, click the button below to login and grant access.', 'sfc');
            ?>
</p>
			<fb:login-button v="2" scope="offline_access,user_photos" onlogin="******"><?php 
            _e('Connect with Facebook', 'sfc');
            ?>
</fb:login-button><?php 
        } else {
            $albums = $albums['data'];
            echo '<table><tr>';
            $i = 1;
            foreach ($albums as $album) {
                echo '<td>';
                $link = admin_url("media-upload.php?post_id={$post_id}&type={$type}&tab={$redir_tab}&album={$album['id']}");
                // retrieve the cover image for the album
                if (false !== ($photo = sfc_photo_get_photo($album['cover_photo'], $user['code']))) {
                    echo "<p><a href='{$link}'><img src='{$photo['picture']}' /></a></p>";
                } else {
                    // TODO cover not available
                }
                echo "<p><a href='{$link}'>{$album['name']}</a></p>";
                echo '</td>';
                if ($i % 3 == 0) {
                    echo '</tr><tr>';
                }
                $i++;
            }
            echo '</tr></table>';
        }
    }
}
Example #25
0
function network_shared_media_media_upload()
{
    global $blog_id, $post;
    if (isset($_POST['send'])) {
        $nsm_blog_id = (int) $_GET['blog_id'];
        reset($_POST['send']);
        $nsm_send_id = (int) key($_POST['send']);
    }
    /* copied from wp-admin/inculdes/ajax-actions.php wp_ajax_send_attachment_to_editor() */
    if (isset($nsm_blog_id) && isset($nsm_send_id)) {
        switch_to_blog($nsm_blog_id);
        if (!current_user_can('upload_files')) {
            $current_blog_name = get_bloginfo('name');
            restore_current_blog();
            wp_die(__('You do not have permission to upload files to site: ') . $current_blog_name);
        }
        $attachment = wp_unslash($_POST['attachments'][$nsm_send_id]);
        $id = $nsm_send_id;
        if (!($post = get_post($id))) {
            wp_send_json_error();
        }
        if ('attachment' != $post->post_type) {
            wp_send_json_error();
        }
        $rel = $url = '';
        $html = $title = isset($attachment['post_title']) ? $attachment['post_title'] : '';
        if (!empty($attachment['url'])) {
            $url = $attachment['url'];
            if (strpos($url, 'attachment_id') || get_attachment_link($id) == $url) {
                $rel = ' rel="attachment wp-att-' . $id . '"';
            }
            $html = '<a href="' . esc_url($url) . '"' . $rel . '>' . $html . '</a>';
        }
        if ('image' === substr($post->post_mime_type, 0, 5)) {
            $align = isset($attachment['align']) ? $attachment['align'] : 'none';
            $size = isset($attachment['image-size']) ? $attachment['image-size'] : 'medium';
            $alt = isset($attachment['image_alt']) ? $attachment['image_alt'] : '';
            $caption = isset($attachment['post_excerpt']) ? $attachment['post_excerpt'] : '';
            $title = '';
            // We no longer insert title tags into <img> tags, as they are redundant.
            $html = get_image_send_to_editor($id, $caption, $title, $align, $url, (bool) $rel, $size, $alt);
        } elseif ('video' === substr($post->post_mime_type, 0, 5) || 'audio' === substr($post->post_mime_type, 0, 5)) {
            global $wp_embed;
            $meta = get_post_meta($id, '_wp_attachment_metadata', true);
            $html = $wp_embed->shortcode($meta, $url);
        }
        /** This filter is documented in wp-admin/includes/media.php */
        $html = apply_filters('media_send_to_editor', $html, $id, $attachment);
        // replace wp-image-<id>, wp-att-<id> and attachment_<id>
        $html = preg_replace(array('#(caption id="attachment_)(\\d+")#', '#(wp-image-|wp-att-)(\\d+)#'), array(sprintf('${1}nsm_%s_${2}', esc_attr($nsm_blog_id)), sprintf('${1}nsm-%s-${2}', esc_attr($nsm_blog_id))), $html);
        if (isset($_POST['chromeless']) && $_POST['chromeless']) {
            // WP3.5+ media browser is identified by the 'chromeless' parameter
            exit($html);
        } else {
            return media_send_to_editor($html);
        }
    }
}
 /**
  * Process images added to meta field.
  *
  * Modified from Faster Image Insert plugin.
  *
  * @return void
  * @author Cory Crowley
  */
 public function insert_images()
 {
     // If post variables are empty, return.
     if (!isset($_POST['at-insert']) || empty($_POST['attachments'])) {
         return;
     }
     // Security Check
     check_admin_referer('media-form');
     // Create Security Nonce
     $nonce = wp_create_nonce('at_ajax_delete');
     // Get Post Id and Field Id
     $term_id = $_POST['post_id'];
     $id = $_POST['field_id'];
     // Modify the insertion string
     $html = '';
     foreach ($_POST['attachments'] as $attachment_id => $attachment) {
         // Strip Slashes
         $attachment = stripslashes_deep($attachment);
         // If not selected or url is empty, continue in loop.
         if (empty($attachment['selected']) || empty($attachment['url'])) {
             continue;
         }
         $li = "<li id='item_{$attachment_id}'>";
         $li .= "<img src='{$attachment['url']}' alt='image_{$attachment_id}' />";
         //$li 	.= "<a title='" . __( 'Delete this image' ) . "' class='at-delete-file' href='#' rel='{$nonce}|{$term_id}|{$id}|{$attachment_id}'>" . __( 'Delete' ) . "</a>";
         $li .= "<a title='" . __('Remove this image', 'geodirectory') . "' class='at-delete-file' href='#' rel='{$nonce}|{$term_id}|{$id}|{$attachment_id}'><img src='" . $this->SelfPath . "/images/delete-16.png' alt='" . __('Remove', 'geodirectory') . "' /></a>";
         $li .= "<input type='hidden' name='{$id}[]' value='{$attachment_id}' />";
         $li .= "</li>";
         $html .= $li;
     }
     // End For Each
     return media_send_to_editor($html);
 }
Example #27
0
/**
 * 
 * Post / Page Video insertion functionality for the media manager
 * 
 */
function s3video_video_media_manager()
{
    $pluginSettings = s3_video_check_plugin_settings();
    $existingVideos = s3_video_get_all_existing_video($pluginSettings);
    if (isset($_POST['insertVideoName']) && !empty($_POST['insertVideoName'])) {
        $insertHtml = "[S3_embed_video file='" . $_POST['insertVideoName'] . "']";
        media_send_to_editor($insertHtml);
        die;
    }
    require_once WP_PLUGIN_DIR . '/s3-video/views/video-management/media_manager_insert_video.php';
}
Example #28
0
function media_upload_mediatags()
{
    if (isset($_POST['send'])) {
        // Return it to TinyMCE
        return media_send_to_editor($html);
    }
    $errors = null;
    return wp_iframe('media_upload_mediatags_form', $errors);
}
Example #29
0
/**
 * {@internal Missing Short Description}}
 *
 * @since 2.5.0
 *
 * @return mixed
 */
function wp_media_upload_handler()
{
    $errors = array();
    $id = 0;
    if (isset($_POST['html-upload']) && !empty($_FILES)) {
        check_admin_referer('media-form');
        // Upload File button was clicked
        $id = media_handle_upload('async-upload', $_REQUEST['post_id']);
        unset($_FILES);
        if (is_wp_error($id)) {
            $errors['upload_error'] = $id;
            $id = false;
        }
    }
    if (!empty($_POST['insertonlybutton'])) {
        $src = $_POST['src'];
        if (!empty($src) && !strpos($src, '://')) {
            $src = "http://{$src}";
        }
        if (isset($_POST['media_type']) && 'image' != $_POST['media_type']) {
            $title = esc_html(wp_unslash($_POST['title']));
            if (empty($title)) {
                $title = esc_html(basename($src));
            }
            if ($title && $src) {
                $html = "<a href='" . esc_url($src) . "'>{$title}</a>";
            }
            $type = 'file';
            if (($ext = preg_replace('/^.+?\\.([^.]+)$/', '$1', $src)) && ($ext_type = wp_ext2type($ext)) && ('audio' == $ext_type || 'video' == $ext_type)) {
                $type = $ext_type;
            }
            /**
             * Filter the URL sent to the editor for a specific media type.
             *
             * The dynamic portion of the hook name, $type, refers to the type
             * of media being sent.
             *
             * @since 3.3.0
             *
             * @param string $html  HTML markup sent to the editor.
             * @param string $src   Media source URL.
             * @param string $title Media title.
             */
            $html = apply_filters($type . '_send_to_editor_url', $html, esc_url_raw($src), $title);
        } else {
            $align = '';
            $alt = esc_attr(wp_unslash($_POST['alt']));
            if (isset($_POST['align'])) {
                $align = esc_attr(wp_unslash($_POST['align']));
                $class = " class='align{$align}'";
            }
            if (!empty($src)) {
                $html = "<img src='" . esc_url($src) . "' alt='{$alt}'{$class} />";
            }
            /**
             * Filter the image URL sent to the editor.
             *
             * @since 2.8.0
             *
             * @param string $html  HTML markup sent to the editor for an image.
             * @param string $src   Image source URL.
             * @param string $alt   Image alternate, or alt, text.
             * @param string $align The image alignment. Default 'alignnone'. Possible values include
             *                      'alignleft', 'aligncenter', 'alignright', 'alignnone'.
             */
            $html = apply_filters('image_send_to_editor_url', $html, esc_url_raw($src), $alt, $align);
        }
        return media_send_to_editor($html);
    }
    if (isset($_POST['save'])) {
        $errors['upload_notice'] = __('Saved.');
        return media_upload_gallery();
    } elseif (!empty($_POST)) {
        $return = media_upload_form_handler();
        if (is_string($return)) {
            return $return;
        }
        if (is_array($return)) {
            $errors = $return;
        }
    }
    if (isset($_GET['tab']) && $_GET['tab'] == 'type_url') {
        $type = 'image';
        if (isset($_GET['type']) && in_array($_GET['type'], array('video', 'audio', 'file'))) {
            $type = $_GET['type'];
        }
        return wp_iframe('media_upload_type_url_form', $type, $errors, $id);
    }
    return wp_iframe('media_upload_type_form', 'image', $errors, $id);
}
function insert_new_scribd_into_post()
{
    //get_currentuserinfo();
    $file = $_POST['datafile'];
    $lightbox = $_POST['lightbox'];
    $linked_text = $_POST['linked_text'];
    $caption = $_POST['caption'];
    //$author = $current_user->display_name;
    $lightbox_width = $_POST['lightbox_width'];
    $lightbox_height = $_POST['lightbox_height'];
    //upload file to Wordpress
    $upload_dir = wp_upload_dir();
    $target_path = $upload_dir['path'];
    $target_path = $target_path . '/' . basename($_FILES['datafile']['name']);
    if (move_uploaded_file($_FILES['datafile']['tmp_name'], $target_path)) {
        //echo ("File was successfully uploaded\n");
    } else {
        echo "There was an error uploading the file. Please try again.\n";
    }
    //get current user id
    global $current_user;
    get_currentuserinfo();
    require_once 'classes/scribd.php';
    $scribd_api_key = get_option('scribd_api_key');
    $scribd_secret = get_option('scribd_secret');
    $my_user_id = $current_user->user_login;
    //creates sub-accounts in the Scribd account based on WP username
    $scribd = new Scribd($scribd_api_key, $scribd_secret);
    $scribd->my_user_id = $my_user_id;
    $file = $target_path;
    $doc_type = $_POST['doc_type'];
    $access = 'private';
    $rev_id = null;
    if ($data = $scribd->upload($file, $doc_type, $access, $rev_id)) {
        //echo ("Put to Scribd successful\n");
    } else {
        echo "Put to Scribd failed\n";
    }
    // returns Array ( [doc_id] => 1026598 [access_key] => key-23nvikunhtextwmdjm2i )
    $doc_id = $data[doc_id];
    $access_key = $data[access_key];
    if ($lightbox_height == null) {
        $lightbox_height = 600;
    }
    if ($lightbox_width == null) {
        $lightbox_width = 700;
    }
    $html = '[scribd doc_id="' . $doc_id . '" access_key="' . $access_key . '" linked_text="' . $linked_text . '" lightbox_width="' . $lightbox_width . '" lightbox_height="' . $lightbox_height . '" lightbox="' . $lightbox . '" caption="' . $caption . '"]';
    $html = apply_filters('media_send_to_editor', $html, $send_id, $attachment);
    return media_send_to_editor($html);
}