/* YouTube code */

//empty code workout
$pattern[]="/\[youtube=null\]/i";
$replacement[]='';

//?si with time
$pattern[]="/\[youtube=https:\/\/youtu\.be\/([a-zA-Z0-9\-_=]+)[?]si=([a-zA-Z0-9\-_=]+)&t=([0-9]+)\]/i";
$replacement[]="<div class=\"ytc\"><iframe width=\"{$defaultYTWidth}\" height=\"{$defaultYTHeight}\" src=\"https://www.youtube.com/embed/\\1?si=\\2&amp;start=\\3\" {$defaultYTparams}></iframe></div>";

//?si without time
$pattern[]="/\[youtube=https:\/\/youtu\.be\/([a-zA-Z0-9\-_=]+)[?]si=([a-zA-Z0-9\-_=]+)\]/i";
$replacement[]="<div class=\"ytc\"><iframe width=\"{$defaultYTWidth}\" height=\"{$defaultYTHeight}\" src=\"https://www.youtube.com/embed/\\1\" {$defaultYTparams}></iframe></div>";

//without ?si - straight copied address with time
$pattern[]="/\[youtube=https:\/\/youtu\.be\/([a-zA-Z0-9\-_=]+)[?]t=([0-9]+)\]/i";
$replacement[]="<div class=\"ytc\"><iframe width=\"{$defaultYTWidth}\" height=\"{$defaultYTHeight}\" src=\"https://www.youtube.com/embed/\\1?start=\\2\" {$defaultYTparams}></iframe></div>";

//without ?si - straight copied address without time
$pattern[]="/\[youtube=https:\/\/youtu\.be\/([a-zA-Z0-9\-_=]+)\]/i";
$replacement[]="<div class=\"ytc\"><iframe width=\"{$defaultYTWidth}\" height=\"{$defaultYTHeight}\" src=\"https://www.youtube.com/embed/\\1\" {$defaultYTparams}></iframe></div>";

//copied from address bar
$pattern[]="/\[youtube=https:\/(\/www\.|\/[a-z]+\.|\/)youtube\.com\/(watch\?v=|shorts\/|live\/)([a-zA-Z0-9&?_=\-]+)\]/i";
$replacement[]="<div class=\"ytc\"><iframe width=\"{$defaultYTWidth}\" height=\"{$defaultYTHeight}\" src=\"https://www.youtube.com/embed/\\3\" {$defaultYTparams}></iframe></div>";

//with manual size
$pattern[]="/\[youtube([1-7][0-9][0-9])x([1-5][0-9][0-9])=https:\/\/youtu\.be\/([a-zA-Z0-9-_=&?;]+)\]/i";
$replacement[]="<div class=\"ytc\"><iframe width=\"\\1\" height=\"\\2\" src=\"https://www.youtube.com/embed/\\3\" {$defaultYTparams}></iframe></div>";

//embed code
$pattern[]="/&lt;iframe width=&quot;([2-9][0-9]+)&quot; height=&quot;([2-9][0-9]+)&quot; src=&quot;https:\/\/www\.youtube\.com\/embed\/([a-zA-Z0-9-_=&?;]+)&quot; title=&quot;([^\r\n]+?)&quot; frameborder=&quot;0&quot; allow=&quot;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share&quot;(.*?) allowfullscreen&gt;&lt;\/iframe&gt;/i";
$replacement[]="<div class=\"ytc\"><iframe width=\"\\1\" height=\"\\2\" src=\"https://www.youtube.com/embed/\\3\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" allowfullscreen></iframe></div>";

/* --YouTube code */