コード例 #1
0
 /**
  * Fetch Flowplayer Drive API authentication code
  *
  * @since    1.2.0
  */
 protected function make_auth_request()
 {
     // get the login info
     $options = fp5_get_settings();
     $user_name = isset($options['user_name']) ? $options['user_name'] : '';
     $password = isset($options['password']) ? $options['password'] : '';
     if (!$user_name || !$password) {
         Flowplayer_Drive_Error::showLoginError();
         return;
     }
     $seed = $this->make_auth_seed_request();
     if (!$seed) {
         return;
     }
     $auth_api_url = add_query_arg(array('callback' => '?', 'username' => $user_name, 'hash' => sha1($user_name . $seed . $password), 'seed' => $seed), $this->account_api_url);
     $args = array('user-agent' => 'wp_flowplayer5/version_' . $this->plugin_version);
     $response = wp_remote_get(esc_url_raw($auth_api_url), $args);
     if (200 != wp_remote_retrieve_response_code($response)) {
         Flowplayer_Drive_Error::showAuthenticationApiError();
         return;
     }
     $auth = $this->json_decode_body($response);
     if (!$auth->success) {
         Flowplayer_Drive_Error::showUsernamePasswordError();
         return;
     }
     return $auth->result->authcode;
 }
コード例 #2
0
 /**
  * Return the player version.
  *
  * @since    1.0.0
  *
  * @return   Player version variable.
  */
 public function get_player_version()
 {
     $options = fp5_get_settings();
     if (isset($options['fp_version']) && 'fp6' === $options['fp_version']) {
         return '6.0.4';
     } else {
         return '5.5.2';
     }
 }
コード例 #3
0
 static function single_video_processing($atts)
 {
     $return = array();
     /**
      * flowplayer shortcode
      *
      * @example [flowplayer id="123" splash="trailer_1080p.jpg" webm="trailer_1080p.webm" mp4="trailer_1080p.mp4" ogg="trailer_1080p.ogv" width="1920" height="1080" skin="functional" autoplay="true" loop="true" fixed="false" subtitles="bunny-en.vtt" fixed_controls="true" coloring="default" preload="auto"]
      */
     $shortcode_defaults = array('id' => '', 'mp4' => '', 'webm' => '', 'ogg' => '', 'flash' => '', 'hls' => '', 'loop' => '', 'autoplay' => '', 'preload' => '', 'poster' => '', 'skin' => '', 'splash' => '', 'subtitles' => '', 'max_width' => '', 'width' => '', 'height' => '', 'ratio' => '', 'fixed' => '', 'rtmp' => '', 'quality' => '', 'qualities' => '', 'coloring' => '', 'fixed_controls' => '', 'background' => '', 'aside_time' => '', 'show_title' => '', 'no_hover' => '', 'no_mute' => '', 'no_volume' => '', 'no_embed' => '', 'live' => '', 'play_button' => '', 'ads_time' => '', 'ad_type' => '', 'description_url' => '', 'lightbox' => '', 'title' => '');
     $atts = array_filter(shortcode_atts($shortcode_defaults, $atts, 'flowplayer'));
     if (!empty($atts['id'])) {
         $return['id'] = $atts['id'];
         // get the meta from the post type
         $custom_fields = get_post_custom($return['id']);
         $custom_fields['title'][0] = get_the_title($return['id']);
     } else {
         $return['id'] = substr(md5(serialize($atts)), 0, 5);
         $custom_fields = array();
     }
     $loop = self::get_custom_fields($custom_fields, 'fp5-loop', $atts, 'loop');
     $autoplay = self::get_custom_fields($custom_fields, 'fp5-autoplay', $atts, 'autoplay');
     $preload = self::get_custom_fields($custom_fields, 'fp5-preload', $atts, 'preload');
     $poster = self::get_custom_fields($custom_fields, 'fp5-poster', $atts, 'poster');
     $skin = self::get_custom_fields($custom_fields, 'fp5-select-skin', $atts, 'skin', 'minimalist');
     $formats = array('application/x-mpegurl' => self::get_custom_fields($custom_fields, 'fp5-hls-video', $atts, 'hls'), 'video/webm' => self::get_custom_fields($custom_fields, 'fp5-webm-video', $atts, 'webm'), 'video/mp4' => self::get_custom_fields($custom_fields, 'fp5-mp4-video', $atts, 'mp4'), 'video/ogg' => self::get_custom_fields($custom_fields, 'fp5-ogg-video', $atts, 'ogg'), 'video/flash' => self::get_custom_fields($custom_fields, 'fp5-flash-video', $atts, 'flash'));
     $subtitles = self::get_custom_fields($custom_fields, 'fp5-vtt-subtitles', $atts, 'subtitles');
     $max_width = self::get_custom_fields($custom_fields, 'fp5-max-width', $atts, 'max_width');
     $ratio = self::get_custom_fields($custom_fields, 'fp5-aspect-ratio', $atts, 'ratio');
     $fixed = self::get_custom_fields($custom_fields, 'fp5-fixed-width', $atts, 'fixed');
     $data_rtmp = self::get_custom_fields($custom_fields, 'fp5-data-rtmp', $atts, 'rtmp');
     $quality = self::get_custom_fields($custom_fields, 'fp5-default-quality', $atts, 'quality');
     $qualities = self::get_custom_fields($custom_fields, 'fp5-qualities', $atts, 'qualities');
     $coloring = self::get_custom_fields($custom_fields, 'fp5-coloring', $atts, 'coloring');
     $fixed_controls = self::get_custom_fields($custom_fields, 'fp5-fixed-controls', $atts, 'fixed_controls');
     $background = self::get_custom_fields($custom_fields, 'fp5-no-background', $atts, 'background');
     $aside_time = self::get_custom_fields($custom_fields, 'fp5-aside-time', $atts, 'aside_time');
     $show_title = self::get_custom_fields($custom_fields, 'fp5-show-title', $atts, 'show_title');
     $no_hover = self::get_custom_fields($custom_fields, 'fp5-no-hover', $atts, 'no_hover');
     $no_mute = self::get_custom_fields($custom_fields, 'fp5-no-mute', $atts, 'no_mute');
     $no_volume = self::get_custom_fields($custom_fields, 'fp5-no-volume', $atts, 'no_volume');
     $no_embed = self::get_custom_fields($custom_fields, 'fp5-no-embed', $atts, 'no_embed');
     $live = self::get_custom_fields($custom_fields, 'fp5-live', $atts, 'live');
     $play_button = self::get_custom_fields($custom_fields, 'fp5-play-button', $atts, 'play_button');
     $ads_time = self::get_custom_fields($custom_fields, 'fp5-ads-time', $atts, 'ads_time');
     $ad_type = self::get_custom_fields($custom_fields, 'fp5-ad-type', $atts, 'ad_type');
     $title = self::get_custom_fields($custom_fields, 'title', $atts, 'title');
     $return['splash'] = self::get_custom_fields($custom_fields, 'fp5-splash-image', $atts, 'splash');
     $return['width'] = self::get_custom_fields($custom_fields, 'fp5-width', $atts, 'width');
     $return['height'] = self::get_custom_fields($custom_fields, 'fp5-height', $atts, 'height');
     $return['description_url'] = self::get_custom_fields($custom_fields, 'fp5-description-url', $atts, 'description_url', get_permalink());
     $return['lightbox'] = self::get_custom_fields($custom_fields, 'fp5-lightbox', $atts, 'lightbox');
     // Global settings
     // set the options for the shortcode - pulled from the register-settings.php
     $options = fp5_get_settings();
     $key = isset($options['key']) ? $options['key'] : '';
     $ga_account_id = isset($options['ga_account_id']) ? $options['ga_account_id'] : '';
     $logo = isset($options['logo']) ? $options['logo'] : '';
     $logo_origin = isset($options['logo_origin']) ? $options['logo_origin'] : '';
     $brand_text = isset($options['brand_text']) ? $options['brand_text'] : '';
     $text_origin = isset($options['text_origin']) ? $options['text_origin'] : '';
     $asf_test = isset($options['asf_test']) ? $options['asf_test'] : '';
     $return['asf_js'] = isset($options['asf_js']) ? $options['asf_js'] : '';
     $return['fp_version'] = isset($options['fp_version']) ? $options['fp_version'] : '';
     // Shortcode processing
     $ratio = $return['width'] != 0 && $return['height'] != 0 ? intval($return['height']) / intval($return['width']) : '';
     if ($fixed == 'true' && $return['width'] != '' && $return['height'] != '') {
         $size = 'width:' . $return['width'] . 'px; height:' . $return['height'] . 'px; ';
     } elseif ($max_width != 0) {
         $size = 'max-width:' . $max_width . 'px; ';
     } else {
         $size = '';
     }
     $return['style'] = array($size, 'background-image: url(' . esc_url($return['splash']) . ');');
     // Prepare div data config
     $return['data_config'] = array();
     if (has_filter('fp5_filter_flowplayer_data')) {
         $return['data_config'] = array(0 < strlen($key) ? 'data-key="' . esc_attr($key) . '"' : '', 0 < strlen($key) && 0 < strlen($logo) ? 'data-logo="' . esc_url($logo) . '"' : '', 0 < strlen($ga_account_id) ? 'data-analytics="' . esc_attr($ga_account_id) . '"' : '', $ratio != 0 ? 'data-ratio="' . esc_attr($ratio) . '"' : '', !empty($data_rtmp) ? 'data-rtmp="' . esc_attr($data_rtmp) . '"' : '', !empty($quality) && !empty($qualities) ? 'data-default-quality="' . esc_attr($quality) . '"' : '', !empty($qualities) ? 'data-qualities="' . esc_attr($qualities) . '"' : '');
     }
     // Prepare video tag data config
     $video_data_config = array();
     if (!empty($title) && !empty($show_title)) {
         $video_data_config['title'] = esc_attr($title);
     }
     $return['video_data_config'] = apply_filters('fp5_video_data_config', $video_data_config, $return['id']);
     // Prepare JS config
     $js_brand_config = array();
     if (!empty($brand_text)) {
         $js_brand_config['text'] = esc_attr($brand_text);
     }
     if (1 == $text_origin) {
         $js_brand_config['showOnOrigin'] = true;
     }
     $js_brand_config = apply_filters('fp5_js_brand_config', $js_brand_config, $return['id']);
     $js_config = array();
     if (0 == $return['width'] && 0 == $return['height']) {
         $js_config['adaptiveRatio'] = true;
     }
     if ('true' == $live) {
         $js_config['live'] = esc_attr($live);
     }
     if ('true' == $no_embed) {
         $js_config['embed'] = false;
     }
     if (0 < strlen($key)) {
         $js_config['key'] = esc_attr($key);
     }
     if (0 < strlen($key) && 0 < strlen($logo)) {
         $js_config['logo'] = esc_url($logo);
     }
     if (0 < strlen($ga_account_id)) {
         $js_config['analytics'] = esc_attr($ga_account_id);
     }
     if ($ratio != 0) {
         $js_config['ratio'] = esc_attr($ratio);
     }
     if (!empty($data_rtmp)) {
         $js_config['rtmp'] = esc_attr($data_rtmp);
     }
     if (!empty($quality) && !empty($qualities)) {
         $js_config['defaultQuality'] = esc_attr($quality);
     }
     if (!empty($qualities)) {
         if ('fp6' === $return['fp_version']) {
             $js_config['qualities'] = explode(',', esc_attr($qualities));
         } else {
             $js_config['qualities'] = esc_attr($qualities);
         }
     }
     if (0 < strlen($key)) {
         $js_config['brand'] = $js_brand_config;
     }
     $return['js_config'] = apply_filters('fp5_js_config', $js_config, $return['id']);
     $return['classes'] = array('flowplayer-video flowplayer-video-' . $return['id'], $skin, !empty($return['splash']) ? 'is-splash' : '', !empty($logo_origin) ? 'commercial' : '', isset($return['id']) ? 'flowplayer-' . $return['id'] : '', 'default' != $coloring ? $coloring : '', $fixed_controls ? 'fixed-controls' : '', $background ? 'no-background' : '', $aside_time ? 'aside-time' : '', $no_hover ? 'no-hover' : '', $no_mute ? 'no-mute' : '', $no_volume ? 'no-volume' : '', $play_button ? 'play-button' : '');
     $return['attributes'] = array($autoplay == 'true' ? 'autoplay' : '', $loop == 'true' ? 'loop' : '', !empty($preload) ? 'preload="' . esc_attr($preload) . '"' : '', $poster == 'true' ? 'poster' : '');
     $return['asf_test'] = !empty($asf_test) ? 'on' : 'off';
     $ads_time = isset($ads_time) ? $ads_time : '';
     $return['ads_time'] = 0 == $ads_time ? 0.01 : $ads_time;
     $return['ad_type'] = !empty($ad_type) ? esc_attr($ad_type) : '';
     $return['source'] = array();
     foreach ($formats as $format => $src) {
         if (!empty($src)) {
             $return['src'][$format] = apply_filters('fp5_filter_video_src', $src, $format, $return['id']);
             $return['source'][$format] = '<source type="' . esc_attr($format) . '" src="' . esc_attr($return['src'][$format]) . '">';
         }
     }
     $return['track'] = '';
     if ('' != $subtitles) {
         $return['track'] = '<track src="' . esc_url($subtitles) . '"/>';
     }
     // Check if a video has been added before output
     if ($formats['video/webm'] || $formats['video/mp4'] || $formats['video/ogg'] || $formats['video/flash'] || $formats['application/x-mpegurl']) {
         return $return;
     }
 }
コード例 #4
0
    /**
     * Flowplayer global JavaScript settings.
     *
     * @since    1.0.0
     */
    public function global_config_script()
    {
        // set the options for the shortcode - pulled from the display-settings.php
        $options = fp5_get_settings();
        $embed_library = !empty($options['library']) ? $options['library'] : '';
        $embed_script = !empty($options['script']) ? $options['script'] : '';
        $embed_skin = !empty($options['skin']) ? $options['skin'] : '';
        $embed_swf = !empty($options['swf']) ? $options['swf'] : '';
        $asf_js = !empty($options['asf_js']) ? $options['asf_js'] : '';
        if (($embed_library || $embed_script || $embed_skin || $embed_swf) && $this->has_flowplayer_video) {
            $return = '<!-- flowplayer global options -->';
            $return .= '<script>';
            $return .= 'flowplayer.conf = {';
            $return .= 'embed: {';
            $return .= !empty($embed_library) ? 'library: "' . esc_js($embed_library) . '",' : '';
            $return .= !empty($embed_script) ? 'script: "' . esc_js($embed_script) . '",' : '';
            $return .= !empty($embed_skin) ? 'skin: "' . esc_js($embed_skin) . '",' : '';
            $return .= !empty($embed_swf) ? 'swf: "' . esc_js($embed_swf) . '"' : '';
            $return .= '}';
            $return .= '};';
            $return .= '</script>';
            echo $return;
        }
        if ($asf_js) {
            ?>
			<script>
			flowplayer(function(api, root) {
				flowplayer_ima.create(api, root);
			});
			</script>
		<?php 
        }
    }