- [ted id=981] or
- http://www.ted.com/talks/ze_frank_s_web_playroom.html
Revisions
- February 14, 2013 @ 12:30:46 [Current Revision] by PeterLugg
- February 14, 2013 @ 12:28:52 by PeterLugg
Revision Differences
| February 14, 2013 @ 12:28:52 | Current Revision | ||
|---|---|---|---|
| Content | |||
| Unchanged: Add the following to your theme's functions.php file | Unchanged: Add the following to your theme's functions.php file | ||
| Unchanged: [php]// Whitelist the TEDTalks oEmbed URL | Unchanged: [php]// Whitelist the TEDTalks oEmbed URL | ||
| Unchanged: wp_oembed_add_provider( 'http://www.ted.com/talks/*', 'http://www.ted.com/ talks/oembed.json' ); | Unchanged: wp_oembed_add_provider( 'http://www.ted.com/talks/*', 'http://www.ted.com/ talks/oembed.json' ); | ||
| Unchanged: function ted_shortcode( $atts ) { | Unchanged: function ted_shortcode( $atts ) { | ||
| Unchanged: // We need to use the WP_Embed class instance | Unchanged: // We need to use the WP_Embed class instance | ||
| Unchanged: global $wp_embed; | Unchanged: global $wp_embed; | ||
| Unchanged: // The "id" parameter is required | Unchanged: // The "id" parameter is required | ||
| Unchanged: if ( empty($atts['id']) ) | Unchanged: if ( empty($atts['id']) ) | ||
| Unchanged: return ''; | Unchanged: return ''; | ||
| Unchanged: // Construct the TEDTalk URL | Unchanged: // Construct the TEDTalk URL | ||
| Unchanged: $url = 'http://www.ted.com/ talks/view/lang/eng/id/' . $atts['id']; | Unchanged: $url = 'http://www.ted.com/ talks/view/lang/eng/id/' . $atts['id']; | ||
| Unchanged: // Run the URL through the handler. | Unchanged: // Run the URL through the handler. | ||
| Unchanged: // This handler handles calling the oEmbed class | Unchanged: // This handler handles calling the oEmbed class | ||
| Unchanged: // and more importantly will also do the caching! | Unchanged: // and more importantly will also do the caching! | ||
| Unchanged: return $wp_embed->shortcode( $atts, $url ); | Unchanged: return $wp_embed->shortcode( $atts, $url ); | ||
| Unchanged: } | Unchanged: } | ||
| Unchanged: add_shortcode( 'ted', 'ted_shortcode' );[/php] | Unchanged: add_shortcode( 'ted', 'ted_shortcode' );[/php] | ||
| Added: Now, you can embed TEDTalks two ways: | |||
| Added: <ul> | |||
| Added: <li>[ted id=981] or</li> | |||
| Added: <li>http://www.ted.com/ talks/ze_frank_ s_web_playroom.html</li> | |||
| Added: </ul> | |||
Note: Spaces may be added to comparison text to allow better line wrapping.
No comments yet.