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


PHP get_allowed_mime_types函数代码示例

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


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

示例1: __construct

 function __construct()
 {
     add_action('init', array($this, 'action_init'));
     $this->allowed_mime_types = function_exists('wp_get_mime_types') ? wp_get_mime_types() : get_allowed_mime_types();
     $this->has_correct_role = BYT_Theme_Utils::check_user_role(BOOKYOURTRAVEL_FRONTEND_SUBMIT_ROLE, $this->get_current_user_id());
     $this->_html_helper = new Html_Helper();
 }
开发者ID:JDjimenezdelgado,项目名称:old-mmexperience,代码行数:7,代码来源:frontend-submit.php

示例2: check_upload

 function check_upload($errors)
 {
     $mime = get_allowed_mime_types();
     $size_limit = (int) wp_convert_hr_to_bytes(fep_get_option('attachment_size', '4MB'));
     $fields = (int) fep_get_option('attachment_no', 4);
     for ($i = 0; $i < $fields; $i++) {
         $tmp_name = isset($_FILES['fep_upload']['tmp_name'][$i]) ? basename($_FILES['fep_upload']['tmp_name'][$i]) : '';
         $file_name = isset($_FILES['fep_upload']['name'][$i]) ? basename($_FILES['fep_upload']['name'][$i]) : '';
         //if file is uploaded
         if ($tmp_name) {
             $attach_type = wp_check_filetype($file_name);
             $attach_size = $_FILES['fep_upload']['size'][$i];
             //check file size
             if ($attach_size > $size_limit) {
                 $errors->add('AttachmentSize', sprintf(__("Attachment (%s) file is too big", 'fep'), $file_name));
             }
             //check file type
             if (!in_array($attach_type['type'], $mime)) {
                 $errors->add('AttachmentType', sprintf(__("Invalid attachment file type.Allowed Types are (%s)", 'fep'), implode(',', $mime)));
             }
         }
         // if $filename
     }
     // endfor
     //return $errors;
 }
开发者ID:shamim2883,项目名称:wp-front-end-pm,代码行数:26,代码来源:fep-attachment-class.php

示例3: __construct

 function __construct()
 {
     global $sc_theme_globals;
     $this->sc_theme_globals = $sc_theme_globals;
     add_action('init', array($this, 'action_init'));
     $this->allowed_mime_types = function_exists('wp_get_mime_types') ? wp_get_mime_types() : get_allowed_mime_types();
     $this->_html_helper = new Html_Helper();
 }
开发者ID:boutitinizar,项目名称:bati-men,代码行数:8,代码来源:frontend-submit.php

示例4: pugpig_adbundles_admin_notice

function pugpig_adbundles_admin_notice()
{
    $allowed_types = get_site_option('upload_filetypes');
    if (!array_key_exists('zip', get_allowed_mime_types())) {
        ?>
    <div class="update-nag"><p><?php 
        _e('Pugpig - Ad Bundles require zips to be in the allowed upload types.');
        ?>
</p></div>
  <?php 
    }
}
开发者ID:shortlist-digital,项目名称:agreable-pugpig-plugin,代码行数:12,代码来源:pugpig_ad_bundles.php

示例5: allowed_file_types

 function allowed_file_types()
 {
     $allowed_file_types = array();
     // http://codex.wordpress.org/Uploading_Files
     $mime_types = get_allowed_mime_types();
     foreach ($mime_types as $type => $mime_type) {
         $extras = explode('|', $type);
         foreach ($extras as $extra) {
             $allowed_file_types[] = $extra;
         }
     }
     return $allowed_file_types;
 }
开发者ID:egill,项目名称:jetpack,代码行数:13,代码来源:class.json-api-site-jetpack.php

示例6: get_custom_uploader_allowed_types

 /**
  * Lista os formatos permitidos dentro do custom uploader
  * 
  * @return array $allowed_mime_types Os tipos permitidos
  */
 function get_custom_uploader_allowed_types($mime_types = array())
 {
     if (empty($mime_types)) {
         $mime_types = get_allowed_mime_types();
     }
     $allowed_mime_types = $mime_types;
     foreach ($mime_types as $key => $value) {
         if (wp_match_mime_types('image, audio, video', $value)) {
             unset($allowed_mime_types[$key]);
         }
     }
     return $allowed_mime_types;
 }
开发者ID:aspto,项目名称:wordpress-themes,代码行数:18,代码来源:custom-uploader.php

示例7: display_ext

function display_ext()
{
    echo '<input  type="text" name="ext" id="ext" value="' . get_option('ext') . '" size="30" style="width:85%" />';
    echo '<p><small>' . __('Entrez les extensions de fichier que vous souhaitez ajouter sans le point (séparé par un espace, ex: "mp3 doc gif")') . '</small></p>';
    echo '<p><strong>' . __('Liste des extensions déjà disponibles : ');
    echo '</strong>';
    $mimes = get_allowed_mime_types();
    $type_aff = array();
    foreach ($mimes as $ext => $mime) {
        $type_aff[] = str_replace('|', ', ', $ext);
    }
    echo implode(', ', $type_aff) . '</p>';
}
开发者ID:arthurlacoste,项目名称:add-more-files-extensions,代码行数:13,代码来源:amfe.php

示例8: wppb_upload_file_type

 function wppb_upload_file_type($file)
 {
     if (isset($_POST['wppb_upload']) && $_POST['wppb_upload'] == 'true') {
         if (isset($_POST['meta_name']) && !empty($_POST['meta_name'])) {
             $meta_name = $_POST['meta_name'];
             /*let's get the field details so we can see if we have any file restrictions */
             $all_fields = get_option('wppb_manage_fields');
             if (!empty($all_fields)) {
                 foreach ($all_fields as $field) {
                     if ($field['meta-name'] == $meta_name) {
                         $allowed_upload_extensions = '';
                         if ($field['field'] == 'Upload' && !empty($field['allowed-upload-extensions'])) {
                             $allowed_upload_extensions = $field['allowed-upload-extensions'];
                         }
                         if ($field['field'] == 'Avatar' && !empty($field['allowed-image-extensions'])) {
                             if (trim($field['allowed-image-extensions']) == '.*') {
                                 $allowed_upload_extensions = '.jpg,.jpeg,.gif,.png';
                             } else {
                                 $allowed_upload_extensions = $field['allowed-image-extensions'];
                             }
                         }
                         $ext = strtolower(substr(strrchr($file['name'], '.'), 1));
                         if (!empty($allowed_upload_extensions) && $allowed_upload_extensions != '.*') {
                             $allowed = str_replace('.', '', array_map('trim', explode(",", strtolower($allowed_upload_extensions))));
                             //first check if the user uploaded the right type
                             if (!in_array($ext, (array) $allowed)) {
                                 $file['error'] = __("Sorry, you cannot upload this file type for this field.", 'profile-builder');
                                 return $file;
                             }
                         }
                         //check if the type is allowed at all by WordPress
                         foreach (get_allowed_mime_types() as $key => $value) {
                             if (strpos($key, $ext) !== false || $key == $ext) {
                                 return $file;
                             }
                         }
                         $file['error'] = __("Sorry, you cannot upload this file type for this field.", 'profile-builder');
                     }
                 }
             }
         }
         if (empty($_POST['meta_name'])) {
             $file['error'] = __("An error occurred, please try again later.", 'profile-builder');
         }
     }
     return $file;
 }
开发者ID:alvarpoon,项目名称:aeg,代码行数:47,代码来源:upload_helper_functions.php

示例9: wp_check_filetype

function wp_check_filetype($filename, $mimes = null)
{
    if (empty($mimes)) {
        $mimes = get_allowed_mime_types();
    }
    $type = false;
    $ext = false;
    foreach ($mimes as $ext_preg => $mime_match) {
        $ext_preg = '!\\.(' . $ext_preg . ')(\\?.*)?$!i';
        if (preg_match($ext_preg, $filename, $ext_matches)) {
            $type = $mime_match;
            $ext = $ext_matches[1];
            break;
        }
    }
    return compact('ext', 'type');
}
开发者ID:shyaken,项目名称:maoy.palt,代码行数:17,代码来源:session.php

示例10: get_image_mime_types

 /**
  * Get image mime types
  *
  * @since  0.1.0
  * @return array
  */
 protected function get_image_mime_types()
 {
     $mime_types = get_allowed_mime_types();
     foreach ($mime_types as $id => $type) {
         if (false === strpos($type, 'image/')) {
             unset($mime_types[$id]);
         }
     }
     /**
      * Filter image mime types
      *
      * @since 0.1.0
      * @param array $mime_types Image mime types.
      */
     $mime_types = apply_filters('icon_picker_image_mime_types', $mime_types);
     // We need to exclude image/svg*.
     unset($mime_types['svg']);
     return $mime_types;
 }
开发者ID:xeiter,项目名称:timeplannr,代码行数:25,代码来源:image.php

示例11: sanitize_file_name

function sanitize_file_name($filename)
{
    $filename_raw = $filename;
    $special_chars = array("?", "[", "]", "/", "\\", "=", "<", ">", ":", ";", ",", "'", "\"", "&", "\$", "#", "*", "(", ")", "|", "~", "`", "!", "{", "}", chr(0));
    // $special_chars = apply_filters('sanitize_file_name_chars', $special_chars, $filename_raw);
    $filename = str_replace($special_chars, '', $filename);
    $filename = preg_replace('/[\\s-]+/', '-', $filename);
    $filename = trim($filename, '.-_');
    // Split the filename into a base and extension[s]
    $parts = explode('.', $filename);
    // Return if only one extension
    if (count($parts) <= 2) {
        return $filename;
    }
    // Process multiple extensions
    $filename = array_shift($parts);
    $extension = array_pop($parts);
    $mimes = get_allowed_mime_types();
    // Loop over any intermediate extensions. Munge them with a trailing underscore if they are a 2 - 5 character
    // long alpha string not in the extension whitelist.
    foreach ((array) $parts as $part) {
        $filename .= '.' . $part;
        if (preg_match("/^[a-zA-Z]{2,5}\\d?\$/", $part)) {
            $allowed = false;
            foreach ($mimes as $ext_preg => $mime_match) {
                $ext_preg = '!^(' . $ext_preg . ')$!i';
                if (preg_match($ext_preg, $part)) {
                    $allowed = true;
                    break;
                }
            }
            if (!$allowed) {
                $filename .= '_';
            }
        }
    }
    $filename .= '.' . $extension;
    return $filename;
}
开发者ID:marcolongitude,项目名称:SocialTecMar,代码行数:39,代码来源:sanitizer.php

示例12: dynimg_404_handler

function dynimg_404_handler()
{
    if (!is_404()) {
        return;
    }
    if (preg_match('/(.*)-([0-9]+)x([0-9]+)(c)?\\.(jpg|png|gif)/i', $_SERVER['REQUEST_URI'], $matches)) {
        $filename = $matches[1] . '.' . $matches[5];
        $width = $matches[2];
        $height = $matches[3];
        $crop = !empty($matches[4]);
        $uploads_dir = wp_upload_dir();
        $temp = parse_url($uploads_dir['baseurl']);
        $upload_path = $temp['path'];
        $findfile = str_replace($upload_path, '', $filename);
        $basefile = $uploads_dir['basedir'] . $findfile;
        $suffix = $width . 'x' . $height;
        if ($crop) {
            $suffix .= 'c';
        }
        if (file_exists($basefile)) {
            // we have the file, so call the wp function to actually resize the image
            //			$resized = image_resize($basefile, $width, $height, $crop, $suffix);
            $resized = image_resize($basefile, $width, $height, true, $suffix);
            // find the mime type
            foreach (get_allowed_mime_types() as $exts => $mime) {
                if (preg_match('!^(' . $exts . ')$!i', $matches[5])) {
                    $type = $mime;
                    break;
                }
            }
            // serve the image this one time (next time the webserver will do it for us)
            header('Content-Type: ' . $type);
            header('Content-Length: ' . filesize($resized));
            readfile($resized);
            exit;
        }
    }
}
开发者ID:vanlong200880,项目名称:uni,代码行数:38,代码来源:dynamic-image-resizer.php

示例13: enqueue_scripts

 public function enqueue_scripts($override = false)
 {
     if (is_admin()) {
         return;
     }
     global $post;
     if (is_page(EDD_FES()->helper->get_option('fes-vendor-dashboard-page', false)) || $override) {
         wp_enqueue_script('jquery');
         wp_enqueue_script('underscore');
         // FES outputs minified scripts by default on the frontend. To load full versions, hook into this and return empty string.
         $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
         $minify = apply_filters('fes_output_minified_versions', $suffix);
         wp_enqueue_script('fes_form', fes_plugin_url . 'assets/js/frontend-form' . $minify . '.js', array('jquery'), fes_plugin_version);
         wp_localize_script('fes_form', 'fes_form', array('ajaxurl' => admin_url('admin-ajax.php'), 'error_message' => __('Please fix the errors to proceed', 'edd_fes'), 'nonce' => wp_create_nonce('fes_nonce'), 'avatar_title' => __('Choose an avatar', 'edd_fes'), 'avatar_button' => __('Select as avatar', 'edd_fes'), 'file_title' => __('Choose a file', 'edd_fes'), 'file_button' => __('Insert file URL', 'edd_fes'), 'feat_title' => __('Choose a featured image', 'edd_fes'), 'feat_button' => __('Select as featured image', 'edd_fes'), 'one_option' => __('You must have at least one option', 'edd_fes'), 'too_many_files_pt_1' => __('You may not add more than ', 'edd_fes'), 'too_many_files_pt_2' => __(' files!', 'edd_fes'), 'file_types' => implode('|', array_keys(get_allowed_mime_types()))));
         wp_enqueue_media();
         wp_enqueue_script('comment-reply');
         wp_enqueue_script('jquery-ui-datepicker');
         wp_enqueue_script('jquery-ui-autocomplete');
         wp_enqueue_script('suggest');
         wp_enqueue_script('jquery-ui-slider');
         wp_enqueue_script('jquery-ui-timepicker', fes_plugin_url . 'assets/js/jquery-ui-timepicker-addon.js', array('jquery-ui-datepicker'));
     }
 }
开发者ID:SelaInc,项目名称:eassignment,代码行数:23,代码来源:class-setup.php

示例14: woocommerce_download_product


//.........这里部分代码省略.........
             * site_url() depends on whether the page containing the download (ie; My Account) is served via SSL because WC
             * modifies site_url() via a filter to force_ssl.
             * So blindly doing a str_replace is incorrect because it will fail when schemes are mismatched. This code
             * handles the various permutations.
             */
            $scheme = parse_url($file_path, PHP_URL_SCHEME);
            if ($scheme) {
                $site_url = set_url_scheme(site_url(''), $scheme);
            } else {
                $site_url = is_ssl() ? str_replace('https:', 'http:', site_url()) : site_url();
            }
            $file_path = str_replace(trailingslashit($site_url), ABSPATH, $file_path);
        } else {
            $network_url = is_ssl() ? str_replace('https:', 'http:', network_admin_url()) : network_admin_url();
            $upload_dir = wp_upload_dir();
            // Try to replace network url
            $file_path = str_replace(trailingslashit($network_url), ABSPATH, $file_path);
            // Now try to replace upload URL
            $file_path = str_replace($upload_dir['baseurl'], $upload_dir['basedir'], $file_path);
        }
        // See if its local or remote
        if (strstr($file_path, 'http:') || strstr($file_path, 'https:') || strstr($file_path, 'ftp:')) {
            $remote_file = true;
        } else {
            $remote_file = false;
            // Remove Query String
            if (strstr($file_path, '?')) {
                $file_path = current(explode('?', $file_path));
            }
            $file_path = realpath($file_path);
        }
        $file_extension = strtolower(substr(strrchr($file_path, "."), 1));
        $ctype = "application/force-download";
        foreach (get_allowed_mime_types() as $mime => $type) {
            $mimes = explode('|', $mime);
            if (in_array($file_extension, $mimes)) {
                $ctype = $type;
                break;
            }
        }
        // Start setting headers
        if (!ini_get('safe_mode')) {
            @set_time_limit(0);
        }
        if (function_exists('get_magic_quotes_runtime') && get_magic_quotes_runtime()) {
            @set_magic_quotes_runtime(0);
        }
        if (function_exists('apache_setenv')) {
            @apache_setenv('no-gzip', 1);
        }
        @session_write_close();
        @ini_set('zlib.output_compression', 'Off');
        @ob_end_clean();
        if (ob_get_level()) {
            @ob_end_clean();
        }
        // Zip corruption fix
        if ($is_IE && is_ssl()) {
            // IE bug prevents download via SSL when Cache Control and Pragma no-cache headers set.
            header('Expires: Wed, 11 Jan 1984 05:00:00 GMT');
            header('Cache-Control: private');
        } else {
            nocache_headers();
        }
        $file_name = basename($file_path);
        if (strstr($file_name, '?')) {
开发者ID:iplaydu,项目名称:Bob-Ellis-Shoes,代码行数:67,代码来源:woocommerce-functions.php

示例15: get_local_media_files_batch_recursive

 /**
  * Recursively go through uploads directories and get a batch of media files.
  * Stops when it has scanned all files/directories or after it has run for
  * $this->media_files_batch_time_limit seconds, whichever comes first.
  *
  * @param string $dir               The directory to start in
  * @param string $start_filename    The file or directory to start at within $dir
  * @param array  $local_media_files Array to populate with media files found
  */
 function get_local_media_files_batch_recursive($dir, $start_filename, &$local_media_files)
 {
     $upload_dir = $this->uploads_dir();
     static $allowed_mime_types;
     if (is_null($allowed_mime_types)) {
         $allowed_mime_types = array_flip(get_allowed_mime_types());
     }
     static $finish_time;
     if (is_null($finish_time)) {
         $finish_time = microtime(true) + $this->media_files_batch_time_limit;
     }
     $dir = '/' == $dir ? '' : $dir;
     $dir_path = $upload_dir . $dir;
     $sub_paths = glob($dir_path . '*', GLOB_MARK);
     // Get all the files except the one we use to store backups.
     $wpmdb_upload_folder = $this->get_upload_info();
     $pattern = '/' . preg_quote($wpmdb_upload_folder, '/') . '/';
     $files = preg_grep($pattern, $sub_paths ? $sub_paths : array(), PREG_GREP_INVERT);
     $reached_start_file = false;
     foreach ($files as $file_path) {
         if (microtime(true) >= $finish_time) {
             break;
         }
         // Are we starting from a certain file within the directory?
         // If so, we skip all the files that come before it.
         if ($start_filename) {
             if (basename($file_path) == $start_filename) {
                 $reached_start_file = true;
                 continue;
             } elseif (!$reached_start_file) {
                 continue;
             }
         }
         $short_file_path = str_replace(array($upload_dir, '\\'), array('', '/'), $file_path);
         // Is directory? We use this instead of is_dir() to save us an I/O call
         if (substr($file_path, -1) == DIRECTORY_SEPARATOR) {
             $this->get_local_media_files_batch_recursive($short_file_path, '', $local_media_files);
             continue;
         }
         // ignore files that we shouldn't touch, e.g. .php, .sql, etc
         $filetype = wp_check_filetype($short_file_path);
         if (!isset($allowed_mime_types[$filetype['type']])) {
             continue;
         }
         if (apply_filters('wpmdbmf_exclude_local_media_file_from_removal', false, $upload_dir, $short_file_path, $this)) {
             continue;
         }
         $local_media_files[] = $short_file_path;
     }
 }
开发者ID:Garth619,项目名称:DMA-Franconnect-Local,代码行数:59,代码来源:wpmdbpro-media-files-base.php


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