| 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.24 |
| 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.23'; |
| 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 |
add_filter('the_content', 'playerjs_content2',12); |
| 55 |
add_filter('script_loader_tag', 'playerjs_async', 11, 2); |
| 56 |
} |
| 57 |
|
| 58 |
} |
| 59 |
$GLOBALS['playerjs_configs'] = new stdClass(); |
| 60 |
$GLOBALS['playerjs_player'] = new PLAYERJS_HTML5(); |
| 61 |
|
| 62 |
} |
| 63 |
|
| 64 |
} |
| 65 |
|
| 66 |
function playerjs_async( $tag, $handle ) { |
| 67 |
if ( 'playerjs-js' !== $handle ) { |
| 68 |
return $tag; |
| 69 |
} |
| 70 |
return str_replace( ' src', ' async="async" src', $tag ); |
| 71 |
} |
| 72 |
|
| 73 |
function playerjs_com_action_links ( $links ) { |
| 74 |
$mylinks = array('<a href="' . admin_url( 'options-general.php?page=playerjs_com_admin' ) . '">Settings</a>'); return array_merge($links, $mylinks); |
| 75 |
} |
| 76 |
|
| 77 |
function playerjs_content($x){ |
| 78 |
$y = strpos($x,'[playerjs'); |
| 79 |
if($y!==FALSE){ |
| 80 |
$z = explode('[playerjs',$x); |
| 81 |
for ($i = ($y===0?0:1); $i < count($z); $i++) { |
| 82 |
$open=0; |
| 83 |
$x1 = 'playerjs'; |
| 84 |
for ($j = 0; $j < strlen($z[$i]); $j++) { |
| 85 |
|
| 86 |
if ($z[$i][$j] == "]" && $open==0) { |
| 87 |
break; |
| 88 |
}else{ |
| 89 |
if($z[$i][$j] == "["){ |
| 90 |
$open++; |
| 91 |
} |
| 92 |
if($z[$i][$j] == "]"){ |
| 93 |
$open--; |
| 94 |
} |
| 95 |
$x1.= $z[$i][$j]; |
| 96 |
} |
| 97 |
} |
| 98 |
if($x1!=''){ |
| 99 |
$x2 = str_replace('[','[',$x1); |
| 100 |
$x2 = str_replace(']',']',$x2); |
| 101 |
$x2 = str_replace("'",'‘',$x2); |
| 102 |
$x = str_replace("[".$x1."]","[".$x2."]",$x); |
| 103 |
} |
| 104 |
} |
| 105 |
} |
| 106 |
return $x; |
| 107 |
} |
| 108 |
|
| 109 |
function playerjs_content2($x){ |
| 110 |
$p = $GLOBALS['playerjs_configs']; |
| 111 |
if(isset($p)){ |
| 112 |
$x.= '<script>function PlayerjsAsync(){'; |
| 113 |
foreach ($p as $k => $v){ |
| 114 |
$x.='var '.$k.' = new Playerjs({'.$v.'});'; |
| 115 |
} |
| 116 |
} |
| 117 |
return $x.'} if(window["Playerjs"]){PlayerjsAsync();}</script>'; |
| 118 |
} |
| 119 |
|
| 120 |
function playerjs_com_handler($atts) { |
| 121 |
$x = ''; |
| 122 |
$u = wp_get_current_user(); |
| 123 |
|
| 124 |
if(isset($atts['file'])||isset($atts['replace'])){ |
| 125 |
|
| 126 |
$r = wp_rand(10000,20000); |
| 127 |
|
| 128 |
$style = ''; |
| 129 |
|
| 130 |
foreach ($atts as $k => $v){ |
| 131 |
if(gettype($k) == "integer" && isset($k0)){ |
| 132 |
$atts[$k0] .=' '.$v; |
| 133 |
unset($atts[$k]); |
| 134 |
}else{ |
| 135 |
$k0 = $k; |
| 136 |
} |
| 137 |
} |
| 138 |
$vars = ''; |
| 139 |
foreach ($atts as $k => $v){ |
| 140 |
$v = str_replace("[","[",$v); |
| 141 |
$v = str_replace("]","]",$v); |
| 142 |
$v = str_replace("»","",$v); |
| 143 |
$v = str_replace("″","",$v); |
| 144 |
$v = str_replace("”","",$v); |
| 145 |
|
| 146 |
if(strpos($v,"[")!==false && strpos($v,"{")!==false){ |
| 147 |
$v = str_replace("‘","pjs'qt",$v); |
| 148 |
$v = str_replace("’","pjs'qt",$v); |
| 149 |
$v = str_replace("′","pjs'qt",$v); |
| 150 |
} |
| 151 |
|
| 152 |
if($k=="file"){ |
| 153 |
$r = md5($v); |
| 154 |
$base = dirname( __FILE__ ) . '/admin/playerjs_base64.php'; |
| 155 |
if(file_exists($base)){ |
| 156 |
include_once($base); |
| 157 |
$v = pjsBase64Encrypt($v); |
| 158 |
} |
| 159 |
} |
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
$dont = false; |
| 164 |
if($k=="watermark" && $v==1){ |
| 165 |
if($u){ |
| 166 |
if($u->data->ID>0){ |
| 167 |
$vars.=',wid:"'.$u->data->user_login.'"'; |
| 168 |
$dont = true; |
| 169 |
} |
| 170 |
} |
| 171 |
} |
| 172 |
|
| 173 |
if(!$dont && $k!='align' && $k!='margin' && $k!='width' && $k!='height'){ |
| 174 |
$vars .= ','.$k.':"'.$v.'"'; |
| 175 |
} |
| 176 |
} |
| 177 |
|
| 178 |
if(!isset($atts['replace'])){ |
| 179 |
$vars.= ',id:"playerjs'.$r.'"'; |
| 180 |
} |
| 181 |
|
| 182 |
$align = playerjs_com_get_option('align',0,''); |
| 183 |
|
| 184 |
if(isset($atts['align'])){ |
| 185 |
$atts['align']=='left'?$style='float:left;':''; |
| 186 |
$align = $atts['align']; |
| 187 |
} |
| 188 |
|
| 189 |
if(isset($atts['margin'])){ |
| 190 |
$style.='margin:'.intval($atts['margin']).'px;'; |
| 191 |
} |
| 192 |
|
| 193 |
// width |
| 194 |
|
| 195 |
$width = playerjs_com_get_option('width',0,''); |
| 196 |
|
| 197 |
isset($atts['width'])?$width = $atts['width']:''; |
| 198 |
|
| 199 |
if($width!=''){ |
| 200 |
$width_ext = 'px'; |
| 201 |
if(strpos($width,'%')>0){ |
| 202 |
$width_ext = '%'; |
| 203 |
} |
| 204 |
$width = str_replace('%','',$width); |
| 205 |
$width = str_replace('px','',$width); |
| 206 |
$style.='width:'.intval($width).$width_ext.';'; |
| 207 |
} |
| 208 |
|
| 209 |
// height |
| 210 |
|
| 211 |
$height = ''; |
| 212 |
|
| 213 |
$customheight = playerjs_com_get_option('customheight',0,''); |
| 214 |
|
| 215 |
if($customheight=="custom"){ |
| 216 |
$height = playerjs_com_get_option('height',0,'280px'); |
| 217 |
} |
| 218 |
|
| 219 |
isset($atts['height'])?$height = $atts['height']:''; |
| 220 |
|
| 221 |
if($height!=''){ |
| 222 |
$height_ext = 'px'; |
| 223 |
if(strpos($height,'%')>0){ |
| 224 |
$height_ext = '%'; |
| 225 |
} |
| 226 |
$height = str_replace('%','',$height); |
| 227 |
$height = str_replace('px','',$height); |
| 228 |
$style.='height:'.intval($height).$height_ext.';'; |
| 229 |
$vars .= ',aspect:"off"'; |
| 230 |
} |
| 231 |
} |
| 232 |
if(substr($vars,0,1)==","){ |
| 233 |
$vars = substr($vars,1); |
| 234 |
} |
| 235 |
if(!isset($atts['replace'])){ |
| 236 |
$x = ($align=='center'?'<center>':'').'<div id="playerjs'.$r.'" '.($style!=''?'style="'.$style.'"':'').'></div>'.($align=='center'?'</center>':''); |
| 237 |
}else{ |
| 238 |
$x = ''; |
| 239 |
} |
| 240 |
$GLOBALS['playerjs_configs']->{'player'.$r} = $vars; |
| 241 |
return $x; |
| 242 |
} |
| 243 |
|
| 244 |
function playerjs_com_get_option($x,$checkbox,$default){ |
| 245 |
$y = get_option('playerjs_com_'.$x); |
| 246 |
//echo($x.' '.gettype($y).' '.$y.'<br>'); |
| 247 |
$y = gettype($y)=="array" ? $y[($checkbox==1?'checkbox':'input')] : $default; |
| 248 |
if($checkbox==0){ |
| 249 |
if(trim($y)==''||trim($y)=='0'){ |
| 250 |
$y = $default; |
| 251 |
} |
| 252 |
} |
| 253 |
return $y; |
| 254 |
} |
| 255 |
|