Version Description
- Added support for
class
andid
attributes (Thanks, Robert)
Download this release
Release Info
Developer | pathawks |
Plugin | Embed PDF |
Version | 1.01 |
Comparing to | |
See all releases |
Version 1.01
- embed.php +62 -0
- readme.txt +41 -0
embed.php
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.01
|
8 |
+
Author URI: http://www.pathawks.com
|
9 |
+
|
10 |
+
Updates:
|
11 |
+
1.01 20110303 - Added support for class and ID attributes
|
12 |
+
1.00 20110224 - First Version
|
13 |
+
|
14 |
+
Copyright 2011 Pat Hawks (email : pat@pathawks.com)
|
15 |
+
|
16 |
+
This program is free software; you can redistribute it and/or modify
|
17 |
+
it under the terms of the GNU General Public License as published by
|
18 |
+
the Free Software Foundation; either version 2 of the License, or
|
19 |
+
(at your option) any later version.
|
20 |
+
|
21 |
+
This program is distributed in the hope that it will be useful,
|
22 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
23 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
24 |
+
GNU General Public License for more details.
|
25 |
+
|
26 |
+
You should have received a copy of the GNU General Public License
|
27 |
+
along with this program; if not, write to the Free Software
|
28 |
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
29 |
+
*/
|
30 |
+
|
31 |
+
wp_embed_register_handler( 'pdf', '#(^(http|wpurl)\:\/\/.+\.pdf$)#i', 'wp_embed_handler_pdf' );
|
32 |
+
|
33 |
+
function wp_embed_handler_pdf( $matches, $atts, $url, $rawattr ) {
|
34 |
+
extract( shortcode_atts( array(
|
35 |
+
'height' => get_option('embed_size_h'),
|
36 |
+
'width' => get_option('embed_size_w'),
|
37 |
+
'border' => '',
|
38 |
+
'style' => '',
|
39 |
+
'title' => '',
|
40 |
+
'class' => 'pdf',
|
41 |
+
'id' => '',
|
42 |
+
), $atts ) );
|
43 |
+
|
44 |
+
$url = str_replace('wpurl://',get_bloginfo('wpurl').'/',$url);
|
45 |
+
|
46 |
+
$embed = '<iframe src="http://docs.google.com/viewer?url='.urlencode($url).'&embedded=true" style="height:'.$height.'px;width:'.$width.'px;" class="'.$class.'"';
|
47 |
+
if ($id) {
|
48 |
+
$embed .= ' id="'.$id.'"';
|
49 |
+
}
|
50 |
+
if ($border) {
|
51 |
+
$embed .= ' frameborder="'.$border.'"';
|
52 |
+
}
|
53 |
+
if ($style) {
|
54 |
+
$embed .= ' style="'.$style.'"';
|
55 |
+
}
|
56 |
+
if ($title) {
|
57 |
+
$embed .= ' title="'.$title.'"';
|
58 |
+
}
|
59 |
+
$embed .= '></iframe>';
|
60 |
+
|
61 |
+
return apply_filters( 'embed_pdf', $embed, $matches, $attr, $url, $rawattr );
|
62 |
+
}
|
readme.txt
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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: 1.01
|
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 |
+
Supported attributes in the embed tag are `class` `id` `title` `height` and `width`
|
18 |
+
|
19 |
+
== Installation ==
|
20 |
+
|
21 |
+
1. Upload `dirtysuds-embed-pdf` to the `/wp-content/plugins/` directory
|
22 |
+
2. Activate **DirtySuds - Embed PDF** through the 'Plugins' menu in WordPress
|
23 |
+
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
|
24 |
+
|
25 |
+
|
26 |
+
== Frequently Asked Questions ==
|
27 |
+
|
28 |
+
= I have an idea for a great way to improve this plugin =
|
29 |
+
|
30 |
+
Great! I'd love to hear from you.
|
31 |
+
postlist@pathawks.com
|
32 |
+
|
33 |
+
|
34 |
+
== Changelog ==
|
35 |
+
|
36 |
+
= 1.01 =
|
37 |
+
* Added support for `class` and `id` attributes (Thanks, _Robert_)
|
38 |
+
|
39 |
+
= 1.00 =
|
40 |
+
* First version
|
41 |
+
* Works
|