Changeset 1729512
- Timestamp:
- 09/13/2017 05:42:06 PM (8 years ago)
- Location:
- iframely/trunk
- Files:
-
- 2 edited
-
iframely.php (modified) (7 diffs)
-
readme.txt (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
iframely/trunk/iframely.php
r1645981 r1729512 5 5 Description: Iframely for WordPress. Embed anything, with responsive widgets. 6 6 Author: Itteco Corp. 7 Version: 0. 4.07 Version: 0.5.0 8 8 Author URI: https://iframely.com/?from=wp 9 9 */ … … 30 30 wp_oembed_add_provider( '#https?://iframe\.ly/.+#i', iframely_create_api_link(), true ); 31 31 32 function maybe_remove_wp_self_embeds( $result, $url, $args ) { 33 32 function maybe_remove_wp_self_embeds( $result, $url, $args ) { 33 34 34 return get_site_option( 'publish_iframely_cards') ? null : $result; 35 35 } … … 45 45 } 46 46 } 47 48 # Make compatible with Automatic AMP-WP plugin: https://github.com/Automattic/amp-wp 49 function is_iframely_amp ( $args ) { 50 return 51 (is_array($args) && array_key_exists('iframely', $args) && $args['iframely'] == 'amp') 52 || (is_string($args) && strpos($args, 'iframely=amp') !== false) 53 || (function_exists('is_amp_endpoint') && is_amp_endpoint()); 54 } 55 56 # Make WP cache &iframe=amp oEmbed requests separately 57 add_filter( 'embed_defaults', 'iframely_amp_embed_defaults' ); 58 function iframely_amp_embed_defaults( $args ) { 59 if (is_iframely_amp($args)) { 60 // args are included in cache key. Bust it for amp 61 $args['iframely'] = 'amp'; 62 } 63 return $args; 64 } 65 66 add_filter( 'oembed_fetch_url', 'maybe_add_iframe_amp', 10, 3 ); 67 function maybe_add_iframe_amp( $provider, $args, $url ) { 68 69 if (is_iframely_amp( $args ) && strpos($provider, '//iframe.ly') !== false) { 70 $provider = add_query_arg( 'iframe', 'amp', $provider ); 71 } 72 return $provider; 73 } 74 75 76 add_filter( 'embed_oembed_html', 'iframely_filter_oembed_result', 10, 3 ); 77 function iframely_filter_oembed_result( $html, $url, $args ) { 78 79 if (strpos($html, '<amp-iframe') !== false || strpos($html, '<amp-facebook') !== false ) { 80 add_action( 'amp_post_template_head', strpos($html, '<amp-iframe') !== false ? 'iframely_add_amp_iframe_js' : 'iframely_add_amp_facebook_js'); 81 // Avoid corrupted amp-iframe overflow div as a result of wpautop 82 remove_filter( 'the_content', 'wpautop' ); 83 // Restore wpautop if it was disabled 84 add_filter( 'the_content', 'iframely_autop_on_amp', 1000); 85 } 86 return $html; 87 }; 88 89 add_filter( 'amp_content_embed_handlers', 'maybe_unregister_default_embed_handlers', 10, 2 ); 90 function maybe_unregister_default_embed_handlers($embed_handler_classes, $post ) { 91 92 if ( get_site_option( 'iframely_disable_default_amp_embeds' ) ) { 93 unset ($embed_handler_classes ['AMP_Twitter_Embed_Handler']); 94 unset ($embed_handler_classes ['AMP_Dailymotion_Embed_Handler']); 95 unset ($embed_handler_classes ['AMP_Facebook_Embed_Handler']); 96 unset ($embed_handler_classes ['AMP_Instagram_Embed_Handler']); 97 unset ($embed_handler_classes ['AMP_Vimeo_Embed_Handler']); 98 unset ($embed_handler_classes ['AMP_YouTube_Embed_Handler']); 99 unset ($embed_handler_classes ['AMP_Pinterest_Embed_Handler']); 100 } 101 return $embed_handler_classes; 102 }; 103 104 105 function iframely_autop_on_amp( $content ) { 106 107 // Logic is taken from wpautop itself re <pre> 108 if ( strpos($content, '<amp-iframe') !== false ) { 109 $chunks = explode( '</amp-iframe>', $content ); 110 $content = ''; 111 112 foreach ( $chunks as $chunk ) { 113 $start = strpos($chunk, '<amp-iframe'); 114 // Malformed html? 115 if ( $start === false ) { 116 $content .= $chunk; 117 continue; 118 } 119 120 $iframe = substr($chunk, $start) . '</amp-iframe>'; 121 $p = wpautop(substr( $chunk, 0, $start)); 122 123 $content .= $p . $iframe; 124 } 125 } else { 126 $content = wpautop($content); 127 } 128 129 return $content; 130 } 131 132 function iframely_add_amp_iframe_js( $amp_template ) { 133 ?> 134 <script custom-element="amp-iframe" src="https://cdn.ampproject.org/v0/amp-iframe-0.1.js" async></script> 135 <?php 136 } 137 138 function iframely_add_amp_facebook_js( $amp_template ) { 139 ?> 140 <script custom-element="amp-facebook" src="https://cdn.ampproject.org/v0/amp-facebook-0.1.js" async></script> 141 <?php 142 } 143 144 47 145 48 146 # fix cache ttl … … 69 167 $wp_embed->usecache = false; 70 168 delete_post_meta( $post_ID, $cachekey_time); 169 // delete_post_meta( $post_ID, $cachekey); 71 170 return $iframely_ttl; 72 171 } else { … … 84 183 # rewrite oembed discovery 85 184 add_filter( 'oembed_endpoint_url', 'publish_embeds_via_iframely', 10, 2) ; 86 87 185 function publish_embeds_via_iframely($url, $permalink, $format = 'json') { 88 186 … … 227 325 iframely_update_option('iframely_api_params', trim($_POST['iframely_api_params'])); 228 326 iframely_update_option('iframely_cache_ttl', (isset($_POST['iframely_cache_ttl'])) ? (int)trim($_POST['iframely_cache_ttl']) : 0); 327 iframely_update_option('iframely_disable_default_amp_embeds', (isset($_POST['iframely_disable_default_amp_embeds'])) ? (int)trim($_POST['iframely_disable_default_amp_embeds']) : 0); 229 328 } 230 329 … … 259 358 Although, we should support the same providers and output the same code, just make it responsive.<br> 260 359 Iframely shortcode will still process such URLs regardless of this setting. 360 </p> 361 </li> 362 363 <li> 364 <p><input type="checkbox" name="iframely_disable_default_amp_embeds" value="1" <?php if (get_site_option('iframely_disable_default_amp_embeds')) { ?> checked="checked" <?php } ?> /> For AMP pages, replace default embeds with Iframely.</p> 365 <p>Iframely works nicely with <a href="https://wordpress.org/plugins/amp/" target="_blank_">AMP WordPress</a> plugin for Google AMP support. 366 It catches all missing embeds and follow your Iframely settings.<br> 367 But you can also choose Iframely for all embeds, including default AMP embeds too.<br> 368 For example, Facebook video will be indeed a nice video without user's text message. 261 369 </p> 262 370 </li> -
iframely/trunk/readme.txt
r1645981 r1729512 1 1 === Iframely Responsive Embeds === 2 2 Contributors: psergeev, ivanp 3 Tags: iframely, oembed, embed, responsive, video, youtube, vimeo, instagram, gist, vine, gif, giphy, google maps, facebook, mu, streamable, gfycat, vidme, Reddit, Tableau, spotify, prezi3 Tags: iframely, oembed, embed, responsive, video, amp, youtube, vimeo, instagram, gist, vine, gif, giphy, google maps, facebook, mu, streamable, gfycat, vidme, Reddit, Tableau, spotify, prezi, apester, qzzr, tidal, mlb, 4 4 Requires at least: 3.5.1 5 Tested up to: 4. 7.45 Tested up to: 4.8.1 6 6 Stable tag: trunk 7 7 License: MIT 8 8 9 9 10 Iframely converts URLs in your posts into responsive embed widgets for over 2000 domains and summary cards for others. 10 Iframely converts URLs in your posts into responsive embed widgets for over 2000 domains and summary cards for others. Also works with AMP. 11 11 12 12 == Description == 13 13 14 14 15 [Iframely](https://iframely.com?from=wp) brings you the responsive embeds and support of over 2000 domains. I t means the embeds will resize, if possible, if you are on responsive theme.16 17 18 Iframely will detect URLs in your posts and replace it with responsive embed codes. Supports all usual suspects such as YouTube, Vimeo, Instagram, Facebook, Giphy, GfyCat, Imgur, Google +, GitHub Gists, Storify, SlideShare, Streamable, Vidme, Reddit, Dailymotion, Spotify, Tableau, Prezi, well, you know, over two thousand of them and keeps growing. [Test some URLs here](https://iframely.com/embed).15 [Iframely](https://iframely.com?from=wp) brings you the responsive embeds and support of over 2000 domains. Iframely also works with AMP. 16 17 18 Iframely will detect URLs in your posts and replace it with responsive embed codes. Supports all usual suspects such as YouTube, Vimeo, Instagram, Facebook, Giphy, GfyCat, Imgur, Google +, GitHub Gists, Storify, SlideShare, Streamable, Vidme, Reddit, Dailymotion, Spotify, Tableau, Prezi, Apester, QZZR, Tidal, MLB, well, you know, over two thousand of them and keeps growing. [Test some URLs here](https://iframely.com/embed). 19 19 20 20 Iframely will also generate and host summary cards for general articles. It includes your own site, and Iframely can replace the default embed cards that your publish via WordPress for other sites to use. 21 21 22 Iframely is powered by server API. API Key is required. Get one at [iframely.com](https://iframely.com) 22 Iframely is powered by server API. API Key is required. Get one at [iframely.com](https://iframely.com). Get help at support at iframely.com. 23 23 24 24 … … 58 58 Just choose this option in your settings. It will essentially put Iframely to be the last in the list, be "a catcher", rather then "an interceptor". 59 59 60 = AMP support = 61 62 Iframely works nicely with [AMP WP plugin](https://wordpress.org/plugins/amp/). It catches all missing embeds and follow your Iframely settings. But you can also opt to have Iframely for all embeds, including default AMP embeds too. For example, Facebook video will be indeed a nice video without user's text message. 60 63 61 64 … … 63 66 == Installation == 64 67 65 The installation is prettystandard:68 The installation is standard: 66 69 67 70 1. Upload the package contents to to the `/wp-content/plugins/` directory … … 86 89 == Frequently Asked Questions == 87 90 88 = Oh, the Facebook! =89 90 Yes, Iframely knows the embed codes for Facebook posts, photos and videos. However, some of the posts can be private and not accesssible to our parsers. For those, we can not convert the URL into embed code. Also, Facebook events don't have native embed codes and so Iframely doesn't support these too.91 92 91 = I thought Iframely would wrap my URL into iframe? = 93 92 … … 98 97 Well, that's the point of responsive embeds. You don't have to. 99 98 100 Iframely widgets will take 100% available width. If you need to limit it, just define your CSS styles for `iframely-widget-container`.101 102 Please, note that not all the embeds codes will be responsive. Some of hosting domains can not be converted responsively. In those cases, Iframely will left-align the embeds. You might want to consider padding and alignment styles, if you don't have generic ones for `iframes` and `images` yet.99 Iframely widgets will take 100% available width. If you need to customize CSS, add '&omit_css=1' as "Optional API query-string param" on Iframely config page and follow [this guide](https://iframely.com/docs/omit-css). 100 101 Please, note that not all the embeds codes will be responsive. Embeds from a tiny number of less frequent publishers cannot be converted responsively without ruining their content. 103 102 104 103 = Is it compatible with other embeds plugins I have? = … … 107 106 * Since default WordPress embeds are not responsive, Iframely can disable the standard code and replaces it with the responsive embeds. Otherwise, you might be wondering why is some widgets are not responsive 108 107 * You can conifugure Iframely to only work in its own shortcode, thus leaving other plugins intact. 108 * Iframely plays well with [AMP](https://wordpress.org/plugins/amp/). 109 109 110 110 = What about embeds in my previous posts? = … … 112 112 Iframely works in native WordPress embeds framework. All your new posts should start seeing responsive widgets. The older posts will be re-cached via WordPress logic itself (usually when you edit and save the post), and should granually get the new embeds code too. However, we do not interfere into this default process and do not re-cache older posts upon install. 113 113 114 To change this logic, define "Cache the embed codes for this number of days" on Iframely options page. 115 114 116 If there's a specific post you'd like to update, just go to Edit and Save it again. It should re-cache it and trigger Iframely. 115 117 … … 122 124 Iframely will work well with multisite installations. Iframely options page is available for super admins only, and the settings will be the same for all blogs on your WPMU setup. 123 125 126 = Oh, the Facebook! = 127 128 Yes, Iframely knows the embed codes for Facebook posts, photos and videos. However, some of the posts can be private and not accesssible to our parsers. For those, we can not convert the URL into embed code. Also, Facebook events don't have native embed codes and so Iframely doesn't support these too. 124 129 125 130 == Changelog == 131 132 = 0.5.0 = 133 134 Making Iframely to work nicely with [AMP WP plugin](https://wordpress.org/plugins/amp/). Iframely now catches all missing embeds and follow your Iframely settings. But you can also opt to have Iframely for all embeds. 135 126 136 127 137 = 0.4.0 =
Note: See TracChangeset
for help on using the changeset viewer.