PluginProbe
Easy Video Player / 1.1.2
Easy Video Player v1.1.2
trunk 1.0.1 1.0.2 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8
easy-video-player / easy-video-player.php

easy-video-player.php in Easy Video Player 1.1.2, at easy-video-player.php

227 lines 8.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: Easy Video Player
4 Version: 1.1.2
5 Plugin URI: http://noorsplugin.com/wordpress-video-plugin/
6 Author: naa986
7 Author URI: http://noorsplugin.com/
8 Description: Easily embed videos into your WordPress blog
9 Text Domain: easy-video-player
10 Domain Path: /languages
11 */
12
13 if (!defined('ABSPATH')) {
14 exit;
15 }
16 if (!class_exists('EASY_VIDEO_PLAYER')) {
17
18 class EASY_VIDEO_PLAYER {
19
20 var $plugin_version = '1.1.2';
21
22 function __construct() {
23 define('EASY_VIDEO_PLAYER_VERSION', $this->plugin_version);
24 $this->plugin_includes();
25 }
26
27 function plugin_includes() {
28 if (is_admin()) {
29 add_filter('plugin_action_links', array(&$this, 'easy_video_player_plugin_action_links'), 10, 2);
30 }
31 add_action('plugins_loaded', array($this, 'plugins_loaded_handler'));
32 add_action('wp_enqueue_scripts', 'easy_video_player_enqueue_scripts');
33 add_action('admin_menu', array($this, 'easy_video_player_add_options_menu'));
34 add_action('wp_head', 'easy_video_player_header');
35 add_shortcode('evp_embed_video', 'evp_embed_video_handler');
36 //allows shortcode execution in the widget, excerpt and content
37 add_filter('widget_text', 'do_shortcode');
38 add_filter('the_excerpt', 'do_shortcode', 11);
39 add_filter('the_content', 'do_shortcode', 11);
40 }
41
42 function plugin_url() {
43 if ($this->plugin_url)
44 return $this->plugin_url;
45 return $this->plugin_url = plugins_url(basename(plugin_dir_path(__FILE__)), basename(__FILE__));
46 }
47
48 function easy_video_player_plugin_action_links($links, $file) {
49 if ($file == plugin_basename(dirname(__FILE__) . '/easy-video-player.php')) {
50 $links[] = '<a href="options-general.php?page=easy-video-player-settings">'.__('Settings', 'easy-video-player').'</a>';
51 }
52 return $links;
53 }
54
55 function plugins_loaded_handler()
56 {
57 load_plugin_textdomain('easy-video-player', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/');
58 }
59
60 function easy_video_player_add_options_menu() {
61 if (is_admin()) {
62 add_options_page(__('Easy Video Player', 'easy-video-player'), __('Easy Video Player', 'easy-video-player'), 'manage_options', 'easy-video-player-settings', array($this, 'easy_video_player_options_page'));
63 }
64 add_action('admin_init', array(&$this, 'easy_video_player_add_settings'));
65 }
66
67 function easy_video_player_add_settings() {
68 register_setting('easy-video-player-settings-group', 'evp_enable_jquery');
69 }
70
71 function easy_video_player_options_page() {
72 $url = "http://noorsplugin.com/wordpress-video-plugin/";
73 $link_text = sprintf(wp_kses(__('For detailed documentation please visit the plugin homepage <a target="_blank" href="%s">here</a>.', 'easy-video-player'), array('a' => array('href' => array(), 'target' => array()))), esc_url($url));
74 ?>
75 <div class="wrap">
76 <h1>Easy Video Player - v<?php echo $this->plugin_version; ?></h1>
77 <div class="update-nag"><?php echo $link_text;?></div>
78 <h2 class="title"><?php _e('General Settings', 'easy-video-player')?></h2>
79 <form method="post" action="options.php">
80 <?php settings_fields('easy-video-player-settings-group'); ?>
81 <table class="form-table">
82 <tr valign="top">
83 <th scope="row"><?php _e('Enable jQuery', 'easy-video-player')?></th>
84 <td><input type="checkbox" id="evp_enable_jquery" name="evp_enable_jquery" value="1" <?php echo checked(1, get_option('evp_enable_jquery'), false) ?> />
85 <p><i><?php _e('By default this option should always be checked.', 'easy-video-player')?></i></p>
86 </td>
87 </tr>
88 </table>
89
90 <p class="submit">
91 <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
92 </p>
93 </form>
94 </div>
95 <?php
96 }
97
98 }
99
100 $GLOBALS['easy_video_player'] = new EASY_VIDEO_PLAYER();
101 }
102
103 function easy_video_player_enqueue_scripts() {
104 if (!is_admin()) {
105 $plugin_url = plugins_url('', __FILE__);
106 $enable_jquery = get_option('evp_enable_jquery');
107 if ($enable_jquery) {
108 wp_enqueue_script('jquery');
109 }
110 wp_register_script('flowplayer-js', $plugin_url . '/lib/flowplayer.min.js');
111 wp_enqueue_script('flowplayer-js');
112 wp_register_style('flowplayer-css', $plugin_url . '/lib/skin/all-skins.css');
113 wp_enqueue_style('flowplayer-css');
114 }
115 }
116
117 function easy_video_player_header() {
118 if (!is_admin()) {
119 $fp_config = '<!-- This content is generated with the Easy Video Player plugin v' . EASY_VIDEO_PLAYER_VERSION . ' - http://noorsplugin.com/wordpress-video-plugin/ -->';
120 $fp_config .= '<script>';
121 $fp_config .= 'flowplayer.conf.embed = false;';
122 $fp_config .= 'flowplayer.conf.keyboard = false;';
123 $fp_config .= '</script>';
124 $fp_config .= '<!-- Easy Video Player plugin -->';
125 echo $fp_config;
126 }
127 }
128
129 function evp_embed_video_handler($atts) {
130 extract(shortcode_atts(array(
131 'url' => '',
132 'width' => '',
133 'height' => '',
134 'ratio' => '0.417',
135 'autoplay' => 'false',
136 'poster' => '',
137 'loop' => '',
138 'muted' => '',
139 'class' => '',
140 'template' => '',
141 ), $atts));
142 //check if mediaelement template is specified
143 if($template=='mediaelement'){
144 $attr = array();
145 $attr['src'] = $url;
146 if(is_numeric($width)){
147 $attr['width'] = $width;
148 }
149 if(is_numeric($height)){
150 $attr['height'] = $height;
151 }
152 if ($autoplay == "true"){
153 $attr['autoplay'] = 'on';
154 }
155 if ($loop == "true"){
156 $attr['loop'] = 'on';
157 }
158 if (!empty($poster)){
159 $attr['poster'] = $poster;
160 }
161 return wp_video_shortcode($attr);
162 }
163 //autoplay
164 if ($autoplay == "true") {
165 $autoplay = " autoplay";
166 } else {
167 $autoplay = "";
168 }
169 //loop
170 if ($loop == "true") {
171 $loop= " loop";
172 }
173 else{
174 $loop= "";
175 }
176 //muted
177 if($muted == "true"){
178 $muted = " muted";
179 }
180 else{
181 $muted = "";
182 }
183 $player = "fp" . uniqid();
184 $color = '';
185 if (!empty($poster)) {
186 $color = 'background: #000 url('.$poster.') 0 0 no-repeat;background-size: 100%;';
187 } else {
188 $color = 'background-color: #000;';
189 }
190 $size_attr = "";
191 if (!empty($width)) {
192 $size_attr = "max-width: {$width}px;max-height: auto;";
193 }
194 $class_array = array('flowplayer', 'minimalist');
195 if(!empty($class)){
196 $shortcode_class_array = array_map('trim', explode(' ', $class));
197 $shortcode_class_array = array_filter( $shortcode_class_array, 'strlen' );
198 $shortcode_class_array = array_values($shortcode_class_array);
199 if(in_array("functional", $shortcode_class_array) || in_array("playful", $shortcode_class_array)){
200 $class_array = array_diff($class_array, array('minimalist'));
201 }
202 $class_array = array_merge($class_array, $shortcode_class_array);
203 $class_array = array_unique($class_array);
204 $class_array = array_values($class_array);
205 }
206
207 $classes = implode(" ", $class_array);
208 $styles = <<<EOT
209 <style>
210 #$player {
211 $size_attr
212 $color
213 }
214 </style>
215 EOT;
216
217 $output = <<<EOT
218 <div id="$player" data-ratio="$ratio" class="{$classes}">
219 <video{$autoplay}{$loop}{$muted}>
220 <source type="video/mp4" src="$url"/>
221 </video>
222 </div>
223 $styles
224 EOT;
225 return $output;
226 }
227