我在WordPress管理区域内有一个字段,位于post.new.php部分。
我使用最新版本的WordPress,以及高级自定义字段插件,以便我可以在header.php
中写出此字段。
我将此字段用于og:video
标记,以便我可以轻松输出安全的视频网址
问题是,默认字段值为https,因此我可以回想起来,视频网址必须始终以https开头。
单击“发布”按钮时,数据库将保存此值,以使处于空白状态的og安全URL仅为https。
例如:
<meta property="og:video" content="https://www.neocsatblog.info/jwplayer/player.swf?file=https%3A%2F%2F&autostart=true&skinName=newtube&skinURL=https%3A%2F%2Fneocsatblog.info%2Fskinning-sdk%2Ffive%2Fnewtube%2Fnewtube.xml" />
这是一个问题,因为我不想在Facebook的帖子中留下空白视频 因此,我需要检查标题中的两件事:
https://
之后字符串中是否有任何字符?如果两个条件都满足,则代码应输出url 当前的PHP代码:
$video_url = get_field('video_url');
if (isset($video_url)) {
$meta1='<meta property="og:video:type" content="application/x-shockwave-flash" />';
$skinURL="https://neocsatblog.info/skinning-sdk/five/newtube/newtube.xml";
$meta2=' <meta property="og:video" content="https://www.neocsatblog.info/jwplayer/player.swf?file='.urlencode($video_url).'&autostart=true&skinName=newtube&skinURL='.urlencode($skinURL).'" />';
echo $meta1;
echo $meta2;
}
答案 0 :(得分:1)
尝试if ( (isset($video)) && (strpos($address, 'https://') == 0) && (strlen($address) > strlen('https://')) ) { // do stuff
答案 1 :(得分:0)
if (isset($video_url) && $video_url !== "https://") {