Closed kraftner closed 1 year ago
Quick workaround for now:
add_action('init', function(){
if(
!class_exists( 'epiphyt\Embed_Privacy\Embed_Privacy' )
){
return;
}
$current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
if ( empty( $_SERVER['HTTP_HOST'] ) ) {
return;
}
$post_id = url_to_postid( $current_url );
if ( $post_id ) {
$post = get_post( $post_id );
if ( $post instanceof WP_Post && has_shortcode( $post->post_content, 'embed_privacy_opt_out' ) ) {
\epiphyt\Embed_Privacy\Embed_Privacy::get_instance()->print_assets();
}
}
}, 11);
Bug/Problem
The way you detect if the current post has the
[embed_privacy_opt_out]
shortcode doesn't work when the site is running on a non standard (80, 443) port, e.g.example.test:8080
The problem is this:
https://github.com/epiphyt/embed-privacy/blob/2cf319a685b1320dc17cdbb677191bcd7e3656f0/inc/class-embed-privacy.php#L1632-L1638
$_SERVER['HTTP_HOST']
already includes the port and the port hence is added twice resulting inexample.test:8080:8080
. This then later results inurl_to_postid()
failing to find the post and the check for the shortcode always failing.Looking at how core does it the section above can probably be replaced with a one-liner:
Steps to reproduce
[embed_privacy_opt_out]
Version
1.7.2
Link
No response
Environment info
No response
Code of Conduct