当前位置: 首页>>代码示例>>PHP>>正文


PHP media_upload_gallery函数代码示例

本文整理汇总了PHP中media_upload_gallery函数的典型用法代码示例。如果您正苦于以下问题:PHP media_upload_gallery函数的具体用法?PHP media_upload_gallery怎么用?PHP media_upload_gallery使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了media_upload_gallery函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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;
            }
            /**
             * 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);
}
开发者ID:HaraShun,项目名称:WordPress,代码行数:97,代码来源:media.php

示例2: media_upload_file

/**
 * {@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);
}
开发者ID:Alenjandro,项目名称:data-my-share,代码行数:53,代码来源:media.php

示例3: 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 );
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:39,代码来源:media.php

示例4: 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);
}
开发者ID:jcsilkey,项目名称:CodeReviewSecurityRepo,代码行数:75,代码来源:media.php

示例5: special_wordp_upload

 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);
 }
开发者ID:rotoballer,项目名称:emily,代码行数:52,代码来源:campaigns.php

示例6: hacklogra_upyun_media_upload_handler

/**
 * {@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);
    }
}
开发者ID:midi214,项目名称:hacklog-remote-attachment-upyun,代码行数:78,代码来源:upload.php


注:本文中的media_upload_gallery函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。