Created
December 27, 2015 00:01
-
-
Save jdembowski/9d65815d927cbed7db7c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Fix oembed_discovery_links output | |
Description: Modify the oembed discovery links in horrible ways | |
Version: 1.0 | |
Author: Jan Dembowski | |
Author URI: https://blog.dembowski.net/ | |
*/ | |
add_filter( 'oembed_discovery_links', 'mh_oembed_add_discovery_links' ); | |
function mh_oembed_add_discovery_links( $output ) { | |
$mh_newencoded = urlencode( home_url() . '/?p=' . get_the_ID() ); | |
$output = '<link rel="alternate" type="application/json+oembed" href="' . esc_url( home_url() . '/?rest_route=%2Foembed%2F1.0%2Fembed&url=' . $mh_newencoded ) . '" />' . "\n"; | |
if ( class_exists( 'SimpleXMLElement' ) ) { | |
$output .= '<link rel="alternate" type="text/xml+oembed" href="' . esc_url( home_url() . '/?rest_route=%2Foembed%2F1.0%2Fembed&url=' . $mh_newencoded ) . '" />' . "\n"; | |
} | |
return $output; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment