├── .gitignore ├── README.md ├── readme.txt ├── smartideo-admin.php ├── smartideo.php └── static ├── qrcode.jpg ├── smartideo.css └── smartideo.js /.gitignore: -------------------------------------------------------------------------------- 1 | /.vscode 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | smartideo 2 | ========= 3 | 4 | Smartideo 是为 WordPress 添加对在线视频支持的一款插件(支持手机、平板等设备HTML5播放)。 目前支持YouTube、哔哩哔哩、腾讯视频、优酷、搜狐视频、56、华数等网站。 5 | 6 | 你可以直接粘贴视频播放页完整的URL到编辑器(单独一行),就可以加载视频播放器。 7 | 8 | 详细介绍:https://7yper.com/3639 9 | 10 | 关注微信公众号,获得更新提醒 11 | 12 | ![关注微信公众号,获得更新提醒](https://7yper.com/usr/uploads/2014/08/972e6fb0794d359.jpg) 13 | -------------------------------------------------------------------------------- /readme.txt: -------------------------------------------------------------------------------- 1 | === Plugin Name === 2 | Contributors: Fens Liu 3 | Tags: video, youtube, youku, QQ, 56, 视频, 播放器, 优酷, 搜狐, 腾讯, bilibili, 抖音 4 | Requires at least: 3.5.0 5 | Tested up to: 6.8.1 6 | Stable tag: 2.8.1 7 | 8 | Smartideo 是为 WordPress 添加对在线视频支持的一款插件(支持手机、平板等设备HTML5播放)。 9 | 10 | == Description == 11 | 12 | Smartideo 是为 WordPress 添加对在线视频支持的一款插件(支持手机、平板等设备HTML5播放)。 目前支持YouTube、哔哩哔哩、腾讯视频、优酷、搜狐视频、56、华数等网站。 13 | 14 | 直接粘贴视频播放页完整的URL到编辑器(单独一行),就可以加载视频播放器。 15 | 16 | = 详细介绍 = 17 | https://7yper.com/3639 18 | 19 | == Installation == 20 | 21 | 1. 你可以在后台插件管理页面中直接搜索 `Smartideo` 并安装 22 | 2. 或者上传文件夹 `smartideo` 至 `/wp-content/plugins/` 目录 23 | 3. 在插件管理页面中激活 Smartideo 24 | 25 | == Changelog == 26 | 27 | = 请关注微信公众号:Typer 与我联系 = 28 | 29 | = 2.8.1 = 30 | * 支持 WordPress 6.8.1 31 | * 新增 支持新的优酷播放页地址 32 | * 移除 优酷client_id相关逻辑 33 | 34 | = 2.8.0 = 35 | * 支持 WordPress 6.6.2 36 | * 新增 抖音视频 37 | * 优化 QQ音乐 38 | * 移除 部份不再支持的平台 39 | 40 | = 2.7.4 = 41 | * 支持 WordPress 6.4.1 42 | 43 | = 2.7.3 = 44 | * 支持 WordPress 6.1.1 45 | * 支持 AcFun H5播放 46 | 47 | = 2.7.2 = 48 | * 提高 兼容性 49 | * 支持 WordPress 6.0 50 | * 优化 哔哩哔哩 51 | * 移除 音悦台 52 | * 移除 酷6网 53 | 54 | = 2.7.1 = 55 | * 提高 兼容性 56 | * 支持 WordPress 5.9.3 57 | * 移除 虾米音乐 58 | 59 | = 2.7.0 = 60 | * 优化 哔哩哔哩播放器 61 | * 修复 爱奇艺解释失败的问题 62 | * 支持 WordPress 5.2.2 63 | 64 | = 2.6.0 = 65 | * 新增 支持新的优酷播放页 66 | * 新增 哔哩哔哩电脑端播放器设置 67 | 68 | = 2.5.2 = 69 | * 优化 哔哩哔哩兼容(PC暂时无法播放) 70 | * 优化 无法解析视频时的提示 71 | 72 | = 2.5.0 = 73 | * 新增 微博视频(感谢 @河南工业大学英语俱乐部) 74 | * 优化 哔哩哔哩播放器(全局H5,感谢 @风农) 75 | * 优化 对爱奇艺的解析 76 | * 优化 Smartideo设置 77 | 78 | = 2.4.4 = 79 | * 修复 一些bug 80 | 81 | = 2.4.3 = 82 | * 优化 Smartideo设置 83 | * 修复 与Editor.md的Emoji表情渲染冲突的问题 84 | * 修复 哔哩哔哩分P失效的问题(哔哩哔哩改了分P的参数) 85 | 86 | = 2.4.2 = 87 | * 优化 哔哩哔哩H5播放器 88 | * 优化 对哔哩哔哩HTTPS的支持 89 | 90 | = 2.4.0 = 91 | * 新增 播放器尺寸设置 92 | * 优化 对YouTube URL的支持 93 | * 优化 对音悦台URL的支持 94 | * 修复 Tips链接无效的问题 95 | * 修复 Tips多个播放器冲突的问题 96 | * 取消 资源加载策略设置 97 | 98 | = 2.3.0 = 99 | 100 | * 新增 源网站页面播放 101 | * 新增 手机访问时支持源页面播放 102 | * 优化 支持WordPress 4.8 103 | 104 | = 2.2.5 = 105 | 106 | * 修复 一些BUG 107 | 108 | = 2.2.4 = 109 | 110 | * 优化 哔哩哔哩H5播放支持分P 111 | * 优化 搜狐视频支持HTTPS 112 | * 优化 网易云音乐支持HTTPS 113 | 114 | = 2.2.3 = 115 | 116 | * 优化 资源加载方式(推荐使用全局加载) 117 | * 优化 哔哩哔哩CID获取逻辑 118 | 119 | = 2.2.0 = 120 | 121 | * 新增 支持爱奇艺(beta) 122 | * 优化 哔哩哔哩播放器选择(自动选择/全局H5) 123 | * 优化 Smartideo设置 124 | 125 | = 2.1.9 = 126 | 127 | * 优化 对哔哩哔哩HTTPS的支持 128 | * 优化 乐视播放器 129 | * 优化 Smartideo设置 130 | 131 | = 2.1.8 = 132 | 133 | * 新增 支持QQ音乐 134 | * 优化 哔哩哔哩H5播放(beta) 135 | 136 | = 2.1.7 = 137 | 138 | * 优化 对秒拍HTTPS的支持 139 | 140 | = 2.1.6 = 141 | 142 | * 修复 秒拍SWF播放器不能加载的BUG 143 | 144 | = 2.1.5 = 145 | 146 | * 新增 支持AcFun新域名(www.acfun.cn) 147 | * 优化 对哔哩哔哩HTTPS的支持 148 | * 优化 HTTPS检测方法 149 | * 优化 Smartideo设置 150 | 151 | = 2.1.4 = 152 | 153 | * 新增 支持秒拍H5播放 154 | * 优化 对优酷HTTPS的支持 155 | * 优化 对哔哩哔哩HTTPS的支持 156 | 157 | = 2.1.3 = 158 | 159 | * 修复 Smartideo设置的BUG 160 | 161 | = 2.1.2 = 162 | 163 | * 新增 支持优酷HTTPS 164 | * 优化 Smartideo设置 165 | 166 | = 2.1.1 = 167 | * 新增 支持WordPress 4.7 168 | * 修复 bilibili H5不能播放的问题(临时方案) 169 | 170 | = 2.1.0 = 171 | * 修复 bilibili H5不能播放的问题 172 | * 修复 美拍视频解析失败的问题 173 | 174 | = 2.0.9 = 175 | * 新增 支持秒拍 176 | * 新增 支持美拍beta 177 | * 新增 bilibili支持分P视频 178 | 179 | = 2.0.8 = 180 | * 新增 bilibili播放器版本设置 181 | 182 | = 2.0.7 = 183 | * 新增 支持乐视新域名(le.com) 184 | * 新增 支持芒果TV新域名(mgtv.com) 185 | * 新增 bilibili支持H5播放 186 | 187 | = 2.0.6 = 188 | * 新增 优酷开放平台的支持 189 | * 新增 Tips区分PC和移动端 190 | 191 | = 2.0.5 = 192 | * 修复 AcFun读取视频信息出错的BUG 193 | 194 | = 2.0.4 = 195 | * 修复 Tips不能加载的BUG 196 | * 修复 Tips可能与其他插件产生冲突的BUG 197 | 198 | = 2.0.3 = 199 | * 新增 支持YouTube 200 | * 新增 Tips配置 201 | * 优化 Tips加载逻辑 202 | * 优化 对bilibili https的支持 203 | 204 | = 2.0.2 = 205 | * 新增 AcFun支持H5播放 206 | * 新增 支持部分网站https 207 | 208 | = 2.0.1 = 209 | * 新增 支持乐视体育 210 | * 优化 AcFun引用 211 | * 优化 Tips加载方式 212 | 213 | = 2.0.0 = 214 | * 新增 播放器响应式支持(播放器根据不同设备的屏幕大小设置不同的屏幕高度和宽度) 215 | * 新增 播放器下方友好提示(不支持H5播放的视频可通过这里引导回源站播放) 216 | * 优化 播放器引用方式(先 iframe 后 embed) 217 | * 优化 核心代码(更简洁更高效) 218 | 219 | = 1.3.7 = 220 | * 修复 播放器可能遮罩其他元素的BUG 221 | * 优化 embed handler 222 | 223 | = 1.3.6 = 224 | * 优化 网易云音乐取消自动播放 225 | 226 | = 1.3.5 = 227 | * 新增 资源加载策略设置 228 | 229 | = 1.3.4 = 230 | * 新增 支持AcFun(A站) 231 | * 新增 支持bilibili(B站) 232 | 233 | = 1.3.3 = 234 | * 新增 支持网易云音乐 235 | * 新增 支持虾米音乐 236 | * 优化 核心代码 237 | 238 | = 1.3.2 = 239 | * 新增 支持搜狐视频专辑URL 240 | * 优化 播放器样式,兼容各种主题 241 | 242 | = 1.3.1 = 243 | * 修复 播放器下方有空白条的BUG 244 | 245 | = 1.3.0 = 246 | * 新增 CSS 247 | * 新增 移动设备不能播放的视频友好显示 248 | * 新增 支持芒果TV 249 | * 修复 腾讯视频部分URL不能正确解析的BUG 250 | * 优化 核心代码 251 | 252 | = 1.2.0 = 253 | * 新增 Smartideo设置 254 | * 优化 核心代码 255 | 256 | = 1.1.0 = 257 | * 新增 支持乐视网 258 | * 新增 支持腾讯视频专辑 259 | * 修复 一个已知的BUG 260 | * 优化 核心代码 261 | 262 | = 1.0.0 = 263 | * Smartideo 的第一个版本 -------------------------------------------------------------------------------- /smartideo-admin.php: -------------------------------------------------------------------------------- 1 | 没有权限!

'; 6 | return false; 7 | } 8 | if(isset($_POST['smartideo_submit']) && $_POST['smartideo_submit'] == '保存'){ 9 | if(!wp_verify_nonce($_POST['nonce'])){ 10 | echo '

保存失败,请重试!

'; 11 | return false; 12 | } 13 | $param = array('smartideo_code', 'width', 'height', 'width_mobile', 'height_mobile', 'response', 'tips_status', 'tips_content', 'tips_content_mobile', 'youku_client_id', 'bilibili_player', 'bilibili_pc_player'); 14 | $option = get_option('smartideo_option'); 15 | if(!is_array($option)){ 16 | $option = array(); 17 | } 18 | foreach($_POST as $key => $val){ 19 | if(in_array($key, $param)){ 20 | $option[$key] = sanitize_text_field($val); 21 | } 22 | } 23 | update_option('smartideo_option', $option); 24 | } 25 | $option = (array)get_option('smartideo_option'); 26 | $option['width'] = isset($option['width']) && $option['width'] > 0 ? $option['width'] : '100%'; 27 | $option['height'] = isset($option['height']) && $option['height'] > 0 ? $option['height'] : '400px'; 28 | $option['width_mobile'] = isset($option['width_mobile']) && $option['width_mobile'] > 0 ? $option['width_mobile'] : '100%'; 29 | $option['height_mobile'] = isset($option['height_mobile']) && $option['height_mobile'] > 0 ? $option['height_mobile'] : '200px'; 30 | 31 | $nonce = wp_create_nonce(); 32 | echo '

Smartideo 设置

'; 33 | echo '
34 | 35 | 36 | 37 | 38 | 64 | 65 | 66 | 67 | 97 | '; 98 | echo ' 99 | 100 | 105 | '; 106 | echo ' 107 | 108 | 124 | '; 125 | echo '
播放器尺寸 39 |
40 |

41 | 44 |

45 |

46 | 49 |

50 |
    51 |
  • 52 | 电脑端: 53 | x 54 | 55 |
  • 56 |
  • 57 | 移动端: 58 | x 59 | 60 |
  • 61 |
62 |
63 |
贴士 68 |
69 |

70 | 74 |

75 |

76 | 80 |

81 |
    82 |
  • 83 | 电脑端: 84 | 85 |
    86 |

    如:如果视频无法播放,点击这里试试

    87 |
  • 88 |
  • 89 | 移动端: 90 | 91 |
    92 |

    如:建议在WIFI环境下播放,土豪请随意~

    93 |
  • 94 |
95 |
96 |
优酷client_id 101 | 102 |
103 |

供优酷开发者使用,没有client_id请留空

104 |
哔哩哔哩电脑端播放器 109 |
110 |

111 | 115 |

116 |

117 | 121 |

122 |
123 |
126 |

127 |
'; 128 | echo '

意见反馈

129 |

你的意见是Smartido成长的动力,欢迎给我们留言,或许你想要的功能下一个版本就会实现哦!

130 |

插件官方页面:https://7yper.com/3639

131 |

微信公众号:Typer

132 | '; 133 | } 134 | } -------------------------------------------------------------------------------- /smartideo.php: -------------------------------------------------------------------------------- 1 | edit = true; 28 | } 29 | 30 | $option = get_option('smartideo_option'); 31 | if(empty($option)){ 32 | $option = array(); 33 | } 34 | $this->option = $option; 35 | extract((array)$option); 36 | $this->bilibili_pc_player = isset($bilibili_pc_player) ? $bilibili_pc_player : 0; 37 | 38 | add_action('wp_enqueue_scripts', array($this, 'smartideo_scripts')); 39 | 40 | wp_embed_unregister_handler('youku'); 41 | wp_embed_unregister_handler('tudou'); 42 | wp_embed_unregister_handler('56com'); 43 | wp_embed_unregister_handler('youtube'); 44 | 45 | // video 46 | wp_embed_register_handler( 'smartideo_youtube', 47 | '#https?://www\.youtube\.com/watch\?v=(?[a-zA-Z0-9_=\-]+)#i', 48 | array($this, 'smartideo_embed_handler_youtube') ); 49 | 50 | wp_embed_register_handler( 'smartideo_bilibili', 51 | '#https?://www\.bilibili\.com/video/(?:[av|BV]+)(?:(?[a-zA-Z0-9_=\-]+)/(?:index_|\#page=)(?[a-zA-Z0-9_=\-]+)|(?[a-zA-Z0-9_=\-]+))#i', 52 | array($this, 'smartideo_embed_handler_bilibili') ); 53 | 54 | wp_embed_register_handler( 'smartideo_douyin', 55 | '#https?://www\.douyin\.com/discover\?modal_id=(?\d+)#i', 56 | array($this, 'smartideo_embed_handler_douyin') ); 57 | 58 | wp_embed_register_handler( 'smartideo_youku', 59 | '#https?://v\.youku\.com/(?:v_show/id_(?[a-z0-9_=\-]+)\.html|video\?vid=(?[a-z0-9_=\-]+))#i', 60 | array($this, 'smartideo_embed_handler_youku') ); 61 | 62 | wp_embed_register_handler( 'smartideo_qq', 63 | '#https?://v\.qq\.com/(?:[a-z0-9_\./]+\?vid=(?[a-z0-9_=\-]+)|(?:[a-z0-9/]+)/(?[a-z0-9_=\-]+))#i', 64 | array($this, 'smartideo_embed_handler_qq') ); 65 | 66 | wp_embed_register_handler( 'smartideo_sohu', 67 | '#https?://my\.tv\.sohu\.com/(?:pl|us)/(?:\d+)/(?\d+)#i', 68 | array($this, 'smartideo_embed_handler_sohu') ); 69 | 70 | wp_embed_register_handler( 'smartideo_wasu', 71 | '#https?://www\.wasu\.cn/play/show/id/(?\d+)#i', 72 | array($this, 'smartideo_embed_handler_wasu') ); 73 | 74 | wp_embed_register_handler( 'smartideo_acfun', 75 | '#https?://www\.acfun\.(?:[tv|cn]+)/v/ac(?\d+)#i', 76 | array($this, 'smartideo_embed_handler_acfun') ); 77 | 78 | wp_embed_register_handler( 'smartideo_iqiyi', 79 | '#https?://www\.iqiyi\.com/(?:[a-zA-Z]+)_(?[a-z0-9_~\-]+)#i', 80 | array($this, 'smartideo_embed_handler_iqiyi') ); 81 | 82 | wp_embed_register_handler( 'smartideo_56', 83 | '#https?://(?:www\.)?56\.com/[a-z0-9]+/(?:play_album\-aid\-[0-9]+_vid\-(?[a-z0-9_=\-]+)|v_(?[a-z0-9_=\-]+))#i', 84 | array($this, 'smartideo_embed_handler_56') ); 85 | 86 | // music 87 | wp_embed_register_handler( 'smartideo_music163', 88 | '#https?://music\.163\.com/\#/song\?id=(?\d+)#i', 89 | array($this, 'smartideo_embed_handler_music163') ); 90 | 91 | wp_embed_register_handler( 'smartideo_musicqq', 92 | '#https?://y\.qq\.com/n/(?:ryqq|yqq)/(?:songDetail|song)/(?\d+)(?:\.html)?#i', 93 | array($this, 'smartideo_embed_handler_musicqq') ); 94 | 95 | } 96 | 97 | # video 98 | public function smartideo_embed_handler_youtube( $matches, $attr, $url, $rawattr ) { 99 | $embed = $this->get_iframe("//www.youtube.com/embed/{$matches['video_id']}", $url); 100 | return apply_filters( 'embed_youtube', $embed, $matches, $attr, $url, $rawattr ); 101 | } 102 | 103 | public function smartideo_embed_handler_bilibili( $matches, $attr, $url, $rawattr ) { 104 | $matches['video_id'] = ($matches['video_id1'] == '') ? $matches['video_id'] : $matches['video_id1']; 105 | $page = ($matches['video_id2'] > 1) ? $matches['video_id2'] : 1; 106 | $cid = ''; 107 | if(wp_is_mobile() || $this->bilibili_pc_player == 1){ 108 | $aid = 0; 109 | $bvid = ''; 110 | if(is_numeric($matches['video_id'])){ 111 | $aid = $matches['video_id']; 112 | }else{ 113 | $bvid = $matches['video_id']; 114 | } 115 | $embed = $this->get_iframe("//player.bilibili.com/player.html?aid={$aid}&bvid={$bvid}&cid={$cid}&page={$page}", $url); 116 | }else{ 117 | $embed = $this->get_link($url); 118 | } 119 | return apply_filters( 'embed_bilibili', $embed, $matches, $attr, $url, $rawattr ); 120 | } 121 | 122 | public function smartideo_embed_handler_douyin( $matches, $attr, $url, $rawattr ) { 123 | $embed = $this->get_iframe("//open.douyin.com/player/video?vid={$matches['video_id']}&autoplay=0", $url, '324px', '672px'); 124 | return apply_filters( 'embed_douyin', $embed, $matches, $attr, $url, $rawattr ); 125 | } 126 | 127 | public function smartideo_embed_handler_youku( $matches, $attr, $url, $rawattr ) { 128 | $matches['video_id'] = $matches['video_id1'] == '' ? $matches['video_id2'] : $matches['video_id1']; 129 | $embed = $this->get_iframe("//player.youku.com/embed/{$matches['video_id']}", $url); 130 | return apply_filters( 'embed_youku', $embed, $matches, $attr, $url, $rawattr ); 131 | } 132 | 133 | public function smartideo_embed_handler_qq( $matches, $attr, $url, $rawattr ) { 134 | $matches['video_id'] = $matches['video_id1'] == '' ? $matches['video_id2'] : $matches['video_id1']; 135 | $embed = $this->get_iframe("//v.qq.com/iframe/player.html?vid={$matches['video_id']}&auto=0", $url); 136 | return apply_filters( 'embed_qq', $embed, $matches, $attr, $url, $rawattr ); 137 | } 138 | 139 | public function smartideo_embed_handler_sohu( $matches, $attr, $url, $rawattr ) { 140 | $embed = $this->get_iframe("//tv.sohu.com/upload/static/share/share_play.html#{$matches['video_id']}_0_0_9001_0", $url); 141 | return apply_filters( 'embed_sohu', $embed, $matches, $attr, $url, $rawattr ); 142 | } 143 | 144 | public function smartideo_embed_handler_wasu( $matches, $attr, $url, $rawattr ) { 145 | $embed = $this->get_iframe("http://www.wasu.cn/Play/iframe/id/{$matches['video_id']}", $url); 146 | return apply_filters( 'embed_wasu', $embed, $matches, $attr, $url, $rawattr ); 147 | } 148 | 149 | public function smartideo_embed_handler_acfun( $matches, $attr, $url, $rawattr ) { 150 | $embed = $this->get_iframe("https://www.acfun.cn/player/ac{$matches['video_id']}", $url); 151 | if(wp_is_mobile()){ 152 | $embed = $this->get_link($url); 153 | } 154 | return apply_filters( 'embed_acfun', $embed, $matches, $attr, $url, $rawattr ); 155 | } 156 | 157 | public function smartideo_embed_handler_iqiyi( $matches, $attr, $url, $rawattr ) { 158 | $embed = ''; 159 | try{ 160 | $request = new WP_Http(); 161 | $data = (array)$request->request($url, array('timeout' => 3)); 162 | if(!isset($data['body'])){ 163 | $data['data'] = ''; 164 | } 165 | preg_match('/"vid":"(\w+)"/i', (string)$data['body'], $match); 166 | $vid = $match[1]; 167 | preg_match('/"tvId":(\d+)/i', (string)$data['body'], $match); 168 | $tvid = $match[1]; 169 | if ($tvid > 0 && !empty($vid)) { 170 | $embed = $this->get_iframe("//open.iqiyi.com/developer/player_js/coopPlayerIndex.html?vid={$vid}&tvId={$tvid}&height=100%&width=100%&autoplay=0", $url); 171 | } 172 | }catch(Exception $e){} 173 | if(empty($embed)){ 174 | $embed = '解析失败,请刷新页面重试'; 175 | } 176 | return apply_filters( 'embed_iqiyi', $embed, $matches, $attr, $url, $rawattr ); 177 | } 178 | 179 | public function smartideo_embed_handler_56( $matches, $attr, $url, $rawattr ) { 180 | $matches['video_id'] = $matches['video_id1'] == '' ? $matches['video_id2'] : $matches['video_id1']; 181 | $embed = $this->get_iframe("http://www.56.com/iframe/{$matches['video_id']}", $url); 182 | return apply_filters( 'embed_56', $embed, $matches, $attr, $url, $rawattr ); 183 | } 184 | 185 | # music 186 | public function smartideo_embed_handler_music163( $matches, $attr, $url, $rawattr ) { 187 | $embed = $this->get_iframe("//music.163.com/outchain/player?type=2&id={$matches['video_id']}&auto=0&height=90", $url, '100%', '110px'); 188 | return apply_filters( 'embed_music163', $embed, $matches, $attr, $url, $rawattr ); 189 | } 190 | 191 | public function smartideo_embed_handler_musicqq( $matches, $attr, $url, $rawattr ) { 192 | $embed = $this->get_iframe("//i.y.qq.com/n2/m/outchain/player/index.html?songid={$matches['video_id']}&songtype=0", $url, '100%', '66px'); 193 | return apply_filters( 'embed_musicqq', $embed, $matches, $attr, $url, $rawattr ); 194 | } 195 | 196 | private function get_embed($url = '', $source = '', $width = '', $height = ''){ 197 | $html = ''; 198 | $html .= 199 | '
200 |
get_size_style($width, $height) . '> 201 | 202 |
'; 203 | if($this->option['tips_status'] == 1 && !$this->edit){ 204 | if(empty($source)){ 205 | $source = 'javascript:void(0);'; 206 | } 207 | $html .= 208 | '
209 | 210 |
'; 211 | } 212 | $html .= '
'; 213 | return $html; 214 | } 215 | 216 | private function get_iframe($url = '', $source = '', $width = '', $height = ''){ 217 | $html = ''; 218 | $html .= 219 | '
220 |
get_size_style($width, $height) . '> 221 | 222 |
'; 223 | if(isset($this->option['tips_status']) && $this->option['tips_status'] == 1 && !$this->edit){ 224 | if(empty($source)){ 225 | $source = 'javascript:void(0);'; 226 | } 227 | $html .= 228 | '
229 | 230 |
'; 231 | } 232 | $html .= '
'; 233 | return $html; 234 | } 235 | 236 | private function get_link($url){ 237 | $html = ''; 238 | $html .= 239 | '
240 |
get_size_style(0, 0) . '> 241 |
242 |

暂时无法播放,可回源网站播放

243 |
244 |
'; 245 | return $html; 246 | } 247 | 248 | public function smartideo_scripts(){ 249 | wp_enqueue_style('smartideo_css', SMARTIDEO_URL . '/static/smartideo.css', array(), SMARTIDEO_VERSION, 'screen'); 250 | wp_enqueue_script('smartideo_js', SMARTIDEO_URL . '/static/smartideo.js', array(), SMARTIDEO_VERSION, true); 251 | } 252 | 253 | public function admin_menu(){ 254 | add_plugins_page('Smartideo 设置', 'Smartideo 设置', 'manage_options', 'smartideo_settings', array($this, 'admin_settings')); 255 | } 256 | 257 | public function admin_settings(){ 258 | require_once 'smartideo-admin.php'; 259 | new smartideo_admin(); 260 | } 261 | 262 | private function is_https(){ 263 | if(strtolower($_SERVER['HTTPS']) == 'on'){ 264 | return true; 265 | }else{ 266 | return false; 267 | } 268 | } 269 | private function get_size_style($width, $height){ 270 | if(empty($width) || empty($height)){ 271 | $width = $height = 0; 272 | if($this->edit){ 273 | $width = $this->width; 274 | $height = $this->height; 275 | }else if(isset($this->option['response']) && $this->option['response'] == 0){ 276 | if(wp_is_mobile()){ 277 | $width = $this->option['width_mobile']; 278 | $height = $this->option['height_mobile']; 279 | }else{ 280 | $width = $this->option['width']; 281 | $height = $this->option['height']; 282 | } 283 | } 284 | } 285 | $style = ''; 286 | if(!empty($width)){ 287 | $style .= "width: {$width};"; 288 | } 289 | if(!empty($height)){ 290 | $style .= "height: {$height};"; 291 | } 292 | if(!empty($style)){ 293 | $style = ' style="' . $style . '"'; 294 | } 295 | return $style; 296 | } 297 | } 298 | -------------------------------------------------------------------------------- /static/qrcode.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nothingisover/smartideo/c2429a4189a0fc4db3ff3571cf80f8f1eecfcb8f/static/qrcode.jpg -------------------------------------------------------------------------------- /static/smartideo.css: -------------------------------------------------------------------------------- 1 | .smartideo { z-index: 0; text-align: center; background: #CCC; line-height: 0; text-indent: 0; } 2 | .smartideo embed, .smartideo iframe { padding: 0; margin: 0; } 3 | .smartideo .player { width: 100%; height: 500px; margin: auto; overflow: hidden; position: relative; } 4 | .smartideo .player a.smartideo-play-link { display: block; width: 50px; height: 50px; text-decoration: none; border: 0; position: absolute; left: 50%; top: 50%; margin: -25px; } 5 | .smartideo .player a.smartideo-play-link p { display: none; } 6 | .smartideo .player .smartideo-play-button { width: 0; height: 0; border-top: 25px solid transparent; border-left: 50px solid #FFF; border-bottom: 25px solid transparent; } 7 | .smartideo .tips { background: #f2f2f2; text-align: center; max-height: 32px; line-height: 32px; font-size: 12px; } 8 | .smartideo .tips a { text-decoration: none; } 9 | 10 | @media screen and (max-width:959px){ 11 | .smartideo .player { height: 450px; } 12 | } 13 | @media screen and (max-width:767px){ 14 | .smartideo .player { height: 400px; } 15 | } 16 | @media screen and (max-width:639px){ 17 | .smartideo .player { height: 350px; } 18 | } 19 | @media screen and (max-width:479px){ 20 | .smartideo .player { height: 250px; } 21 | } 22 | -------------------------------------------------------------------------------- /static/smartideo.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var smartideoTips = document.getElementsByClassName('smartideo-tips'); 3 | if(smartideoTips.length > 0){ 4 | var mobile = navigator.userAgent.toLowerCase().match(/(ipad|ipod|iphone|android|mmp|smartphone|midp|wap|xoom|symbian|j2me|blackberry|win ce)/i) != null; 5 | for(var i = 0; i < smartideoTips.length; i++){ 6 | var smartideoTip = smartideoTips[i]; 7 | var content = ""; 8 | if(mobile){ 9 | content = smartideoTip.getAttribute("smartideo-title-mobile"); 10 | }else{ 11 | content = smartideoTip.getAttribute("smartideo-title"); 12 | } 13 | if(content == ""){ 14 | smartideoTip.style.display = "none"; 15 | }else{ 16 | smartideoTip.innerHTML = content; 17 | } 18 | } 19 | } 20 | })(); --------------------------------------------------------------------------------