function canonical( $canonical ) { $url = \wp_parse_url($canonical); $canonical = ''; if ( isset( $url['scheme'] ) ) { $canonical .= isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http'; $canonical .= '://'; } if ( isset( $url['host'] ) ) { $canonical .= $_SERVER['HTTP_HOST']; } if ( isset( $url['port'] ) ) { $canonical .= ':' . $url['port']; } if ( isset( $url['path'] ) ) { $canonical .= $url['path']; } if ( isset( $url['query'] ) ) { $canonical .= '?' . $url['query']; } return $canonical; } add_filter( 'wpseo_canonical', 'canonical', 10, 2 ); function og_tags( $ogTag ) { if ($url = \wp_parse_url($ogTag)) { $ogTag = ''; if (isset($url['scheme'])) { $ogTag .= isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http'; $ogTag .= '://'; } if (isset($url['host'])) { $ogTag .= $_SERVER['HTTP_HOST']; } if (isset($url['port'])) { $ogTag .= ':' . $url['port']; } if (isset($url['path'])) { $ogTag .= $url['path']; } if (isset($url['query'])) { $ogTag .= '?' . $url['query']; } return $ogTag; } return $ogTag; } add_filter( 'wpseo_opengraph_url', 'og_tags'); add_filter( 'wpseo_opengraph_image', 'og_tags');