execute the_content after shortcode
-
Currently I am using WordPress and host some video’s on it
Due to heavy 3rd party stealing I have decided to enable Nginx Secure Links
function my_function($content){ $new_content = preg_replace_callback('/https?.([^ ]*)?\.('.implode('|',explode(',',$this -> options['extensions'])).')/', array($this, 'convert'), $content); return $new_content ; } add_filter('the_content', 'my_function',99); function secure_url($url, $path){ $expires = time() + $this -> options['ttl']; $secret = $this -> options['secret']; $md5 = md5("$expires$path $secret", true); $md5 = base64_encode($md5); $md5 = strtr($md5, '+/', '-_'); $md5 = str_replace('=', '', $md5); //var_dump($url . $path . '?md5=' . $md5 . '&expires=' . $expires); return $url . $path . '?md5=' . $md5 . '&expires=' . $expires; }
This return a url
https://website.nl/pathtovideofile.mp4?md5={string}&&expires={time()+ttl}
When using Gutenberg Blocks this works fine how ever when using the Classic editor (With shortcodes) this will break See below the output
<video class="wp-video-shortcode" id="video-1372-1_html5" width="640" height="360" poster="https://website.nl/wp-content/uploads/2020/03/big_buck_bunny.jpg" preload="metadata" style="width: 640px; height: 360px;" src="https://website.nl/wp-content/uploads/2020/03/big_buck_bunny.mp4?md5=9-NRRzjHR22W9s1CVsJ5Fg&expires=1586083573?_=1"><source type="video/mp4" src="https://website.nl/wp-content/uploads/2020/03/big_buck_bunny.mp4?md5=9-NRRzjHR22W9s1CVsJ5Fg&expires=1586083573?_=1"><source type="video/webm" src="https://website.nl/wp-content/uploads/2020/03/big_buck_bunny.webm?md5=DhuI17PSLcOjM0J_C0laeA&expires=1586083573?_=1"><a href="https://website.nl/wp-content/uploads/2020/03/big_buck_bunny.mp4">https://website.nl/wp-content/uploads/2020/03/big_buck_bunny.mp4?md5=1-J8b6nfvJ68SU_fngqasA&expires=1586083573</a></video>
Is it possible to execute the add_filter(‘the_content’, ‘my_function’,99); after the wp_video_shortcode function?
It breaks on the
$type = wp_check_filetype( $atts['src'], wp_get_mime_types() );
- The topic ‘execute the_content after shortcode’ is closed to new replies.