Skip to content

Instantly share code, notes, and snippets.

@cliffordp
Last active August 29, 2015 14:10
Show Gist options
  • Save cliffordp/7afaa8700d2a5711e9d6 to your computer and use it in GitHub Desktop.
Save cliffordp/7afaa8700d2a5711e9d6 to your computer and use it in GitHub Desktop.
Adding custom SmugMug domain to oEmbed whitelist in WordPress (full regex version)
<?php
// From http://tourkick.com/2014/smugmug-custom-domain-oembed-wordpress/
// This version is based on the SmugMug code from wp-includes/class-oembed.php
// Even if you set both WWW and non-WWW versions as CNAMEs in your DNS settings, an oEmbed attempt to the wrong custom SmugMug domain (e.g. WWW if the custom domain in your SmugMug settings is non-WWW) will not work, which is why (www\.)? is not in the regex
// for a custom SmugMug subdomain like http://media.mydomain.com (notice the "backslash-dot" after the subdomain)
wp_oembed_add_provider( '#https?://?media\.mydomain\.com/.*#i', 'http://api.smugmug.com/services/oembed/', true );
// for a custom SmugMug domain like http://mydomain.com:
//wp_oembed_add_provider( '#https?://?mydomain\.com/.*#i', 'http://api.smugmug.com/services/oembed/', true );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment