Version Description
- First version
- Works
Download this release
Release Info
Developer | pathawks |
Plugin | Embed PDF |
Version | 1.00 |
Comparing to | |
See all releases |
Version 1.00
- embed.php +67 -0
- readme.txt +36 -0
embed.php
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: DirtySuds - Embed PDF
|
4 |
+
Plugin URI: http://dirtysuds.com
|
5 |
+
Description: Embed a PDF using Google Docs Viewer
|
6 |
+
Author: Pat Hawks
|
7 |
+
Version: 1.00.20110224
|
8 |
+
Author URI: http://www.pathawks.com
|
9 |
+
|
10 |
+
Updates:
|
11 |
+
1.00.20110224 - First Version
|
12 |
+
|
13 |
+
Copyright 2011 Pat Hawks (email : pat@pathawks.com)
|
14 |
+
|
15 |
+
This program is free software; you can redistribute it and/or modify
|
16 |
+
it under the terms of the GNU General Public License as published by
|
17 |
+
the Free Software Foundation; either version 2 of the License, or
|
18 |
+
(at your option) any later version.
|
19 |
+
|
20 |
+
This program is distributed in the hope that it will be useful,
|
21 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
22 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
23 |
+
GNU General Public License for more details.
|
24 |
+
|
25 |
+
You should have received a copy of the GNU General Public License
|
26 |
+
along with this program; if not, write to the Free Software
|
27 |
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
28 |
+
*/
|
29 |
+
|
30 |
+
wp_embed_register_handler( 'pdf', '#(^http.+\.pdf$)#i', 'wp_embed_handler_pdf' );
|
31 |
+
|
32 |
+
function wp_embed_handler_pdf( $matches, $attr, $url, $rawattr ) {
|
33 |
+
|
34 |
+
$width = get_option('embed_size_w');
|
35 |
+
$height = round($width * 1.32);
|
36 |
+
if ($height > get_option('embed_size_h')) {
|
37 |
+
$height = get_option('embed_size_h');
|
38 |
+
}
|
39 |
+
|
40 |
+
if ($attr['height']) {
|
41 |
+
$height = $attr['height'];
|
42 |
+
}
|
43 |
+
|
44 |
+
if ($attr['width']) {
|
45 |
+
$width = $attr['width'];
|
46 |
+
}
|
47 |
+
|
48 |
+
if ($attr['height'] && !$attr['width']) {
|
49 |
+
$width = round($height / 1.32);
|
50 |
+
}
|
51 |
+
|
52 |
+
if ($attr['width'] && !$attr['height']) {
|
53 |
+
$height = round($width * 1.32);
|
54 |
+
}
|
55 |
+
|
56 |
+
if ($height > get_option('embed_size_h') && !$attr['height']) {
|
57 |
+
$height = get_option('embed_size_h');
|
58 |
+
}
|
59 |
+
|
60 |
+
if ($width > get_option('embed_size_w') && !$attr['width']) {
|
61 |
+
$width = get_option('embed_size_w');
|
62 |
+
}
|
63 |
+
|
64 |
+
$embed = '<iframe src="http://docs.google.com/viewer?url='.urlencode($url).'&embedded=true" style="height:'.$height.'px;width:'.$width.'px;margin:0;border:0;"></iframe>';
|
65 |
+
|
66 |
+
return apply_filters( 'embed_pdf', $embed, $matches, $attr, $url, $rawattr );
|
67 |
+
}
|
readme.txt
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== DirtySuds - Embed PDF ===
|
2 |
+
Contributors: pathawks
|
3 |
+
Donate link: http://www.pathawks.com/p/wordpress-plugins.html
|
4 |
+
Tags: plugins, wordpress, embed, eombed, pdf, google, Google Docs
|
5 |
+
Requires at least: 3.0
|
6 |
+
Tested up to: 3.1
|
7 |
+
Stable tag: trunk
|
8 |
+
|
9 |
+
Adds pseudo oembed support for PDF documents
|
10 |
+
|
11 |
+
== Description ==
|
12 |
+
|
13 |
+
Will embed a PDF file using Google Docs Viewer
|
14 |
+
Simply include the URL for a PDF document on it's own line, or wrapped in the embed tag like `[embed]http://example.com/file.pdf[/embed]` and the plugin will embed the PDF into the page using the Google Docs Viewer embed code.
|
15 |
+
The url must end with `.pdf`
|
16 |
+
|
17 |
+
== Installation ==
|
18 |
+
|
19 |
+
1. Upload 'dirtysuds-embed--pdf' to the '/wp-content/plugins/' directory
|
20 |
+
2. Activate **DirtySuds - Embed PDF** through the 'Plugins' menu in WordPress
|
21 |
+
3. That's it. Now when you embed a PDF using the Wordpress `[embed]` shortcode, the plugin will embed the document using the Google Docs viewer
|
22 |
+
|
23 |
+
|
24 |
+
== Frequently Asked Questions ==
|
25 |
+
|
26 |
+
= I have an idea for a great way to improve this plugin =
|
27 |
+
|
28 |
+
Great! I'd love to hear from you.
|
29 |
+
postlist@pathawks.com
|
30 |
+
|
31 |
+
|
32 |
+
== Changelog ==
|
33 |
+
|
34 |
+
= 1.00 =
|
35 |
+
* First version
|
36 |
+
* Works
|