/** * Main tab handler * * @param noting. * @return nothing. * * Note that wp_iframe() will add the css for the "media" page when the callback * function begins with "media". **/ function media_upload_pac_pickapictab() { // Two things can happen here, either we need to show the first page after the search button has been hit // or we need to display the paginated results for previous searches. if (isset($_POST['pac_pickapic_search_term']) && isset($_POST['pac_pickapic_results_per_page']) || isset($_GET['pac_pickapic_search_term']) && isset($_GET['pac_pickapic_results_per_page']) && isset($_GET['paged']) && !isset($_POST['pac_pickapic_choose'])) { // Displays the search results $search_term = sanitize_text_field($_REQUEST['pac_pickapic_search_term'], ''); $results = absint($_REQUEST['pac_pickapic_results_per_page']); $paged = 0; if (isset($_REQUEST['paged'])) { $paged = absint($_REQUEST['paged']); } wp_iframe('media_pac_pickapic_search_results', $search_term, $results, $paged); return; } else { if (isset($_POST['pac_pickapic_choose'])) { // A picture has been selected so we must download it from flickr and show it to the user. //TODO: Implement better error handling check_admin_referer('pac_pickapic_nonce', 'pac_pickapic_nonce_field'); //Show the selected image using get_media_item wp_iframe('media_pac_pickapic_final_form'); return; } else { if (isset($_POST['send'])) { // Check the final form arguments generated by get_media_item() function // and if they are ok the image will be inserted to the editor media_upload_form_handler(); } } } wp_iframe('media_pac_pickapic_search'); }
function mediaUpload() { $errors = array(); if (!empty($_POST)) { $return = media_upload_form_handler(); if (is_string($return)) { return $return; } if (is_array($return)) { $errors = $return; } } wp_iframe(array($this, 'mediaForm'), $errors); }
function sp_ev_media_upload_external_videos() { $errors = array(); if (!empty($_POST)) { $return = media_upload_form_handler(); if (is_string($return)) { return $return; } if (is_array($return)) { $errors = $return; } } return wp_iframe('media_upload_external_videos_form', $errors); }
function media_upload_gallery() { $errors = array(); if (!empty($_POST)) { $return = media_upload_form_handler(); if (is_string($return)) { return $return; } if (is_array($return)) { $errors = $return; } } wp_enqueue_script('admin-gallery'); return wp_iframe(array(&$this, 'media_upload_gallery_form'), $errors); }
function dt_a_portfolio_mu() { $errors = array(); if (!empty($_POST)) { $return = media_upload_form_handler(); if (is_string($return)) { return $return; } if (is_array($return)) { $errors = $return; } } wp_enqueue_style('media'); wp_enqueue_script('admin-gallery'); return wp_iframe('dt_portfolio_media_form', $errors); }
public static function render_media_external_tab() { $errors = null; if (!empty($_POST)) { $return = media_upload_form_handler(); if (is_string($return)) { return $return; } if (is_array($return)) { $errors = $return; } } wp_enqueue_style('media'); require_once dirname(__FILE__) . "/jwp6-media-external.php"; return wp_iframe("jwp6_media_external_tab", $errors); //wp_redirect(JWP6_PLUGIN_URL . 'jwp6-media-external.php'); //exit(); }
function select_images_page($post_type, $options) { // remove browser upload option remove_all_actions('post-plupload-upload-ui'); if (!current_user_can('upload_files')) { wp_die(__('You do not have permission to upload files.', THEME_ADMIN_TD)); } wp_enqueue_script('plupload-handlers'); wp_enqueue_script('image-edit'); wp_enqueue_script('set-post-thumbnail'); wp_enqueue_style('imgareaselect'); @header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset')); // IDs should be integers $ID = isset($ID) ? (int) $ID : 0; $post_id = isset($post_id) ? (int) $post_id : 0; // Require an ID for the edit screen if (isset($action) && $action == 'edit' && !$ID) { wp_die(__('You are not allowed to be here', THEME_ADMIN_TD)); } $errors = array(); 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 (isset($_GET['upload-page-form'])) { $errors = array_merge($errors, (array) media_upload_form_handler()); $location = 'upload.php'; if ($errors) { $location .= '?message=3'; } wp_redirect(admin_url($location)); exit; } $title = __('Upload New Media', THEME_ADMIN_TD); $parent_file = 'upload.php'; require_once './admin-header.php'; $form_class = 'media-upload-form type-form validate'; if (get_user_setting('uploader')) { $form_class .= ' html-uploader'; } ?> <div class="wrap"> <?php screen_icon(); ?> <h2><?php echo esc_html($title); ?> </h2> <form enctype="multipart/form-data" method="post" action="<?php echo admin_url('edit.php?post_type=' . $post_type . '&page=' . $post_type . '-quick'); ?> " class="<?php echo $form_class; ?> " id="file-form"> <?php media_upload_form(); ?> <script type="text/javascript"> jQuery(function($){ var preloaded = $(".media-item.preloaded"); if ( preloaded.length > 0 ) { preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');}); } updateMediaForm(); post_id = 0; shortform = 1; }); </script> <input type="hidden" name="post_id" id="post_id" value="0" /> <input type="hidden" name="sub_page" value="create_posts" /> <?php wp_nonce_field('media-form'); ?> <div id="media-items" class="hide-if-no-js"></div> <?php submit_button(__('Use these images', THEME_ADMIN_TD), 'button savebutton', 'save'); ?> </form> </div> <?php }
function sb_media_upload_suggested() { $errors = array(); if (!empty($_POST)) { $return = media_upload_form_handler(); if (is_string($return)) { return $return; } if (is_array($return)) { $errors = $return; } } return wp_iframe('sb_media_upload_suggested_form', $errors); }
/** * Handles the 'Download From URL' tab * * This will close the TB Frame if the photo is 'inserted' (saved), or download * the image from an external source if 'submitted'. If the image comes from Flickr, * it will also attempt to obtain more details about it through the Flickr API. * * @since 1.0.8 * This works different from the WordPress 'From URL' tab, is it will * download the image locally and place it directly in the Media Library */ public function onBgmUrl() { $errors = false; $attachment_id = isset($_POST['attachment_id']) ? $_POST['attachment_id'] : 0; // Save any changes made, then close the TB Frame if successful if (isset($_POST['insert'])) { $errors = media_upload_form_handler(); if (!$errors) { echo '<html><head><script type="text/javascript">/* <![CDATA[ */ var win=window.dialogArguments||opener||parent||top; win.tb_remove(); /* ]]> */</script></head><body></body></html>'; die; } } // Attempt to download and save the image if (isset($_POST['submit']) && current_user_can('upload_files')) { check_admin_referer('media-form'); // die() if invalid NONCE $gallery_id = (int) $_POST['post_id']; $image_url = trim($_POST['url']); if (!empty($image_url)) { $title = ''; $description = ''; // Check if it's a Flickr URL if (preg_match('#^http[s]?://farm\\d{1,3}\\.(?:staticflickr|static\\.flickr).com\\/\\d+\\/(\\d+)_.+\\.(?:jpg|png|gif)$#i', $image_url, $matches)) { $flickr_photo_id = $matches[1]; // Obtain some more details about the image from Flickr $flickr = new FlickrApi($this->owner); if ($flickr->isValid($info = $flickr->call('photos.getInfo', array('photo_id' => $flickr_photo_id))) && isset($info['photo'])) { $info = $info['photo']; $title = $info['title']['_content']; $license_info = $flickr->getLicenseById($info['license']); $description = sprintf(__('<p>%s</p><p>By: <a href="http://www.flickr.com/photos/%s/%s/">%s</a> (%s)</p>', $this->owner->getName()), $info['description']['_content'], $info['owner']['nsid'], $info['id'], $info['owner']['username'], !empty($license_info['url']) ? sprintf('<a href="%s">%s</a>', $license_info['url'], $license_info['name']) : $license_info['name']); } unset($flickr); } $attachment_id = Images::importImage($image_url, $gallery_id, $title, $description); if (!$attachment_id) { $errors = __('Unable to import image at specified URL', $this->owner->getName()); } } } // Display the form wp_enqueue_style('media'); // Either this, or give callback function a funky 'media_' prefix >_< return wp_iframe(array($this, 'onBgmUrlForm'), $errors, $attachment_id); }
* @package WordPress * @subpackage Administration */ /** Load WordPress Administration Bootstrap */ require_once './admin.php'; $parent_file = 'upload.php'; $submenu_file = 'upload.php'; wp_reset_vars(array('action')); switch ($action) { case 'editattachment': $attachment_id = (int) $_POST['attachment_id']; check_admin_referer('media-form'); if (!current_user_can('edit_post', $attachment_id)) { wp_die(__('You are not allowed to edit this attachment.')); } $errors = media_upload_form_handler(); if (empty($errors)) { $location = 'media.php'; if ($referer = wp_get_original_referer()) { if (false !== strpos($referer, 'upload.php') || url_to_postid($referer) == $attachment_id) { $location = $referer; } } if (false !== strpos($location, 'upload.php')) { $location = remove_query_arg('message', $location); $location = add_query_arg('posted', $attachment_id, $location); } elseif (false !== strpos($location, 'media.php')) { $location = add_query_arg('message', 'updated', $location); } wp_redirect($location); exit;
/** * Handler for rendering the JW Playlist Manager tab. * @return string The HTML to render the tab. */ function jwplayer_render() { $errors = null; if (!empty($_POST)) { $return = media_upload_form_handler(); if (is_string($return)) { return $return; } if (is_array($return)) { $errors = $return; } } wp_enqueue_script('admin-gallery'); require_once dirname(__FILE__) . "/EmbedManager.php"; return wp_iframe("media_jwplayer_insert_form", $errors); }
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); }
/** * {@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); } }
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 ); }
if (isset($action) && $action == 'edit' && !$ID) { wp_die(__("You are not allowed to be here")); } if (isset($_GET['inline'])) { $errors = array(); 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 (isset($_GET['upload-page-form'])) { $errors = array_merge($errors, (array) media_upload_form_handler()); $location = 'upload.php'; if ($errors) { $location .= '?message=3'; } wp_redirect(admin_url($location)); } $title = __('Upload New Media'); $parent_file = 'upload.php'; require_once './admin-header.php'; ?> <div class="wrap"> <?php screen_icon(); ?> <h2><?php
static function image_insert() { add_filter('media_send_to_editor', array(__CLASS__, '_capture_html'), 99); media_upload_form_handler(); }
public function s3_library_iframe() { if (!empty($_POST)) { $return = media_upload_form_handler(); if (is_string($return)) { return $return; } } wp_iframe(array($this, 's3_library_tab')); }
/** * {@internal Missing Short Description}} * * @since 2.5.0 * * @return unknown */ function media_upload_library() { $errors = array(); if (!empty($_POST)) { $return = media_upload_form_handler(); if (is_string($return)) { return $return; } if (is_array($return)) { $errors = $return; } } return wp_iframe('media_upload_library_form', $errors); }
/** Edit Image iframe **/ public static function showIframeEditImage(Main $owner) { if (!defined('IFRAME_REQUEST')) { define('IFRAME_REQUEST', true); } if (!isset($_GET['id'])) { die; } // How did you get here? Hmm! $id = (int) $_GET['id']; $post = get_post($id); $vars = array(); $did_save = false; // Handle save request if (isset($_REQUEST['save'])) { $errors = media_upload_form_handler(); $did_save = true; } // Queue additional scripts and styles wp_enqueue_script('image-edit'); wp_enqueue_style('media'); // Send iframe header iframe_header(); if ($id == 0 || $post == false || $post->post_type != 'attachment' || $post->post_status == 'trash') { // Invalid ID or item was deleted $vars = array('deleted' => true); } else { $vars = array('did_save' => $did_save, 'has_error' => isset($errors[$id]), 'nonce' => wp_nonce_field('media-form', '_wpnonce', false, false), 'media_item' => get_media_item($id, array('toggle' => false, 'show_title' => false, 'send' => false, 'delete' => false, 'errors' => isset($errors[$id]) ? $errors[$id] : null)), 'submit' => get_submit_button(__('Save all changes'), 'button', 'save', false)); } // Render template $owner->template->display('gallery_edit_image.html.twig', $vars); // Send iframe footer and then 'die'. iframe_footer(); die; }