2

I would like to this:
If php found this specific meta tag in the html source,then delete from header:

<meta property="og:video:type" content="application/x-shockwave-flash" /> <meta property="og:video" content="https://www.neocsatblog.info/jwplayer/player.swf?file=&autostart=true&skinName=newtube&skinURL=https%3A%2F%2Fneocsatblog.info%2Fskinning-sdk%2Ffive%2Fnewtube%2Fnewtube.xml" />

I tryed this way, but dosen't work:

if ( $fullmeta == '<meta property="og:video:type" content="application/x-shockwave-flash" /> <meta property="og:video" content="https://www.neocsatblog.info/jwplayer/player.swf?file=&autostart=true&skinName=newtube&skinURL=https%3A%2F%2Fneocsatblog.info%2Fskinning-sdk%2Ffive%2Fnewtube%2Fnewtube.xml" />') {
     $fullmeta="";  
   }

The full codeblock where the full meta is declareted:

<? 
 $video_url = get_field('video_urlasd');
if (isset($video_url) && $video_url !== "https://") {
  $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).'" />';
  $fullmeta=$meta1.$meta2;
  echo $fullmeta;
  }else{
      echo chop($fullmeta,"asd");
  }
   if ( $fullmeta == '<meta property="og:video:type" content="application/x-shockwave-flash" /> <meta property="og:video" content="https://www.neocsatblog.info/jwplayer/player.swf?file=&autostart=true&skinName=newtube&skinURL=https%3A%2F%2Fneocsatblog.info%2Fskinning-sdk%2Ffive%2Fnewtube%2Fnewtube.xml" />') {
     echo $fullmeta="";  
   }
  ?>

I don't know why, because on the HTML source I found it and looks like same as I copied!

2 Answers2

0

You could use str_replace for this.

$fullmeta = '<meta property="og:video:type" content="application/x-shockwave-flash" /> <meta property="og:video" content="https://www.neocsatblog.info/jwplayer/player.swf?file=&autostart=true&skinName=newtube&skinURL=https%3A%2F%2Fneocsatblog.info%2Fskinning-sdk%2Ffive%2Fnewtube%2Fnewtube.xml" />';
$html_without_crap =  str_replace($fullmeta,"",$Where_it_needs_to_look);

PHP docs: http://php.net/manual/en/function.str-replace.php

Web Weave
  • 160
  • 2
  • 7
0

Replace this part of your code

if (isset($video_url) && $video_url !== "https://") {

with this

if (!empty($video_url) && $video_url !== "https://") {
zajonc
  • 1,935
  • 5
  • 20
  • 25
  • The problem is with both solution : When we have videos, this methods also delete og video tags. As you can see I use variable in full codeblock for file url. I would like to only remove this meta tags, when the file section is empty (`?file=''`); – Szántai Ádám Jul 19 '16 at 20:41
  • @SzántaiÁdám You are right - my mistake. I've changed the solution and provide only that one with the DOM object. – zajonc Jul 19 '16 at 20:54
  • if I understand correctly for this method we need the every html tags in the source right? – Szántai Ádám Jul 19 '16 at 21:17
  • Yes, you have to provide a HTML source contains tags you want to delete. You can get it when you create it in PHP or with `file_get_contents` function or send it by ajax, etc. Any metod you want use need to provide a string with HTML contains that tags as the input for this solution. – zajonc Jul 19 '16 at 21:25
  • Is there is a problem with provide complete HTML source? Do you need to get for example only head section and work with it? – zajonc Jul 19 '16 at 21:38
  • Yeah, it's just cant work, it's so many appostrofs on there with differnd types and with varribels. I would like to use this on wordpress header.php – Szántai Ádám Jul 20 '16 at 06:17
  • I've changed my solution to not using a DOM but simply to check is `$video_url` not empty. – zajonc Jul 20 '16 at 06:51
  • Yeah, this solution is working fine, thanks for the tipp! – Szántai Ádám Jul 20 '16 at 18:21