Changeset 701765
- Timestamp:
- 04/22/2013 08:02:59 PM (13 years ago)
- File:
-
- 1 edited
-
slideonline/trunk/slideonline.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
slideonline/trunk/slideonline.php
r663817 r701765 4 4 Plugin URI: http://slideonline.com/ 5 5 Description: Easily embed your presentations in a WordPress blog. SlideOnline.com is a free service to share PowerPoint presentations online. 6 Version: 1. 16 Version: 1.2 7 7 Author: Julian Magnone 8 8 Author URI: http://magn.com 9 10 This plugin allows WordPress users to embed SlideOnline presentations into the blog posts. The code below is organized in the following way: 11 First section contains procedures to embed the presentations using the shortcode [slideonline id=""] 12 The second section contains directives to configure the oEmbed functionality into the WordPress by using a hook. This will allow to add 13 SlideOnline as an oEmbed provider and then be able to use it by pasting the links. 9 14 */ 10 15 16 /* Section #2: Configure Embed options by using IFRAME and defaults */ 11 17 12 18 $slideonline_options = array( … … 93 99 } 94 100 101 /* Section #2: Configure oEmbed functionality */ 102 103 function add_oembed_slideonline(){ 104 //wp_oembed_add_provider( 'http://slideonline.com/presentation/*', 'http://slideonline.com/oembed'); 105 wp_oembed_add_provider("#http://(.+)?slideonline\.com/presentation/.*#i", "http://slideonline.com/oembed", true); 106 } 107 add_action('init','add_oembed_slideonline'); 108 109 function slideonline_oembed_html($html, $url, $args) { 110 global $content_width; 111 112 preg_match('/width="([0-9]*)"/', $html, $matches); 113 if (!empty($matches) AND !empty($matches[1])) 114 { 115 $width = (int)$matches[1]; 116 } 117 118 // Set the width of the video 119 $width_pattern = "/width=\"[0-9]*\"/"; 120 //$html = preg_replace($width_pattern, "width='340'", $html); 121 if (!empty($content_width)) 122 { 123 $html = preg_replace($width_pattern, "width=\"{$content_width}\"", $html); 124 $new_width = $content_width; 125 } 126 127 preg_match('/height="([0-9]*)"/', $html, $matches); 128 if (!empty($matches) AND !empty($matches[1])) 129 { 130 $height = (int)$matches[1]; 131 if (!empty($new_width)) $new_height = $new_width * $height / $width; 132 // Set the height of the video 133 $height_pattern = "/height=\"[0-9]*\"/"; 134 $html = preg_replace($height_pattern, "height='{$new_height}'", $html); 135 } 136 return $html; // return updated content 137 } // end slideonline_oembed_html 138 add_filter('embed_oembed_html', 'slideonline_oembed_html', 10, 3); 139 140 //Custom oEmbed Size 141 function slideonline_oembed_defaults($embed_size) { 142 if(is_front_page()) { 143 $embed_size['width'] = 640; 144 $embed_size['height'] = 480; 145 } 146 else { 147 $embed_size['width'] = 640; 148 $embed_size['height'] = 480; 149 } 150 return $embed_size; 151 } 152 add_filter('embed_defaults', 'slideonline_oembed_defaults'); 95 153 96 154
Note: See TracChangeset
for help on using the changeset viewer.