Version Description
- Error checking added
Download this release
Release Info
Developer | k3davis |
Plugin | Google Doc Embedder |
Version | 0.3 |
Comparing to | |
See all releases |
Code changes from version 0.2.1 to 0.3
- gviewer.php +42 -10
- readme.txt +6 -3
gviewer.php
CHANGED
@@ -5,7 +5,7 @@ Plugin Name: Google Doc Embedder
|
|
5 |
Plugin URI: http://wordpress.org/extend/plugins/google-document-embedder/
|
6 |
Description: Lets you embed PDF files and PowerPoint presentations in a page or post using the Google Document Viewer.
|
7 |
Author: Kevin Davis
|
8 |
-
Version: 0.
|
9 |
Author URI: http://www.davismetro.com/
|
10 |
*/
|
11 |
|
@@ -18,20 +18,52 @@ function gviewer_func($atts) {
|
|
18 |
'height' => '500'
|
19 |
), $atts));
|
20 |
|
21 |
-
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
HERE;
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
|
|
|
|
30 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
|
32 |
-
|
|
|
|
|
|
|
|
|
33 |
}
|
34 |
|
35 |
add_shortcode('gview', 'gviewer_func');
|
36 |
|
37 |
-
?>
|
5 |
Plugin URI: http://wordpress.org/extend/plugins/google-document-embedder/
|
6 |
Description: Lets you embed PDF files and PowerPoint presentations in a page or post using the Google Document Viewer.
|
7 |
Author: Kevin Davis
|
8 |
+
Version: 0.3
|
9 |
Author URI: http://www.davismetro.com/
|
10 |
*/
|
11 |
|
18 |
'height' => '500'
|
19 |
), $atts));
|
20 |
|
21 |
+
// supported file types - list acceptable extensions separated by |
|
22 |
+
$exts = "pdf|ppt";
|
23 |
+
|
24 |
+
// check link for validity
|
25 |
+
if (!validLink($file)){
|
26 |
+
$code = "\n<!-- GVIEW EMBED ERROR: invalid URL, please use fully qualified URL -->\n";
|
27 |
+
} elseif (!validType($file,$exts)) {
|
28 |
+
$code = "\n<!-- GVIEW EMBED ERROR: unsupported file type -->\n";
|
29 |
+
} else {
|
30 |
+
|
31 |
+
$code=<<<HERE
|
32 |
+
<iframe src="http://docs.google.com/gview?url=%U%&embedded=true" style="width:%W%px; height:%H%px;" frameborder="0"></iframe>
|
33 |
HERE;
|
34 |
|
35 |
+
$code = str_replace("%U%", $file, $code);
|
36 |
+
$code = str_replace("%W%", $width, $code);
|
37 |
+
$code = str_replace("%H%", $height, $code);
|
38 |
+
if ($save == "1") {
|
39 |
+
$code .= "<p><a href=\"$file\" target=\"_blank\">download file</a></p>";
|
40 |
+
}
|
41 |
+
|
42 |
}
|
43 |
+
|
44 |
+
return $code;
|
45 |
+
}
|
46 |
+
|
47 |
+
function validLink($link) {
|
48 |
+
|
49 |
+
$urlregex = "^https?\:\/\/([a-z0-9+!*(),;?&=\$_.-]+(\:[a-z0-9+!*(),;?&=\$_.-]+)?@)?[a-z0-9+\$_-]+(\.[a-z0-9+\$_-]+)*(\:[0-9]{2,5})?(\/([a-z0-9+\$_-]\.?)+)*\/?(\?[a-z+&\$_.-][a-z0-9;:@/&%=+\$_.-]*)?(#[a-z_.-][a-z0-9+\$_.-]*)?\$";
|
50 |
+
|
51 |
+
if (eregi($urlregex, $link)) {
|
52 |
+
return true;
|
53 |
+
} else {
|
54 |
+
return false;
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
function validType($link, $exts) {
|
59 |
|
60 |
+
if(preg_match("/($exts)$/i",$link)){
|
61 |
+
return true;
|
62 |
+
} else {
|
63 |
+
return false;
|
64 |
+
}
|
65 |
}
|
66 |
|
67 |
add_shortcode('gview', 'gviewer_func');
|
68 |
|
69 |
+
?>
|
readme.txt
CHANGED
@@ -18,9 +18,8 @@ Note: This plugin utilizes an undocumented feature of the Google Document viewer
|
|
18 |
== Installation ==
|
19 |
|
20 |
1. Upload the entire `google-document-embedder` folder to the `/wp-content/plugins/` directory.
|
21 |
-
|
22 |
-
|
23 |
-
You will find 'Contact' menu in your WordPress admin panel.
|
24 |
|
25 |
For basic usage, please see the [FAQ].
|
26 |
|
@@ -34,6 +33,7 @@ Use the custom shortcode `[gview]` to embed the file, as shown:
|
|
34 |
|
35 |
`[gview file="http://url.to/file.pdf"]`
|
36 |
|
|
|
37 |
Optional attributes:
|
38 |
|
39 |
* `save=` : Set to 0 if you wish to suppress the direct download link to the file under the embedded viewer
|
@@ -49,6 +49,9 @@ View the source on the web page where you've embedded the viewer. In order to de
|
|
49 |
|
50 |
== Changelog ==
|
51 |
|
|
|
|
|
|
|
52 |
= 0.2 =
|
53 |
* Initial beta release. Fully functional, but no niceties...
|
54 |
|
18 |
== Installation ==
|
19 |
|
20 |
1. Upload the entire `google-document-embedder` folder to the `/wp-content/plugins/` directory.
|
21 |
+
2. Activate the plugin through the 'Plugins' menu in WordPress.
|
22 |
+
3. Done.
|
|
|
23 |
|
24 |
For basic usage, please see the [FAQ].
|
25 |
|
33 |
|
34 |
`[gview file="http://url.to/file.pdf"]`
|
35 |
|
36 |
+
|
37 |
Optional attributes:
|
38 |
|
39 |
* `save=` : Set to 0 if you wish to suppress the direct download link to the file under the embedded viewer
|
49 |
|
50 |
== Changelog ==
|
51 |
|
52 |
+
= 0.3 =
|
53 |
+
* Error checking added
|
54 |
+
|
55 |
= 0.2 =
|
56 |
* Initial beta release. Fully functional, but no niceties...
|
57 |
|