本文整理汇总了PHP中media_send_to_editor函数的典型用法代码示例。如果您正苦于以下问题:PHP media_send_to_editor函数的具体用法?PHP media_send_to_editor怎么用?PHP media_send_to_editor使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了media_send_to_editor函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send_to_editor
/**
* 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;
}
示例2: media_upload_flag
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');
}
示例3: wpgmappity_upload
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);
}
示例4: insert_doc_into_post
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);
}
示例5: s3video_playlist_media_manager
/**
*
* 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';
}
示例6: media_upload_nextgen
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);
}
示例7: render_media_embed_playlist_tab
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);
}
示例8: send_to_editor
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;
}
示例9: media_upload_crystal_form_handler
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');
}
示例10: s2sfu_media_upload_handler
/**
* 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);
}
示例11: media_upload_nextgen
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);
}
示例12: media_upload_file
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 );
}
示例13: wp_media_upload_handler
/**
* {@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);
}
示例14: media_upload_flash
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 );
}
示例15: media_upload_gmedia
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);
}
}
}