settings = require($config_path); } $this->settings['view_path'] = realpath(AOPP_AOPLAYER_DIR) . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR; } /** * getAdmin() */ public function wpPlayer() { for ($i=1; $i<=10; $i++){ add_shortcode('aopp-player-'.$i, [$this, 'aopp_player']); } } /** * aopp_player() */ public function aopp_player($player, $source = null, $tag) { self::resourceRegistration(); $player = shortcode_atts([ 'showplaylist' => $this->settings['player']['showplaylist'], 'width' => $this->settings['player']['width'], 'height' => $this->settings['player']['height'], 'controls' => $this->settings['player']['controls'], 'preload' => $this->settings['player']['preload'], 'contenttype' => $this->settings['player']['contenttype'], 'playlistposition' => $this->settings['player']['playlistposition'], 'autoplay' => $this->settings['player']['autoplay'], 'orderbutton' => $this->settings['player']['orderbutton'], 'orderbuttonposition' => $this->settings['player']['orderbuttonposition'], 'orderbuttonlink' => $this->settings['player']['orderbuttonlink'], 'orderbuttontitle' => $this->settings['player']['orderbuttontitle'], 'orderbuttoncolor' => $this->settings['player']['orderbuttoncolor'], 'orderbuttontime' => $this->settings['player']['orderbuttontime'], 'autoplaysound' => $this->settings['player']['autoplaysound'], 'orderbuttonfontsize' => $this->settings['player']['orderbuttonfontsize'], 'orderbuttonleft' => $this->settings['player']['orderbuttonleft'], 'orderbuttonright' => $this->settings['player']['orderbuttonright'], 'positionplayer' => $this->settings['player']['positionplayer'], ], $player); $source = self::parseSource($source); wp_enqueue_style('aopp_plugin_css'); wp_enqueue_style('aopp_plugin_playlist_css'); wp_enqueue_style('aopp_plugin_speed_css'); wp_enqueue_style('aopp_css'); $css = ''; if ($player['width']=='100%') { $css .= ' position: relative; width:100%; max-width:'.$player['width'].'; '; } else { $player['width'] = (int) $player['width']; $css .= ' position: relative; width:100%; max-width:'.$player['width'].'px; '; } if ($player['positionplayer']=='center') { $css .= ' margin:0 auto 0 auto; '; } elseif ($player['positionplayer']=='left') { $css .= ' margin:0 auto 0 0; '; } elseif ($player['positionplayer']=='right') { $css .= ' margin:0 0 0 auto; '; } $css = ' .aopp_wrap_video{ '.$css.' } .'.$tag.' iframe{ position: absolute; top: 0; left: 0; width: 100%; height: 100%; } '; $css .= ' @media (max-width: 767px) { .aopp_wrap_video{ min-width:280px; } .'.$tag.' iframe{ min-width:280px; } } '; if ($player['width']>768 || $player['width']=='100%') { $css .= ' @media (min-width: 768px) and (max-width: 1024px) { .aopp_wrap_video{ min-width:640px; } .'.$tag.' iframe{ min-width:640px; } } '; } wp_register_style('responsive-player', false); wp_enqueue_style('responsive-player'); wp_add_inline_style('responsive-player', $css); wp_enqueue_script('aopp_plugin_js'); wp_enqueue_script('aopp_plugin_localize_js'); wp_enqueue_script('aopp_plugin_playlist_js'); wp_enqueue_script('aopp_plugin_speed_js'); $showplaylist = 'data-showplaylist="false"'; $class_playlist = ''; $class_pl_position = ''; if ($player['showplaylist']=='true') { $class_playlist = 'mep-playlist'; $showplaylist = 'data-showplaylist="true"'; if ($player['playlistposition']=='top') { $class_pl_position = ''; } elseif ($player['playlistposition']=='left') { $class_pl_position = ''; } elseif ($player['playlistposition']=='right') { $class_pl_position = ''; } elseif ($player['playlistposition']=='bottom') { $class_pl_position = 'video_bottom'; } } /* $width = ' width="'.$this->settings['player']['width'].'" '; if (!empty($player['width'])) { $width = 'width="'.$player['width'].'"'; } $height = ''; if (!empty($player['height'])) { $height = 'height="'.$player['height'].'"'; } */ $controls = 'controls="'.$this->settings['player']['controls'].'"'; if ($player['controls']=='controls') { $controls = 'controls="controls"'; } $autoplay = ''; if ($player['autoplay']=='true') { $autoplay = ' autoplay muted '; } $preload = 'preload="'.$this->settings['player']['preload'].'"'; if (!empty($player['preload'])) { $preload = 'preload="'.$player['preload'].'"'; } $poster = ''; if (!empty($player['poster'])) { $poster = 'poster="'.$player['poster'].'"'; } if (empty($player['autoplaysound'])) { $player['autoplaysound'] = $this->settings['player']['autoplaysound']; } if (empty($player['orderbutton'])) { $player['orderbutton'] = $this->settings['player']['orderbutton']; } if (empty($player['orderbuttonposition'])) { $player['orderbuttonposition'] = $this->settings['player']['orderbuttonposition']; } if (empty($player['orderbuttonlink'])) { $player['orderbuttonlink'] = $this->settings['player']['orderbuttonlink']; } if (empty($player['orderbuttontitle'])) { $player['orderbuttontitle'] = $this->settings['player']['orderbuttontitle']; } if (empty($player['orderbuttoncolor'])) { $player['orderbuttoncolor'] = $this->settings['player']['orderbuttoncolor']; } if (empty($player['orderbuttontime'])) { $player['orderbuttontime'] = $this->settings['player']['orderbuttontime']; } if (empty($player['orderbuttonfontsize'])) { $player['orderbuttonfontsize'] = $this->settings['player']['orderbuttonfontsize']; } if (empty($player['orderbuttonleft'])) { $player['orderbuttonleft'] = $this->settings['player']['orderbuttonleft']; } if (empty($player['orderbuttonright'])) { $player['orderbuttonright'] = $this->settings['player']['orderbuttonright']; } add_action('print_footer_scripts', function() use ($player, $tag) { self::aoplayer_script($player, $tag); } ); if ($player['contenttype'] == 'video') { $html = ''; } elseif ($player['contenttype'] == 'audio') { $html = ''; } else { $html = ''; } return '
'.$html.'
'; } /** * parseSource($source) */ protected function parseSource($source='') { if (empty($source)) { return $source; } $source = strip_tags($source); $source = preg_replace('/(\»|\″|\”|\“|\”|amp;)/i', '"', $source); $source = preg_replace('/[\r\n\s]{1,}/i', ' ', $source); $source = preg_replace('/[\s\]]+\]/i', ']', $source); preg_match_all('/([aopp-source[\s]{1,}(link=\"(.*?)\"[\s]{1,}poster=\"(.*?)\"[\s]{1,}title=\"(.*?)\"[\s]{1,}type=\"(.*?)\")\])/i', $source, $src); $new_source = []; for ($i=0; $i $src[3][$i], 'poster' => $src[4][$i], 'title' => $src[5][$i], 'type' => $src[6][$i], ]; } return $new_source; } public function aoplayer_script($player, $tag) { $order_html = ''; if ( $player['orderbutton']=='true' && !empty($player['orderbuttonlink']) && filter_var($player['orderbuttonlink'], FILTER_VALIDATE_URL) ) { $position_ext = ['topleft','topright','topcenter','bottomleft','bottomright','bottomcenter','leftcenter','rightcenter','center']; if (empty($player['orderbuttonposition']) || !in_array($player['orderbuttonposition'], $position_ext)) { $player['orderbuttonposition'] = 'center'; } $color_ext = ['default','info','primary','warning','danger','success']; if (empty($player['orderbuttoncolor']) || !in_array($player['orderbuttoncolor'], $color_ext)) { $player['orderbuttoncolor'] = 'default'; } $len = (iconv_strlen($player['orderbuttontitle'], 'UTF-8')*8)/2; if ($player['orderbuttonposition']=='topleft') { $style = 'position:absolute;z-index:9990;left:'.$player['orderbuttonleft'].'px;top:4px'; } elseif ($player['orderbuttonposition']=='topright') { $style = 'position:absolute;z-index:9990;right:'.$player['orderbuttonright'].'px;top:4px'; } elseif ($player['orderbuttonposition']=='topcenter') { $style = 'position:absolute;z-index:9990;left:50%;margin-left:-'.$len.'px;top:4px'; } elseif ($player['orderbuttonposition']=='bottomleft') { $style = 'position:absolute;z-index:9990;left:'.$player['orderbuttonleft'].'px;bottom:30px'; } elseif ($player['orderbuttonposition']=='bottomright') { $style = 'position:absolute;z-index:9990;right:'.$player['orderbuttonright'].'px;bottom:30px'; } elseif ($player['orderbuttonposition']=='bottomcenter') { $style = 'position:absolute;z-index:9990;left:50%;margin-left:-'.$len.'px;bottom:30px'; } elseif ($player['orderbuttonposition']=='leftcenter') { $style = 'position:absolute;z-index:9990;left:'.$player['orderbuttonleft'].'px'; } elseif ($player['orderbuttonposition']=='rightcenter') { $style = 'position:absolute;z-index:9990;right:'.$player['orderbuttonright'].'px'; } else { $style = ''; } $order_html .= ''; } $warning_html = ''; if ($player['autoplay']=='true' && $player['autoplaysound']=='true') { $warning_html .= '
'; $warning_html .= '
'.__('Sound on', 'aoplayer').'
'; $warning_html .= '
'; } if ($player['controls']=='controls') { $features = "['playlistfeature', 'prevtrack', 'playpause', 'nexttrack', 'loop', 'current', 'progress', 'duration', 'volume', 'fullscreen', 'speed']"; } else { $features = "[]"; } ?>