• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wp_get_mime_types函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: filter_images

/**
 * Automatically resample and save the downsized versions of each graphic.
 *
 * @param array $meta
 *
 * @return array
 */
function filter_images($meta)
{
    $n = function ($function) {
        return __NAMESPACE__ . "\\{$function}";
    };
    add_filter('image_resize_dimensions', $n('upscale_dimensions'), 1, 6);
    $uploads = wp_upload_dir();
    // Generate a placeholder for the full image
    $file = basename($meta['file']);
    $file_base_path = trailingslashit($uploads['basedir']) . str_replace($file, '', $meta['file']);
    $new_parent = create_placeholder($file, $file_base_path);
    // Generate placeholders for each image size
    foreach ($meta['sizes'] as $name => $data) {
        if (false !== strpos($name, '-ph')) {
            $new_file = create_placeholder($data['file'], $file_base_path);
            $meta['sizes'][$name]['file'] = $new_file;
        }
    }
    $file_ext = pathinfo($file, PATHINFO_EXTENSION);
    $mime_type = 'application/octet-stream';
    $mime_types = wp_get_mime_types();
    foreach ($mime_types as $extension => $type) {
        if (preg_match("/{$file_ext}/i", $extension)) {
            $mime_type = $type;
            break;
        }
    }
    $meta['sizes']['full-ph'] = array('file' => $new_parent, 'width' => $meta['width'], 'height' => $meta['height'], 'mime-type' => $mime_type);
    remove_filter('image_resize_dimensions', $n('upscale_dimensions'), 1);
    return $meta;
}
开发者ID:10up,项目名称:swiftstream,代码行数:38,代码来源:pixelate.php


示例2: __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


示例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: get_mime_type

 protected function get_mime_type($extension)
 {
     $mime_types = wp_get_mime_types();
     $extensions = array_keys($mime_types);
     foreach ($extensions as $_extension) {
         if (preg_match("/{$extension}/i", $_extension)) {
             return $mime_types[$_extension];
         }
     }
     return;
 }
开发者ID:brutalenemy666,项目名称:carbon-image-library,代码行数:11,代码来源:WP_Media.php


示例5: tm_player

function tm_player($player = '', $args = array())
{
    if (empty($player) || empty($args['files'])) {
        return;
    }
    $defaults = array('files' => array(), 'poster' => '', 'autoplay' => false);
    $args = wp_parse_args($args, $defaults);
    extract($args);
    /* JWPlayer */
    if ($player == 'jwplayer') {
        $options = array('file' => trim($files[0]), 'image' => $poster);
        $atts = arr2atts($options);
        $jwplayer_shortcode = '[jwplayer' . $atts . ']';
        echo apply_filters('tm_video_filter', $jwplayer_shortcode);
    } elseif ($player == 'flowplayer' && function_exists('flowplayer_content_handle')) {
        $atts = array('splash' => $poster);
        foreach ($files as $key => $file) {
            $att = $key == 0 ? 'src' : 'src' . $key;
            $atts[$att] = $file;
        }
        echo flowplayer_content_handle($atts, '', '');
        tm_flowplayer_script();
    } elseif ($player == 'videojs' && function_exists('video_shortcode')) {
        $atts = array('poster' => $poster);
        foreach ($files as $key => $file) {
            $att = $key == 0 ? 'src' : 'src' . $key;
            if (strpos($file, '.mp4') !== false) {
                $atts['mp4'] = $file;
            }
            if (strpos($file, '.webm') !== false) {
                $atts['webm'] = $file;
            }
            if (strpos($file, '.ogg') !== false) {
                $atts['ogg'] = $file;
            }
        }
        echo video_shortcode($atts, '', '');
        tm_add_videojs_swf();
    } else {
        $atts = array();
        foreach ($files as $file) {
            $file = trim($file);
            if (strpos($file, 'youtube.com') !== false) {
                $atts['youtube'] = $file;
            } else {
                $type = wp_check_filetype($file, wp_get_mime_types());
                $atts[$type['ext']] = $file;
            }
        }
        echo wp_video_shortcode($atts);
    }
}
开发者ID:venamax,项目名称:trixandtrax-cl,代码行数:52,代码来源:videos-functions.php


示例6: coder_sanitize_upload

 /**
  * Function to sanitize upload
  *
  * @access public
  * @since 1.1
  *
  * @param $coder_upload
  * @return string
  *
  */
 function coder_sanitize_upload($coder_upload, $coder_setting)
 {
     /*
      * Array of valid upload file types.
      *
      * The array includes upload mime types that are included in wp_get_mime_types()
      */
     $coder_mimes = wp_get_mime_types();
     // Return an array with file extension and mime_type.
     $coder_file = wp_check_filetype($coder_upload, $coder_mimes);
     // If $coder_upload has a valid mime_type, return it; otherwise, return the default.
     return $coder_file['ext'] ? $coder_upload : $coder_setting->default;
 }
开发者ID:kafleg,项目名称:coder-customizer-framework,代码行数:23,代码来源:sanitize-upload.php


示例7: get_mime_extensions

 static function get_mime_extensions()
 {
     $mime_types = wp_get_mime_types();
     $extensions = array();
     foreach ($mime_types as $ext => $mime) {
         $ext = explode('|', $ext);
         $extensions[$mime] = $ext;
         $mime_parts = explode('/', $mime);
         if (empty($extensions[$mime_parts[0]])) {
             $extensions[$mime_parts[0]] = array();
         }
         $extensions[$mime_parts[0]] = $extensions[$mime_parts[0] . '/*'] = array_merge($extensions[$mime_parts[0]], $ext);
     }
     return $extensions;
 }
开发者ID:netmagik,项目名称:netmagik,代码行数:15,代码来源:media.php


示例8: get_extension

 /**
  * Get extension
  *
  * @param string $path
  * @return string
  */
 public function get_extension($path)
 {
     $type = $this->get_mime($path);
     $match = [];
     $ext = '';
     if ($type) {
         foreach (wp_get_mime_types() as $extensions => $content_type) {
             if ($content_type == $type) {
                 $ext = explode('|', $extensions)[0];
                 break;
             }
         }
     }
     return $ext;
 }
开发者ID:hametuha,项目名称:wpametu,代码行数:21,代码来源:Mime.php


示例9: get_column_options

 /**
  * @see CACIE_Editable_Model::get_column_options()
  * @since 1.0
  */
 public function get_column_options($column)
 {
     $options = parent::get_column_options($column);
     switch ($column['type']) {
         // WP Default
         // Custom columns
         case 'column-taxonomy':
             $options = $this->get_term_options($column['taxonomy']);
             break;
         case 'column-mime_type':
             $mime_types = wp_get_mime_types();
             $options = array_combine($mime_types, $mime_types);
             break;
     }
     return $options;
 }
开发者ID:bruno-barros,项目名称:w.eloquent.light,代码行数:20,代码来源:media.php


示例10: x_shortcode_audio_player

function x_shortcode_audio_player($atts)
{
    extract(shortcode_atts(array('id' => '', 'class' => '', 'style' => '', 'src' => '', 'advanced_controls' => '', 'preload' => '', 'autoplay' => '', 'loop' => '', 'mp3' => '', 'oga' => ''), $atts, 'x_audio_player'));
    $id = $id != '' ? 'id="' . esc_attr($id) . '"' : '';
    $class = $class != '' ? 'x-audio player ' . esc_attr($class) : 'x-audio player';
    $style = $style != '' ? 'style="' . $style . '"' : '';
    $src = $src != '' ? explode('|', $src) : array();
    $advanced_controls = $advanced_controls == 'true' ? ' advanced-controls' : '';
    $preload = $preload != '' ? ' preload="' . $preload . '"' : ' preload="metadata"';
    $autoplay = $autoplay == 'true' ? ' autoplay' : '';
    $loop = $loop == 'true' ? ' loop' : '';
    //
    // Deprecated parameters.
    //
    $mp3 = $mp3 != '' ? '<source src="' . $mp3 . '" type="audio/mpeg">' : '';
    $oga = $oga != '' ? '<source src="' . $oga . '" type="audio/ogg">' : '';
    //
    // Variable markup.
    //
    $data = cs_generate_data_attributes('x_mejs');
    //
    // Enqueue scripts.
    //
    wp_enqueue_script('mediaelement');
    //
    // Build sources.
    //
    $sources = array();
    foreach ($src as $file) {
        $mime = wp_check_filetype($file, wp_get_mime_types());
        $sources[] = '<source src="' . esc_url($file) . '" type="' . $mime['type'] . '">';
    }
    if ($mp3 != '') {
        $sources[] = $mp3;
    }
    if ($oga != '') {
        $sources[] = $oga;
    }
    //
    // Markup.
    //
    $output = "<div {$id} class=\"{$class}{$autoplay}{$loop}\" {$data} {$style}>" . "<audio class=\"x-mejs{$advanced_controls}\"{$preload}{$autoplay}{$loop}>" . implode('', $sources) . '</audio>' . '</div>';
    return $output;
}
开发者ID:nayabbukhari,项目名称:circulocristiano,代码行数:44,代码来源:audio-player.php


示例11: sideload_attachment

 private function sideload_attachment($attachment, $_to_post_id, $date)
 {
     if ('image' === $attachment->type) {
         $response = wp_remote_head($attachment->url);
         if (200 == wp_remote_retrieve_response_code($response)) {
             $_mimes = array_flip(wp_get_mime_types());
             $_content_type = wp_remote_retrieve_header($response, 'content-type');
             if (isset($_mimes[$_content_type])) {
                 $_ext = strtok($_mimes[$_content_type], '|');
                 $_temp_file = download_url($attachment->url);
                 // TODO check for WP_Error
                 $_new_file = str_replace('.tmp', '.' . $_ext, $_temp_file);
                 rename($_temp_file, $_new_file);
                 $file_array = array();
                 $file_array['name'] = basename($_new_file);
                 $file_array['tmp_name'] = $_new_file;
                 $attachment_id = media_handle_sideload($file_array, $_to_post_id, '', array('post_date' => $date, 'post_date_gmt' => $date));
             }
         }
     }
 }
开发者ID:westi,项目名称:pjw-groupme-importer,代码行数:21,代码来源:class-pjw-groupme-wp-api.php


示例12: allow_video_uploads

 /**
  * Matt & Mike J requested that we allow video uploads from the API for mobile apps, even without the VideoPress upgrade..
  * https://videop2.wordpress.com/2014/08/21/videopress-iteration/#comment-3377
  */
 function allow_video_uploads($mimes)
 {
     // if we are on Jetpack, bail - Videos are already allowed
     if (!defined('IS_WPCOM') || !IS_WPCOM) {
         return $mimes;
     }
     // extra check that this filter is only ever applied during REST API requests
     if (!defined('REST_API_REQUEST') || !REST_API_REQUEST) {
         return $mimes;
     }
     // bail early if they already have the upgrade..
     if (get_option('video_upgrade') == '1') {
         return $mimes;
     }
     // lets whitelist to only specific clients right now
     $clients_allowed_video_uploads = array();
     $clients_allowed_video_uploads = apply_filters('rest_api_clients_allowed_video_uploads', $clients_allowed_video_uploads);
     if (!in_array($this->api->token_details['client_id'], $clients_allowed_video_uploads)) {
         return $mimes;
     }
     $mime_list = wp_get_mime_types();
     $site_exts = explode(' ', get_site_option('upload_filetypes'));
     $video_exts = explode(' ', get_site_option('video_upload_filetypes', false, false));
     $video_exts = apply_filters('video_upload_filetypes', $video_exts);
     $video_mimes = array();
     if (!empty($video_exts)) {
         foreach ($video_exts as $ext) {
             foreach ($mime_list as $ext_pattern => $mime) {
                 if ($ext != '' && strpos($ext_pattern, $ext) !== false) {
                     $video_mimes[$ext_pattern] = $mime;
                 }
             }
         }
         $mimes = array_merge($mimes, $video_mimes);
     }
     return $mimes;
 }
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:41,代码来源:class.wpcom-json-api-upload-media-v1-1-endpoint.php


示例13: dynimg_404_handler

function dynimg_404_handler()
{
    if (!is_404()) {
        return;
    }
    // Has the file name the proper format for this handler?
    if (!preg_match('/(.*)-([0-9]+)x([0-9]+)(c)?\\.(\\w+)($|\\?|#)/i', $_SERVER['REQUEST_URI'], $matches)) {
        return;
    }
    $mime_types = wp_get_mime_types();
    $img_ext = $matches[5];
    $ext_known = false;
    // The extensions for some MIME types are set as regular expression (PCRE).
    foreach ($mime_types as $rgx_ext => $mime_type) {
        if (preg_match("/{$rgx_ext}/i", $img_ext)) {
            if (wp_image_editor_supports(array('mime_type' => $mime_type))) {
                $ext_known = true;
                break;
            }
        }
    }
    if (!$ext_known) {
        return;
    }
    $filename = urldecode($matches[1] . '.' . $img_ext);
    $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;
    // Serve the image this one time (next time the webserver will do it for us)
    dynimg_create_save_stream($basefile, $width, $height, $crop);
}
开发者ID:afftt,项目名称:infos-ping,代码行数:36,代码来源:dynamic-image-resizer.php


示例14: test_wp_get_mime_types

 /**
  * @ticket 21594
  */
 function test_wp_get_mime_types()
 {
     $mimes = wp_get_mime_types();
     $this->assertInternalType('array', $mimes);
     $this->assertNotEmpty($mimes);
     add_filter('mime_types', '__return_empty_array');
     $mimes = wp_get_mime_types();
     $this->assertInternalType('array', $mimes);
     $this->assertEmpty($mimes);
     remove_filter('mime_types', '__return_empty_array');
     $mimes = wp_get_mime_types();
     $this->assertInternalType('array', $mimes);
     $this->assertNotEmpty($mimes);
     // upload_mimes shouldn't affect wp_get_mime_types()
     add_filter('upload_mimes', '__return_empty_array');
     $mimes = wp_get_mime_types();
     $this->assertInternalType('array', $mimes);
     $this->assertNotEmpty($mimes);
     remove_filter('upload_mimes', '__return_empty_array');
     $mimes2 = wp_get_mime_types();
     $this->assertInternalType('array', $mimes2);
     $this->assertNotEmpty($mimes2);
     $this->assertEquals($mimes2, $mimes);
 }
开发者ID:jaspermdegroot,项目名称:develop.wordpress,代码行数:27,代码来源:functions.php


示例15: wp_video_shortcode

/**
 * Builds the Video shortcode output.
 *
 * This implements the functionality of the Video Shortcode for displaying
 * WordPress mp4s in a post.
 *
 * @since 3.6.0
 *
 * @global int $content_width
 * @staticvar int $instance
 *
 * @param array  $attr {
 *     Attributes of the shortcode.
 *
 *     @type string $src      URL to the source of the video file. Default empty.
 *     @type int    $height   Height of the video embed in pixels. Default 360.
 *     @type int    $width    Width of the video embed in pixels. Default $content_width or 640.
 *     @type string $poster   The 'poster' attribute for the `<video>` element. Default empty.
 *     @type string $loop     The 'loop' attribute for the `<video>` element. Default empty.
 *     @type string $autoplay The 'autoplay' attribute for the `<video>` element. Default empty.
 *     @type string $preload  The 'preload' attribute for the `<video>` element.
 *                            Default 'metadata'.
 *     @type string $class    The 'class' attribute for the `<video>` element.
 *                            Default 'wp-video-shortcode'.
 * }
 * @param string $content Shortcode content.
 * @return string|void HTML content to display video.
 */
function wp_video_shortcode($attr, $content = '')
{
    global $content_width;
    $post_id = get_post() ? get_the_ID() : 0;
    static $instance = 0;
    $instance++;
    /**
     * Filter the default video shortcode output.
     *
     * If the filtered output isn't empty, it will be used instead of generating
     * the default video template.
     *
     * @since 3.6.0
     *
     * @see wp_video_shortcode()
     *
     * @param string $html     Empty variable to be replaced with shortcode markup.
     * @param array  $attr     Attributes of the video shortcode.
     * @param string $content  Video shortcode content.
     * @param int    $instance Unique numeric ID of this video shortcode instance.
     */
    $override = apply_filters('wp_video_shortcode_override', '', $attr, $content, $instance);
    if ('' !== $override) {
        return $override;
    }
    $video = null;
    $default_types = wp_get_video_extensions();
    $defaults_atts = array('src' => '', 'poster' => '', 'loop' => '', 'autoplay' => '', 'preload' => 'metadata', 'width' => 640, 'height' => 360);
    foreach ($default_types as $type) {
        $defaults_atts[$type] = '';
    }
    $atts = shortcode_atts($defaults_atts, $attr, 'video');
    if (is_admin()) {
        // shrink the video so it isn't huge in the admin
        if ($atts['width'] > $defaults_atts['width']) {
            $atts['height'] = round($atts['height'] * $defaults_atts['width'] / $atts['width']);
            $atts['width'] = $defaults_atts['width'];
        }
    } else {
        // if the video is bigger than the theme
        if (!empty($content_width) && $atts['width'] > $content_width) {
            $atts['height'] = round($atts['height'] * $content_width / $atts['width']);
            $atts['width'] = $content_width;
        }
    }
    $is_vimeo = $is_youtube = false;
    $yt_pattern = '#^https?://(?:www\\.)?(?:youtube\\.com/watch|youtu\\.be/)#';
    $vimeo_pattern = '#^https?://(.+\\.)?vimeo\\.com/.*#';
    $primary = false;
    if (!empty($atts['src'])) {
        $is_vimeo = preg_match($vimeo_pattern, $atts['src']);
        $is_youtube = preg_match($yt_pattern, $atts['src']);
        if (!$is_youtube && !$is_vimeo) {
            $type = wp_check_filetype($atts['src'], wp_get_mime_types());
            if (!in_array(strtolower($type['ext']), $default_types)) {
                return sprintf('<a class="wp-embedded-video" href="%s">%s</a>', esc_url($atts['src']), esc_html($atts['src']));
            }
        }
        if ($is_vimeo) {
            wp_enqueue_script('froogaloop');
        }
        $primary = true;
        array_unshift($default_types, 'src');
    } else {
        foreach ($default_types as $ext) {
            if (!empty($atts[$ext])) {
                $type = wp_check_filetype($atts[$ext], wp_get_mime_types());
                if (strtolower($type['ext']) === $ext) {
                    $primary = true;
                }
            }
        }
//.........这里部分代码省略.........
开发者ID:nakamuraagatha,项目名称:reseptest,代码行数:101,代码来源:media.php


示例16: sanitize_file_name

/**
 * Sanitizes a filename, replacing whitespace with dashes.
 *
 * Removes special characters that are illegal in filenames on certain
 * operating systems and special characters requiring special escaping
 * to manipulate at the command line. Replaces spaces and consecutive
 * dashes with a single dash. Trims period, dash and underscore from beginning
 * and end of filename. It is not guaranteed that this function will return a
 * filename that is allowed to be uploaded.
 *
 * @since 2.1.0
 *
 * @param string $filename The filename to be sanitized
 * @return string The sanitized filename
 */
function sanitize_file_name( $filename ) {
	$filename_raw = $filename;
	$special_chars = array("?", "[", "]", "/", "\\", "=", "<", ">", ":", ";", ",", "'", "\"", "&", "$", "#", "*", "(", ")", "|", "~", "`", "!", "{", "}", "%", "+", chr(0));
	/**
	 * Filter the list of characters to remove from a filename.
	 *
	 * @since 2.8.0
	 *
	 * @param array  $special_chars Characters to remove.
	 * @param string $filename_raw  Filename as it was passed into sanitize_file_name().
	 */
	$special_chars = apply_filters( 'sanitize_file_name_chars', $special_chars, $filename_raw );
	$filename = preg_replace( "#\x{00a0}#siu", ' ', $filename );
	$filename = str_replace( $special_chars, '', $filename );
	$filename = str_replace( array( '%20', '+' ), '-', $filename );
	$filename = preg_replace( '/[\r\n\t -]+/', '-', $filename );
	$filename = trim( $filename, '.-_' );

	if ( false === strpos( $filename, '.' ) ) {
		$mime_types = wp_get_mime_types();
		$filetype = wp_check_filetype( 'test.' . $filename, $mime_types );
		if ( $filetype['ext'] === $filename ) {
			$filename = 'unnamed-file.' . $filetype['ext'];
		}
	}

	// Split the filename into a base and extension[s]
	$parts = explode('.', $filename);

	// Return if only one extension
	if ( count( $parts ) <= 2 ) {
		/**
		 * Filter a sanitized filename string.
		 *
		 * @since 2.8.0
		 *
		 * @param string $filename     Sanitized filename.
		 * @param string $filename_raw The filename prior to sanitization.
		 */
		return apply_filters( 'sanitize_file_name', $filename, $filename_raw );
	}

	// Process multiple extensions
	$filename = array_shift($parts);
	$extension = array_pop($parts);
	$mimes = get_allowed_mime_types();

	/*
	 * Loop over any intermediate extensions. Postfix 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;
	/** This filter is documented in wp-includes/formatting.php */
	return apply_filters('sanitize_file_name', $filename, $filename_raw);
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:86,代码来源:formatting.php


示例17: array

        if (!empty($bg_video_args)) {
            $attr_strings = array('loop', 'preload="1"', 'autoplay=""', 'muted="muted"');
            if ($video_mute) {
                //$attr_strings[] = 'muted="muted"';
            }
            if ($video_autoplay) {
                //$attr_strings[] = 'autoplay=""';
            }
            if ($bg_video_cover && !in_array($bg_video_cover, array('none'))) {
                $bg_video_path = wp_get_attachment_image_src($bg_video_cover, 'kleo-full-width');
                $attr_strings[] = 'poster="' . esc_url($bg_video_path[0]) . '"';
            }
            $bg_video .= sprintf('<div class="video-wrap"><video %s class="full-video" webkit-playsinline>', join(' ', $attr_strings));
            $source = '<source type="%s" src="%s" />';
            foreach ($bg_video_args as $video_type => $video_src) {
                $video_type = wp_check_filetype($video_src, wp_get_mime_types());
                $bg_video .= sprintf($source, $video_type['type'], esc_url($video_src));
            }
            $bg_video .= '</video></div>';
            $section_classes[] = 'bg-full-video no-video-controls';
        }
        break;
    default:
        break;
}
if ($column_gap == 'no') {
    $section_classes[] = 'no-col-gap';
}
if ($vertical_align == 'yes') {
    $section_classes[] = 'vertical-col';
}
开发者ID:VLabsInc,项目名称:WordPressPlatforms,代码行数:31,代码来源:vc_row.php


示例18: wp_playlist_shortcode

    function wp_playlist_shortcode($output, $attr)
    {
        global $content_width;
        $post = get_post();
        static $instance = 0;
        $instance++;
        if (isset($attr['orderby'])) {
            $attr['orderby'] = sanitize_sql_orderby($attr['orderby']);
            if (!$attr['orderby']) {
                unset($attr['orderby']);
            }
        }
        extract(shortcode_atts(array('type' => 'audio', 'order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post ? $post->ID : 0, 'include' => '', 'exclude' => '', 'style' => 'light', 'tracklist' => true, 'tracknumbers' => true, 'images' => true, 'artists' => true), $attr, 'playlist'));
        $id = intval($id);
        if ('RAND' == $order) {
            $orderby = 'none';
        }
        $args = array('post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => $type, 'order' => $order, 'orderby' => $orderby);
        if (!empty($include)) {
            $args['include'] = $include;
            $_attachments = get_posts($args);
            $attachments = array();
            foreach ($_attachments as $key => $val) {
                $attachments[$val->ID] = $_attachments[$key];
            }
        } elseif (!empty($exclude)) {
            $args['post_parent'] = $id;
            $args['exclude'] = $exclude;
            $attachments = get_children($args);
        } else {
            $args['post_parent'] = $id;
            $attachments = get_children($args);
        }
        if (empty($attachments)) {
            return '';
        }
        if (is_feed()) {
            $output = "\n";
            foreach ($attachments as $att_id => $attachment) {
                $output .= wp_get_attachment_link($att_id) . "\n";
            }
            return $output;
        }
        $outer = 22;
        $default_width = 640;
        $default_height = 360;
        $theme_width = empty($content_width) ? $default_width : $content_width - $outer;
        $theme_height = empty($content_width) ? $default_height : round($default_height * $theme_width / $default_width);
        $data = compact('type');
        foreach (array('tracklist', 'tracknumbers', 'images', 'artists') as $key) {
            $data[$key] = filter_var(${$key}, FILTER_VALIDATE_BOOLEAN);
        }
        $tracks = array();
        foreach ($attachments as $attachment) {
            $url = wp_get_attachment_url($attachment->ID);
            $ftype = wp_check_filetype($url, wp_get_mime_types());
            $track = array('src' => $url, 'type' => $ftype['type'], 'title' => $attachment->post_title, 'caption' => $attachment->post_excerpt, 'description' => $attachment->post_content);
            $track['meta'] = array();
            $meta = wp_get_attachment_metadata($attachment->ID);
            if (!empty($meta)) {
                foreach (wp_get_attachment_id3_keys($attachment) as $key => $label) {
                    if (!empty($meta[$key])) {
                        $track['meta'][$key] = $meta[$key];
                    }
                }
                if ('video' === $type) {
                    if (!empty($meta['width']) && !empty($meta['height'])) {
                        $width = $meta['width'];
                        $height = $meta['height'];
                        $theme_height = round($height * $theme_width / $width);
                    } else {
                        $width = $default_width;
                        $height = $default_height;
                    }
                    $track['dimensions'] = array('original' => compact('width', 'height'), 'resized' => array('width' => $theme_width, 'height' => $theme_height));
                }
            }
            if ($images) {
                $id = get_post_thumbnail_id($attachment->ID);
                if (!empty($id)) {
                    list($src, $width, $height) = wp_get_attachment_image_src($id, 'full');
                    $track['image'] = compact('src', 'width', 'height');
                    list($src, $width, $height) = wp_get_attachment_image_src($id, 'thumbnail');
                    $track['thumb'] = compact('src', 'width', 'height');
                } else {
                    $src = wp_mime_type_icon($attachment->ID);
                    $width = 48;
                    $height = 64;
                    $track['image'] = compact('src', 'width', 'height');
                    $track['thumb'] = compact('src', 'width', 'height');
                }
            }
            $tracks[] = $track;
        }
        $data['tracks'] = $tracks;
        $safe_type = esc_attr($type);
        $safe_style = esc_attr($style);
        $playlist_meta = 'true' == $this->options('playlist_meta') ? "" : " hide-playlist-meta-pro ";
        ob_start();
        if (1 === $instance) {
//.........这里部分代码省略.........
开发者ID:katstar01,项目名称:fivebeers,代码行数:101,代码来源:video-player.php


示例19: get_allowed_mime_types

/**
 * Retrieve list of allowed mime types and file extensions.
 *
 * @since 2.8.6
 *
 * @uses apply_filters() Calls 'upload_mimes' on returned array
 * @uses wp_get_upload_mime_types() to fetch the list of mime types
 * 
 * @return array Array of mime types keyed by the file extension regex corresponding to those types.
 */
function get_allowed_mime_types()
{
    return apply_filters('upload_mimes', wp_get_mime_types());
}
开发者ID:ryanbrainard,项目名称:wordpress,代码行数:14,代码来源:functions.php


示例20: elseif

if ('images' == $limit_file_type) {
    $limit_types = 'jpg,jpeg,png,gif';
} elseif ('video' == $limit_file_type) {
    $limit_types = 'mpg,mov,flv,mp4';
} elseif ('audio' == $limit_file_type) {
    $limit_types = 'mp3,m4a,wav,wma';
} elseif ('text' == $limit_file_type) {
    $limit_types = 'txt,rtx,csv,tsv';
} elseif ('any' == $limit_file_type) {
    $limit_types = '';
} else {
    $limit_types = pods_var($form_field_type . '_allowed_extensions', $options, '', null, true);
}
$limit_types = trim(str_replace(array(' ', '.', "\n", "\t", ';'), array('', ',', ',', ','), $limit_types), ',');
if (pods_version_check('wp', '3.5')) {
    $mime_types = wp_get_mime_types();
    if (in_array($limit_file_type, array('images', 'audio', 'video'))) {
        $new_limit_types = array();
        foreach ($mime_types as $type => $mime) {
            if (0 === strpos($mime, $limit_file_type)) {
                $type = explode('|', $type);
                $new_limit_types = array_merge($new_limit_types, $type);
            }
        }
        if (!empty($new_limit_types)) {
            $limit_types = implode(',', $new_limit_types);
        }
    } elseif ('any' != $limit_file_type) {
        $new_limit_types = array();
        $limit_types = explode(',', $limit_types);
        foreach ($limit_types as $k => $limit_type) {
开发者ID:Ingenex,项目名称:redesign,代码行数:31,代码来源:plupload.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wp_get_mu_plugins函数代码示例发布时间:2022-05-23
下一篇:
PHP wp_get_link_cats函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap