Skip to content

Commit d48f816

Browse files
author
Chris Gårdenberg
committed
fix: Fixes oEmbed canonical links.
fixes #310
1 parent adad674 commit d48f816

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

PLUGIN-CHECKSUM

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
fa6db2546b77aeb493995cdec0dc90b8
1+
39da0f746baf81ac7cdfa93c9ad6c50f

includes/edu-options.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,24 @@ function edu_set_canonical_url( $canonical_url ) {
8484
EDU()->stop_timer( $t );
8585
}
8686

87+
function edu_oembed_discovery_links( $output ) {
88+
global $wp_query;
89+
if ( isset( $wp_query->queried_object ) && ( isset( $wp_query->query['courseId'] ) || isset( $wp_query->query['edu_programme'] ) ) ) {
90+
$output = '';
91+
92+
if ( is_singular() ) {
93+
$output .= '<link rel="alternate" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( get_home_url() . $_SERVER['REQUEST_URI'] ) ) . '" />' . "\n";
94+
95+
if ( class_exists( 'SimpleXMLElement' ) ) {
96+
$output .= '<link rel="alternate" type="text/xml+oembed" href="' . esc_url( get_oembed_endpoint_url( get_home_url() . $_SERVER['REQUEST_URI'], 'xml' ) ) . '" />' . "\n";
97+
}
98+
}
99+
}
100+
echo $output;
101+
}
102+
87103
add_filter( 'get_canonical_url', 'edu_set_canonical_url' );
104+
add_filter( 'oembed_discovery_links', 'edu_oembed_discovery_links' );
88105

89106
function edu_no_index() {
90107
$t = EDU()->start_timer( __METHOD__ );

0 commit comments

Comments
 (0)