WordPress: Restrict direct access to files – Prevent hotlinking
A useful bit of code to prevent files from being accessed (or...
22.May.2021 | Code Snippets, Wordpress
A quick snipped of code filter parameters into YouTube oEmbed requests.
Handy to remove suggested videos, YouTube contols and info. Paste this into your functions.php file
function custom_youtube_querystring( $html, $url, $attr, $post_id ) {
if (strpos($html, 'youtube')!= FALSE || strpos($html, 'youtu.be') != FALSE) {
$args = [
'rel' => 0,
'controls' => 0,
'showinfo' => 0,
'modestbranding' => 1,
];
$params = '?feature=oembed&';
foreach ($args as $arg => $value) {
$params .= $arg;
$params .= '=';
$params .= $value;
$params .= '&';
}
$html = str_replace( '?feature=oembed', $params, $html );
}
return $html;
}
add_filter('embed_oembed_html', 'custom_youtube_querystring', 10, 4);
Coding Tips, Wordpress, Wordpress Function, WordPress Tips
Share
A useful bit of code to prevent files from being accessed (or...
Get the featured image dimensions (width and height) in WordPress. Paste the...
In the early days (2003), WordPress was essentially a blogging tool and...
If you have recently bought a 4k monitor, you may have noticed your Adobe software shrinking to an annoyingly small...
A recent freelance project has given me a chance to work with the Vebra and Dezrez API’s to create a...
A quick way to manually disable the WordPress emojicons code without needing a plugin. Pop this in your functions.php file:...