PluginProbe
PlayerJS – Free Custom HTML5 Video and Audio Player Builder / 2.21
PlayerJS – Free Custom HTML5 Video and Audio Player Builder v2.21
trunk 2.2 2.21 2.24 2.25
playerjs / playerjs.php

playerjs.php in PlayerJS – Free Custom HTML5 Video and Audio Player Builder 2.21, at playerjs.php

227 lines 6.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: PlayerJS
4 * Plugin URI: https://playerjs.com/docs/q=wordpress
5 * Description: Embed your created player in PlayerJS Builder and play HTML5 Video, Audio, HLS, DASH, YouTube, Vimeo
6 * Version: 2.21
7 * Author: Playerjs.com
8 * Author URI: https://playerjs.com
9 * License: GPL-2.0+
10 * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
11 * Text Domain: playerjs
12 */
13
14
15 if (!defined('ABSPATH')) {
16 exit;
17 }
18
19 if(is_admin()) {
20
21 add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'playerjs_com_action_links' );
22
23 include( dirname( __FILE__ ) . '/admin/playerjs_com_admin.php' );
24
25 }else{
26
27 if (!class_exists('PLAYERJS_HTML5')) {
28
29 class PLAYERJS_HTML5 {
30
31 var $plugin_version = '2.21';
32
33 function __construct() {
34 define('PLAYERJS_VERSION', $this->plugin_version);
35 add_action('wp_enqueue_scripts',array($this, 'plugin_script'));
36 $this->plugin_includes();
37 }
38
39 function plugin_script() {
40 $path = get_option('playerjs_com_script_path');
41 $path = $path ? $path['input'] : '';
42 if(trim($path)==''){
43 $path = plugins_url('').'/playerjs/playerjs_default.js';
44 }
45 wp_enqueue_script('playerjs-js', $path);
46 }
47
48 function plugin_includes() {
49 add_filter('the_content', 'playerjs_content' );
50 add_shortcode('playerjs', 'playerjs_com_handler');
51 add_filter('widget_text', 'do_shortcode');
52 add_filter('the_excerpt', 'do_shortcode', 11);
53 add_filter('the_content', 'do_shortcode', 11);
54 }
55
56 }
57
58 $GLOBALS['playerjs_player'] = new PLAYERJS_HTML5();
59
60 }
61
62 }
63
64 function playerjs_com_action_links ( $links ) {
65 $mylinks = array('<a href="' . admin_url( 'options-general.php?page=playerjs_com_admin' ) . '">Settings</a>'); return array_merge($links, $mylinks);
66 }
67
68 function playerjs_content($x){
69 $y = strpos($x,'[playerjs');
70 if($y!==FALSE){
71 $z = explode('[playerjs',$x);
72 for ($i = ($y===0?0:1); $i < count($z); $i++) {
73 $open=0;
74 $x1 = 'playerjs';
75 for ($j = 0; $j < strlen($z[$i]); $j++) {
76
77 if ($z[$i][$j] == "]" && $open==0) {
78 break;
79 }else{
80 if($z[$i][$j] == "["){
81 $open++;
82 }
83 if($z[$i][$j] == "]"){
84 $open--;
85 }
86 $x1.= $z[$i][$j];
87 }
88 }
89 if($x1!=''){
90 $x2 = str_replace('[','&#91;',$x1);
91 $x2 = str_replace(']','&#93;',$x2);
92 $x2 = str_replace("'",'&#8216;',$x2);
93 $x = str_replace("[".$x1."]","[".$x2."]",$x);
94 }
95 }
96 }
97 return $x;
98 }
99
100 function playerjs_com_handler($atts) {
101 $x = '';
102 $u = wp_get_current_user();
103
104 if(isset($atts['file'])||isset($atts['replace'])){
105
106 $r = rand(10000,20000);
107
108 $style = '';
109
110 foreach ($atts as $k => $v){
111 if(gettype($k) == "integer" && isset($k0)){
112 $atts[$k0] .=' '.$v;
113 unset($atts[$k]);
114 }else{
115 $k0 = $k;
116 }
117 }
118 foreach ($atts as $k => $v){
119 $vars = '';
120 $v = str_replace("&#091;","[",$v);
121 $v = str_replace("&#093;","]",$v);
122 $v = str_replace("&#187;","",$v);
123 $v = str_replace("&#8243;","",$v);
124 $v = str_replace("&#8221;","",$v);
125
126 if(strpos($v,"[")!==false && strpos($v,"{")!==false){
127 $v = str_replace("&#8216;","pjs'qt",$v);
128 $v = str_replace("&#8217;","pjs'qt",$v);
129 $v = str_replace("&#8242;","pjs'qt",$v);
130 }
131
132 if($k=="file"){
133 $r = md5($v);
134 $base = dirname( __FILE__ ) . '/admin/playerjs_base64.php';
135 if(file_exists($base)){
136 include_once($base);
137 $v = pjsBase64Encrypt($v);
138 }
139 }
140
141
142
143 $dont = false;
144 if($k=="watermark" && $v==1){
145 if($u){
146 if($u->data->ID>0){
147 $vars.=',wid:"'.$u->data->user_login.'"';
148 $dont = true;
149 }
150 }
151 }
152
153 if(!$dont && $k!='align' && $k!='margin' && $k!='width' && $k!='height'){
154 $vars .= ','.$k.':"'.$v.'"';
155 }
156 }
157
158 if(!isset($atts['replace'])){
159 $vars.= ',id:"playerjs'.$r.'"';
160 }
161
162 $align = playerjs_com_get_option('align',0,'');
163
164 if(isset($atts['align'])){
165 $atts['align']=='left'?$style='float:left;':'';
166 $align = $atts['align'];
167 }
168
169 if(isset($atts['margin'])){
170 $style.='margin:'.$atts['margin'].'px;';
171 }
172
173 // width
174
175 $width = playerjs_com_get_option('width',0,'');
176
177 isset($atts['width'])?$width = $atts['width']:'';
178
179 if($width!=''){
180 $style.='width:'.(strpos($width,'%')>0?$width:(strpos($width,'px')>0?$width:$width.'px')).';';
181 }
182
183 // height
184
185 $height = '';
186
187 $customheight = playerjs_com_get_option('customheight',0,'');
188
189 if($customheight=="custom"){
190 $height = playerjs_com_get_option('height',0,'280px');
191 }
192
193 isset($atts['height'])?$height = $atts['height']:'';
194
195 if($height!=''){
196 $style.='height:'.(strpos($height,'%')>0?$height:(strpos($height,'px')>0?$height:$height.'px')).';';
197 $vars .= ',aspect:"off"';
198 }
199
200 if(!isset($atts['replace'])){
201 $x = ($align=='center'?'<center>':'').'<div id="playerjs'.$r.'" '.($style!=''?'style="'.$style.'"':'').'></div>'.($align=='center'?'</center>':'');
202 }else{
203 $x = '';
204 }
205
206 if(substr($vars,0,1)==","){
207 $vars = substr($vars,1);
208 }
209
210 $x.='<script>var player'.$r.' = new Playerjs({'.$vars.'});</script>';
211
212 }
213 return $x;
214 }
215
216 function playerjs_com_get_option($x,$checkbox,$default){
217 $y = get_option('playerjs_com_'.$x);
218 //echo($x.' '.gettype($y).' '.$y.'<br>');
219 $y = gettype($y)=="array" ? $y[($checkbox==1?'checkbox':'input')] : $default;
220 if($checkbox==0){
221 if(trim($y)==''||trim($y)=='0'){
222 $y = $default;
223 }
224 }
225 return $y;
226 }
227