Beispiel #1
0
 /**
  * Translate a 'videopress' or 'wpvideo' shortcode and arguments into a video player display.
  *
  * @link http://codex.wordpress.org/Shortcode_API Shortcode API
  * @param array $attr shortcode attributes
  * @return string HTML markup or blank string on fail
  */
 public function shortcode_callback($attr, $content = '')
 {
     global $content_width;
     $guid = $attr[0];
     if (!$this->is_valid_guid($guid)) {
         return '';
     }
     $attr = shortcode_atts(array('w' => 0, 'freedom' => false, 'flashonly' => false, 'autoplay' => false, 'hd' => false), $attr);
     $attr['forcestatic'] = false;
     $attr['freedom'] = (bool) $attr['freedom'];
     $attr['hd'] = (bool) $attr['hd'];
     $attr['width'] = absint($attr['w']);
     if ($attr['width'] < $this->min_width) {
         $attr['width'] = 0;
     } elseif (isset($content_width) && $content_width > $this->min_width && $attr['width'] > $content_width) {
         $attr['width'] = 0;
     }
     if ($attr['width'] === 0 && isset($content_width) && $content_width > $this->min_width) {
         $attr['width'] = $content_width;
     }
     if ($attr['width'] % 2 === 1) {
         $attr['width']--;
     }
     $options = apply_filters('videopress_shortcode_options', array('freedom' => $attr['freedom'], 'force_flash' => (bool) $attr['flashonly'], 'autoplay' => (bool) $attr['autoplay'], 'forcestatic' => $attr['forcestatic'], 'hd' => (bool) $attr['hd']));
     // Enqueue VideoPress scripts
     self::enqueue_scripts();
     require_once dirname(__FILE__) . '/class.videopress-video.php';
     require_once dirname(__FILE__) . '/class.videopress-player.php';
     $player = new VideoPress_Player($guid, $attr['width'], $options);
     if (is_feed()) {
         return $player->asXML();
     } else {
         return $player->asHTML();
     }
 }
Beispiel #2
0
 /**
  * Translate a 'videopress' or 'wpvideo' shortcode and arguments into a video player display.
  *
  * @link http://codex.wordpress.org/Shortcode_API Shortcode API
  * @param array $attr shortcode attributes
  * @return string HTML markup or blank string on fail
  */
 public function shortcode_callback($attr, $content = '')
 {
     global $content_width;
     $guid = $attr[0];
     if (!$this->is_valid_guid($guid)) {
         return '';
     }
     $attr = shortcode_atts(array('w' => 0, 'h' => 0, 'freedom' => false, 'flashonly' => false, 'autoplay' => false, 'hd' => false, 'permalink' => true, 'loop' => false, 'at' => 0, 'defaultlangcode' => false), $attr);
     $attr['forcestatic'] = false;
     $attr['freedom'] = (bool) $attr['freedom'];
     $attr['hd'] = (bool) $attr['hd'];
     $attr['width'] = absint($attr['w']);
     if ($attr['width'] < $this->min_width) {
         $attr['width'] = 0;
     } elseif (isset($content_width) && $content_width > $this->min_width && $attr['width'] > $content_width) {
         $attr['width'] = 0;
     }
     if ($attr['width'] === 0 && isset($content_width) && $content_width > $this->min_width) {
         $attr['width'] = $content_width;
     }
     if ($attr['width'] % 2 === 1) {
         $attr['width']--;
     }
     /**
      * Filter the default VideoPress shortcode options.
      *
      * @module videopress
      *
      * @since 2.5.0
      *
      * @param array $args Array of VideoPress shortcode options.
      */
     $options = apply_filters('videopress_shortcode_options', array('freedom' => $attr['freedom'], 'force_flash' => (bool) $attr['flashonly'], 'autoplay' => $attr['autoplay'], 'forcestatic' => $attr['forcestatic'], 'hd' => $attr['hd'], 'permalink' => $attr['permalink'], 'loop' => $attr['autoplay'], 'at' => (int) $attr['at'], 'defaultlangcode' => $attr['defaultlangcode']));
     // Enqueue VideoPress scripts
     self::register_scripts();
     require_once dirname(__FILE__) . '/class.videopress-video.php';
     require_once dirname(__FILE__) . '/class.videopress-player.php';
     $player = new VideoPress_Player($guid, $attr['width'], $options);
     if (is_feed()) {
         return $player->asXML();
     } else {
         return $player->asHTML();
     }
 }
Beispiel #3
0
 /**
  * Translate a 'videopress' or 'wpvideo' shortcode and arguments into a video player display.
  *
  * @link http://codex.wordpress.org/Shortcode_API Shortcode API
  * @param array $attr shortcode attributes
  * @return string HTML markup or blank string on fail
  */
 public function shortcode($attr)
 {
     global $content_width;
     $guid = $attr[0];
     if (!self::is_valid_guid($guid)) {
         return '';
     }
     if (array_key_exists($guid, $this->shown)) {
         $this->shown[$guid]++;
     } else {
         $this->shown[$guid] = 1;
     }
     extract(shortcode_atts(array('w' => 0, 'freedom' => false, 'flashonly' => false, 'autoplay' => false, 'hd' => false), $attr));
     $freedom = (bool) $freedom;
     /**
      * Test if embedded blog prefers videos only displayed in Freedom-loving formats
      */
     if ($freedom === false && (bool) get_option('video_player_freedom', false)) {
         $freedom = true;
     }
     $forcestatic = get_option('video_player_static', false);
     /**
      * Set the video to HD if the blog option has it enabled
      */
     if ((bool) get_option('video_player_high_quality', false)) {
         $hd = true;
     }
     $width = absint($w);
     unset($w);
     if ($width < self::min_width) {
         $width = 0;
     } elseif (isset($content_width) && $content_width > self::min_width && $width > $content_width) {
         $width = 0;
     }
     if ($width === 0 && isset($content_width) && $content_width > self::min_width) {
         $width = $content_width;
     }
     if ($width % 2 === 1) {
         $width--;
     }
     $options = array('freedom' => $freedom, 'force_flash' => (bool) $flashonly, 'autoplay' => (bool) $autoplay, 'forcestatic' => $forcestatic, 'hd' => (bool) $hd);
     unset($freedom);
     unset($flashonly);
     add_action('wp_footer', array($this, 'print_scripts'), -1);
     $player = new VideoPress_Player($guid, $width, $options);
     if ($player instanceof VideoPress_Player) {
         if (is_feed()) {
             return $player->asXML();
         } else {
             return $player->asHTML();
         }
     } else {
         return 'error';
     }
 }
Beispiel #4
0
/**
 * Translate a 'videopress' or 'wpvideo' shortcode and arguments into a video player display.
 *
 * Expected input formats:
 *
 * [videopress OcobLTqC]
 * [wpvideo OcobLTqC]
 *
 * @link http://codex.wordpress.org/Shortcode_API Shortcode API
 * @param array $attr shortcode attributes
 * @return string HTML markup or blank string on fail
 */
function videopress_shortcode_callback($attr)
{
    global $content_width;
    /**
     * We only accept GUIDs as a first unnamed argument.
     */
    $guid = $attr[0];
    /**
     * Make sure the GUID passed in matches how actual GUIDs are formatted.
     */
    if (!videopress_is_valid_guid($guid)) {
        return '';
    }
    /**
     * Set the defaults
     */
    $defaults = array('w' => 0, 'at' => 0, 'hd' => true, 'loop' => false, 'freedom' => false, 'autoplay' => false, 'permalink' => true, 'flashonly' => false, 'defaultlangcode' => false);
    $attr = shortcode_atts($defaults, $attr, 'videopress');
    /**
     * Cast the attributes, post-input.
     */
    $attr['width'] = absint($attr['w']);
    $attr['hd'] = (bool) $attr['hd'];
    $attr['freedom'] = (bool) $attr['freedom'];
    /**
     * If the provided width is less than the minimum allowed
     * width, or greater than `$content_width` ignore.
     */
    if ($attr['width'] < VIDEOPRESS_MIN_WIDTH) {
        $attr['width'] = 0;
    } elseif (isset($content_width) && $content_width > VIDEOPRESS_MIN_WIDTH && $attr['width'] > $content_width) {
        $attr['width'] = 0;
    }
    /**
     * If there was an invalid or unspecified width, set the width equal to the theme's `$content_width`.
     */
    if (0 === $attr['width'] && isset($content_width) && $content_width >= VIDEOPRESS_MIN_WIDTH) {
        $attr['width'] = $content_width;
    }
    /**
     * If the width isn't an even number, reduce it by one (making it even).
     */
    if (1 === $attr['width'] % 2) {
        $attr['width']--;
    }
    /**
     * Filter the default VideoPress shortcode options.
     *
     * @module videopress
     *
     * @since 2.5.0
     *
     * @param array $args Array of VideoPress shortcode options.
     */
    $options = apply_filters('videopress_shortcode_options', array('at' => (int) $attr['at'], 'hd' => $attr['hd'], 'loop' => $attr['autoplay'] || $attr['loop'], 'freedom' => $attr['freedom'], 'autoplay' => $attr['autoplay'], 'permalink' => $attr['permalink'], 'force_flash' => (bool) $attr['flashonly'], 'defaultlangcode' => $attr['defaultlangcode'], 'forcestatic' => false));
    // Register VideoPress scripts
    wp_register_script('videopress', 'https://v0.wordpress.com/js/videopress.js', array('jquery', 'swfobject'), '1.09');
    require_once dirname(__FILE__) . '/class.videopress-video.php';
    require_once dirname(__FILE__) . '/class.videopress-player.php';
    $player = new VideoPress_Player($guid, $attr['width'], $options);
    if (is_feed()) {
        return $player->asXML();
    } else {
        return $player->asHTML();
    }
}
 /**
  * Translate a 'videopress' or 'wpvideo' shortcode and arguments into a video player display.
  *
  * @link http://codex.wordpress.org/Shortcode_API Shortcode API
  * @param array $attr shortcode attributes
  * @return string HTML markup or blank string on fail
  */
 public function shortcode($attr)
 {
     global $content_width;
     $guid = $attr[0];
     if (!self::is_valid_guid($guid)) {
         return '';
     }
     if (array_key_exists($guid, $this->shown)) {
         $this->shown[$guid]++;
     } else {
         $this->shown[$guid] = 1;
     }
     extract(shortcode_atts(array('w' => 0, 'freedom' => false, 'flashonly' => false, 'autoplay' => false), $attr));
     $freedom = (bool) $freedom;
     $width = absint($w);
     unset($w);
     if ($width < self::min_width) {
         $width = 0;
     } elseif (isset($content_width) && $content_width > self::min_width && $width > $content_width) {
         $width = 0;
     }
     if ($width === 0 && isset($content_width) && $content_width > self::min_width) {
         $width = $content_width;
     }
     if ($width % 2 === 1) {
         $width--;
     }
     $options = array('freedom' => $freedom, 'force_flash' => (bool) $flashonly, 'autoplay' => (bool) $autoplay);
     unset($freedom);
     unset($flashonly);
     add_action('wp_footer', array(&$this, 'print_scripts'), -1);
     $player = new VideoPress_Player($guid, $width, $options);
     if ($player instanceof VideoPress_Player) {
         if (is_feed()) {
             return $player->asXML();
         } else {
             return $player->asHTML();
         }
     } else {
         return 'error';
     }
 }