Embed PDF - Version 1.04

Version Description

  • Changed URL for Google Docs Viewer to reflect change that Google made
Download this release

Release Info

Developer pathawks
Plugin Icon wp plugin Embed PDF
Version 1.04
Comparing to
See all releases

Code changes from version 1.03 to 1.04

Files changed (2) hide show
  1. embed.php +31 -12
  2. readme.txt +12 -2
embed.php CHANGED
@@ -4,10 +4,12 @@ Plugin Name: DirtySuds - Embed PDF
4
  Plugin URI: http://dirtysuds.com
5
  Description: Embed a PDF using Google Docs Viewer
6
  Author: Dirty Suds
7
- Version: 1.03
8
  Author URI: http://blog.dirtysuds.com
 
9
 
10
  Updates:
 
11
  1.03 20110321 - Automatically enable auto-embeds on activation
12
  1.02 20110315 - Added support for `gdoc` shortcode
13
  1.01 20110303 - Added support for class and ID attributes
@@ -34,7 +36,6 @@ Updates:
34
  register_activation_hook( __FILE__, 'dirtysuds_embed_pdf_enable_embeds' );
35
  wp_embed_register_handler( 'pdf', '#(^(http|wpurl)\:\/\/.+\.pdf$)#i', 'dirtysuds_embed_pdf' );
36
  add_shortcode( 'gdoc', 'dirtysuds_embed_pdf' );
37
- add_filter('plugin_row_meta', 'dirtysuds_embed_pdf_rate',10,2);
38
 
39
  function dirtysuds_embed_pdf_enable_embeds() {
40
  update_option('embed_autourls',1);
@@ -44,21 +45,19 @@ function dirtysuds_embed_pdf( $matches, $atts, $url, $rawattr=null ) {
44
  extract( shortcode_atts( array(
45
  'height' => get_option('embed_size_h'),
46
  'width' => get_option('embed_size_w'),
47
- 'border' => '',
48
  'style' => '',
49
  'title' => '',
50
  'class' => 'pdf',
51
  'id' => '',
52
  ), $atts ) );
53
-
54
- $url = str_replace('wpurl://',get_bloginfo('wpurl').'/',$url);
55
 
56
  if (!strstr($url,'http://') && strstr($atts,'http://')) {
57
  $url = $atts;
58
  extract( shortcode_atts( array(
59
  'height' => get_option('embed_size_h'),
60
  'width' => get_option('embed_size_w'),
61
- 'border' => '',
62
  'style' => '',
63
  'title' => '',
64
  'class' => 'pdf',
@@ -66,20 +65,39 @@ function dirtysuds_embed_pdf( $matches, $atts, $url, $rawattr=null ) {
66
  ), $matches ) );
67
  }
68
 
69
- $embed = '<iframe src="http://docs.google.com/viewer?url='.urlencode($url).'&amp;embedded=true" style="height:'.$height.'px;width:'.$width.'px;" class="'.$class.'"';
70
  if ($id) {
71
  $embed .= ' id="'.$id.'"';
72
  }
73
- if ($border) {
74
- $embed .= ' frameborder="'.$border.'"';
 
 
75
  }
 
76
  if ($style) {
77
- $embed .= ' style="'.$style.'"';
 
 
78
  }
79
  if ($title) {
80
  $embed .= ' title="'.$title.'"';
81
  }
82
- $embed .= '></iframe>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
 
84
  return apply_filters( 'embed_pdf', $embed, $matches, $attr, $url, $rawattr );
85
  }
@@ -89,4 +107,5 @@ function dirtysuds_embed_pdf_rate($links,$file) {
89
  $links[] = '<a href="http://wordpress.org/extend/plugins/dirtysuds-embed-pdf/">Rate this plugin</a>';
90
  }
91
  return $links;
92
- }
 
4
  Plugin URI: http://dirtysuds.com
5
  Description: Embed a PDF using Google Docs Viewer
6
  Author: Dirty Suds
7
+ Version: 1.04
8
  Author URI: http://blog.dirtysuds.com
9
+ License: GPL2
10
 
11
  Updates:
12
+ 1.04 20111125 - Automatically enable auto-embeds on activation
13
  1.03 20110321 - Automatically enable auto-embeds on activation
14
  1.02 20110315 - Added support for `gdoc` shortcode
15
  1.01 20110303 - Added support for class and ID attributes
36
  register_activation_hook( __FILE__, 'dirtysuds_embed_pdf_enable_embeds' );
37
  wp_embed_register_handler( 'pdf', '#(^(http|wpurl)\:\/\/.+\.pdf$)#i', 'dirtysuds_embed_pdf' );
38
  add_shortcode( 'gdoc', 'dirtysuds_embed_pdf' );
 
39
 
40
  function dirtysuds_embed_pdf_enable_embeds() {
41
  update_option('embed_autourls',1);
45
  extract( shortcode_atts( array(
46
  'height' => get_option('embed_size_h'),
47
  'width' => get_option('embed_size_w'),
48
+ 'border' => '0',
49
  'style' => '',
50
  'title' => '',
51
  'class' => 'pdf',
52
  'id' => '',
53
  ), $atts ) );
 
 
54
 
55
  if (!strstr($url,'http://') && strstr($atts,'http://')) {
56
  $url = $atts;
57
  extract( shortcode_atts( array(
58
  'height' => get_option('embed_size_h'),
59
  'width' => get_option('embed_size_w'),
60
+ 'border' => '0',
61
  'style' => '',
62
  'title' => '',
63
  'class' => 'pdf',
65
  ), $matches ) );
66
  }
67
 
68
+ $embed = '<iframe src="http://docs.google.com/viewer?url='.urlencode($url).'&amp;embedded=true" class="'.$class.'"';
69
  if ($id) {
70
  $embed .= ' id="'.$id.'"';
71
  }
72
+
73
+ $embed .= ' frameborder="'.$border.'"';
74
+ if ($border != '0') {
75
+ $border .= 'px';
76
  }
77
+
78
  if ($style) {
79
+ $embed .= ' style="height:'.$height.'px;width:'.$width.'px;border:'.$border.';'.$style.'"';
80
+ } else {
81
+ $embed .= ' style="height:'.$height.'px;width:'.$width.'px;border:'.$border.'"';
82
  }
83
  if ($title) {
84
  $embed .= ' title="'.$title.'"';
85
  }
86
+ $embed .= ' width="'.$width.'" height="'.$height.'"></iframe>';
87
+
88
+ $embed = '<![if !IE]>'.$embed.'<![endif]>';
89
+
90
+ $embed .= '<!--[if IE]>'.
91
+ '<object width="'.$width.'" height="'.$height.'" type="application/pdf" data="'.$url.'" class="'.$class.' ie"';
92
+
93
+ if ($id) {
94
+ $embed .= ' id="'.$id.'"';
95
+ }
96
+
97
+ $embed .= '>'.
98
+ '<div style="width:'.$width.';height:'.$height.';text-align:center;background:#fff;color:#000;margin:0;border:0;padding:0">Unable to display PDF<br /><a href="'.$url.'">Click here to download</a></div>'.
99
+ '</object>'.
100
+ '<![endif]-->';
101
 
102
  return apply_filters( 'embed_pdf', $embed, $matches, $attr, $url, $rawattr );
103
  }
107
  $links[] = '<a href="http://wordpress.org/extend/plugins/dirtysuds-embed-pdf/">Rate this plugin</a>';
108
  }
109
  return $links;
110
+ }
111
+ add_filter('plugin_row_meta', 'dirtysuds_embed_pdf_rate',10,2);
readme.txt CHANGED
@@ -1,7 +1,7 @@
1
  === Embed PDF ===
2
  Contributors: dirtysuds, pathawks
3
  Donate link: http://www.pathawks.com/p/wordpress-plugins.html
4
- Tags: plugins, wordpress, embed, eombed, pdf, google, Google Docs, shortcode
5
  Requires at least: 2.9
6
  Tested up to: 3.1.2
7
  Stable tag: 1.03
@@ -33,14 +33,19 @@ If you'd just like to change the size of one instance, you can use the standard
33
 
34
  `[embed width="400" height="600"]http://example.com/document.pdf[/embed]`
35
 
 
36
  = I have an idea for a great way to improve this plugin =
37
 
38
  Great! I'd love to hear from you.
 
39
  plugins@dirtysuds.com
40
 
41
 
42
  == Changelog ==
43
 
 
 
 
44
  = 1.03 =
45
  * Automatically enable auto-embeds on plugin activation
46
 
@@ -52,4 +57,9 @@ plugins@dirtysuds.com
52
 
53
  = 1.00 =
54
  * First version
55
- * Works
 
 
 
 
 
1
  === Embed PDF ===
2
  Contributors: dirtysuds, pathawks
3
  Donate link: http://www.pathawks.com/p/wordpress-plugins.html
4
+ Tags: WordPress,embed,google,media,plugin,plugins,Post,posts,simple,pdf,google,Google Docs
5
  Requires at least: 2.9
6
  Tested up to: 3.1.2
7
  Stable tag: 1.03
33
 
34
  `[embed width="400" height="600"]http://example.com/document.pdf[/embed]`
35
 
36
+
37
  = I have an idea for a great way to improve this plugin =
38
 
39
  Great! I'd love to hear from you.
40
+
41
  plugins@dirtysuds.com
42
 
43
 
44
  == Changelog ==
45
 
46
+ = 1.04 =
47
+ * Changed URL for Google Docs Viewer to reflect change that Google made
48
+
49
  = 1.03 =
50
  * Automatically enable auto-embeds on plugin activation
51
 
57
 
58
  = 1.00 =
59
  * First version
60
+ * Works
61
+
62
+ == Upgrade Notice ==
63
+
64
+ = 1.04 =
65
+ * Fixed problem with Google Docs viewer. Upgrade immediately.