| 1 |
<?php |
| 2 |
|
| 3 |
// sanitizes lesson video output |
| 4 |
function wpc_sanitize_video($video) { |
| 5 |
$video = wp_kses($video, |
| 6 |
array( |
| 7 |
'iframe' => array( |
| 8 |
'src' => true, |
| 9 |
'width' => true, |
| 10 |
'height' => true, |
| 11 |
'title' => true, |
| 12 |
'frameborder' => true, |
| 13 |
'allow' => true, |
| 14 |
'allowfullscreen' => true |
| 15 |
), |
| 16 |
'video' => array( |
| 17 |
'autopictureinpicture' => true, |
| 18 |
'controls' => true, |
| 19 |
'controlslist' => true, |
| 20 |
'crossorigin' => true, |
| 21 |
'disablepictureinpicture' => true, |
| 22 |
'disableremoteplayback' => true, |
| 23 |
'height' => true, |
| 24 |
'loop' => true, |
| 25 |
'muted' => true, |
| 26 |
'playsinline' => true, |
| 27 |
'poster' => true, |
| 28 |
'preload' => true, |
| 29 |
'src' => true, |
| 30 |
'width' => true |
| 31 |
), |
| 32 |
'source' => array( |
| 33 |
'src' => true, |
| 34 |
'type' => true |
| 35 |
) |
| 36 |
) |
| 37 |
); |
| 38 |
|
| 39 |
if( strpos($video, 'javascript:') === false ){ |
| 40 |
return $video; |
| 41 |
} else { |
| 42 |
return; |
| 43 |
} |
| 44 |
|
| 45 |
} |
| 46 |
|
| 47 |
function wpc_video_and_content_kses(){ |
| 48 |
|
| 49 |
$allowed = wp_kses_allowed_html( 'post' ); |
| 50 |
$allowed['style'] = array(); |
| 51 |
$allowed['iframe'] = array( |
| 52 |
'src' => true, |
| 53 |
'width' => true, |
| 54 |
'height' => true, |
| 55 |
'title' => true, |
| 56 |
'frameborder' => true, |
| 57 |
'allow' => true, |
| 58 |
'allowfullscreen' => true |
| 59 |
); |
| 60 |
$allowed['video'] = array( |
| 61 |
'autopictureinpicture' => true, |
| 62 |
'controls' => true, |
| 63 |
'controlslist' => true, |
| 64 |
'crossorigin' => true, |
| 65 |
'disablepictureinpicture' => true, |
| 66 |
'disableremoteplayback' => true, |
| 67 |
'height' => true, |
| 68 |
'loop' => true, |
| 69 |
'muted' => true, |
| 70 |
'playsinline' => true, |
| 71 |
'poster' => true, |
| 72 |
'preload' => true, |
| 73 |
'src' => true, |
| 74 |
'width' => true |
| 75 |
); |
| 76 |
$allowed['source'] = array( |
| 77 |
'src' => true, |
| 78 |
'type' => true |
| 79 |
); |
| 80 |
|
| 81 |
return $allowed; |
| 82 |
} |
| 83 |
|
| 84 |
?> |