WPCOM_JSON_API_Endpoint::allow_video_uploads PHP Méthode

allow_video_uploads() public méthode

public allow_video_uploads ( $mimes )
    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();
        /**
         * Filter the list of whitelisted video clients.
         *
         * @module json-api
         *
         * @since 3.2.0
         *
         * @param array $clients_allowed_video_uploads Array of whitelisted Video clients.
         */
        $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();
        $video_exts = explode(' ', get_site_option('video_upload_filetypes', false, false));
        /**
         * Filter the video filetypes allowed on the site.
         *
         * @module json-api
         *
         * @since 3.2.0
         *
         * @param array $video_exts Array of video filetypes allowed on the site.
         */
        $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;
    }